Reputation:
I have some XML similar to this:
<envelope xmlns="http://test">
<header>
<msgId />
</header>
<body>
<element1 />
</body>
</envelope>
I want to add a namespace to the <element1>
node. Can anyone help me how to do this with XSLT?
Upvotes: 0
Views: 275
Reputation: 5892
Use Attribute Value Templates with name()
<xsl:template match="element1">
<xsl:element name="{name()}" namespace="http://other-namespace">
…
with identity transformation will give you
<envelope xmlns="http:\\test">
<header>
<msgId/>
</header>
<body>
<element1 xmlns="http://other-namespace"/>
…
Upvotes: 1
Reputation: 32831
<xsl:template match="element1">
<xsl:element name="element1" namespace="http:..."/>
</xsl:template>
Upvotes: 1