I have an xml file where i need to replace one of the tag without replacing the incoming prefix for the namespace. For example for below XML:
<f:table xmlns:f="https://www.test.com">
<f:name>Peter</f:name>
<f:lname>Jenkins</f:lname>
<f:height>71</f:height>
</f:table>
I need to replace lname with lastname but still keep the prefix (f in this case) intact. Desired output would be like below. Note the prefix can change so it won't be f always
<f:table xmlns:f="https://www.test.com">
<f:name>Peter</f:name>
<f:lastname>Jenkins</f:lastname>
<f:height>71</f:height>
</f:table>
I have tried with below XSLT and this would replace lname with lastname without the original prefix intact. Please help
<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="table/lname">
<lastname><xsl:apply-templates select="@*|node()" /></lastname>
</xsl:template>
</xsl:stylesheet>