Debug optimization problem
Added by Anonymous about 13 years ago
Legacy ID: #10688246 Legacy Poster: Libor (liborvalenta)
I'm using Saxon 9.3 EE and for one of the stylesheets I'm getting this compilation error: [code] 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) [/code] 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?
Replies (5)
Please register to reply
RE: Debug optimization problem - Added by Anonymous about 13 years ago
Legacy ID: #10689364 Legacy Poster: Michael Kay (mhkay)
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.
RE: Debug optimization problem - Added by Anonymous about 13 years ago
Legacy ID: #10693113 Legacy Poster: Libor (liborvalenta)
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.
RE: Debug optimization problem - Added by Anonymous about 13 years ago
Legacy ID: #10693169 Legacy Poster: Libor (liborvalenta)
I've done pruning up to this point main.xsl: <xsl:transform version="2.0" xmlns:xsl="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: <xsl:transform version="2.0" xmlns:xsl="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.
RE: Debug optimization problem - Added by Anonymous about 13 years ago
Legacy ID: #10694728 Legacy Poster: oneil (ond1)
Hi, This problem has already been fixed in the Saxon release version 9.3.0.5. Please see the bug ID: [url=https://sourceforge.net/tracker/?func=detail&aid=3184807&group_id=29872&atid=397617]3184807[/url]). 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.
RE: Debug optimization problem - Added by Anonymous about 13 years ago
Legacy ID: #10695063 Legacy Poster: Libor (liborvalenta)
Thanks, we will try that.
Please register to reply