You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Ralf Steppacher <st...@esteam.de> on 2002/04/15 13:20:36 UTC

Transformer: process failed:java.lang.ArrayIndexOutOfBoundsException: 0

Hello everybody.

I've got a problem transforming "large" XML documents with xalan-j 2.3.1
under certain conditions. Large is about >70KB.
I have a JSP and several beans associated to it that gather data from a
database.
While transforming larger documents (as a DOMSource) I get an
"ArrayIndexOutOfBoundsException: 0" exception after a little while and
transformation stops, there is no stack trace available.
This error occurs only if the document is the first one to be
transformed by the jsp's request! All succeeding documents (>300KB!) are
processed correctly. The problem is not specific to a certain document
but arises with what ever document I choose to be the first one (if it 
is large enough).
In the code I create a StylesheetRoot object for every selected
subsection of the page and retrieve a Transformer object from it. The
Transformer object then transformes a DOMSource.

Everything works fine when I transform the XML data on the commandline
or within a tool like XMLSpy (using xalan-j 2.3.1).
I tried different releases of xalan-j 2.x.

The ArrayIndexOutOfBoundsException is thrown in
TransformerImpl::executeChildTemplates(ElemTemplateElement,boolean)
called from line 2069 in TransformerImpl.


I greatly appreciate any hint on what I am doing wrong or if this might 
be a bug.
Many thanks in advance!

Ralf Steppacher

-----------
Snippet from the JSP:

    XMLTransform tf = null;

    <jsp:useBean id="companyInfo" scope="session" type="ldb.CompanyInfo"/>
    <%  name="companyInfo";
title=ldbSession.getString(DBConstants.DK_MENUE_COMPANY_DETAILS); %>
    <%@ include file="../../html/ProfileSectionStart.html" %>
    <%
        tf = companyInfo.getXMLTransform(ldbRequest);
        tf.setStyleSheet("ProfileSupplierInfo.xslt");
        tf.process(conn, out);
    %>


For every option there is code like this in the JSP.


------------
Snippet from XMLTransform:

     public boolean process(Connection conn, Writer out)
     {
        Document xmlDoc = getDocument(conn);
        if (xmlDoc==null)
          return false; // No input

        try
        { // Tranform now
	Source xmlSource = new DOMSource( xmlDoc );
          Result result = new StreamResult( out );
          /* obtain transformer context for this Templates object. */
          Transformer transformer = xslInput.newTransformer();
	/* Configure transformer with stored parameters. */
          java.util.Enumeration params = transformerParams.keys();
          while ( params.hasMoreElements() ) {
	    String param = ((String)params.nextElement());
              transformer.setParameter( param, transformerParams.get(
param ) );
          }

          transformer.transform( xmlSource, result );

        // Done
        }
        catch (Exception exptn)
        {
          DebugMsg(1, "process failed:" + exptn.getMessage());
          error =ERR_XALANERROR;
          return false;
        }
     }