XML 目录文件无法解析

发布于 2024-08-30 14:11:07 字数 2458 浏览 3 评论 0原文

我正在使用 OASIS v 1.1 兼容解析器(Norm Walsh 的 XMLResolver 以及下面的目录。然而,我很确定我在这里犯了一些明显的错误(这是我第一次需要使用 v 1.1 功能),因为尝试解决 OxChapML.dtd 失败了。任何人都可以看到这个明显的错误吗?或者甚至是微妙的错误?

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD XML Catalogs V1.1//EN"
         "http://www.oasis-open.org/committees/entity/release/1.1/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
        <group  xml:base="file:///Volumes/Ac-EDP/DTG/SP%20DTD%20management/OUP_DTD/">
                <public publicId="-//OXFORD//DTD OXCHAPML//EN" uri="OxChapML.dtd"/>
                <public publicId="-//OXFORD//DTD OXENCYCLML//EN" uri="xEncyclML.dtd"/>
                <public publicId="-//OXFORD//DTD OXLAWML//EN" uri="OxLawML.dtd"/>
                <public publicId="-//OXFORD//DTD OXSTRUCTML//EN" uri="OxStructML.dtd"/>
                <public publicId="-//OXFORD//DTD OXLAWREPML//EN" uri="OxLawRepML.dtd"/>
                <public publicId="-//OXFORD//DTD OXBILINGML//EN" uri="OxBilingML.dtd"/>
                <public publicId="-//OXFORD//DTD OXMONOLINGML//EN" uri="OxMonolingML.dtd"/>
                <public publicId="-//OXFORD//DTD TIMELINES//EN" uri="timelines.dtd"/>
                <systemSuffix OxChapML.dtd" systemIdSuffix="OxChapML.dtd"/>
                <systemSuffix uri="xEncyclML.dtd" systemIdSuffix="xEncyclML.dtd"/>
                <systemSuffix systemIdSuffix="OxLawML.dtd" uri="OxLawML.dtd"/>
                <systemSuffix systemIdSuffix="OxStructML.dtd" uri="OxStructML.dtd"/>
                <systemSuffix systemIdSuffix="OxLawRepML.dtd" uri="OxLawRepML.dtd"/>
                <systemSuffix systemIdSuffix="OxBilingML.dtd" uri="OxBilingML.dtd"/>
                <systemSuffix systemIdSuffix="OxMonolingML.dtd" uri="OxMonolingML.dtd"/>
                <systemSuffix systemIdSuffix="timelines.dtd" uri="timelines.dtd"/>
        </group>        
</catalog>

更新:使用 group 元素上设置的 xml:base 可以很好地解析所有 public 元素。那些应该使用失败的 systemSuffix 元素来解析的元素因此,如果我有一个使用 PUBLIC 标识符声明其 DocType 的文档,它将毫无问题地解析(我的 CatalogManager.properties 有一个但是,如果我只有一个 SYSTEM 标识符(例如“OxChapML.dtd”),则应该与适当的 systemSuffix 相匹配,但它不是。打开解析器上的调试显示它甚至没有尝试通过 systemSuffix 进行匹配。

I'm using an OASIS v 1.1 compatible resolver (Norm Walsh's XMLResolver in conjunction with the catalog below. However, I'm pretty sure I've made some sort of obvious error here (this is the first time I've needed to use v 1.1 features) since attempting to resolve OxChapML.dtd fails. Can anyone see something obviously wrong with this? Or even subtly wrong?

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE catalog PUBLIC "-//OASIS//DTD XML Catalogs V1.1//EN"
         "http://www.oasis-open.org/committees/entity/release/1.1/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
        <group  xml:base="file:///Volumes/Ac-EDP/DTG/SP%20DTD%20management/OUP_DTD/">
                <public publicId="-//OXFORD//DTD OXCHAPML//EN" uri="OxChapML.dtd"/>
                <public publicId="-//OXFORD//DTD OXENCYCLML//EN" uri="xEncyclML.dtd"/>
                <public publicId="-//OXFORD//DTD OXLAWML//EN" uri="OxLawML.dtd"/>
                <public publicId="-//OXFORD//DTD OXSTRUCTML//EN" uri="OxStructML.dtd"/>
                <public publicId="-//OXFORD//DTD OXLAWREPML//EN" uri="OxLawRepML.dtd"/>
                <public publicId="-//OXFORD//DTD OXBILINGML//EN" uri="OxBilingML.dtd"/>
                <public publicId="-//OXFORD//DTD OXMONOLINGML//EN" uri="OxMonolingML.dtd"/>
                <public publicId="-//OXFORD//DTD TIMELINES//EN" uri="timelines.dtd"/>
                <systemSuffix OxChapML.dtd" systemIdSuffix="OxChapML.dtd"/>
                <systemSuffix uri="xEncyclML.dtd" systemIdSuffix="xEncyclML.dtd"/>
                <systemSuffix systemIdSuffix="OxLawML.dtd" uri="OxLawML.dtd"/>
                <systemSuffix systemIdSuffix="OxStructML.dtd" uri="OxStructML.dtd"/>
                <systemSuffix systemIdSuffix="OxLawRepML.dtd" uri="OxLawRepML.dtd"/>
                <systemSuffix systemIdSuffix="OxBilingML.dtd" uri="OxBilingML.dtd"/>
                <systemSuffix systemIdSuffix="OxMonolingML.dtd" uri="OxMonolingML.dtd"/>
                <systemSuffix systemIdSuffix="timelines.dtd" uri="timelines.dtd"/>
        </group>        
</catalog>

Update: All of the public elements resolve just fine using the xml:base set on the group element. It's only those elements that should be resolved using the systemSuffix elements that are failing. So, if I have a document that declares its DocType using a PUBLIC identifier, it will resolve with no problems (my CatalogManager.properties has a prefer=public setting in it). If, however, I just have a SYSTEM identifier (e.g "OxChapML.dtd") this should be matched by the appropriate systemSuffix but it isn't. Turning up the debugging on the resolver shows that it isn't even trying to match via systemSuffix.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

智商已欠费 2024-09-06 14:11:07

DTD 位于哪里?与目录文件在同一目录中吗?您的 URI 都是相对的。相对 URI 是相对于目录文件的位置进行解析的(除非已设置 xml:base)。它们与正在验证的 XML 文件的位置无关。

如果不知道各个文件相对于彼此的位置,就很难猜测问题。

您是否能够使用任何 DTD 来获得目录解析?

Where are the DTDs located? In the same directory as the catalogue file? Your URIs are all relative. Relative URIs are resolved relative to the location of the catalogue file (unless xml:base has been set). They are not relative to the location of the XML file being validated.

It's hard to guess the issue without knowing where the various files are located relative to each other.

Are you able to get catalogue resolution working with any DTD as all?

遗失的美好 2024-09-06 14:11:07

我刚刚遇到了一种需要很长时间才能解决的情况,在我的开发环境中一切运行良好,但在生产中却默默地死亡。

起初我认为这可能是目录文件上的 XML 命名空间问题,但那是一条死胡同。

事实证明,目录层次结构中其中一个catalog.xml 文件中存在DOCTYPE 声明是罪魁祸首。我忽略的开发环境和生产环境之间的区别是后者(封闭内联网中的 VDI)无法访问开放互联网。因此目录解析器无法打开catalog.dtd 文件的系统标识符(即http: URL)。一旦我删除了 DOCTYPE 声明,一切就按预期进行了。

非常令人沮丧。目录解析器对此保持沉默可能会被视为一个错误 - 它应该至少将此类错误渗透到日志中,或者最好抛出异常。

通常,您可以将 Catalog.xml 作为格式良好的 XML 进行处理,因此通常可以安全地省略 DOCTYPE 声明。

I just ran into a situation that took a long time to resolve, one where in my development environment everything ran fine but in production it died silently.

At first I thought this might be an XML Namespace issue on the catalog file but that was a blind alley.

It turns out that the presence of the DOCTYPE declaration on one of the catalog.xml files in the catalog hierarchy was the culprit. The difference between the development and production environments that I'd overlooked was that the latter (a VDI in a closed intranet) doesn't have access to the open internet. So the catalog resolver was unable to open the system identifier of the catalog.dtd file (i.e., an http: URL). As soon as I removed the DOCTYPE declaration everything worked as expected.

Very frustrating. That the catalog resolver was silent on this might be considered a bug — it should percolate a error of this sort at least into the logs, or preferably throw an exception.

As a rule you probably can process your catalog.xml as well-formed XML so it's generally safe to leave off the DOCTYPE declaration.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文