DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=27055>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=27055

DOM level 3 : Cannot import 2 XSD within the same namespace





------- Additional Comments From [EMAIL PROTECTED]  2004-02-19 09:46 -------
Actually, the note says:

NOTE: The above is carefully worded so that multiple <import>ing of the same 
schema document will not constitute a violation of clause 2 of Schema 
Properties Correct (§3.15.6), but applications are allowed, indeed encouraged, 
to avoid <import>ing the same schema document more than once to forestall the 
necessity of establishing identity component by component. Given that the 
schemaLocation [attribute] is only a hint, it is open to applications to ignore 
all but the first <import> for a given namespace, regardless of the ·actual 
value· of schemaLocation, but such a strategy risks missing useful information 
when new schemaLocations are offered.

This would seem to apply when importing the SAME schema DOCUMENT.
In my case, I am importing seperate and different documents targeting the same 
namespace. This is (I thought) a standard way to break large schemas into 
logical blocks in seperate files.

I could do as you suggest, and I probably will have to in the short term, cut 
and paste all my schemas into one file, but these are actually standard UK 
local government schemas (eGIF) and I would much prefer be able to process them 
as they are.

I have modified my test to test validation at parse time as well as post parse:

String strXml = "<A xmlns='ABC'><B>b</B><C>c</C></A>";
javax.xml.parsers.DocumentBuilderFactory dbf= 
   javax.xml.parsers.DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
//dbf.setAttribute("http://xml.org/sax/features/validation",Boolean.FALSE);
//dbf.setAttribute("http://apache.org/xml/features/nonvalidating/load-external-
dtd", Boolean.FALSE);
// parse validation
dbf.setAttribute("http://xml.org/sax/features/validation",Boolean.TRUE);
dbf.setAttribute("http://apache.org/xml/features/validation/schema";, 
Boolean.TRUE); 
dbf.setAttribute("http://apache.org/xml/features/nonvalidating/load-external-
dtd",Boolean.FALSE);
dbf.setAttribute
("http://java.sun.com/xml/jaxp/properties/schemaLanguage";, "http://www.w3.org/20
01/XMLSchema");
dbf.setAttribute("http://apache.org/xml/properties/schema/external-
schemaLocation","ABC A.xsd");
//
javax.xml.parsers.DocumentBuilder parser = dbf.newDocumentBuilder();
parser.setErrorHandler(myErrorHandler);
// Load XML without validating it
org.w3c.dom.Document dom = parser.parse(new org.xml.sax.InputSource(new 
java.io.StringReader(strXml)));
[.. check myErrorHandler]
// Now validate against arbitrary schema
org.w3c.dom.DOMConfiguration config = dom.getDomConfig();
config.setParameter("error-handler", myErrorHandler);
config.setParameter("validate", Boolean.TRUE);
config.setParameter("schema-type", "http://www.w3.org/2001/XMLSchema";);
config.setParameter("schema-location", "A.xsd");
dom.normalizeDocument();
[.. check myErrorHandler]

both validation fail in the same way, which is reassuring

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to