1

我正在寻找一种解决方案来解决由 document() 函数 (XSLT) 引用的文档中的 xincludes。

在我的评估中,我尝试了 xsltproc(不起作用),现在我坚持使用 saxon 6.5.5 和 apache xerces 2.11.0。

这是我当前的命令行。

java.exe  -cp lib\xercesImpl-2.7.1.jar;\lib\saxon.jar 
 -Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl  
 -Djavax.xml.parsers.SAXParserFactory= org.apache.xerces.jaxp.SAXParserFactoryImpl  
 -Dorg.apache.xerces.xni.parser.XMLParserConfiguration=org.apache.xerces.parsers.XIncludeParserConfiguration 
 com.icl.saxon.StyleSheet 
 -o OUTPUT.XML INPUT.XML COPY.XSLT  

也许我必须添加一些参数或者我必须使用一些额外的库。感谢您的回复。BR

马库斯

4

2 回答 2

1

我认为 Saxon 9 Java 有一个xi命令行选项可以执行 XInclude,例如在 Saxon 9.6 HE 中我尝试-xi -it:main -xsl:test2014112604.xsl使用样式表

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:mf="http://example.com/mf"
    exclude-result-prefixes="xs mf"
    version="2.0">

<xsl:template name="main">
  <xsl:copy-of select="document('test2014112604.xml')"/>
</xsl:template>

</xsl:stylesheet>

和文件 test2014112604.xsl 为

<root>
  <include xmlns="http://www.w3.org/2001/XInclude" href="test2014112605.xml"/>
</root>

和包括在内

<test>...</test>

这样撒克逊人的输出

<?xml version="1.0" encoding="UTF-8"?><root>
  <test xml:base="test2014112605.xml">...</test>
</root>
于 2014-11-26T15:37:17.403 回答
0

我刚刚在命令行中添加了一个 URI 解析器。

-Dorg.apache.xerces.xni.parser.XMLParserConfiguration=org.apache.xerces.parsers.XIncludeParserConfiguration 
 net.sf.saxon.Transform
 -x:org.apache.xml.resolver.tools.ResolvingXMLReader
 -y:org.apache.xml.resolver.tools.ResolvingXMLReader
 -r:org.apache.xml.resolver.tools.CatalogResolver   

我要感谢 Mickael Kay 和 Dave Pawson 的帮助。

于 2014-12-01T09:02:15.797 回答