I got the following XML:
<?xml version="1.0" encoding="UTF-8"?>
<batch>
  <batchnummer>782</batchnummer>
  <continueonerror>true</continueonerror>
  <metafileversion>1.0</metafileversion>
<documentset>
  <naam></naam>
  <type></type>
  <subsets>
<subset>
  <staple>true</staple>
  <subdocuments>
    <subdocument>
      <document>thr6UhEw5bER6Cjt8uKOCg</document>
      <stamp></stamp>
      <mediatype>Briefpapier</mediatype>
      <duplex>false</duplex>
    </subdocument>
    <subdocument>
      <document>thr6UhEw5bER6Cjt8uRUiA</document>
      <stamp></stamp>
      <mediatype>Briefpapier</mediatype>
      <duplex>false</duplex>
    </subdocument>
  </subdocuments>
</subset>
<subset>
  <staple>true</staple>
  <subdocuments>
    <subdocument>
      <document>thr6UhEw5bER6Cjt8uSxgA</document>
      <stamp></stamp>
      <mediatype>Blanco</mediatype>
      <duplex>false</duplex>
    </subdocument>
    <subdocument>
      <document>thr6UhEw5bER6Cjt8uSCCg</document>
      <stamp></stamp>
      <mediatype>Blanco</mediatype>
      <duplex>false</duplex>
    </subdocument>
    <subdocument>
      <document>thr6UhEw5bER6Cjt8uKOCg</document>
      <stamp></stamp>
      <mediatype>Briefpapier</mediatype>
      <duplex>false</duplex>
    </subdocument>
    <subdocument>
      <document>thr6UhEw5bER6Cjt8uUH-A</document>
      <stamp></stamp>
      <mediatype>Briefpapier</mediatype>
      <duplex>false</duplex>
    </subdocument>
  </subdocuments>
</subset>
</subsets>
  <documenten>
    <document>
      <naam>00000782_000001.rtf</naam>
      <code>thr6UhEw5bER6Cjt8uKOCg</code>
      <duplex>false</duplex>
      <type>RTF</type>
    </document>
    <document>
      <naam>00000782_000002.rtf</naam>
      <code>thr6UhEw5bER6Cjt8uRUiA</code>
      <duplex>false</duplex>
      <type>RTF</type>
    </document>
    <document>
      <naam>00000782_000003.rtf</naam>
      <code>thr6UhEw5bER6Cjt8uSCCg</code>
      <duplex>false</duplex>
      <type>RTF</type>
    </document>
    <document>
      <naam>00000782_000004.rtf</naam>
      <code>thr6UhEw5bER6Cjt8uSxgA</code>
      <duplex>false</duplex>
      <type>RTF</type>
    </document>
    <document>
      <naam>00000782_000005.rtf</naam>
      <code>thr6UhEw5bER6Cjt8uUH-A</code>
      <duplex>false</duplex>
      <type>RTF</type>
    </document>
  </documenten>
</documentset>
  <batchcontrole>
    <cntset>29</cntset>
    <cntdoc>75</cntdoc>
    <cntsub>58</cntsub>
  </batchcontrole>
</batch>
and the following XSLT:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
    <xsl:for-each select="//subsets/subset">
        <subset>
            <xsl:for-each select="subdocuments/subdocument">
                <documentname><xsl:value-of select="./document"/></documentname>
                <documentcode><xsl:value-of select="//document/naam[../code='./document']/text()"/></documentcode>
            </xsl:for-each>
        </subset>
    </xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Somehow I cant dynamicly select the "naam" node. when i do a specific xpath select example
//document/naam[../code='thr6UhEw5bER6Cjt8uSCCg']/text()
It works fine but as soon as I replace it with current()/document or ./document it doenst retrieve anything anymore...
when I use a static xpath it just works fine and retrieve the information for every foreach loop.
How can I make the xpath dynamicly inside de xslt?
Currently trying to figure out xslt although I cant really get it to work properly...