如何获取xml形式的output
nicholas@mordor:~/xml$
nicholas@mordor:~/xml$ java -jar /usr/share/java/saxon.jar -o outputfile.xml note.xml note.xsl
nicholas@mordor:~/xml$
nicholas@mordor:~/xml$ cat outputfile.xml
<?xml version="1.0" encoding="UTF-8"?>
Tove
Jani
Reminder
Don't forget me this weekend!
nicholas@mordor:~/xml$
nicholas@mordor:~/xml$ cat note.xml
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
nicholas@mordor:~/xml$
nicholas@mordor:~/xml$ cat note.xsl
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output media-type="text/html"/>
<xsl:mode on-no-match="shallow-copy" />
</xsl:stylesheet>
nicholas@mordor:~/xml$ 指定输出文件looks不足。可能用于生成xml的xsl文件不正确
发布于 2020-12-04 02:52:17
从评论中可以看出,您使用的是非常古老的Saxon6产品,它只支持XSLT1.0。更新的版本(当前是10.3)实现了XSLT 3.0。
当您的样式表指定version="3.0“,而您的XSLT处理器只支持1.0时,它将以”向前兼容模式“运行。在这种模式下,1.0规范中没有定义的元素和属性将被忽略。其中一个元素是xsl:mode,因此样式表就好像没有xsl:mode声明一样运行。这意味着不是浅复制,而是默认的“不匹配”模板行为,它输出源文档的文本节点并忽略元素节点。
发布于 2020-12-04 14:29:40
输出与预期一致:
nicholas@mordor:~/xml$
nicholas@mordor:~/xml$ rm outputfile.xml
nicholas@mordor:~/xml$
nicholas@mordor:~/xml$ java -jar /home/nicholas/saxon/saxon-he-10.3.jar -o:outputfile.xml note.xml note.xsl
nicholas@mordor:~/xml$
nicholas@mordor:~/xml$ cat outputfile.xml
<?xml version="1.0" encoding="UTF-8"?><note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>nicholas@mordor:~/xml$
nicholas@mordor:~/xml$
nicholas@mordor:~/xml$ cat note.xsl
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output media-type="text/html"/>
<xsl:mode on-no-match="shallow-copy" />
</xsl:stylesheet>
nicholas@mordor:~/xml$ 我只是认为我might能够使用系统库。
https://stackoverflow.com/questions/65128003
复制相似问题