cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From linli22 <linl...@home.com>
Subject RE: more data on the SAXException problem when using xalan with cocoon
Date Thu, 17 Aug 2000 03:39:42 GMT
Don't sent to me mail any more!!!! 

-----Original Message-----
From:	Donald Ball [SMTP:balld@webslingerZ.com]
Sent:	Sunday, August 13, 2000 2:21 PM
To:	xalan-dev@xml.apache.org; cocoon-dev@xml.apache.org
Subject:	more data on the SAXException problem when using xalan with cocoon

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
XMLParser(parser));

        Enumeration enum = params.keys();
        while (enum.hasMoreElements()) {
          String name = (String) enum.nextElement();
          String value = (String)params.get(name);
          processor.setStylesheetParam(name,processor.createXString(value));
        }

        XSLTInputSource i = new XSLTInputSource(in);
        // inBase not used for now (external entities are already included
at parse time)
        XSLTInputSource s = new XSLTInputSource(sheet);
        s.setSystemId(sheetBase);
        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
based,
                // 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
parser
                // 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


Mime
View raw message