[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: deep "copy-of" a source fragment
On Tuesday 03 September 2002 23:48, Terence Kearns wrote: > but if I change > match="/" > to > match="/html/body" > > then I get leaf nodes again :( > I also tried ... > makes no difference if I change > > select="node()" > to > select="." > or > select="@*|node()" > > Is there no way at all to copy a fragment from the source tree onto the > result tree?! The problem is, if you have: <xsl:template match="/html/body"> ... </xsl:template> then the default template will be applied to all the nodes that aren't part of /html/body. The default template is to copy text nodes and ignore everything else, so that might explain your problem. Instead of changing select to select="node()" and match="/html/body", you should try, <xsl:template match="/"> <xsl:copy-of select="html/body/node()"/> </xsl:template> If that doesn't work, then I don't know what's wrong. An alternative to using copy-of is to use the "identity template", which can look something like this (untested): <!-- ignore all nodes unless otherwise specified --> <xsl:template match="node()" priority="0"/> <xsl:template match="/html/body//@* | /html/body//node()"> <xsl:copy> <xsl:apply-templates select="@*"/> <xsl:apply-templates select="node()"/> </xsl:copy> </xsl:template> You might want to go this route if you ever want to apply other templates to specific elements in the /html/body//* tree. Using xsl:copy-of doesn't allow you to modify the output of the copy with other templates. If you don't think you'll ever need to apply other templates, then copy-of should work fine. -- Peter Davis XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|