Input
<root>
<category1>
<node>
<subnode>value</subnode>
</node>
</category1>
<category2>
<node>
<subnode>value</subnode>
</node>
</category2>
</root>
Output
<root>
<node>
<subnode>value</subnode>
</category1>
</node>
<node>
<subnode>value</subnode>
</category2>
</node>
</root>
Or
<root>
<node>
<subnode>value</subnode>
<status>category1</status>
</node>
<node>
<subnode>value</subnode>
<status>category2</status>
</node>
</root>
Attempt
<xsl:template match="//node">
<xsl:copy>
<xsl:copy-of select="child::node()" />
<xsl:copy-of select=".." />
<!--
Why isn't something like this possible?
<xsl:copy-of select="ancestor::local-name()"/>
-->
</xsl:copy>
</xsl:template>
Details
Hopefully, the above was clear enough :).
Additional Details (Optional)
For those feeling especially generous this Christmas I invite you to continue reading :D.
I'm having some trouble learning XSLT and feel like I'm missing some general/syntactical concepts but I also need to do some 'complicated' transforms. For example:
Input
<root>
<category1>
<node>
<name>category1 node pk</name>
</node>
</category1>
<groups>
<node>
<name>First Group</name>
<members>
<name>category1 node pk</name>
</members>
</node>
<node>
<name>Second Group</name>
<members>
<name>category1 node pk</name>
</members>
</node>
</groups>
</root>
Output
<root>
<node>
<name>category1 node pk</name>
<group>All</group>
<status>category1</status>
</node>
<node>
<name>category1 node pk</name>
<group>First Group</group>
<status>category1</status>
</node>
<node>
<name>category1 node pk</name>
<group>Second Group</group>
<status>category1</status>
</node>
</root>
So for the XSLT experts out there what I would like to know is how you went about learning XSLT 1.0? Especially to deal with more complicated transforms.
Are there any books or tutorials that you found especially useful?
Finally how long do you think it would take for someone new to become proficient enough to pull off the above transform w/o help?
<group>ALL</group>or<group>First Group</group>? - Mathias Müller