You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2004/02/05 20:41:20 UTC

DO NOT REPLY [Bug 26697] New: - Java extension functions in XSLTC returning NodeList causes exception on xsl:copy-of

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26697>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=26697

Java extension functions in XSLTC returning NodeList causes exception on xsl:copy-of

           Summary: Java extension functions in XSLTC returning NodeList
                    causes exception on xsl:copy-of
           Product: XalanJ2
           Version: 2.5
          Platform: All
               URL: http://www.lewisd.com/files/xalan-bug.tar.gz
        OS/Version: All
            Status: NEW
          Severity: Major
          Priority: Other
         Component: org.apache.xalan.xsltc
        AssignedTo: xalan-dev@xml.apache.org
        ReportedBy: dlewis@cucbc.com


When trying to do xsl:copy-of on a nodeset returned from a Java extension
function, in XSLTC, an ArrayIndexOutOfBoundsException is thrown. (Acctually,
it's a TransletException wrapping the AIOOBE.)
It seems like it might be somehow related to namespaces.
After tracing the exception down a bit, it seems to be in the outputting of
attributes.  The exception does not occur if I remove the namespace from the
attributes.

At the URL specified in this bug report is a tar.gz containing some Java source,
the version of Xalan I've encountered this with, and some xml and xslt files. 
There is also a README file describing the exact steps to duplicate the bug.

Tested on 2 versions of Java:
1. Blackdown-1.3.1-02b-FCS
2. java full version "1.3.1_01"

Below is a copy of my mail to the list, describing in more detail.

------ BEGIN EMAIL -------

I understand from the documentation that org.w3c.dom.NodeList is a valid
return-type for an extension function, that should be converted approptiately.
I'm having problems, however, whenever I try to output the NodeList using
xsl:copy-of.  I can call count($list) or count($list/*), or I can even do a
xsl:value-of on $list or $list/*, and they all behave as I would expect.
However, when I try to do xsl:copy-of on $list or $list/*, I get an
ArrayIndexOutOfBoundsException.
The NodeList I return has one element (in this case), and that element has
around 70 child elements, and a few attributes.

The exception I see when I do <xsl:copy-of select="$list/*" /> is:
org.apache.xalan.xsltc.TransletException:
java.lang.ArrayIndexOutOfBoundsException: -7 < 0
        at org.apache.xalan.xsltc.dom.SAXImpl.copy(SAXImpl.java:1392)
        at org.apache.xalan.xsltc.dom.DOMAdapter.copy(DOMAdapter.java:309)
        at org.apache.xalan.xsltc.dom.MultiDOM.copy(MultiDOM.java:540)
        at components1.template$dot$4()
        at components1.applyTemplates2()
        at components1.template$dot$1()
        at components1.applyTemplates2()
        at components1.applyTemplates()
        at components1.transform()

(components1 is the name of my xslt file)

I added a e.printStackTrace to the dom.SAXImpl class so I could see what the
real exception is and got a few extra lines:
java.lang.ArrayIndexOutOfBoundsException: -7 < 0
        at java.util.Vector.elementAt(Vector.java:427)
        at org.apache.xml.dtm.ref.sax2dtm.SAX2DTM2.copyAttribute(SAX2DTM2.java:3347)
        at org.apache.xalan.xsltc.dom.SAXImpl.copy(SAXImpl.java:1361)
        at org.apache.xalan.xsltc.dom.DOMAdapter.copy(DOMAdapter.java:309)
        at org.apache.xalan.xsltc.dom.MultiDOM.copy(MultiDOM.java:540)

I've tried this with my own implementation of NodeList, and with
org.apache.xpath.NodeSet, and I get the exact same stack trace regardless of
which I use.