Difficulty during XSLT events tracing
Added by Aristarkh Skvortsov over 11 years ago
Hello! Could you, please, advise. I'm trying to perform some XSL transformation using Saxon#9.1.0.8, and it worked fine until I added trace listener to the controller. Exception which I have got:
The context item is not set ; SystemID: file:/E:/docbook/xsl/common/l10n.xsl; Line#: 22; Column#: -1 net.sf.saxon.trans.XPathException: The context item is not set at net.sf.saxon.expr.Expression.dynamicError(Expression.java:967) at net.sf.saxon.expr.ContextItemExpression.evaluateItem(ContextItemExpression.java:172) at net.sf.saxon.expr.ExpressionTool.evaluate(ExpressionTool.java:296) at net.sf.saxon.instruct.GeneralVariable.getSelectValue(GeneralVariable.java:374) at net.sf.saxon.instruct.LocalParam.processLeavingTail(LocalParam.java:143) at net.sf.saxon.instruct.Block.processLeavingTail(Block.java:556) at net.sf.saxon.instruct.Template.expand(Template.java:220) at net.sf.saxon.instruct.CallTemplate.process(CallTemplate.java:257) at net.sf.saxon.instruct.DocumentInstr.evaluateItem(DocumentInstr.java:278) at net.sf.saxon.expr.ExpressionTool.evaluate(ExpressionTool.java:296) at net.sf.saxon.instruct.GeneralVariable.getSelectValue(GeneralVariable.java:374) at net.sf.saxon.instruct.LocalParam.processLeavingTail(LocalParam.java:143) at net.sf.saxon.instruct.Block.processLeavingTail(Block.java:556) at net.sf.saxon.instruct.Template.expand(Template.java:220) at net.sf.saxon.instruct.CallTemplate$CallTemplatePackage.processLeavingTail(CallTemplate.java:440) at net.sf.saxon.instruct.ApplyTemplates.apply(ApplyTemplates.java:212) at net.sf.saxon.instruct.ApplyTemplates.process(ApplyTemplates.java:170) at net.sf.saxon.instruct.DocumentInstr.evaluateItem(DocumentInstr.java:278) at net.sf.saxon.expr.ExpressionTool.evaluate(ExpressionTool.java:296) at net.sf.saxon.instruct.GeneralVariable.getSelectValue(GeneralVariable.java:374) at net.sf.saxon.instruct.Instruction.assembleParams(Instruction.java:147) at net.sf.saxon.instruct.CallTemplate.processLeavingTail(CallTemplate.java:291) at net.sf.saxon.instruct.Block.processLeavingTail(Block.java:556) at net.sf.saxon.instruct.Template.applyLeavingTail(Template.java:203) at net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:293) at net.sf.saxon.instruct.ApplyTemplates.apply(ApplyTemplates.java:210) at net.sf.saxon.instruct.ApplyTemplates.process(ApplyTemplates.java:170) at net.sf.saxon.instruct.DocumentInstr.evaluateItem(DocumentInstr.java:278) at net.sf.saxon.functions.StringFn.evaluateItem(StringFn.java:54) at net.sf.saxon.functions.NormalizeSpace.evaluateItem(NormalizeSpace.java:75) at net.sf.saxon.instruct.SimpleContentConstructor.evaluateItem(SimpleContentConstructor.java:261) at net.sf.saxon.instruct.ValueOf.processLeavingTail(ValueOf.java:243) at net.sf.saxon.instruct.Template.applyLeavingTail(Template.java:203) at net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:293) at net.sf.saxon.instruct.ApplyTemplates.apply(ApplyTemplates.java:210) at net.sf.saxon.instruct.ApplyTemplates.process(ApplyTemplates.java:170) at net.sf.saxon.instruct.DocumentInstr.evaluateItem(DocumentInstr.java:278) at net.sf.saxon.expr.ExpressionTool.evaluate(ExpressionTool.java:296) at net.sf.saxon.instruct.GeneralVariable.getSelectValue(GeneralVariable.java:374) at net.sf.saxon.instruct.LocalParam.processLeavingTail(LocalParam.java:143) at net.sf.saxon.instruct.Block.processLeavingTail(Block.java:556) at net.sf.saxon.instruct.Template.expand(Template.java:220) at net.sf.saxon.instruct.CallTemplate.process(CallTemplate.java:257) at net.sf.saxon.instruct.CallTemplate.processLeavingTail(CallTemplate.java:281) at net.sf.saxon.instruct.Block.processLeavingTail(Block.java:556) at net.sf.saxon.instruct.Instruction.process(Instruction.java:93) at net.sf.saxon.instruct.ElementCreator.processLeavingTail(ElementCreator.java:296) at net.sf.saxon.instruct.Block.processLeavingTail(Block.java:556) at net.sf.saxon.instruct.Instruction.process(Instruction.java:93) at net.sf.saxon.instruct.ElementCreator.processLeavingTail(ElementCreator.java:296) at net.sf.saxon.instruct.Block.processLeavingTail(Block.java:556) at net.sf.saxon.expr.LetExpression.processLeavingTail(LetExpression.java:557) at net.sf.saxon.instruct.Template.applyLeavingTail(Template.java:203) at net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:293) at net.sf.saxon.instruct.ApplyTemplates.defaultAction(ApplyTemplates.java:378) at net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:284) at net.sf.saxon.instruct.ApplyTemplates.apply(ApplyTemplates.java:210) at net.sf.saxon.instruct.ApplyTemplates.processLeavingTail(ApplyTemplates.java:174) at net.sf.saxon.instruct.Block.processLeavingTail(Block.java:556) at net.sf.saxon.instruct.Choose.processLeavingTail(Choose.java:686) at net.sf.saxon.instruct.Block.processLeavingTail(Block.java:556) at net.sf.saxon.instruct.Choose.processLeavingTail(Choose.java:686) at net.sf.saxon.expr.LetExpression.processLeavingTail(LetExpression.java:557) at net.sf.saxon.instruct.Template.applyLeavingTail(Template.java:203) at net.sf.saxon.instruct.ApplyTemplates.applyTemplates(ApplyTemplates.java:293) at net.sf.saxon.Controller.transformDocument(Controller.java:1807) at net.sf.saxon.Controller.transform(Controller.java:1621) at org.ascent.xml.debugger.Debugger$DebuggerTask.transformDocument(Debugger.java:373) at org.ascent.xml.debugger.Debugger$DebuggerTask.run(Debugger.java:264) at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)
The code which I used to transform is:
TransformerFactoryImpl factory = new TransformerFactoryImpl(); Source xslSource = new StreamSource(xslFile); Source xmlSource = new StreamSource(xmlFile); Transformer newTransformer = factory.newTransformer(xslSource); Controller controller = (Controller)newTransformer; controller.getConfiguration().setConfigurationProperty(LINE_NUMBERING, true); controller.getConfiguration().setConfigurationProperty(COMPILE_WITH_TRACING, true); controller.getConfiguration().setConfigurationProperty(ALLOW_EXTERNAL_FUNCTIONS, true); controller.getConfiguration().setConfigurationProperty(TIMING, false); controller.getConfiguration().setDebugger(new XsltDebugger()); controller.setErrorListener(new XsltErrorListener()); controller.addTraceListener(new TraceListenerStub()); newTransformer.transform(xmlSource, new StreamResult(new File("E:\\result.xml")));
I tried to remove line <controller.addTraceListener(new TraceListenerStub());> and transformation worked fine. Do you have any idea, where I made a mistake?
Thank you.
Replies (1)
RE: Difficulty during XSLT events tracing - Added by Michael Kay over 11 years ago
The specification for Controller.addTraceListener() says that it has no effect unless tracing was enabled when the stylesheet was compiled. You've set COMPILE_WITH_TRACING on the Configuration, but only AFTER the stylesheet was compiled. This doesn't immediately explain the failure, but it does suggest that you are doing things wrong.
9.1 is getting a bit old. We appreciate that some people are still using the old Saxon-B because not all features were carried forward into Saxon-HE. However, the chances of us fixing any problems found in Saxon 9.1 are fairly slim at this point unless they are very major.
Please register to reply