cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Donald Ball <>
Subject more data on the SAXException problem when using xalan with cocoon
Date Sun, 13 Aug 2000 21:21:11 GMT
i realized on the plane from minneapolis to seattle what was going wrong
and why i was having such trouble replicating it in a simple test. it was
only when redirecting from an XSP+XSLT page to an XSLT page that the
problem was exposed. the XSP pages always did an XSLT pass after the logic
run was complete, even if the user had been redirected to another page and
the XSLT was unncessary. If the user was redirected to another page with
an XSLT pass, it was highly likely that two XSLT transforms would occur
simultaneously, which was causing problems due to, i presume, some thread
unsafe code somewhere in xalan.

i fixed it so that the XSP page does not finish with an XSLT process if
the user has been redirected to another page, and i have not seen the
problem recur in many tests - however, it seems likely that the problem
could easily recur under very heavy load on uncached pages.

here's the relevant code from cocoon's XalanTransformer:

    public Document transform(Document in, String inBase, Document sheet,
        String sheetBase, Document out, Dictionary params)
        throws Exception {

        XSLTProcessor processor = XSLTProcessorFactory.getProcessor(new

        Enumeration enum = params.keys();
        while (enum.hasMoreElements()) {
          String name = (String) enum.nextElement();
          String value = (String)params.get(name);

        XSLTInputSource i = new XSLTInputSource(in);
        // inBase not used for now (external entities are already included
at parse time)
        XSLTInputSource s = new XSLTInputSource(sheet);
        XSLTResultTarget o = new XSLTResultTarget(out);
        processor.process(i, s, o);
        return out;

    class XMLParser extends XMLParserLiaisonDefault {
        Parser parser;
        Document document;

        public XMLParser(Parser parser) {
            this.parser = parser;

        public Document createDocument() {
            return this.parser.createEmptyDocument();

        public void parse(InputSource in) throws IOException, SAXException
            this.document = this.parser.parse(in, false);

            // The Xalan stylesheet is normally built from SAX events,
            // so if a DocumentHandler is specified, we need to produce
            // SAX events from the DOM tree.
            if (m_docHandler != null) {
                (new TreeWalker(m_docHandler)).traverse(this.document);

                // Note that when cocoon transitions to being more SAX
                // this function will be called recursivly while the
parser is
                // still in the middle of a parse, and thus the parser
will have
                // created on the fly (or perhaps cloned) since the Xerces
                // is not (to my knowledge) reentrant.

i suspect the problem is somewhere in the XMLParser code since both of the
errors i got indicated there was some structural problem with the
stylesheet (i can repost the stacktraces if necessary). does anyone have
any clues?

- donald

View raw message