Hi, I have found the following problem: A relative URI in a import namespace statement like <xsd:import namespace="http://www.w3.org/1999/xlink" schemaLocation="xlink.xsd"/> is resolved to the URI of the XML Source to be parsed and not to the containing XML Schema. Regards Thomas
This is not a bug, this is a default behavior. To overwrite this behavior, implement your own EntityResolver and register it with a parser. Look also at: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=2510
I have reopened the bug because I have a further question: The resolveEntity(String publicId, String systemId) method is called with the relative systemId. How should this method obtain the absolute URI of the XML Schema which contains this relative URI? For implementing your suggestion the method should be called with a resolved absolute URI. Regards Thomas
The resolveEntity method will always be called with an absolute URI when you gave the parser a chance to have some absolute base URI for creating absolute URI's from relative ones. If you use parse(String systemId) you should supply an absolute URI. If you use parse(InputSource input) you can use setSystemId at the InputSource to set the absolute URI. What you will most likely do in such EntityResolver is either keeping some hashtables of public and system identifiers to 'real' locations and than return an InputSource created from that 'real' location. For doing this xerces contains an nice base class org.apache.readers.XMLCatalogHandler and the XCatalog that can load such mappings from a file using an xml based format. You can also use the EntityResolver to handle your own vnd.mycompany.myscheme:/.. URI scheme(s) or do both, eg. if you created the InputStream using some application specific procedure that doesn´t map to the URI schemes known to xerces like file:// http://. For resolving relative to absolute URI´s have a look at the java.net.URI class in JDK1.4 and http://www.ietf.org/rfc/rfc2396.txt
Okay, with your comment it seems to be a problem with the JAXP Implementation. I use the method public void parse(java.io.InputStream is, DefaultHandler dh, java.lang.String systemId) of javax.xml.parsers.SAXParser. The method is called with this systemId: file:/D:/htdocs/xmledi/xml/ssregw_paper_template.xml And the resolveEntity(String publicId, String systemId) Method than is called with the relative URI "ssregw_paper.xsd" which is contained in the InputStream. I have attched the Java sources.
Created attachment 319 [details] class used for validation
Created attachment 320 [details] class used as DefaultHandler