Schema validation

S

Samuel Penn

I'm trying to validate an XML document against a Schema, but keep on
running up against an error along the lines of:

Error: URI=null Line=3: Element type "article" is not declared.
Error: URI=null Line=4: Attribute "xmlns:xsi" is not declared for element
"article".
Error: URI=null Line=4: Attribute "xsi:noNamespaceSchemaLocation" is not
declared for element "article".
Error: URI=null Line=5: Element type "body" is not declared.

The code I am using is as follows:

private void
load(InputSource in) {
try {
DocumentBuilderFactory dbf;

dbf = DocumentBuilderFactory.newInstance();
dbf.setNamespaceAware(true);
dbf.setValidating(true);

DocumentBuilder db = dbf.newDocumentBuilder();
document = db.parse(in);
} catch (Exception e) {
e.printStackTrace();
}
}

If validation isn't switched on, then the document loads fine. The
document also validates against an online validator I've found.
(http://tools.decisionsoft.com/schemaValidate.html).

I also get a similar error if I try to validate using the xmlvalidate
task in Ant 1.6. I'm guessing that it's not loading the schema, even
though the schema is declared in the XML document.

xmllint also worked with these documents, though doesn't seem to support
substitutionGroup (at least, not the version I have).

If anyone has any ideas, I'd be grateful. XML and XSD are attached.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top