Эта ошибка возникает после устранения проблемы в Saxon 9 HE, Java - Stati c error, XTSE0210, XTSE0165, XPST0017
При вызове XSLT-преобразования из в следующем java коде
public static Document transformAsDocument(Document inputDoc, String xslDoc, Map<String,
Object> params, String xslContextPath, String fullXsltFilePath) throws XmlException {
try {
System.setProperty("javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl");
TransformerFactory factory = TransformerFactory.newInstance();
factory.setURIResolver(new ClasspathResourceURIResolver(xslContextPath));
factory.setAttribute(FeatureKeys.GENERATE_BYTE_CODE, false);
String systemId = XMLUtils.class.getResource(fullXsltFilePath).toString();
Templates template = factory.newTemplates(new StreamSource(new StringReader(xslDoc), systemId));
Transformer xformer = template.newTransformer();
if (params != null) {
for (Map.Entry<String, Object> entry : params.entrySet()) {
xformer.setParameter(entry.getKey(), entry.getValue());
}
}
DOMResult result = new DOMResult();
DOMSource domSource = new DOMSource(inputDoc);
xformer.transform(domSource, result);
return (Document) result.getNode();
} catch (TransformerConfigurationException e) {
throw new XmlException(e);
} catch (TransformerException e) {
SourceLocator locator = e.getLocator();
if (locator != null) {
Map<String, Object> message = new HashMap<String, Object>();
message.put("col", locator.getColumnNumber());
message.put("line", locator.getLineNumber());
message.put("publicId", locator.getPublicId());
message.put("systemId", locator.getSystemId());
throw new XmlException(message.toString(), e);
}
throw new XmlException(e);
} catch (Exception e) {
throw new XmlException(e);
}
}
мы видим следующую трассировку стека.
java.lang.NullPointerException
at net.sf.saxon.lib.StandardURIResolver.resolve(StandardURIResolver.java:153)
at net.sf.saxon.functions.DocumentFn.resolveURI(DocumentFn.java:411)
at net.sf.saxon.functions.DocumentFn.makeDoc(DocumentFn.java:283)
at net.sf.saxon.functions.DocAvailable.docAvailable(DocAvailable.java:68)
at net.sf.saxon.functions.DocAvailable.isDocAvailable(DocAvailable.java:31)
at net.sf.saxon.functions.DocAvailable.call(DocAvailable.java:45)
at net.sf.saxon.functions.DocAvailable.call(DocAvailable.java:21)
at net.sf.saxon.expr.FunctionCall.iterate(FunctionCall.java:547)
at net.sf.saxon.expr.Expression.effectiveBooleanValue(Expression.java:886)
at net.sf.saxon.expr.instruct.Choose.choose(Choose.java:901)
at net.sf.saxon.expr.instruct.Choose.iterate(Choose.java:952)
at net.sf.saxon.expr.instruct.GlobalVariable.getSelectValue(GlobalVariable.java:643)
at net.sf.saxon.expr.instruct.GlobalVariable.actuallyEvaluate(GlobalVariable.java:724)
at net.sf.saxon.expr.instruct.GlobalVariable.evaluateVariable(GlobalVariable.java:692)
at net.sf.saxon.expr.GlobalVariableReference.evaluateVariable(GlobalVariableReference.java:126)
at net.sf.saxon.expr.VariableReference.evaluateItem(VariableReference.java:559)
at net.sf.saxon.expr.SimpleStepExpression.iterate(SimpleStepExpression.java:113)
at net.sf.saxon.expr.SlashExpression.iterate(SlashExpression.java:902)
at net.sf.saxon.expr.Atomizer.iterate(Atomizer.java:321)
at net.sf.saxon.expr.GeneralComparison.effectiveBooleanValue(GeneralComparison.java:685)
at net.sf.saxon.expr.instruct.Choose.choose(Choose.java:901)
at net.sf.saxon.expr.instruct.Choose.iterate(Choose.java:952)
at net.sf.saxon.expr.instruct.GlobalVariable.getSelectValue(GlobalVariable.java:643)
at net.sf.saxon.expr.instruct.GlobalVariable.actuallyEvaluate(GlobalVariable.java:724)
at net.sf.saxon.expr.instruct.GlobalVariable.evaluateVariable(GlobalVariable.java:692)
at net.sf.saxon.expr.GlobalVariableReference.evaluateVariable(GlobalVariableReference.java:126)
at net.sf.saxon.expr.VariableReference.iterate(VariableReference.java:536)
at net.sf.saxon.expr.instruct.ForEach.processLeavingTail(ForEach.java:434)
at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:687)
at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:347)
at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:505)
at net.sf.saxon.Controller.transformDocument(Controller.java:2423)
at net.sf.saxon.Controller.transform(Controller.java:1979)
at net.sf.saxon.s9api.XsltTransformer.transform(XsltTransformer.java:596)
at net.sf.saxon.jaxp.TransformerImpl.transform(TransformerImpl.java:73)
java.lang.AssertionError: Internal error: no value for variable $g_ndsTemplateDoc at line 118 of
at net.sf.saxon.expr.VariableReference.iterate(VariableReference.java:547) ~[Saxon-HE-9.8.0-15.jar:na]
at net.sf.saxon.expr.instruct.ForEach.processLeavingTail(ForEach.java:434) ~[Saxon-HE-9.8.0-15.jar:na]
at net.sf.saxon.expr.instruct.Block.processLeavingTail(Block.java:687) ~[Saxon-HE-9.8.0-15.jar:na]
at net.sf.saxon.expr.instruct.TemplateRule.applyLeavingTail(TemplateRule.java:347) ~[Saxon-HE-9.8.0-15.jar:na]
at net.sf.saxon.trans.Mode.applyTemplates(Mode.java:505) ~[Saxon-HE-9.8.0-15.jar:na]
at net.sf.saxon.Controller.transformDocument(Controller.java:2423) ~[Saxon-HE-9.8.0-15.jar:na]
at net.sf.saxon.Controller.transform(Controller.java:1979) ~[Saxon-HE-9.8.0-15.jar:na]
at net.sf.saxon.s9api.XsltTransformer.transform(XsltTransformer.java:596) ~[Saxon-HE-9.8.0-15.jar:na]
at net.sf.saxon.jaxp.TransformerImpl.transform(TransformerImpl.java:73) ~[Saxon-HE-9.8.0-15.jar:na]
Ошибка происходит из следующего фрагмента XSLT, который находится в цепочке больших XSLT.
<xsl:variable name="paramsDoc" select="if (doc-available('input:request')) then doc('input:request') else ()"/>
Тот же XSLT работает из командной строки, как в Saxon 9 HE, Java - Stati c ошибки, XTSE0210, XTSE0165, XPST0017