XML目录文件无法解析 [英] XML Catalog file failing to resolve

查看:229
本文介绍了XML目录文件无法解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

 <?xml version =1.0encoding =UTF-8? > 
<!DOCTYPE目录PUBLIC - // OASIS // DTD XML目录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 = - // OXFO​​RD // DTD OXCHAPML // ENuri =OxChapML .dtd/>
< public publicId = - // OXFO​​RD // DTD OX ENCYCLML // ENuri =xEncyclML.dtd/>
< public publicId = - // OXFO​​RD // DTD OXLAWML // ENuri =OxLawML.dtd/>
< public publicId = - // OXFO​​RD // DTD OXSTRUCTML // ENuri =OxStructML.dtd/>
< public publicId = - // OXFO​​RD // DTD OXLAWREPML // ENuri =OxLawRepML.dtd/>
< public publicId = - // OXFO​​RD // DTD OXBILINGML // ENuri =OxBilingML.dtd/>
< public publicId = - // OXFO​​RD // DTD OXMONOLINGML // ENuri =OxMonolingML.dtd/>
< public publicId = - // OXFO​​RD // DTD TIMELINES // ENuri =timelines.dtd/>
< systemSuffix OxChapML.dtdsystemIdSuffix =OxChapML.dtd/>
< systemSuffix uri =xEncyclML.dtdsystemIdSuffix =xEncyclML.dtd/>
< ; systemSuffix systemIdSuffix =OxLawML.dtduri =OxLawML.dtd/>
< systemSuffix systemIdSuffix =OxStructML.dtduri =OxStructML.dtd/>
< systemSuffix systemIdSuffix =OxLawRepML.dtduri =OxLawRepML.dtd/>
< systemSuffix systemIdSuffix =OxBilingML.dtduri =OxBilingML.dtd/>
< systemSuffix systemIdSuffix = OxMonolingML.dtduri =OxMonolingML.dtd/>
< systemSuffix systemIdSuffix =timelines.dtduri =timelines.dtd/>
< / group>
< / catalog>

更新:所有公开元素使用 group 元素上设置的 xml:base 设置就好了。只有那些应该使用失败的 systemSuffix 元素解析的元素。因此,如果我有一个使用PUBLIC标识符声明其DocType的文档,它将解决没有问题(我的CatalogManager.properties中有一个 prefer = public 设置)。但是,如果我只有一个SYSTEM标识符(例如OxChapML.dtd),则应该使用相应的 systemSuffix 进行匹配,但事实并非如此。打开解析器上的调试表明它甚至没有尝试通过 systemSuffix 匹配。

解决方案

我刚遇到了一个需要很长时间才能解决的问题,在我的开发环境中,一切都运行正常,但在生产环境中,默默地



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



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



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



通常你可以处理你的catalog.xml是格式良好的XML,因此通常可以放弃DOCTYPE声明。


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.

解决方案

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.

这篇关于XML目录文件无法解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆