Subject: Re: [xsl] deep "copy-of" a source fragment From: Peter Davis <pdavis152@xxxxxxxxx> Date: Wed, 4 Sep 2002 00:06:13 -0700 |
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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] deep "copy-of" a source fragm, Terence Kearns | Thread | Re: [xsl] deep "copy-of" a source f, Terence Kearns |
[xsl] deep "copy-of" a source fragm, Terence Kearns | Date | RE: [xsl] deep "copy-of" a source f, Robert Koberg |
Month |