Re: [xslt] possible bug in xsltproc/libxslt

On 2005-11-01 09:00:00 +0200, Iosif Fettich wrote:
> <xsl:for-each select="/root/matches/match[ @cl_id = $class_id ]">
>   <xsl:sort select="/root/items/item[ @item_id = @it_id ]/@weight"
> Attribute @it_id should (in my hopes :) refer to the selected match 
> element... what it apparently does not at all.

Your hopes are not the standard. Of course, @ has the same meaning
before and after the = in the XPath expression above.

> I tried to first set an variable that should hold the @it_id
> attribute and then use sort, like
> <xsl:for-each select="/root/matches/match[ @cl_id = $class_id ]">
>   <xsl:variable name="it_id" value="@it_id"/>
>   <xsl:sort select="/root/items/item[ @item_id = $it_id ]/@weight"
> but that's not working, as sort needs to be the first child of the 
> for-each element.

Yes, because the variable value would depend on the node selected in
for-each, and XSLT doesn't allow variable for this kind of behavior.

Perhaps you should read the XSLT specification and understand the
difference between the current node (given by "current()") and the
context node (given by "."). This would answer your questions.

Vincent Lefèvre <vincent vinc17 org> - Web: <>
100% accessible validated (X)HTML - Blog: <>
Work: CR INRIA - computer arithmetic / SPACES project at LORIA

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]