I need to do two things:
- Remove duplicate notes from source XML
- Generate HTML document with values from the source after the transformation in step 1 (duplicates has been removed)
I have a working solution for each of the two steps in separate XSLT-files but I cannot figure out how to combine the operations in one XSLT-file - so the output of step 1 is used as the input of step 2.
Source data (XML):
<products>
<product>
<price>200EUR</price>
<size>XL</size>
<skuid>453</skuid>
</product>
<product>
<price>200EUR</price>
<size>XL</size>
<skuid>453</skuid>
</product>
</products>
Step 1 file for taking only unique products based on id (XSLT)
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:key name="skukey" match="product" use="skuid"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match=
"product[not(generate-id() = generate-id(key('skukey', skuid)[1]))]"
/>
</xsl:stylesheet>
Step 2 file for generating HTML (XSLT)
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<xsl:for-each select="products/product">
<p>
<xsl:value-of select="price"/>
<xsl:value-of select="size"/>
</p>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>