Hi,
Thanks for the responce. I'm sorry about the lack of code. It's frustrating not being able to do this. I've created a tool that must take the XML output of someone else's work and I need to change it to fit the structure that my system requires(XSLT transformation of XML is the bit that I cannot grasp). The examples I am using are simplified versions of what I need (I didn't want to post huge chunks of code).
I was using the stylesheet above which works well for what I originally specified but I'd like to change it to move <function> all it's attributes and elements to the correct node identified by nodename. The stylesheet is as follows.
Code:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:key name="k1" match="function" use="@nodename"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="functionality[@available = 'true']">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="key('k1', parent::node/name)/node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="function"/>
</xsl:stylesheet>
I have two issues one is to move function but not into functionality just into node. I was thinking that <xsl:template match="functionality[@available = 'true']"> would be the line to change to match node or anything but that didn't work. From your comments I'm thinking maybe the change belongs with the first copy function in the stylesheet.
Also the current stylesheet moves the elements of function but not the function tag so I need to address that. I was guessing that may be something to do with parent:: and node() but to be honest, I'm totally lost. I feel like I'm stabbing in the dark.
I'm thinking that instead of tweaking the above stylesheet maybe coming at it again from scratch may be best as the spec is different.
I think I need to learn the basics, although I thought this was the basics.
Thanks for all your help.
ps the choice of <node> tag by me for an example was a bad choice. Too many nodes floating about.