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