У меня есть следующий xml. Это набор родительских узлов записи, содержащих идентификаторы, количество и категорию.
<Data>
<record>
<identifier>1000</identifier>
<category>B</category>
<quantity>90.00</quantity>
</record>
<record>
<identifier>1000</identifier>
<category>B</category>
<quantity>50.00</quantity>
</record>
<record>
<identifier>1001</identifier>
<category>B</category>
<quantity>13.00</quantity>
</record>
<record>
<identifier>1002</identifier>
<category>B</category>
<quantity>100.00</quantity>
</record>
I need to group by the record element by the child "identifier". The excpected output is this.
<Data>
<records>
<record>
<identifier>1000</identifier>
<category>B</category>
<quantity>90.00</quantity>
</record>
<record>
<identifier>1000</identifier>
<category>B</category>
<quantity>50.00</quantity>
</record>
</records>
<records>
<record>
<identifier>1001</identifier>
<category>B</category>
<quantity>13.00</quantity>
</record>
</records>
<records>
<record>
<identifier>1002</identifier>
<category>B</category>
<quantity>100.00</quantity>
</record>
</records>
I'm using this xslt but it's not working neither at grouping level.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:output method="xml" indent="yes" encoding="UTF-8" omit-xml-declaration="yes" />
<xsl:template match="Data">
<Data>
<xsl:for-each-group select="record" group-by="identifier">
<records>
<xsl:for-each select="current-group()">
<xsl:copy>
<xsl:value-of select="*" />
</xsl:copy>
</xsl:for-each>
</records>
</xsl:for-each-group>
</Data>
</xsl:template>
How can I fix it to make it work?
<?xml version="2.0" encoding="UTF-8"?>
. Не. - person Alejandro   schedule 28.01.2020