This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: copying child nodes n-level deep
- To: <xsl-list at lists dot mulberrytech dot com>
- Subject: Re: [xsl] copying child nodes n-level deep
- From: "Rob Lugt" <roblugt at elcel dot com>
- Date: Thu, 26 Jul 2001 16:17:08 +0100
- References: <A5635321370DD411BBE800508B6521CC49E741@exchsrv1.infoglide.com>
- Reply-To: xsl-list at lists dot mulberrytech dot com
Ram Anantha wrote
>
> Given:
> <A>
> <B>
> <C id="1">
> <D id1="2">
> <E>hello</E>
> </D>
> </C>
> </B>
> </A>
>
> I would like to copy all the elements and their children starting from D.
> The logic is, take the grand-child of B (in this case D) and copy it
(along
> with all its children). The only known element name is B..How can I write
a
> generic xsl code such that from the following schema:
>
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>
Regards
~Rob
--
Rob Lugt
ElCel Technology
http://www.elcel.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list