I'm very new to XSLT, and I'd like to know how to create a node based on the text of another node. For example, if have the XML:
<axis pos="6" values="3">
<title>Device</title>
<label code="7">Autologous Tissue Substitute</label>
<label code="J">Synthetic Substitute</label>
<label code="K">Nonautologous Tissue Substitute</label>
</axis>
I'd like to transform it into:
<stuff>
<Device pos="6" code="7">Autologous Tissue Substitute</Device>
<Device pos="6" code="J">Synthetic Substitute</Device>
<Device pos="6" code="K">Nonautologous Tissue Substitute</Device>
</stuff>
I've tried the following XSLT, but it just spews errors at me:
<xsl:template match="axis">
<stuff>
<xsl:apply-templates select="label" />
</stuff>
</xsl:template>
<xsl:template match="label">
<xsl:element name="{../title}">
<xsl:value-of select="text()" />
</xsl:element>
<xsl:attribute name="pos">
<xsl:value-of select="../@pos" />
</xsl:attribute>
<xsl:attribute name="code">
<xsl:value-of select="@code" />
</xsl:attribute>
</xsl:template>
<xsl:element>element. Place them inside (before the<xsL:value-of>element) and it will work.