[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Zerces 1.4.2, JAXP, schema - can't validate
- From: "Zehavi, Gil" <Gil_Zehavi@icomverse.com>
- To: 'Pete Sahm' <psahm@usadatanet.net>
- Date: Tue, 07 Aug 2001 10:52:09 +0300
You need to tell the parser to use the schema for validation using:
setFeature("http://apache.org/xml/features/validation/schema", true);
I could not manage to do it (setFeature command) using the same code you
wrote. Therefore I used the DOMParser class to parse the doc and then
continue with JAXP classes. Here is the code:
DOMParser parser = new DOMParser();
parser.setFeature("http://xml.org/sax/features/validation", true);
parser.setFeature("http://apache.org/xml/features/validation/schema", true);
parser.setErrorHandler(_errorHandler);
parser.parse(filePath);
Document doc = parser.getDocument();
Gil
-----Original Message-----
From: Pete Sahm [mailto:psahm@usadatanet.net]
Sent: Monday, August 06, 2001 9:53 PM
To: XML Dev List
Subject: Zerces 1.4.2, JAXP, schema - can't validate
Hi,
Has anyone been able to successfully perform a validating parse against a
schema using Xerces 1.4.2, the JAXP, and Java 1.3.1?
I've seen several posts regarding the subject that I have gone though, yet
none seem to enable me to perform a validating parse on the sample
documents that ship with Xerces: personal-schema.xml using personal.xsd (or
any other docs/schemas, for that matter).
The following snippet is the code I am using, and no matter what I have
tried I keep getting parse errors: "Element type "xxx" must be declared."
Document doc = null;
System.setProperty("javax.xml.parsers.DocumentBuilderFactory",
"org.apache.xerces.jaxp.DocumentBuilderFactoryImpl");
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setValidating(true);
DocumentBuilder db = dbf.newDocumentBuilder();
db.setErrorHandler(this);
doc = db.parse(xmlFile);
My CLASSPATH contains only the Xerces jar and directory containing the
class containing the above code.
Any and all help is greatly appreciated.
Thanks in advance,
Pete
------------------------------------------------------------------
The xml-dev list is sponsored by XML.org <http://www.xml.org>, an initiative
of OASIS <http://www.oasis-open.org>
The list archives are at http://lists.xml.org/archives/xml-dev/
To unsubscribe from this elist send a message with the single word
"unsubscribe" in the body to: xml-dev-request@lists.xml.org