当我将xsl:include
更改为xsl:import
时,它以某种方式工作,并且不会返回空文件。我正在使用Xslt30Processor
类和函数Xslt30Processor::TransformFiletoFile()
,即使transform.c
也不起作用。当我的xslt有一个";xsl:result-document;声明它也不起作用。
我甚至尝试使用Saxon/C的前一个版本(1.2.0系列(,但即使这样也不起作用。有什么选项可以使用xsl:include
或其他什么东西吗。
这适用于Java和.NET,但不适用于C API。在使用JNI时,我没有得到任何错误或异常。请帮忙。
这里有一个演示问题的小例子:
source.xml
:
<xml/>
main.xsl
:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" encoding="utf-8" standalone="yes"/>
<xsl:include href="referenced.xsl" />
<xsl:template match="/">hello</xsl:template>
</xsl:stylesheet>
referenced.xsl
:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:f="my-functions.org"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="2.0">
<xsl:function name="f:next-nr" as="xs:integer">
<xsl:param name="node"/>
<xsl:sequence select="xs:integer(replace($node, 'D', ''))"/>
</xsl:function>
</xsl:stylesheet>
当运行Transform.exe
的C版本时,不会返回任何错误,也不会产生任何输出。当我把这个测试用例放在一起时,我注意到,对于这个例子,如果我把include改为import并不重要。如果我使用Saxon 10.6的tools文件夹中的Transform.exe,则会按预期生成一个文件。但是,我找不到任何适用于Saxon10.6的C/C++文件。
结果文件的问题是一个单独的问题,具有相同的结果。
我想我已经找到了样式表编译失败的一个原因,这似乎是HE找不到categories.xml的构建/配置问题。
编译的堆栈跟踪:
Exception in thread "main" java.lang.ExceptionInInitializerError
at net.sf.saxon.regex.RECompiler.escape(Unknown Source)
at net.sf.saxon.regex.RECompiler.parseTerminal(Unknown Source)
at net.sf.saxon.regex.RECompiler.piece(Unknown Source)
at net.sf.saxon.regex.RECompiler.parseBranch(Unknown Source)
at net.sf.saxon.regex.RECompiler.parseExpr(Unknown Source)
at net.sf.saxon.regex.RECompiler.compile(Unknown Source)
at net.sf.saxon.regex.ARegularExpression.<init>(Unknown Source)
at net.sf.saxon.java.JavaPlatform.compileRegularExpression(Unknown Source)
at net.sf.saxon.Configuration.compileRegularExpression(Unknown Source)
at net.sf.saxon.functions.RegexFunction.tryToBindRegularExpression(Unknown Source)
at net.sf.saxon.functions.RegexFunction.makeFunctionCall(Unknown Source)
at net.sf.saxon.functions.Replace.makeFunctionCall(Unknown Source)
at net.sf.saxon.functions.RegexFunctionSansFlags.makeFunctionCall(Unknown Source)
at net.sf.saxon.functions.registry.BuiltInFunctionSet.bind(Unknown Source)
at net.sf.saxon.functions.FunctionLibraryList.bind(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parseFunctionCall(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parseBasicStep(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parseStepExpression(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parseRelativePath(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parsePathExpression(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parseSimpleMappingExpression(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parseUnaryExpression(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parseExprSingle(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parseFunctionCall(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parseBasicStep(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parseStepExpression(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parseRelativePath(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parsePathExpression(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parseSimpleMappingExpression(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parseUnaryExpression(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parseExprSingle(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parseExpression(Unknown Source)
at net.sf.saxon.expr.parser.XPathParser.parse(Unknown Source)
at net.sf.saxon.expr.parser.ExpressionTool.make(Unknown Source)
at net.sf.saxon.style.StyleElement.makeExpression(Unknown Source)
at net.sf.saxon.style.XSLSequence.prepareAttributes(Unknown Source)
at net.sf.saxon.style.StyleElement.<unknown>(Unknown Source)
at net.sf.saxon.style.StyleElement.processAllAttributes(Unknown Source)
at net.sf.saxon.style.StyleElement.processAllAttributes(Unknown Source)
at net.sf.saxon.style.PrincipalStylesheetModule.processAllAttributes(Unknown Source)
at net.sf.saxon.style.PrincipalStylesheetModule.preprocess(Unknown Source)
at net.sf.saxon.style.Compilation.compilePackage(Unknown Source)
at net.sf.saxon.style.StylesheetModule.loadStylesheet(Unknown Source)
at net.sf.saxon.style.Compilation.compileSingletonPackage(Unknown Source)
at net.sf.saxon.s9api.XsltCompiler.compile(Unknown Source)
at net.sf.saxon.option.cpp.Xslt30Processor.getXslt30Transformer(Unknown Source)
at net.sf.saxon.option.cpp.Xslt30Processor.transformToFile(Unknown Source)
Caused by: java.lang.RuntimeException: Unable to read categories.xml file
at net.sf.saxon.regex.charclass.Categories.build(Unknown Source)
at net.sf.saxon.regex.charclass.Categories.getCategory(Unknown Source)
at net.sf.saxon.regex.charclass.Categories.<clinit>(Unknown Source)
... 47 more
因此,导致编译失败的既不是xsl:include
也不是xsl:result-document
,在尝试编译包含代码中的正则表达式时,HE构建似乎没有或找不到其categories.xml文件。
作为一种变通方法,我认为可以在没有许可证的情况下运行SaxonC EE 11.2(-license:off
(,因为它只使用HE功能,而EE包是正确构建的,可以找到其categories.xml,这样它在编译正则表达式时就不会失败。
我已经提出https://saxonica.plan.io/issues/5372关于categories.xml文件失败。