yoshimura Posted February 7, 2011 Share Posted February 7, 2011 I'd like to match everything for the first child node of the root.Here's how my XSLT starts out: <xsl:template match="/"> <html> <head> <link rel="stylesheet" type="text/css" href="lexpress.css" /> <title>L'Express — <xsl:value-of select="/Lexpress/Date"/></title> </head> <body> <h1>L'Express</h1><p class="date"><xsl:value-of select="/Lexpress/Date"/></p> <xsl:apply-templates/> </body> </html> </xsl:template> The DOM tree looks like this:Root Date Article Article Article ArticleI don't want the Date element to show up at the top of the HTML output document. Link to comment Share on other sites More sharing options...
Martin Honnen Posted February 8, 2011 Share Posted February 8, 2011 Either make sure your apply-templates processes only the elements you are interested in so perhaps doing <xsl:apply-templates select="Root/Article"/> instead of the <xsl:apply-templates/> you have helps.Or add <xsl:template match="Date"/> that way the Date element will be processed but not generate any output. Link to comment Share on other sites More sharing options...
yoshimura Posted February 8, 2011 Author Share Posted February 8, 2011 This: <xsl:apply-templates select="Root/Article"/> Does indeed work.I was being too generic with my DOM tree example; Each Article element actually have different names. There is a possibility of 30-something different element names that are children of the root.The code below didn't work: <xsl:template match="Date"/> Link to comment Share on other sites More sharing options...
yoshimura Posted February 9, 2011 Author Share Posted February 9, 2011 Solution: <xsl:apply-templates select="Root/*[position()!=1]"/> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.