Reputation: 71
I have currently this type of request. The problem is that the existing code can manage only one block of Attribute. I need to cut the attribute block and create N new blocks.
Input :
<Request>
<Attributes>
<Attribute>
<Complimentary>
Test1
</Complimentary>
</Attribute>
<Attribute>
<Complimentary>
Test2
</Complimentary>
</Attribute>
<Attribute>
<Complimentary>
TestN
</Complimentary>
</Attribute>
</Attributes>
</Request>
Output :
<Request>
<Attributes>
<Attribute>
<Complimentary>
Test1
</Complimentary>
</Attribute>
</Attributes>
<Attributes>
<Attribute>
<Complimentary>
Test2
</Complimentary>
</Attribute>
</Attributes>
<Attributes>
<Attribute>
<Complimentary>
TestN
</Complimentary>
</Attribute>
</Attributes>
</Request>
Thanks in advance
Upvotes: 0
Views: 200
Reputation: 116957
If I read this correctly, you want to do:
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Attributes">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="Attribute">
<Attributes>
<xsl:copy-of select="."/>
</Attributes>
</xsl:template>
</xsl:stylesheet>
Upvotes: 1