On 14/10/11 20:20, Mark R Maxey wrote:

Xerces Java Users,

Xerces is failing to correctly resolve XSDs to their locations using XML catalogs that prefer public IDs during the loading of the XSDs for schema validation. After extensive debugging, we've found that the following method out of _XMLCatalogResolver_ <http://www.java2s.com/Open-Source/Java-Document/XML/xerces-2_9_1/org/apache/xerces/util/XMLCatalogResolver.java.htm> is always passed a "null" for the publicId :

*public**_ LSInput_* <http://www.java2s.com/Open-Source/Java-Document/6.0-JDK-Core/w3c/org/w3c/dom/ls/LSInput.java.htm> resolveResource(*_ String_* <http://www.java2s.com/Open-Source/Java-Document/6.0-JDK-Core/lang/java/lang/String.java.htm> type, *_String_* <http://www.java2s.com/Open-Source/Java-Document/6.0-JDK-Core/lang/java/lang/String.java.htm> namespaceURI, *_ String_* <http://www.java2s.com/Open-Source/Java-Document/6.0-JDK-Core/lang/java/lang/String.java.htm> publicId, *_String_* <http://www.java2s.com/Open-Source/Java-Document/6.0-JDK-Core/lang/java/lang/String.java.htm> systemId, *_String_* <http://www.java2s.com/Open-Source/Java-Document/6.0-JDK-Core/lang/java/lang/String.java.htm> baseURI) {

This prevents _XMLCatalogResolver_ <http://www.java2s.com/Open-Source/Java-Document/XML/xerces-2_9_1/org/apache/xerces/util/XMLCatalogResolver.java.htm> from being able to use public IDs to resolve schema references.

Further debugging indicates the possible problem/solution lies in & around line 957 of XSDHandler <https://svn.apache.org/repos/asf/xerces/java/tags/Xerces-J_2_11_0/src/org/apache/xerces/impl/xs/traversers/XSDHandler.java>. This seems like it is the appropriate place to set the public ID to be the name of the schemaNamespace.


Has anyone encountered these issues before? Let us know if you have difficulty reproducing the issue. If you agree it is a bug, I'll be glad to submit it to JIRA.


Thanks!
Mark Maxey

I think you probably could use catalogs. If you pass a namespace to XMLCatalogResolver then it is passed into the catalog using resolveURI so you I think that you should be able to use rewriteURI entries to achieve what you want.

Whether this makes sense is another matter.  On my reading of the spec:-

http://www.oasis-open.org/committees/entity/spec-2001-08-06.html#s.uri.res

I'd expect the URI resolution entries to be used to process URI references - i.e. physical locations of documents like XSLT document locations or, for XML schemas, the schemaLocation attribute. Rewriting URI prefixes doesn't make much sense for namespaces. This is useful for rewriting a bunch of URI references for a web server to a local copy by matching prefixes.

I'd be interested in hearing from anyone involved in the original spec for catalogs as to whether rewriteURI was intended for namespace URI's or not. I suspect it wasn't considered at the time and hence there's no consensus.

So you may find it less diseased to continue to use namespaces as public identifiers but write your own entity resolver.


Chris Simmons.

Reply via email to