Subject: Re: [xsl] Apply-templates - how to omit top level element tags? From: David Carlisle <davidc@xxxxxxxxx> Date: Thu, 8 Sep 2005 09:44:45 +0100 |
Unfortunately, I still don't grok the difference between: > Unfortunately, I still don't grok the difference between: > > * > . > node() Part of your problem is that you are using xsl:value-of rather than xsl:copy-of, value-of always gives teh _string value_ of its argument, so you never see the difference between an element and a text node using value-of Consider an input of <a>www <b>zzz</b> <!-- yyy --> <z/> </a> and <xsl:template match="a"> ... </xsl:template> then if ... is <xsl:copy-of select="."/> You will output a copy of the current node (which is a) a node includes all children etc so you get <a>www <b>zzz</b> <!-- yyy --> <z/> </a> then if ... is <xsl:copy-of select="*"/> then * is short for child::* and selects all child elements so you get <b>zzz</b><z/> note, no top level a, no comments and no text nodes, including indentation white space nodes. then if ... is <xsl:copy-of select="node()"/> then node() is short for child::node() which selects all child nodes (elements, text, comments and processing instructions) and you get www <b>zzz</b> <!-- yyy --> <z/> (no top level <a> element, as you only copied children. David ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Apply-templates - how to , Mike Schinkel | Thread | Re: [xsl] Apply-templates - how to , Jon Gorman |
Re: [xsl] Moving an element to a ne, David Carlisle | Date | Re: [xsl] Get value from update.xml, Joris Gillis |
Month |