let's say I have this input file
<root>
<keyword>
<name>foo</name>
<value>bar</value>
</keyword>
<keyword>
<name>123</name>
<value>456</value>
</keyword>
</root>
and I want this output:
<root>
<keyword>
<name>foobar</name>
<value>bar</value>
</keyword>
<keyword>
<name>123</name>
<value>456</value>
</keyword>
</root>
Now, I have this working transformation, but I want to know how to make it more elegant.
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<!-- copy all nodes and attributes -->
<xsl:template match="@*|node()" name = "identity">
<xsl:copy >
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match = "/root/keyword/name[text() = 'foo']">
<name>foobar</name>
</xsl:template>
</xsl:stylesheet>
After matching the desired node, I am repeatedly setting it again instead of simply replacing it. Can I do this more elegantly? My request may sound a little ridiculous, but I want to dig deeper into xslt and understand better.
Thanks very much!