Subject: Re: [xsl] copying child nodes n-level deep From: "Rob Lugt" <roblugt@xxxxxxxxx> Date: Thu, 26 Jul 2001 17:13:40 +0100 |
Ram Anantha wrote >> If you want to perform a deep copy (all elements and their children), use >> <xsl:copy-of> as opposed to <xsl:copy> which only copies the current >> element. Selecting the grand-children of the current node can be performed >> simply with a concatenation of two child::* axis specifiers:- >> >> <xsl:template match="B"> >> <xsl:copy-of select="child::*/child::*"/> >> </xsl:template> > > ---------------------------------- > Thanks, Rob for your response. > > What should I change if I need to make a deep-copy of everything except the > attributes? Can I still use xsl:copy-of? > Ram, rather than replying to individual posters please reply to the list with follow-up questions, and try to specify your original question as precisely as possible. If you don't want attributes then the problem is a little more difficult. You can't make use of <xsl:copy-of> so you'll have to use recursion. You don't want to make use of the built-in template for elements because that only copies the text value of the element. Also, you don't want to replace the built-in template for elements because then you will copy all and sundry. One solution is to make use of modes:- <xsl:template match="B"> <xsl:apply-templates mode="copy" select="child::*/child::*"/> </xsl:template> <xsl:template match="*" mode="copy"> <xsl:copy> <xsl:apply-templates mode="copy"/> </xsl:copy> </xsl:template> In this way you decide at what branch to start the recursive copy, and you avoid the built-in template. Regards ~Rob XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] copying child nodes n-le, Oliver Becker | Thread | [xsl] This can't be right, XML with, Dylan Walsh |
[xsl] XPointer info, Maulik Modi | Date | RE: [xsl] XSLT with XML-Spy, Oleg Tkachenko |
Month |