title: How to get path (array child numbers) to a given element in XSLT
body: <p>I wonder, if there is a way to determine a path to a given source node in xslt. Let's assume the following source XML file:</p>
  
  <pre><code>&lt;one&gt;
   &lt;two&gt;
    &lt;three/&gt;
    &lt;three this="true"/&gt;
   &lt;/two&gt;
   &lt;two&gt;
    &lt;three/&gt;
   &lt;/two&gt;
  &lt;/one&gt;
  </code></pre>
  
  <p>I'd like to have a function (custom template) that for node three with attribute this="true" would output something like the following: "1,1,2" - which means: starting from the root go into the first element, then to the first element and then to the second element to reach this particular node.</p>
  
  <p>(the purpouse of this is that i want to have unique identifiers to content that i take from a particular place in the source XML document and transform it to my desired output)</p>
  
  <p>EDIT:
  i found this:</p>
  
  <pre><code>  &lt;xsl:template name="genPath"&gt;
      &lt;xsl:param name="prevPath"/&gt;
      &lt;xsl:variable name="currPath" select="concat('/',name(),'[',
        count(preceding-sibling::*[name() = name(current())])+1,']',$prevPath)"/&gt;
      &lt;xsl:for-each select="parent::*"&gt;
        &lt;xsl:call-template name="genPath"&gt;
          &lt;xsl:with-param name="prevPath" select="$currPath"/&gt;
        &lt;/xsl:call-template&gt;
      &lt;/xsl:for-each&gt;
      &lt;xsl:if test="not(parent::*)"&gt;
        &lt;xsl:value-of select="$currPath"/&gt;      
      &lt;/xsl:if&gt;
    &lt;/xsl:template&gt;
  </code></pre>
  
  <p>under: <a href="https://stackoverflow.com/questions/953197/how-do-you-output-the-current-element-path-in-xslt">How do you output the current element path in XSLT?</a></p>
  
  <p>With several modification, this will output what i need by putting:</p>
  
  <pre><code>&lt;xsl:call-template name="genPath"&gt;
  </code></pre>
  
  <p>Somewhere, but this way of calling it would output the path to the current node. How to modify it to enable to write a path to a specific child of the current node?</p>
  
  <p>Something like:</p>
  
  <pre><code>&lt;xsl:call-template name="genPath" select="n1:tagname/n1:tagname2"&gt;
  </code></pre>
  
  <p>(i know that the syntax above is incorrect)</p>