V
V
Vladimir2014-08-19 20:26:52
XSL & XSLT
Vladimir, 2014-08-19 20:26:52

How to make xsl:key work in the current context?

There is a script snippet:

<xsl:apply-templates select="item1/item2[generate-id(.)=generate-id(key('DutyKey',item3))]">
  <xsl:sort order="ascending" select="item3"/>	
</xsl:apply-templates>

With the help of which I get rid of duplication of lines when displaying a table in the called template.
The xml itself looks like:
<item0>
  <item1>
    <item2>
      <item3>
      </item3>
    </item2>
    <item2>
      <item3>
      </item3>
    </item2>
  </item1>
</item0>

There can be several item0 elements - and this is the problem. The keys are built immediately for the entire document, and not for the current item1, and as a result, the table is filled only for the first item0.
How can I make key() generate keys for the current context only?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question