多个传递XSLT包括Saxon在Camel和Java中的不同处理方式

时间:2015-08-01 20:45:47

标签: apache-camel xslt-2.0 saxon

在JUnit测试中使用Saxon 9.5.1-4作为我的XSLT转换引擎,我看到以下警告:

  

警告:样式表模块file:/C:/svn/prime/code/trunk/xslt/target/main/classes/xsl/common/to-common-result.xsl包含或导入多次。这是允许的,但可能会导致错误或意外行为

但是当它在Apache-Camel 2.13.1下运行时,它会在警告之后失败。

15:11:29,714 WARN  [org.apache.camel.builder.xml.XsltErrorListener] (ServerService Thread Pool -- 90) Stylesheet module ../common/to-common-result.xsl is included or imported more than once. This is permitted, but may lead to errors or unexpected behavior
15:11:29,714 ERROR [org.apache.camel.builder.xml.XsltErrorListener] (ServerService Thread Pool -- 90) A stylesheet cannot import itself; SystemID: ; Line#: 11; Column#: 53: net.sf.saxon.trans.XPathException: A stylesheet cannot import itself
    at net.sf.saxon.style.StyleElement.compileError(StyleElement.java:1961) [Saxon-HE-9.5.1-4.jar:]
    at net.sf.saxon.style.XSLGeneralIncorporate.checkForRecursion(XSLGeneralIncorporate.java:234) [Saxon-HE-9.5.1-4.jar:]
    at net.sf.saxon.style.XSLGeneralIncorporate.getIncludedStylesheet(XSLGeneralIncorporate.java:123) [Saxon-HE-9.5.1-4.jar:]
    at net.sf.saxon.style.StylesheetModule.spliceIncludes(StylesheetModule.java:143) [Saxon-HE-9.5.1-4.jar:]
    at net.sf.saxon.style.XSLGeneralIncorporate.getIncludedStylesheet(XSLGeneralIncorporate.java:210) [Saxon-HE-9.5.1-4.jar:]

有什么可以解释这种差异?

导入结构如下所示:

A imports B, C;
B imports D, E, F;
C imports G;
F imports G;

此示例中的G为to-common-result.xsl

1 个答案:

答案 0 :(得分:1)

我认为线索是错误信息

15:11:29,714 ERROR [org.apache.camel.builder.xml.XsltErrorListener] (ServerService Thread Pool -- 90) A stylesheet cannot import itself; SystemID: ; Line#: 11; Column#: 53: net.sf.saxon.trans.XPathException: A stylesheet cannot import itself

SystemId为空。这表明样式表在某种程度上是在不知道每个模块的正确URI的情况下编译的,这意味着Saxon可能会认为模块正在导入自身,因为它们都有一个空白的URI。

因此,您需要了解Apache-Camel如何调用转换,以及为什么它没有为Saxon提供样式表的正确基URI。