Reputation: 1357
My need: I want to deep copy all the childs of a single selected node without actually copying it. Example: from
<father><son i="1" /><son i="2" /><son i="0"><lastNode /></son></father>
i wish to extract
<son i="1" /><son i="2" /><son i="0"><lastNode /></son>
I know that i can do this with a cycle for-each and then a xsl:copy-of. I am wondering if there is a simpler expression to achieve the same result. Some idea?
Follow-up. My question missed a couple of points. I should had said that all the childs means "all the possible childs", including textnodes; another verification that a better question already contains the answer. Second, what I have learned from you - the community - is that I was enough dumb to try to solve by XSL what in facts was more a XPATH issue. Thanks to all of you for this insight
Cheers.
Upvotes: 2
Views: 3701
Reputation: 26658
Try select all children..
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:copy-of select="father/*"/>
</xsl:template>
</xsl:stylesheet>
E.G. Given input
<father><son i="1" /><son i="2" /><niceSon /><son i="0"><lastNode /></son></father>
It outputs
<son i="1" /><son i="2" /><niceSon /><son i="0"><lastNode /></son>
Upvotes: 3