XalanJ2
  1. XalanJ2
  2. XALANJ-2424

set:distinct() over attribute list breaks XSLTC throwing HIERARCHY_REQUEST_ERR

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.7.1, 2.7
    • Component/s: XSLTC
    • Labels:
      None
    • Environment:
      Linux, Sun java 1.6
    • Fix priority:
      fp3

      Description

      If you do set:distinct over attribute list, XSLTC-compiled translet throws HIERARCHY_REQUEST_ERR exception.
      Exception is localised to point where set:distinct is called, even if it is assigned into a variable.

      Test case:
      <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:set="http://exslt.org/sets" version="1.0">
      <xsl:output method="html" />
      <xsl:template match="/">
      <xsl:variable name="attrs" select="set:distinct(source/element/@attr)" />
      <html><body>
      <xsl:for-each select="$attrs">
      <xsl:value-of select="." />
      </xsl:for-each>
      </body></html>
      </xsl:template>
      </xsl:stylesheet>

      With xml
      <source>
      <element attr="val1" name="foobar" />
      <element attr="val2" name="bar" />
      <element attr="val2" name="baz" />
      <element attr="val3" name="baz" />
      </source>

      that will cause an Exception to be thrown when variable is assigned.

      My unedicated guess is that it tries to apply-templates over selected nodes into document in place where set:distinct is computed. This happens, as I see for different partially-serialized document, before variable's enclosing element is closed. I've disassembled the stylesheet but didn't understand much from there, it goes like this:
      // 30 66:invokeinterface #110 <Method org.w3c.dom.NodeList DOM.makeNodeList(DTMAxisIterator)>
      // 31 71:invokestatic #116 <Method org.w3c.dom.NodeList ExsltSets.distinct(org.w3c.dom.NodeList)>
      // 32 74:aload_0
      // 33 75:aload_1
      // 34 76:invokestatic #122 <Method DTMAxisIterator BasisLibrary.nodeList2Iterator(org.w3c.dom.NodeList, org.apache.xalan.xsltc.Translet, DOM)>
      // 35 79:new #126 <Class CachedNodeListIterator>
      // 36 82:dup_x1
      // 37 83:swap
      // 38 84:invokespecial #127 <Method void CachedNodeListIterator(DTMAxisIterator)>
      // 39 87:iload 4
      // 40 89:invokeinterface #41 <Method DTMAxisIterator DTMAxisIterator.setStartNode(int)>
      // 41 94:astore 9
      // 42 96:aload_3
      // 43 97:ldc1 #129 <String "html">
      // 44 99:dup2
      // 45 100:invokeinterface #14 <Method void SerializationHandler.startElement(String)>

      P.S. If said variable is located in prologue (not inside any xsl:template) the bug persists.

      1. Process.jad
        14 kB
        Илья Казначеев
      2. xml1.xml
        0.2 kB
        Илья Казначеев
      3. xsl1.xsl
        0.4 kB
        Илья Казначеев

        Issue Links

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              Илья Казначеев
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development