You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "peter royal (JIRA)" <xa...@xml.apache.org> on 2006/06/15 18:05:29 UTC

[jira] Created: (XALANJ-2301) NPE in ElemTemplateElement for a ElemSort as part of an ElemForEach when dynamically generating a Templates

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

         Key: XALANJ-2301
         URL: http://issues.apache.org/jira/browse/XALANJ-2301
     Project: XalanJ2
        Type: Bug

    Versions: 2.7    
    Reporter: peter royal


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.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2301) NPE in ElemTemplateElement for a ElemSort as part of an ElemForEach when dynamically generating a Templates

Posted by "Henry Zongaro (JIRA)" <xa...@xml.apache.org>.
    [ http://issues.apache.org/jira/browse/XALANJ-2301?page=comments#action_12417818 ] 

Henry Zongaro commented on XALANJ-2301:
---------------------------------------

It looks like the problem occurs if an xsl:sort element (within either xsl:apply-templates or xsl:for-each) has a namespace declaration.  One work-around would be to move the namespace declaration to the instruction that contains the xsl:sort; another work-around would be to use XSLTC.

By the way, in case you're wondering why you had to wait so long for any comments on this bug report to appear, it makes it much easier to track down the source of a problem if you provide a complete stand-alone test case that demonstrates the problem.

> NPE in ElemTemplateElement for a ElemSort as part of an ElemForEach when dynamically generating a Templates
> -----------------------------------------------------------------------------------------------------------
>
>          Key: XALANJ-2301
>          URL: http://issues.apache.org/jira/browse/XALANJ-2301
>      Project: XalanJ2
>         Type: Bug

>     Versions: 2.7
>     Reporter: peter royal
>  Attachments: j2301.out, j2301.xml, j2301.xsl
>
> 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.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2301) NPE in ElemTemplateElement for a ElemSort as part of an ElemForEach when dynamically generating a Templates

Posted by "Brian Minchau (JIRA)" <xa...@xml.apache.org>.
    [ http://issues.apache.org/jira/browse/XALANJ-2301?page=comments#action_12420674 ] 

Brian Minchau commented on XALANJ-2301:
---------------------------------------

Peter has suggested a fix in ElemForEach, however the traceback above shows a problem with ElemApplyTemplates, so it looks like there are a few places that need the same fix, so the fix is not complete.

John Gentilin remembers that in a previous bug triage that we would use the the ElemForEach code for ElemApplyTemplates.

A work around is to move the namespace declaration up to the parent element of the sort element.

> NPE in ElemTemplateElement for a ElemSort as part of an ElemForEach when dynamically generating a Templates
> -----------------------------------------------------------------------------------------------------------
>
>          Key: XALANJ-2301
>          URL: http://issues.apache.org/jira/browse/XALANJ-2301
>      Project: XalanJ2
>         Type: Bug

>     Versions: 2.7
>     Reporter: peter royal
>  Attachments: j2301.out, j2301.xml, j2301.xsl
>
> 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.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2301) NPE in ElemTemplateElement for a ElemSort as part of an ElemForEach when dynamically generating a Templates

Posted by "Henry Zongaro (JIRA)" <xa...@xml.apache.org>.
    [ http://issues.apache.org/jira/browse/XALANJ-2301?page=comments#action_12447555 ] 
            
Henry Zongaro commented on XALANJ-2301:
---------------------------------------

I had a look around, and it looks like xsl:apply-templates is the only other instruction that suffers this problem, and as John Gentilin observed, ElemApplyTemplates ends up using the ElemForEach.appendChild, so it would inherit the fix.  So I think the patch will fix both problems and that those are the only two instances of the problem.

> NPE in ElemTemplateElement for a ElemSort as part of an ElemForEach when dynamically generating a Templates
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: XALANJ-2301
>                 URL: http://issues.apache.org/jira/browse/XALANJ-2301
>             Project: XalanJ2
>          Issue Type: Bug
>    Affects Versions: 2.7
>            Reporter: peter royal
>         Attachments: j2301.out, j2301.xml, j2301.xsl
>
>
> 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.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org


[jira] Commented: (XALANJ-2301) NPE in ElemTemplateElement for a ElemSort as part of an ElemForEach when dynamically generating a Templates

Posted by "Brian Minchau (JIRA)" <xa...@xml.apache.org>.
    [ http://issues.apache.org/jira/browse/XALANJ-2301?page=comments#action_12447531 ] 
            
Brian Minchau commented on XALANJ-2301:
---------------------------------------

per the Xalan-J triage on November 6, 2006 the patch should be applied as-is
even if there are other bugs that are similar.

> NPE in ElemTemplateElement for a ElemSort as part of an ElemForEach when dynamically generating a Templates
> -----------------------------------------------------------------------------------------------------------
>
>                 Key: XALANJ-2301
>                 URL: http://issues.apache.org/jira/browse/XALANJ-2301
>             Project: XalanJ2
>          Issue Type: Bug
>    Affects Versions: 2.7
>            Reporter: peter royal
>         Attachments: j2301.out, j2301.xml, j2301.xsl
>
>
> 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.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-dev-help@xml.apache.org