i would like convert xml, that:
This is my code:
<?xml version="1.0" encoding="UTF-8"?>
<IDataXMLCoder version="1.0">
<record javaclass="xxx">
<record name="result" javaclass="yyy">
<value name="errorCode">0</value>
<value name="errorDesc">OK</value>
</record>
</record>
</IDataXMLCoder>
And i would like to convert to something like that:
<IDataXMLCoder>
<record>
<result>
<errorCode>0</errorCode>
<errorDesc>OK</errorDesc>
</result>
</record>
</IDataXMLCoder>
As you see,
name="errorCode"
is now the name of node. Value of this node is
0
I wrote so far that code:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="no" indent="yes"/>
<!--<xsl:strip-space elements="*"/>--> <!--po usunieciu nie bedzie wciec-->
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match=
"*/@*[contains('|javaclass|version|',
concat('|',name(),'|')
)
]"/>
<xsl:template match="@*">
<xsl:element name="{current()}">
<xsl:value-of select="."/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
And i got that:
<IDataXMLCoder>
<record>
<record>
<result>result</result>
<value>
<errorCode>errorCode</errorCode>0</value>
<value>
<errorDesc>errorDesc</errorDesc>OK</value>
</record>
</record>
</IDataXMLCoder>
So, how can i turn it into what i want? Thanks, for any help.
Here is a sample stylesheet that achieves the described result for the posted input sample:
If that does not suffice then you need to explain your requirements in more detail.