Uploaded image for project: 'XalanJ2'
  1. XalanJ2
  2. XALANJ-2546

xsl:sort lang attribute ignores parameter value, only hard-coding works

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.7.1
    • Fix Version/s: 2.7.2
    • Component/s: Xalan
    • Security Level: No security risk; visible to anyone (Ordinary problems in Xalan projects. Anybody can view the issue.)
    • Labels:
      None
    • Environment:
      java version "1.6.0_20", Xalan 2.7.1

      Description

      I have an XSL stylesheet that uses xsl:sort for a list of names. I added the lang attribute to the sort, using a variable passed to the stylesheet for its value: lang="{$locale}". When sorting a list of Russian names, the ordering is incorrect. I can see that the parameter value is present and correct in the stylesheet as it executes by using an xsl:message statement. When I hard-code the value of lang to ru (lang="ru"), the sort works correctly. This defect cause improper sorting in Russian and Polish, a defect in our application.

      1. sorting-example.zip
        5 kB
        Don Smith
      2. XALANJ-2546.diff
        2 kB
        Gary Gregory

        Issue Links

          Activity

          Hide
          tbaki Tarik Baki added a comment -

          Could we get feedback on this?

          Show
          tbaki Tarik Baki added a comment - Could we get feedback on this?
          Hide
          ajez Adam Jez added a comment -

          Could we get feedback regarding this defect?

          Show
          ajez Adam Jez added a comment - Could we get feedback regarding this defect?
          Hide
          garydgregory Gary Gregory added a comment -

          Can you provide a sample input document, XSL and expected output document?

          Better yet, a unit test?

          Show
          garydgregory Gary Gregory added a comment - Can you provide a sample input document, XSL and expected output document? Better yet, a unit test?
          Hide
          dhsmith Don Smith added a comment - - edited

          I have attached sorting-examples.zip which contains a simple alphabet sorting xsl, plus three alphabet files. The sorting seems to work correctly except in the -xsltc case, where the last letter in Polish looks like an L, instead of a Z.

          I have also attached the stylesheet from our application that does not work correctly (we compile all of our stylesheets using xsltc). Search for the $lang parameter to see the sorts that don't work properly with Russian and Polish names, even though the proper language code is passed to the stylesheet at runtime.

          Show
          dhsmith Don Smith added a comment - - edited I have attached sorting-examples.zip which contains a simple alphabet sorting xsl, plus three alphabet files. The sorting seems to work correctly except in the -xsltc case, where the last letter in Polish looks like an L, instead of a Z. I have also attached the stylesheet from our application that does not work correctly (we compile all of our stylesheets using xsltc). Search for the $lang parameter to see the sorts that don't work properly with Russian and Polish names, even though the proper language code is passed to the stylesheet at runtime.
          Hide
          ajez Adam Jez added a comment -

          When could we get feedback regarding this defect?

          Show
          ajez Adam Jez added a comment - When could we get feedback regarding this defect?
          Hide
          ajez Adam Jez added a comment -

          When could we get any feedback regarding this defect?

          Show
          ajez Adam Jez added a comment - When could we get any feedback regarding this defect?
          Hide
          ajez Adam Jez added a comment -

          When could we get any feedback regarding this defect?

          Show
          ajez Adam Jez added a comment - When could we get any feedback regarding this defect?
          Hide
          garydgregory Gary Gregory added a comment -

          I'll take a look at this tonight.

          Show
          garydgregory Gary Gregory added a comment - I'll take a look at this tonight.
          Hide
          garydgregory Gary Gregory added a comment -

          Thank you for the example test. I've ported these to the Xalan test framework as:

          commit -m "Test XALANJ-2546 xsl:sort lang attribute ignores parameter value, only hard-coding works...." -N (13 paths specified)
              Adding         C:/svn/org/apache/xalan/test/tests/conf/sort/sort-alphabet-english.param
              Adding         C:/svn/org/apache/xalan/test/tests/conf/sort/sort-alphabet-english.xml
              Adding         C:/svn/org/apache/xalan/test/tests/conf/sort/sort-alphabet-english.xsl
              Adding         C:/svn/org/apache/xalan/test/tests/conf/sort/sort-alphabet-polish.param
              Adding         C:/svn/org/apache/xalan/test/tests/conf/sort/sort-alphabet-polish.xml
              Adding         C:/svn/org/apache/xalan/test/tests/conf/sort/sort-alphabet-polish.xsl
              Adding         C:/svn/org/apache/xalan/test/tests/conf/sort/sort-alphabet-russian.param
              Adding         C:/svn/org/apache/xalan/test/tests/conf/sort/sort-alphabet-russian.xml
              Adding         C:/svn/org/apache/xalan/test/tests/conf/sort/sort-alphabet-russian.xsl
              Sending        C:/svn/org/apache/xalan/test/tests/conf-gold
              Adding         C:/svn/org/apache/xalan/test/tests/conf-gold/sort/sort-alphabet-english.out
              Adding         C:/svn/org/apache/xalan/test/tests/conf-gold/sort/sort-alphabet-polish.out
              Adding         C:/svn/org/apache/xalan/test/tests/conf-gold/sort/sort-alphabet-russian.out
              Transmitting file data ...
              Committed revision 1347840.

          See the param files for instructions.

          To see the tests pass for TRAX:

          Run org.apache.qetest.xsl.StylesheetTestletDriver -goldDir tests/conf-gold -param.lang ru

          To see the same tests fail for XSLTC:

          Run org.apache.qetest.xsl.StylesheetTestletDriver -goldDir tests/conf-gold -param.lang ru -flavor xsltc

          Make sure you have the "output" directory on the classpath.

          Looking at org.apache.xalan.xsltc.compiler.Sort, it seems clear that _lang is not coded right because it is not a AttributeValue.

          The attached patch fixes that BUT does not fix the issue. The behavior appears unchanged.

          This requires more digging or help from others.

          It would be interesting to know if XSLTC can deal with /any/ input parameters or if this is isolated to the sort class.

          Show
          garydgregory Gary Gregory added a comment - Thank you for the example test. I've ported these to the Xalan test framework as: commit -m "Test XALANJ-2546 xsl:sort lang attribute ignores parameter value, only hard-coding works...." -N (13 paths specified) Adding C:/svn/org/apache/xalan/test/tests/conf/sort/sort-alphabet-english.param Adding C:/svn/org/apache/xalan/test/tests/conf/sort/sort-alphabet-english.xml Adding C:/svn/org/apache/xalan/test/tests/conf/sort/sort-alphabet-english.xsl Adding C:/svn/org/apache/xalan/test/tests/conf/sort/sort-alphabet-polish.param Adding C:/svn/org/apache/xalan/test/tests/conf/sort/sort-alphabet-polish.xml Adding C:/svn/org/apache/xalan/test/tests/conf/sort/sort-alphabet-polish.xsl Adding C:/svn/org/apache/xalan/test/tests/conf/sort/sort-alphabet-russian.param Adding C:/svn/org/apache/xalan/test/tests/conf/sort/sort-alphabet-russian.xml Adding C:/svn/org/apache/xalan/test/tests/conf/sort/sort-alphabet-russian.xsl Sending C:/svn/org/apache/xalan/test/tests/conf-gold Adding C:/svn/org/apache/xalan/test/tests/conf-gold/sort/sort-alphabet-english.out Adding C:/svn/org/apache/xalan/test/tests/conf-gold/sort/sort-alphabet-polish.out Adding C:/svn/org/apache/xalan/test/tests/conf-gold/sort/sort-alphabet-russian.out Transmitting file data ... Committed revision 1347840. See the param files for instructions. To see the tests pass for TRAX: Run org.apache.qetest.xsl.StylesheetTestletDriver -goldDir tests/conf-gold -param.lang ru To see the same tests fail for XSLTC: Run org.apache.qetest.xsl.StylesheetTestletDriver -goldDir tests/conf-gold -param.lang ru -flavor xsltc Make sure you have the "output" directory on the classpath. Looking at org.apache.xalan.xsltc.compiler.Sort , it seems clear that _lang is not coded right because it is not a AttributeValue . The attached patch fixes that BUT does not fix the issue. The behavior appears unchanged. This requires more digging or help from others. It would be interesting to know if XSLTC can deal with /any/ input parameters or if this is isolated to the sort class.
          Hide
          garydgregory Gary Gregory added a comment -

          Fixed in SVN: Committed revision 1348522.

          Show
          garydgregory Gary Gregory added a comment - Fixed in SVN: Committed revision 1348522.
          Hide
          williamstw Tim Williams added a comment -

          Fixed - see Gary's latest comment.

          Show
          williamstw Tim Williams added a comment - Fixed - see Gary's latest comment.
          Hide
          ajez Adam Jez added a comment -

          I would like to recall that this issue is still not fixed. Don tested the patch the day after it was committed and unfortunately it did not resolve the issue. Please reopen this defect.

          Show
          ajez Adam Jez added a comment - I would like to recall that this issue is still not fixed. Don tested the patch the day after it was committed and unfortunately it did not resolve the issue. Please reopen this defect.
          Hide
          garydgregory Gary Gregory added a comment -

          Are you getting the latest from SVN and building locally?

          Is your specific case not covered in the test cases I added?

          Show
          garydgregory Gary Gregory added a comment - Are you getting the latest from SVN and building locally? Is your specific case not covered in the test cases I added?
          Hide
          dhsmith Don Smith added a comment -

          I got the latest source from svn and built a new xalan.jar. If fixes the problem.

          Show
          dhsmith Don Smith added a comment - I got the latest source from svn and built a new xalan.jar. If fixes the problem.
          Hide
          garydgregory Gary Gregory added a comment -

          Ok, great. Thank you for the update.

          Show
          garydgregory Gary Gregory added a comment - Ok, great. Thank you for the update.

            People

            • Assignee:
              Unassigned
              Reporter:
              dhsmith Don Smith
            • Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development