XSLT transform throws java.lang.StackOverflowError on docbook document 
containing large table
---------------------------------------------------------------------------------------------

                 Key: XALANJ-2466
                 URL: https://issues.apache.org/jira/browse/XALANJ-2466
             Project: XalanJ2
          Issue Type: Bug
      Security Level: No security risk; visible to anyone (Ordinary problems in 
Xalan projects.  Anybody can view the issue.)
    Affects Versions: 2.7.1
         Environment: Windows XP, Eclipse
            Reporter: Hans van Rijswijk


Transforming a docbook document with Xalan ends up with a 
java.lang.StackOverflowError.
I am using Xalan-J version 2.7.1, docbook-xsl version 1.74.0, docbook-xml 
version 4.5.

The following small Java program ilustrates this.
Setting NUMROWS  to a lower value makes the error disappear. However, I need 
this program to run with large tables too. 
Scaleability is a high priority issue. I think something has been solved in a 
recursive way, which makes the transformation of large tables not scaleable.
I am running the program under Eclipse with standard stack size settings. The 
error also appears in other environments.

package test;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

/**
 * 
 * Xalan Processor
 * 
 */
public class XalanProcessor {

        public static int NUMROWS = 700;
        
        public static final String CHARSETNAME = "utf-8";
        public static TransformerFactory tFactory = 
TransformerFactory.newInstance("org.apache.xalan.processor.TransformerFactoryImpl",
 XalanProcessor.class.getClassLoader());
        public static void transform(Source src, URL xsltUri, OutputStream out, 
final OutputStream debug) 
        throws TransformerConfigurationException, TransformerException {
                // Setup Transformer
                Source xsltSrc = new StreamSource(xsltUri.toExternalForm());
                Transformer transformer = tFactory.newTransformer(xsltSrc);
                
                if (debug != null) {
                        try {
                        debug.write("newTransformer 
successful".getBytes(CHARSETNAME));
                        } catch (IOException e){
                                
                        }
                }
                Result res = new StreamResult(out);

                // Start the transformation process
                transformer.transform(src, res);
        }

        
        private static File _reportFile = null;
        private static OutputStream _reportStream;
        private static File _transformedFile;

        public static void main(String[] args) {
                URL xsltUri = null;
                OutputStream _transformedStream = null;
                OutputStream _debugStream = null;
                
                try {
                        _reportFile = File.createTempFile("Report", ".tmp");
                        _reportStream = new FileOutputStream(_reportFile);
                        String string = "<!DOCTYPE book PUBLIC \"-//OASIS//DTD 
DocBook XML V4.5//EN\"\n" +
                                        "\"file:\\Documents and 
Settings\\hans\\workspace1\\xalan-fop-stacktest\\formatting\\docbook-xml-4.5\\docbookx.dtd\">\n"
 +
                                        "<book>\n" +
                                        "<title>Report</title>\n" +
                                        "\n" +
                                        "<chapter>\n" +
                                        "<title>First Section</title>\n" +
                                        "\n" +
                                        "<para>Some para.</para>\n" +
                                        "<para>Some list:<itemizedlist>\n" +
                                        "<listitem><para>A 
listitem</para></listitem>\n" +
                                        "</itemizedlist>\n" +
                                        "</para>\n" +
                                        "<sect1><title>Sect 
title</title><table>\n" +
                                        "<title>Table title</title>\n" +
                                        "<tgroup cols=\"1\"><colspec 
colname=\"leftcol\"/><colspec colnum=\"1\" colname=\"rightcol\"/><spanspec 
spanname=\"allcolumns\" namest=\"leftcol\" nameend=\"rightcol\"/>\n" +
                                        "<thead>\n" +
                                        "<row>\n" +
                                        "<entry><![CDATA[name]]></entry>\n" +
                                        "</row>\n" +
                                        "</thead>\n" +
                                        "<tbody>\n";
                        _reportStream.write(string.getBytes(CHARSETNAME));
                        
                        for (int i = 1; i <= NUMROWS; i++) {
                                string = "<row>\n" +
                                "<entry><![CDATA[name"+i+"]]></entry>\n" +
                                "</row>\n" ;
                                
_reportStream.write(string.getBytes(CHARSETNAME));
                        }
                        string = "</tbody>\n" +
                                        "</tgroup>\n" +
                                        "</table>\n" +
                                        "</sect1>\n" +
                                        "</chapter>\n" +
                                        "</book>\n";
                        _reportStream.write(string.getBytes(CHARSETNAME));
                        _reportStream.close();
                        
                        _transformedFile = File.createTempFile("Output", ".fo");
                        _transformedStream = new 
FileOutputStream(_transformedFile);

                } catch (FileNotFoundException e1) {
                        e1.printStackTrace();
                } catch (IOException e1) {
                        e1.printStackTrace();
                }

                try {
                        xsltUri = new URL("file:\\Documents and 
Settings\\hans\\workspace1\\xalan-fop-stacktest\\formatting\\docbook-xsl-1.74.0\\fo\\docbook.xsl");
                } catch (MalformedURLException e1) {
                        e1.printStackTrace();
                }
                
                try {
                        XalanProcessor.transform(new StreamSource(_reportFile), 
xsltUri, _transformedStream, _debugStream);
                        _transformedStream.close();
                } catch (TransformerConfigurationException e) {
                        e.printStackTrace();
                } catch (TransformerException e) {
                        e.printStackTrace();
                } catch (IOException e) {
                        e.printStackTrace();
                }
                System.out.println("Done");
        }
        
}


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to