【问题标题】:xslt document function doesn't resolve the xinclude tags in the referenced xml filexslt 文档函数无法解析引用的 xml 文件中的 xinclude 标记
【发布时间】:2014-11-26 13:22:40
【问题描述】:

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

在我的评估中,我尝试了 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

马库斯

【问题讨论】:

    标签: xml xslt saxon xinclude xerces2-j


    【解决方案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>
    

    【讨论】:

    • 感谢您的快速答复。我知道 Saxon 9.6 可以做到,但我还需要函数 saxon:evaluate 或 exsl:evaluate。这些仅在 Saxon 9.6 的 PE(或更高版本)版本中可用。
    【解决方案2】:

    我刚刚在命令行中添加了一个 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 的帮助。

    【讨论】:

      猜你喜欢
      • 2019-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-31
      • 2020-04-13
      • 1970-01-01
      相关资源
      最近更新 更多