[no subject]

Essentially, the solution provided does not "Terminate" a for-each or
any such. This is not possible in XSL. What the solution does,
instead, is to choose only the elements that are to be included in the
for-each, totally bypassing those that are not desired.

An example of the difference between procedural programming and
declerative/functional programming:

We want those elem that have numeric values less than or equal 3.

Input:

<?xml version="1.0"?>
<root>
  <elem val="1">Something</elem>
  <elem val="2">Something</elem>
  <elem val="3">Something</elem>
  <elem val="4">Something</elem>
  <elem val="5">Something</elem>
</root>

Procedural solution would be (pseudocode):
<xsl:template match="root">
  <xsl:for-each select="elem">
    <xsl:if test="number(@val) &lt;=3"><xsl:terminate/></xsl:if> <!--
Will not work! -->
    <!-- generate output here -->
  </xsl:for-each>
</xsl:template>

Functional solution, which chooses only the elements to use:
<xsl:template match="root">
  <xsl:for-each select="elem[number(@val) &lt;=3]"> <!-- Here is the
difference -->
    <!-- generate output here -->
  </xsl:for-each>
</xsl:template>

You can use keys to generate an index over the chosen elements for
faster processing, but the generics behind the two approaches are, in
this matter, the same. So a short answer to your question would be
"Yes, you can use keys, as well as other approaches".

I would advice you to make a simple test case (with simple names and
simple structure), and try to solve this. When you understand that,
you can make the case more and more like your real world problem,
until it is solved.
If you have problems, you will have a much better chance of help, if
you post a simple case with desired output, and where you are stuck
with your XSL (simple as well).

Regards,
Ragulf Pickaxe :-)

Current Thread