XalanJ2
  1. XalanJ2
  2. XALANJ-1368

multiple key definitions (same name) do not work as expected on longer strings

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.4
    • Fix Version/s: 2.7
    • Security Level: No security risk; visible to anyone (Ordinary problems in Xalan projects. Anybody can view the issue.)
    • Labels:
      None
    • Environment:
      Operating System: Other
      Platform: Other
    • Xalan info:
      PatchAvailable

      Description

      At the weekend we found a problem in Cocoon 2.1 (CVS head) using the used Xalan
      2.4.1 and XSLTC there
      (http://marc.theaimsgroup.com/?l=xml-cocoon-dev&m=103985066026426&w=2).

      The files used for the tests were
      xml-cocoon2\src\webapp\samples\flow\examples\prefs\pages\userInfo.xsp
      and version 1.5
      http://cvs.apache.org/viewcvs.cgi/xml-cocoon2/src/java/org/apache/cocoon/components/language/markup/xsp/java/jpath.xsl
      I will attach simplified versions of both files.

      In the XSL there was a aggregated key declaration (or how is it called?):

      <xsl:key name="JPathExprs" match="jpath:if" use="@test"/>
      <xsl:key name="JPathExprs" match="jpath:when" use="@test"/>
      <xsl:key name="JPathExprs" match="jpath:for-each" use="@select"/>
      <xsl:key name="JPathExprs" match="jpath:value-of" use="@select"/>

      When applying templates like

      <xsl:apply-templates select="//jpath:if | //jpath:when | //jpath:value-of |
      //jpath:for-each"/>

      and using a template like

      <xsl:template match="jpath:if | jpath:when | jpath:for-each | jpath:value-of">
      <tr>
      <td>
      <xsl:value-of select="name()"/>
      </td>
      <td>
      <xsl:value-of select="concat(@test, @select)"/>
      </td>
      <td>
      <xsl:value-of select="generate-id()"/>
      </td>
      <td>
      <xsl:value-of select="generate-id(key('JPathExprs', concat(@test,
      @select)))"/>
      </td>
      <td>
      <xsl:value-of select="count(key('JPathExprs', concat(@test,
      @select)))"/>
      </td>
      </tr>
      </xsl:template>

      the generate-id() and the count() return wrong values for strings like "check
      and firstName = ''". The generate-id() return is empty and the count() return is
      0. But as you can guess those expressions are important for Muenchian Grouping.

      1. patch.j1368.txt
        4 kB
        Henry Zongaro
      2. ASF.LICENSE.NOT.GRANTED--test.xsl
        1 kB
        Jörg Heinicke
      3. ASF.LICENSE.NOT.GRANTED--test.xml
        0.8 kB
        Jörg Heinicke

        Issue Links

          Activity

          Hide
          Jörg Heinicke added a comment -

          A work-around is the change of the key definition from the multiple one to a
          single one unioning the elements in match attribute and the attributes in use
          attribute:

          <xsl:key name="JPathExprs"
          match="jpath:if | jpath:when | jpath:for-each | jpath:value-of"
          use="concat(@test, @select)"/>

          Now the generate-id() and count return correct values.

          Show
          Jörg Heinicke added a comment - A work-around is the change of the key definition from the multiple one to a single one unioning the elements in match attribute and the attributes in use attribute: <xsl:key name="JPathExprs" match="jpath:if | jpath:when | jpath:for-each | jpath:value-of" use="concat(@test, @select)"/> Now the generate-id() and count return correct values.
          Hide
          Jörg Heinicke added a comment -

          Created an attachment (id=4223)
          Simplified XML test file.

          Show
          Jörg Heinicke added a comment - Created an attachment (id=4223) Simplified XML test file.
          Hide
          Jörg Heinicke added a comment -

          Created an attachment (id=4224)
          Simplified stylesheet to show the errors. Change the commenting in the key definitions to see the effect

          Show
          Jörg Heinicke added a comment - Created an attachment (id=4224) Simplified stylesheet to show the errors. Change the commenting in the key definitions to see the effect
          Hide
          Henry Zongaro added a comment -

          I tried reproducing the problem you describe using XSLTC from Xalan-J version 2.4.0 through to 2.6.0 and was not able to reproduce it. Are you still able to reproduce this problem? If so, can you reproduce it in a standalone environment, or do you need to use Cocoon to reproduce it?

          Show
          Henry Zongaro added a comment - I tried reproducing the problem you describe using XSLTC from Xalan-J version 2.4.0 through to 2.6.0 and was not able to reproduce it. Are you still able to reproduce this problem? If so, can you reproduce it in a standalone environment, or do you need to use Cocoon to reproduce it?
          Hide
          joerg20 added a comment -

          You wrote you can not reproduce it using XSLTC while this bug is about Xalan.

          Show
          joerg20 added a comment - You wrote you can not reproduce it using XSLTC while this bug is about Xalan.
          Hide
          Henry Zongaro added a comment -

          My apologies - I was confused by your statement that you were "using the used Xalan 2.4.1 and XSLTC there." I am now able to reproduce this problem.

          Show
          Henry Zongaro added a comment - My apologies - I was confused by your statement that you were "using the used Xalan 2.4.1 and XSLTC there." I am now able to reproduce this problem.
          Hide
          Henry Zongaro added a comment -

          Attaching text patch file.

          Show
          Henry Zongaro added a comment - Attaching text patch file.
          Hide
          Jörg Heinicke added a comment -

          Ah, I see. This comment refers just to the thread as we found 2 issues at once. One for Xalan (this bug, XalanJ-1368), one for XSLTC (XalanJ-1369). Sorry for any inconvenience

          Show
          Jörg Heinicke added a comment - Ah, I see. This comment refers just to the thread as we found 2 issues at once. One for Xalan (this bug, XalanJ-1368), one for XSLTC (XalanJ-1369). Sorry for any inconvenience
          Hide
          Brian Minchau added a comment -

          Testing new "Xalan-keywords" field with the new "PatchAvailable" keyword.

          Show
          Brian Minchau added a comment - Testing new "Xalan-keywords" field with the new "PatchAvailable" keyword.
          Hide
          Henry Zongaro added a comment -

          Fix applied to CVS.

          Show
          Henry Zongaro added a comment - Fix applied to CVS.
          Hide
          Joanne Tong added a comment -

          I have reviewed Henry's patch, and I believe it correctly resolves the problem.

          Show
          Joanne Tong added a comment - I have reviewed Henry's patch, and I believe it correctly resolves the problem.
          Hide
          Brian Minchau added a comment -

          Joerg, as the issue reporter please confirm that this is fixed to your satisfaction in the Xalan-J 2.7 release, that was released on Aug 8, 2005, then we can close this issue.

          Show
          Brian Minchau added a comment - Joerg, as the issue reporter please confirm that this is fixed to your satisfaction in the Xalan-J 2.7 release, that was released on Aug 8, 2005, then we can close this issue.
          Hide
          joerg20 added a comment -

          Yes, it works for me.

          Am I not allowed to close the bug or am I just blind to find the button?

          Show
          joerg20 added a comment - Yes, it works for me. Am I not allowed to close the bug or am I just blind to find the button?
          Hide
          Brian Minchau added a comment -

          Joerg, it seems that only JIRA accounts marked as "developer" of a project can close an issue. I know that your JIRA account doesn't have that attribute, thats why you can't close the issue.

          The user interface of JIRA is different depending on your authority. I'm changing the
          fix version to 2.7, then closing this issue.
          -Brian

          Show
          Brian Minchau added a comment - Joerg, it seems that only JIRA accounts marked as "developer" of a project can close an issue. I know that your JIRA account doesn't have that attribute, thats why you can't close the issue. The user interface of JIRA is different depending on your authority. I'm changing the fix version to 2.7, then closing this issue. -Brian

            People

            • Assignee:
              Unassigned
              Reporter:
              Jörg Heinicke
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development