Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Usage of key inside a for loop of a RTF does not work properly

From: Geert Josten <Geert.Josten@----------->
To:
Date: 1/5/2005 1:02:00 PM
I think I am  quite clear now. SO I can think that As
I am inside for loop of RTF so key selects nodes in
RTF which does not produce any result.

Taking a more close look at what you mailed earlier, I noticed the definition of xsl:key. Though, 
the definition of $levelreference is missing, but I assume that is a reference to a document fragment.



Yes, the problem in your case is that you switch context from input doc to fragment with your outer 
for-each loop. Doing so makes the key work on the fragment instead of the input doc. Your lines 
above are on the right track...



I assume that the key you specified is supposed to work on the input doc rather than the fragment. 
Well, you could use the following trick to switch back context to the input doc:



<xsl:variable name="current" select="." />



<!-- outer loop -->
<xsl:for-each select="node-set($levelreference)/*">
  <xsl:variable name="id"  select="@levelref" />

  <!-- here comes the trick :P -->
  <xsl:for-each select="$current">

    <!-- compressed inner loop to one value-of statement -->
    <xsl:value-of select="key('professionlevelkey', $id)/@value" />

  </xsl:for-each>



</xsl:for-each>



But again, if you can tell us how you construct $levelreference, we might be able to suggest an even 
better solution, preventing use of fragments at all perhaps...



Cheers


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent