[Solved] Separate duplicates from unique

If I understand correctly your explanation, you want to do something like: XSL 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:key name=”cust-by-charge” match=”Customer” use=”chargeto” /> <xsl:template match=”/CustomerRecord”> <Root> <Customer_PO> <xsl:copy-of select=”Customer[count(key(‘cust-by-charge’, chargeto)) > 1]”/> </Customer_PO> <Customer_Falty> <xsl:copy-of select=”Customer[count(key(‘cust-by-charge’, chargeto)) = 1]”/> </Customer_Falty> </Root> </xsl:template> </xsl:stylesheet> Possibly there’s a more elegant approach that would … Read more

[Solved] Merge different products belong to each standard – V2 [duplicate]

This XSLT will do the thing: <xsl:stylesheet xmlns:xsl=”http://www.w3.org/1999/XSL/Transform” xmlns:x=”http://ws.wso2.org/dataservice” xmlns=”http://ws.wso2.org/dataservice” exclude-result-prefixes=”x” version=”1.0″> <xsl:output indent=”yes” method=”xml” /> <xsl:template match=”x:Standards”> <Standards namespace=”{namespace-uri()}”> <xsl:apply-templates select=”.//x:Standard” /> </Standards> </xsl:template> <xsl:template match=”x:Standard”> <Standard> <xsl:copy-of select=”x:ProductID” /> <xsl:copy-of select=”x:Prefix”/> <xsl:copy-of select=”x:SNumber”/> <RelatedProducts> <xsl:apply-templates select=”.//x:RelatedProduct”/> </RelatedProducts> <xsl:copy-of select=”x:S1″/> <xsl:copy-of select=”x:S2″/> </Standard> </xsl:template> <xsl:template match=”x:RelatedProduct”> <xsl:element name=”RelatedProduct”> <xsl:element name=”RelationType”> <xsl:value-of select=”name(..)” /> </xsl:element> … Read more

[Solved] Sibling as Child

In XSLT 2.0, you could have probably made use of xsl:for-each-group, using its group-starting-with attribute. In XSLT 1.0 though, this can be achieved by use of keys. You can define a key to look up the Loop-2000B elements by their first preceding Loop-2000A element <xsl:key name=”B” match=”ex:Loop-2000B” use=”generate-id(preceding-sibling::ex:Loop-2000A[1])” /> Similarlym you could do the same … Read more

[Solved] Tokenize and compare dates in xslt 1.0

Xalan supports the EXSLT str:tokenize() function, so that will take care of that. After that, you just need to sort the tokens by the individual date & time components, and grab the last one. <xsl:for-each select=”str:tokenize($dates, ‘;’)”> <!– sort by year –> <xsl:sort select=”substring(., 9, 4)”/> <!– sort by month –> <xsl:sort select=”string-length(substring-before(‘JanFebMarAprMayJunJulAugSepOctNovDec’, substring(., 1, … Read more