This is my first question here.
I am trying to create a xslt that transforms XML to Text. I need to find the distinct list of the LANG and OFFICEID concatenation, that can then be used in a xsl:for-each loop
I have created a minimal Version of the XML I am working with
<docinfo>
<printfile customer="Migrol">
<envelope postagetype="A">
<index name="LANG" value="G"/>
<index name="OFFICEID" value="500"/>
</envelope>
<envelope postagetype="A">
<index name="LANG" value="F"/>
<index name="OFFICEID" value="500"/>
</envelope>
<envelope postagetype="A">
<index name="LANG" value="G"/>
<index name="OFFICEID" value="500"/>
</envelope>
<envelope postagetype="A">
<index name="LANG" value="I"/>
<index name="OFFICEID" value="300"/>
</envelope>
<envelope postagetype="A">
<index name="LANG" value="G"/>
<index name="OFFICEID" value="100"/>
</envelope>
<envelope postagetype="A">
<index name="LANG" value="G"/>
<index name="OFFICEID" value="100"/>
</envelope>
<envelope postagetype="A">
<index name="LANG" value="I"/>
<index name="OFFICEID" value="300"/>
</envelope>
<envelope postagetype="A">
<index name="LANG" value="G"/>
<index name="OFFICEID" value="500"/>
</envelope>
</printfile>
</docinfo>
With XPath 2.0 this can be solved by using the Statement
/docinfo/printfile/distinct-values(envelope/concat(index[@name='OFFICEID']/@value, index[@name='LANG']/@value))
or
/docinfo/printfile/envelope[not(concat(index[@name='OFFICEID']/@value, index[@name='LANG']/@value)=preceding-sibling::envelope/concat(index[@name='OFFICEID']/@value, index[@name='LANG']/@value))]/concat(index[@name='OFFICEID']/@value, index[@name='LANG']/@value)
Sadly I have not found a way to acchive this in XPath 1.0. The concat function seems to be giving me hassles here.
A simple version of the XSLT I want to use
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="printfile">
<xsl:for-each select="/docinfo/printfile/envelope[not(concat(index[@name='OFFICEID']/@value, index[@name='LANG']/@value)=preceding-sibling::envelope/concat(index[@name='OFFICEID']/@value, index[@name='LANG']/@value))]">
<xsl:variable name="OID" select="index[@name='OFFICEID'][1]/@value"/>
<xsl:variable name="LANG" select="index[@name='LANG'][1]/@value"/>
<xsl:value-of select="$OID"/>
<xsl:text> </xsl:text>
<xsl:value-of select="$LANG"/>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:template>
<!-- suppress default text -->
<xsl:template match="text()"/>
</xsl:stylesheet>
The result should look something like
"500 G"
"500 F"
"300 I"
"100 G"
Does anyone have a suggestion on how this could be achieved with XSLT and XPath 1.0