Archive

Archive for November, 2009

XSLT – copy node with attributes without childs

November 11th, 2009 No comments

Simple solution for not-so-trivial problem of copying xml node with all its attributes, but without child nodes.

Without the last condition, solution is easy, one would use <xsl:copy-of>, but with it things are a bit harder, you should do smt. like:

<xsl:copy select="."> <!-- this copies element name -->
   <xsl:copy-of select="@*"/> <!-- this copies all its attributes -->
   ...what..ever..you..want..here...
</xsl:copy>

And thats all, seems easy but it took me some time to realize it (And I must do it myself, because google didn’t helped me !).

Categories: devel, xml, xsl Tags: