Strange Xerces2 behaviour when validating xmls with namespaceses. 2003-05-14 - By Alex Shuksto
Good day everybody.
There is some strange things with xerces when i'm trying to validate attached file "test.xml", defined with "test.xsd" (also attached):
I can instanciate org.apache.xerces.parsers.DOMParser, set the features and parse file:
---
import org.apache.xerces.parsers.DOMParser;
...
DOMParser domParser = new DOMParser();
domParser.setFeature("http://xml.org/sax/features/validation", true); domParser.setFeature("http://apache.org/xml/features/validation/schema", true); domParser.setFeature("http://apache.org/xml/features/validation/schema-full -checking", true);
domParser.parse("test.xml");
---
and everything will be o'key, but if i want to use javax.xml.parsers.DocumentBuilderFactory and javax.xml.parsers.DocumentBuilder as follows:
---
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilder;
...
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance(); documentBuilderFactory.setAttribute("http://xml.org/sax/features/validation", new Boolean(true)); documentBuilderFactory.setAttribute("http://apache.org/xml/features/validation /schema", new Boolean(true)); documentBuilderFactory.setAttribute("http://apache.org/xml/features/validation /schema-full-checking", new Boolean(true));
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
documentBuilder .parse("test.xml");
---
then I'll get an instances of org.apache.xerces.jaxp.DocumentBuilderFactoryImpl (correct) and org.apache.xerces.jaxp.DocumentBuilderImpl (correct) (with org.apache.xerces.parsers.DOMParser inside with correctly setted features) and an error: "[Error] test.xml:6:62: cvc-elt.1: Cannot find the declaration of element 'myns:root'." (wrong!). Tell me, please, where i'm wrong.
Thanks a priori.
--------------------------------------------------------------------- To unsubscribe, e-mail: xerces-j-user-unsubscribe@(protected) For additional commands, e-mail: xerces-j-user-help@(protected)
|
|