XML Catalog file failing to resolve

大兔子大兔子 提交于 2019-12-08 05:36:07

问题


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.


回答1:


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?




回答2:


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.



来源:https://stackoverflow.com/questions/2738429/xml-catalog-file-failing-to-resolve

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!