I'm using Saxon 9.3 EE and for one of the stylesheets I'm getting this
compilation error:
Cause: Attempt to end document in serializer when elements are unclosed
java.lang.IllegalStateException: Attempt to end document in serializer when elements are unclosed
at net.sf.saxon.serialize.XMLEmitter.endDocument(XMLEmitter.java:113)
at net.sf.saxon.event.ProxyReceiver.endDocument(ProxyReceiver.java:110)
at net.sf.saxon.trace.ExpressionPresenter.close(ExpressionPresenter.java:185)
at net.sf.saxon.expr.Expression.explain(Expression.java:578)
at net.sf.saxon.expr.Optimizer.trace(Optimizer.java:351)
at net.sf.saxon.expr.LetExpression.optimize(LetExpression.java:206)
at net.sf.saxon.expr.ExpressionVisitor.optimize(ExpressionVisitor.java:230)
at net.sf.saxon.style.XSLTemplate.optimize(XSLTemplate.java:412)
at net.sf.saxon.style.PrincipalStylesheetModule.compileStylesheet(PrincipalStylesheetModule.java:814)
at net.sf.saxon.PreparedStylesheet.setStylesheetDocument(PreparedStylesheet.java:355)
at net.sf.saxon.PreparedStylesheet.prepare(PreparedStylesheet.java:186)
at net.sf.saxon.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:132)
at com.atypon.literatum.util.xml.TransformerCache.instantiateTemplate(TransformerCache.java:151)
I was able to work it around by disabling optimizations
xformFactory.setAttribute(FeatureKeys.OPTIMIZATION_LEVEL, "0");
How can I find what is the real problem? What document is being serialized?
What are those unclosed elements? What steps should I take to debug it?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The problem occurs while outputting the optimiser trace messages, so you
should be able to avoid it by avoiding use of -explain. I would like to have a
copy of the stylesheet that causes the problem so that I can fix it.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks Michael,
you are right, it has something to do with the
FeatureKeys.TRACE_OPTIMIZER_DECISIONS set to Boolean.TRUE. We do not use that
in production, so I re-enabled optimizations and hacked the debug mode to skip
optimizer decisions tracing for this specific transformation.
I will try to strip out all java extension calls and get smallest style sheet
where tracing optimizer decision is still failing.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've done pruning up to this point
main.xsl:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="2.0" xmlns:xsl="<span>[http://www.w3.org/1999/XSL/Transform]</span>
(http://www.w3.org/1999/XSL/Transform)">
This is still causing the "java.lang.IllegalStateException: Attempt to end
document in serializer when elements are unclosed" when tracing of optimizer
decisions is enabled.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm using Saxon 9.3 EE and for one of the stylesheets I'm getting this
compilation error:
I was able to work it around by disabling optimizations
xformFactory.setAttribute(FeatureKeys.OPTIMIZATION_LEVEL, "0");
How can I find what is the real problem? What document is being serialized?
What are those unclosed elements? What steps should I take to debug it?
The problem occurs while outputting the optimiser trace messages, so you
should be able to avoid it by avoiding use of -explain. I would like to have a
copy of the stylesheet that causes the problem so that I can fix it.
Thanks Michael,
you are right, it has something to do with the
FeatureKeys.TRACE_OPTIMIZER_DECISIONS set to Boolean.TRUE. We do not use that
in production, so I re-enabled optimizations and hacked the debug mode to skip
optimizer decisions tracing for this specific transformation.
I will try to strip out all java extension calls and get smallest style sheet
where tracing optimizer decision is still failing.
I've done pruning up to this point
main.xsl:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="2.0" xmlns:xsl="<span>[http://www.w3.org/1999/XSL/Transform]</span> (http://www.w3.org/1999/XSL/Transform)">
<xsl:import href="xxx.xsl"/>
<xsl:template match="foo">
<xsl:variable name="bar">
<xsl:apply-imports/>
</xsl:variable>
<xsl:value-of select="$bar"/>
</xsl:template>
</xsl:transform>
xxx.xsl:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="2.0" xmlns:xsl="<span>[http://www.w3.org/1999/XSL/Transform]</span> (http://www.w3.org/1999/XSL/Transform)">
<xsl:template match="foo">
<xsl:value-of select="'x'"/>
</xsl:template>
</xsl:transform>
This is still causing the "java.lang.IllegalStateException: Attempt to end
document in serializer when elements are unclosed" when tracing of optimizer
decisions is enabled.
Hi,
This problem has already been fixed in the Saxon release version 9.3.0.5.
Please see the bug ID: 3184807).
I am not sure which version you are currently running but if you do an upgrade
to 9.3.0.5 then you should be OK.
Thanks, we will try that.