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 gathers data from a database and displays it according to the user's selections as a html page. 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! 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 XML Spy (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! 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 inputtry
{ // 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;
}
}