撒克逊 cli 与氧气差异
saxon cli vs oxygen discrepancy
我正在尝试将 xml 转换为 html。带氧的Xpath如下:
<a href="#cite{count(preceding::citation) + 1}">
<xsl:value-of select="count(preceding::citation) + 1"/>
</a>
基本上,这样做的目的是根据前面的引用计数插入编号引用 link。
这在氧气中转化时有效。
当从命令行 运行 时,1
是所有 link 的输出。
我尝试过的命令行命令如下所示:
java -jar /usr/share/java/saxon9he.jar -s:report1.xml -xsl:test.xsl -o:output4.html -t
我也试过saxon9ee:
java -cp /usr/share/java/saxon9ee.jar com.saxonica.Transform -s:report1.xml -xsl:test.xsl -o:output3.html -t
感谢任何帮助!
test.xsl 可以在这里找到
http://pastebin.com/6qZeEgD8
report1.xml
http://pastebin.com/5SMY8c7W
contentconfig.xml
http://pastebin.com/A2etm4Cr
这里是 -t
输出:
Saxon-HE 9.7.0.4J from Saxonica
Java version 1.7.0_79
Stylesheet compilation time: 1.59928s (1599.280903ms)
Processing file:/root /CRIReportProject/cpreport.xml
Using parser com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser
Building tree for file:/root/CRIReportProject/cpreport.xml using class net.sf.saxon.tree.tiny.TinyBuilder
Tree built in 1.296529ms
Tree size: 27 nodes, 54 characters, 5 attributes
URIResolver.resolve href="contentconfig.xml" base="file:/root/CRIReportProject/cptest.xsl"
Building tree for file:/root/CRIReportProject/contentconfig.xml using class net.sf.saxon.tree.tiny.TinyBuilder
Tree built in 3.144498ms
Tree size: 28 nodes, 161 characters, 6 attributes
Execution time: 131.347609ms
已用内存:8428592
您正在使用 match="method" 在模板规则中执行 count(preceding::citation)
,评估的上下文项是文档 report1.xml
中的 <method>
元素。本文档不包含 <citation>
元素,因此 count(preceding::citation)
应该 return 为零是完全合理的。您周围的 <xsl:if>
查看另一个文档 contentconfig.xml
,但它不会更改该文档的上下文。也许 xsl:if
应该更改为 xsl:for-each
,但是您还需要进行其他更改,因为代码还在寻找诸如 sup/a/@id
之类的元素,这些元素不存在于任一源文档。
我不知道为什么这段代码在 oXygen 中的表现会有所不同。
顺便说一句,如果你确实将 xsl:if 更改为 xsl:for-each,那么你可能可以将 count(preceding::citation)+1
更改为 position()
,这将是很多更有效率。
我正在尝试将 xml 转换为 html。带氧的Xpath如下:
<a href="#cite{count(preceding::citation) + 1}">
<xsl:value-of select="count(preceding::citation) + 1"/>
</a>
基本上,这样做的目的是根据前面的引用计数插入编号引用 link。
这在氧气中转化时有效。
当从命令行 运行 时,1
是所有 link 的输出。
我尝试过的命令行命令如下所示:
java -jar /usr/share/java/saxon9he.jar -s:report1.xml -xsl:test.xsl -o:output4.html -t
我也试过saxon9ee:
java -cp /usr/share/java/saxon9ee.jar com.saxonica.Transform -s:report1.xml -xsl:test.xsl -o:output3.html -t
感谢任何帮助!
test.xsl 可以在这里找到
http://pastebin.com/6qZeEgD8
report1.xml
http://pastebin.com/5SMY8c7W
contentconfig.xml
http://pastebin.com/A2etm4Cr
这里是 -t
输出:
Saxon-HE 9.7.0.4J from Saxonica
Java version 1.7.0_79
Stylesheet compilation time: 1.59928s (1599.280903ms)
Processing file:/root /CRIReportProject/cpreport.xml
Using parser com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser
Building tree for file:/root/CRIReportProject/cpreport.xml using class net.sf.saxon.tree.tiny.TinyBuilder
Tree built in 1.296529ms
Tree size: 27 nodes, 54 characters, 5 attributes
URIResolver.resolve href="contentconfig.xml" base="file:/root/CRIReportProject/cptest.xsl"
Building tree for file:/root/CRIReportProject/contentconfig.xml using class net.sf.saxon.tree.tiny.TinyBuilder
Tree built in 3.144498ms
Tree size: 28 nodes, 161 characters, 6 attributes
Execution time: 131.347609ms
已用内存:8428592
您正在使用 match="method" 在模板规则中执行 count(preceding::citation)
,评估的上下文项是文档 report1.xml
中的 <method>
元素。本文档不包含 <citation>
元素,因此 count(preceding::citation)
应该 return 为零是完全合理的。您周围的 <xsl:if>
查看另一个文档 contentconfig.xml
,但它不会更改该文档的上下文。也许 xsl:if
应该更改为 xsl:for-each
,但是您还需要进行其他更改,因为代码还在寻找诸如 sup/a/@id
之类的元素,这些元素不存在于任一源文档。
我不知道为什么这段代码在 oXygen 中的表现会有所不同。
顺便说一句,如果你确实将 xsl:if 更改为 xsl:for-each,那么你可能可以将 count(preceding::citation)+1
更改为 position()
,这将是很多更有效率。