简体   繁体   English

通过 OASIS DITA dtd 验证 XML

[英]validate XML via OASIS DITA dtd

I have a problem when validating a file against a DTD.我在根据 DTD 验证文件时遇到问题。 XML files says only: XML 文件只说:

<!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"[]>

and that bit cannot be changed.并且该位无法更改。

I have the DTD files (there's actually 98 DTD files in 16 subfolders), but I don't know how to reference them, or even better, include (embed?) them in the application, ie create a standalone validator for that.我有 DTD 文件(在 16 个子文件夹中实际上有 98 个 DTD 文件),但我不知道如何引用它们,或者更好的是,在应用程序中包含(嵌入?)它们,即为此创建一个独立的验证器。

I am using the .net XmlReader class and it works fine, however I get the An error has occurred while opening external DTD我正在使用 .net XmlReader 类并且它工作正常,但是我收到An error has occurred while opening external DTD

Thanks!谢谢! Bartosz巴托斯

The DITA DTDs as provided by OASIS include an XML catalog used to resolve the public IDs. OASIS 提供的 DITA DTD 包括用于解析公共 ID 的 XML 目录。 If you are using the DTDs as packaged with the DITA Open Toolkit the catalog is the file catalog-dita.xml in the root of the OT distribution.如果您使用 DITA Open Toolkit 打包的 DTD,则目录是 OT 发行版根目录中的文件 catalog-dita.xml。 If it is some other package then you'll have to look around for the catalog.如果它是其他一些包,那么您将不得不四处寻找目录。

I'm not familiar with .net XML processing but there must be some way to use catalogs when parsing XML, comparable to the Apache resolver.jar classes.我不熟悉 .net XML 处理,但在解析 XML 时必须有某种方法来使用目录,类似于 Apache resolver.jar 类。

Cheers,干杯,

Eliot艾略特

One option is to implement a custom entity resolver that reads the catalog file.一种选择是实现读取目录文件的自定义实体解析器。 Mircrosoft offers little support for dita and DTD's since they appear to lean towards schemas. Mircrosoft 几乎不支持 dita 和 DTD,因为它们似乎倾向于模式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM