尝试以下操作:
<xsl:template match="products">
<xsl:for-each-group select="product" group-by="parent_product_id">
<xsl:text>"</xsl:text>
<xsl:value-of select="parent_product_id"/><xsl:text>"|"</xsl:text>
<xsl:value-of select="brand_name"/><xsl:text>"|"</xsl:text>
<xsl:value-of select="colour"/><xsl:text>"|"</xsl:text>
<xsl:value-of select="currency"/><xsl:text>"|"</xsl:text>
<xsl:value-of select="rrp_price"/><xsl:text>"|"</xsl:text>
<xsl:value-of select="distinct-values(current-group()/size)" separator=","/><xsl:text>"|"</xsl:text>
<xsl:value-of select="sum(current-group()/stock_quantity)"/><xsl:text>"|"</xsl:text>
<xsl:text>"
</xsl:text>
</xsl:for-each-group>
</xsl:template>
您可以在以下位置看到转换:
https://xsltfiddle.liberty-development.net/94hvTyS