I´m new with XSLT and I'm trying to transform a XML in other.
The source XML is something like that:
<NoticeContent>
<Version> 1.0 </Version>
<Publisher>me</Publisher>
<Specification>1</Specification>
<Instance>1</Instance>
<NewState>10</NewState>
<Info>
<SDTInInfoExtra>
<Name> Client</Name>
<Value> 1 </Value>
</SDTInInfoExtra>
<SDTInInfoExtra>
<Name> LocalId </Name>
<Value>10 </Value>
</SDTInInfoExtra>
</Info>
</NoticeContent>
And the expected:
<?xml version="1.0" encoding="UTF-8"?>
<NoticeContent>
<Version></Version>
<Timestamp></Timestamp>
<Publisher></Publisher>
<Instance></Instance>
<NewState></NewState>
<Info>
<Characteristic name="Client" value="1" />
<Characteristic name="LocalId" value="10" />
</Info>
</NoticeContent>
I'm trying with the following XSL:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()" />
</xsl:copy>
</xsl:template>
<xsl:template match="Info">
<xsl:for-each select="SDTInInfoExtra">
<xsl:value-of select="Name" />
<xsl:value-of select="Value" />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
The problem is trying to convert the tags like:
<SDTInInfoExtra>
<Name> LocalId </Name>
<Value>10 </Value>
</SDTInInfoExtra>
into:
<Characteristic name="Client" value="1" />
Thanks a lot for the help!