i am trying to filter on a specific field and concat on another field:
Input:
<?xml version="1.0" encoding="UTF-8"?>
<payloads>
<payload>
<firstname>michael</firstname>
<secondname>brown</secondname>
<number>1</number>
</payload>
<payload>
<firstname>michael</firstname>
<secondname>brown</secondname>
<number>2</number>
</payload>
<payload>
<firstname>michael</firstname>
<secondname>brown</secondname>
<number>3</number>
</payload>
</payloads>
Output:
<?xml version="1.0" encoding="UTF-8"?>
<payloads>
<payload>
<firstname>michael</firstname>
<secondname>brown</secondname>
<number>1,2,3</number>
</payload>
</payloads>
I know that i need to loop through each payload tag, but at the moment i am unable to get it too output correctly. At the moment i have this:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="payloads">
<xsl:copy>
<xsl:for-each select="payload">
<payload>
<xsl:value-of select="firstname"/>
<xsl:value-of select="secondname"/>
<xsl:value-of select="number"/>
</payload>
</xsl:for-each>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
firstname,secondnameand then "aggregate" (concat) all of their numbers?