XSLT 转换之前的 DTD 验证
我必须编写 XSLT 将一个 XML 文件转换为另一个 XML 文件。原始输入文件必须对于 DTD 有效。有没有一种方法可以让 XSLT 在转换之前根据 DTD 验证输入 xml 文件?如果输入文件不符合 DTD,也将拒绝该输入文件。
另外,我将在 Oxygen XML Editor 等工具中运行 XSLT。
提前致谢。 杰康
I have to write an XSLT to convert a XML file into another XML file. The original input file has to valid with respect to a DTD. Is there a way in which XSLT can validate the input xml file against the DTD before converting it ? Also reject the input file if it does not conform to the DTD.
Also , I will run the XSLT in a tool like Oxygen XML Editor.
Thanks in advance.
JK
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您必须通过 XSLT 处理器来完成此操作。我认为 XSLT 本身没有办法做到这一点。
在oXygen中,您可以转到“首选项”中的“XML / XSLT-FO-XQuery / XSLT / Saxon / Saxon-HE/PE/EE”,然后打开或关闭DTD验证(有一个组合框)。
You have to do this through your XSLT processor. I don't think there is a way to do this in XSLT itself.
In oXygen, you can go to "XML / XSLT-FO-XQuery / XSLT / Saxon / Saxon-HE/PE/EE" in Preferences and turn DTD validation on or off (there is a combo box).
不适用于内置 XSLT-1.0 函数(它也无法以干净的方式检测非格式良好)。您的环境可能能够通过其他工具(例如 DOM 构建器)提供此功能。
Not with builtin XSLT-1.0 functions (which cannot detect non-well-formedness in a clean manner either). Your environment may be able to provide this through other tools such as DOM Builders.
这完全取决于您使用的工具。在本例中,这是有关 Oxygen 编辑器的问题。 XSLT 规范中没有任何内容要求处理器在读取 XML 时执行 DTD 验证。
This depends entirely on the tool you are using. In this case, this is a question about the Oxygen editor. There's nothing in the specification for XSLT that requires a processor to perform DTD validation when reading XML.