xsl-list
[Top] [All Lists]

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

2005-01-05 21:40:48
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...
$levelreference is an RTF which I populated by using
xsl:for-each on a key. My XML is very complex so I am
using lots of keys to get the appropriate result.
Again also I can see some performance degradation
because of usage of lost of xsl:for-each. Anyway I
will look into the performance later.
Thanks for your help.

regards,
Ranjan

--- Geert Josten <Geert(_dot_)Josten(_at_)daidalos(_dot_)nl> wrote:

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


--~------------------------------------------------------------------
XSL-List info and archive: 
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to:
http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--





                
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - 250MB free storage. Do more. Manage less. 
http://info.mail.yahoo.com/mail_250

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>