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

NPE in ElemTemplateElement for a ElemSort as part of an ElemForEach when dynamically generating a Templates

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.7
    • None
    • None
    • None
    • PatchAvailable

    Description

      The XSL fragment that created this is:

      <xsl:apply-templates select="something>
      <xsl:sort select="@something"/>
      </xsl:apply-templates>

      resulting in:

      java.lang.NullPointerException
      at org.apache.xalan.templates.ElemTemplateElement.getStylesheetRoot(ElemTemplateElement.java:171)
      at org.apache.xalan.templates.ElemTemplateElement.resolvePrefixTables(ElemTemplateElement.java:1033)
      at org.apache.xalan.templates.ElemTemplateElement.compose(ElemTemplateElement.java:190)
      at org.apache.xalan.templates.ElemSort.compose(ElemSort.java:333)
      at org.apache.xalan.templates.ElemForEach.compose(ElemForEach.java:136)
      at org.apache.xalan.templates.ElemCallTemplate.compose(ElemCallTemplate.java:113)
      at org.apache.xalan.templates.ElemApplyTemplates.compose(ElemApplyTemplates.java:127)
      at org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:357)
      at org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:362)
      at org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:362)
      at org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:362)
      at org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:362)
      at org.apache.xalan.templates.StylesheetRoot.composeTemplates(StylesheetRoot.java:362)
      at org.apache.xalan.templates.StylesheetRoot.recompose(StylesheetRoot.java:337)
      at org.apache.xalan.processor.StylesheetHandler.endDocument(StylesheetHandler.java:468)
      ... then enters my code

      ... this occurs because the ElemSort has a single entry in its m_declaredPrefixes vector, an entry for 'xsl'.

      A 1-line fix to ElemForEach.java fixes this. In appendChild, when adding a sort element, just add:

      newChild.setParentElem( this );

      before returning the newChild.

      Attachments

        1. j2301.xsl
          1.0 kB
          Henry Zongaro
        2. j2301.xml
          0.2 kB
          Henry Zongaro
        3. j2301.out
          0.3 kB
          Henry Zongaro

        Issue Links

          Activity

            People

              Unassigned Unassigned
              proyal Peter A Royal Jr.
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated: