Project

Profile

Help

Bug #2323

closed

Different XSLT compilation error obtained when I set SAXResult to transformer

Added by Radu Coravu over 9 years ago. Updated almost 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Internals
Sprint/Milestone:
Start date:
2015-03-03
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.6
Fix Committed on Branch:
9.6
Fixed in Maintenance Release:
Platforms:

Description

An XSLT stylesheet has an error in it at some point.

The created Saxon transformer is called to transform over a custom SAXResult implementation.

When the transformation runs, it reports a different error than the one which exists in the XSLT styleshet:

java.lang.RuntimeException: Internal error evaluating template at line 5 in module file:/C:/Users/radu_coravu/Desktop/test.xsl

at net.sf.saxon.expr.instruct.Template.applyLeavingTail(Template.java:375)

at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:1146)

at net.sf.saxon.Controller.transformDocument(Controller.java:2176)

at net.sf.saxon.Controller.transform(Controller.java:1777)

at net.sf.saxon.s9api.XsltTransformer.transform(XsltTransformer.java:547)

at net.sf.saxon.jaxp.TransformerImpl.transform(TransformerImpl.java:186)

at ro.sync.dxsl.debugger.AbstractXSLTDebugger.run(AbstractXSLTDebugger.java:540)

at java.lang.Thread.run(Unknown Source)

Caused by: java.lang.IllegalStateException: Attempt to end document in serializer when elements are unclosed

at net.sf.saxon.serialize.XMLEmitter.endDocument(XMLEmitter.java:257)

at net.sf.saxon.event.ProxyReceiver.endDocument(ProxyReceiver.java:120)

at net.sf.saxon.event.ReceivingContentHandler.endDocument(ReceivingContentHandler.java:236)

at ro.sync.dxsl.debugger.backmapping.ContentFilter.endDocument(ContentFilter.java:96)

at ro.sync.dxsl.debugger.backmapping.BackMappingSAXResult$BackMappingContentHandler.endDocument(BackMappingSAXResult.java:343)

at net.sf.saxon.event.ContentHandlerProxy.close(ContentHandlerProxy.java:316)

at net.sf.saxon.event.ProxyReceiver.close(ProxyReceiver.java:104)

at net.sf.saxon.event.ComplexContentOutputter.close(ComplexContentOutputter.java:543)

at net.sf.saxon.expr.instruct.ResultDocument.processInstruction(ResultDocument.java:610)

at net.sf.saxon.Configuration.processResultDocument(Configuration.java:2024)

at net.sf.saxon.expr.instruct.ResultDocument.process(ResultDocument.java:519)

at net.sf.saxon.expr.instruct.ResultDocument.processLeavingTail(ResultDocument.java:505)

at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:44)

at net.sf.saxon.expr.instruct.TraceExpression.processLeavingTail(TraceExpression.java:287)

at net.sf.saxon.expr.instruct.Instruction.process(Instruction.java:44)

at net.sf.saxon.expr.instruct.TraceExpression.processLeavingTail(TraceExpression.java:287)

at net.sf.saxon.expr.instruct.Template.applyLeavingTail(Template.java:354)

... 7 more

The method "ResultDocument.processInstruction" has a finally clause which closes the receiver if an error occurs when transforming:

    try {

        out.startDocument(0);

        content.process(context);

        out.endDocument();

    } catch (XPathException err) {

        err.setXPathContext(context);

        err.maybeSetLocation(this);

        throw err;

    } finally {

        //RECEIVER CLOSE IS CALLED

        out.close();

    }

and in this case the ContentHandlerProxy.close() method delegates to the "handler.endDocument()" method which throws an exception because not all elements in the SAX handler have been closed. The elements have not been closed because of the original exception which is now masked by this IllegalStateException which jumps from the finally clause.


Files

test.xsl (508 Bytes) test.xsl Radu Coravu, 2015-03-09 10:04
test.xml (47 Bytes) test.xml Radu Coravu, 2015-03-09 10:04

Please register to edit this issue

Also available in: Atom PDF