首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用saxon和xslt指定xml文件的输出?

如何使用saxon和xslt指定xml文件的输出?
EN

Stack Overflow用户
提问于 2020-12-03 22:33:44
回答 2查看 126关注 0票数 0

如何获取xml形式的output

代码语言:javascript
复制
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不足。可能用于生成xmlxsl文件不正确

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 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声明一样运行。这意味着不是浅复制,而是默认的“不匹配”模板行为,它输出源文档的文本节点并忽略元素节点。

票数 1
EN

Stack Overflow用户

发布于 2020-12-04 14:29:40

输出与预期一致:

代码语言:javascript
复制
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能够使用系统库。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65128003

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档