Updated with Minimal, Complete and Verifiable information thanks @Kenneth for drawing my attention.
So, I'm trying to rename an xml attribute using xslt, but I keep getting this error message:
Reference to undeclared namespace prefix: 'json'.
This is my source xml:
<?xml version="1.0" encoding="utf-8"?> <data> <code>SO000009</code> <businessPartner>70833A356B9A428CBDDCD2A76A49681F</businessPartner> <startDateTime>2018-01-25T15:24:27Z</startDateTime> <subject>Test</subject> <equipments jsonArray="true">80202</equipments> </data>
This is how I want the xml to be:
<?xml version="1.0" encoding="utf-16"?> <data xmlns:json="http://james.newtonking.com/projects/json"> <code>SO000009</code> <businessPartner>70833A356B9A428CBDDCD2A76A49681F</businessPartner> <startDateTime>2018-01-25T15:24:27Z</startDateTime> <subject>Test</subject> <equipments json:Array="true">80202</equipments> </data>
And this is my xslt:
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output indent="yes"/> <xsl:template match="/data"> <data xmlns:json="http://james.newtonking.com/projects/json"> <xsl:apply-templates select="node()|@*" /> </data> </xsl:template> <xsl:template match="@*"> <xsl:attribute name="{local-name()}"> <xsl:value-of select="." /> </xsl:attribute> </xsl:template> <xsl:template match="node()"> <xsl:copy> <xsl:apply-templates select="node()|@*" /> </xsl:copy> </xsl:template> <xsl:template match="@jsonArray"> <xsl:attribute name="json:Array"> <xsl:value-of select="."/> </xsl:attribute> </xsl:template> </xsl:stylesheet>
When I'm trying to convert my xml, I keep getting this message:
Error occurred while compiling stylesheet 'CS_jsonArray.xslt'.
Code: 0x80004005
Reference to undeclared namespace prefix: 'json'.