DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5761>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5761

Multi Level Sorting fails when select-statement returns no result in xsl:sort

           Summary: Multi Level Sorting fails when select-statement returns
                    no result in xsl:sort
           Product: XalanJ2
           Version: 2.2.x
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Major
          Priority: Other
         Component: Xalan
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


I detected a bug in xsl:sort when trying to use
parameters in the XSL-stylesheet to control/select
the sorting criteria.

The way how the stylesheet is constructed to do this
is described in 'XSLT Programmers Reference, 2nd ed.,
Michael Kay, Wrox Press' on page 298.

I've done test against the Microsoft MSXML-Stylesheet
Processor, which behaves correctly to the specification.
Xalan failes as describes below:

I put together a simple test case:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
        
<xsl:output method="html"/>


<xsl:template match="/">
<html>
<head>
<title>XSL Sorting Example</title>
</head>
<body>
<h3>Result of sorted entries:</h3>
<table border="1">
<tr><th>LineCnt</th><th>Position</th><th>Name</th><th>Key 1</th><th>Key 
2</th><th>Key 3</th></tr>
                                
<!-- Multi Level Sorting is done in the following xslt-element
      Have a look at the parameter-value of the select-attribute
      in the first <xsl:sort> element:
                                      
         Correct behviour:
         select="@key3": This gives back a valid list of values,
                                            so sorting is done correctly. 
Setting this
                                            selection critera returns values 
found in the
                                            example data.
                                                                
        select="@key4": Because there are no 'key4' attributes
                                           in the example data, no values are 
returned
                                           after evaluation of this expression. 
                                           In this situation Xalan didn't use 
next level
                                           for sorting ('key2'-values) instead 
does
                                           something undefined.
                                           (Using the third sorting-level, 
seems to skip sorting-level 2)
                                                                 
      This behaivour leads to wrong results, if you control the sorting
      hierarchy with parameters
-->
<xsl:apply-templates select="example/entry">
        <xsl:sort select="@key4" data-type="number"/>
        <xsl:sort select="@key2" data-type="number"/>
        <xsl:sort select="@key3" data-type="number"/>
</xsl:apply-templates>
                                
                                
</table>
</body>
</html>

</xsl:template>

<!-- Just outputing some data -->
<xsl:template match="entry">
        <tr>
             <td><xsl:value-of select="position()"/></td>
             <td><xsl:value-of select="@pos"/></td>
                <td><xsl:value-of select="."/></td>
                <td><xsl:value-of select="@key1"/></td>
                <td><xsl:value-of select="@key2"/></td>
                <td><xsl:value-of select="@key3"/></td>
        </tr>
</xsl:template>

</xsl:stylesheet>

Reply via email to