Reputation: 69
New to XSLT/XML transformations and in need of some basic help if possible.
I have an XML file which is similar to
<inputName attribute1="renameUsingThis"> Data </inputName>
I require the output to be
<renameUsingThis attribute1="renameUsingThis"> Data </renameUsingThis>
I've seen some examples on here, but can't tweak to how I need it and don't know enough to reverse engineer at the moment.
Thanks in advance.
Upvotes: 0
Views: 595
Reputation: 106
Try this:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="inputName">
<xsl:element name="{@attribute1}">
<xsl:apply-templates select="node()|@*"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
You may test transformation here: http://www.xsltcake.com/slices/4DKz0w
Upvotes: 3