[xslt] possible bug in xsltproc/libxslt


hope to get a clue if I hit a bug or if I'm just doing something stupid/illegal.

I've attached an .xml file and an .xslt stylesheet.

I tried to simplfy this as much as possible, without loosing the relevance of the problem.

The output I get by running

$ xsltproc bug.xslt bug.xml

      Class 3
             Item 3, weight 1, position 1
             Item 1, weight 3, position 0
             Item 2, weight 2, position 1

isn't sorted as expected, based on the items weight.

It might be that there is no bug whatsoever and I'm just doing something illegal, however I couldn't so far get any evidence that the construct I'm using is flawed or not allowed.

I know now that the problem is related to the

<xsl:sort select="/root/items/item[ item_id = @it_id]/@weight"

construct I'm using; the problem disappears if I do not try to select for sorting an value outside/above of the current node_set, but so far I just cannot convince me that this would be incorrect or illegal.

Many thanks,

Iosif Fettich

PS. Using Fedora Core 4,

$ rpm -qi libxslt
Name : libxslt Relocations: /usr
Version : 1.1.14 Vendor: Red Hat, Inc.
Release : 2 Build Date: Lu 23 mai 2005 21:30:18 EEST
Install Date: Sî 25 iun 2005 11:51:26 EEST Build Host: tweety.build.redhat.com
Group : Development/Libraries Source RPM: libxslt-1.1.14-2.src.rpm
Size : 1857109 License: MIT
Signature : DSA/SHA1, Mi 25 mai 2005 00:42:42 EEST, Key ID b44269d04f2a6fd2
Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
URL : http://xmlsoft.org/XSLT/
Summary : Library providing XSLT support.
Description :
This C library lets you transform XML files into other XML files (or
HTML, text, etc.) using the standard XSLT stylesheet transformation
mechanism. To use it, you need to have a versi
    <item item_id="1" weight="3"/>
    <item item_id="2" weight="2"/>
    <item item_id="3" weight="1"/>
    <class class_id="1" class_name="C1"/>
    <class class_id="2" class_name="C2"/>
    <class class_id="3" class_name="C3"/>
    <match cl_id="3" it_id="3"/> 
    <match cl_id="3" it_id="1"/> 
    <match cl_id="3" it_id="2"/> 

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0" 




<xsl:output encoding="ISO-8859-1" 




<xsl:template match="/">

  <xsl:for-each select="/root/classes/class">

    <xsl:variable name="class_id"             select="@class_id"/>

    <xsl:if test="count( /root/matches/match [ cl_id = $class_id ] ) >= 1">

      Class <xsl:value-of select="$class_id"/>

      <xsl:call-template name="show_one_class_items">

        <xsl:with-param name="class_id" select="$class_id"/>





<xsl:template name="show_one_class_items">

  <xsl:param name="class_id"/>

        <xsl:for-each select="/root/matches/match[ @cl_id = $class_id]">

          <xsl:sort select="/root/items/item[ item_id = @it_id]/@weight" 



          <xsl:variable name="item_id" select="@it_id"/>

          <xsl:variable name="position" select="position() mod 2"/>

          <xsl:for-each select="/root/items/item[ @item_id = $item_id ]">

             Item <xsl:value-of select="concat( $item_id, 

                                                ', weight ', @weight, 

                                                ', position ', $position)"/>






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