error XML validation JAXP:org.xml.sax.SAXParseException

KaR

Joined
Oct 8, 2008
Messages
5
Reaction score
0
Hello,

I try to validate a DOM Document using:

SchemaFactory factory=SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Source schemaFile=new StreamSource("myschema.xsd");
schema schema=factory.newSchema(schemaFile);
Validator validator=schema.newValidator();
validator.validate(new DOMSource(document));


I don't validate using the parse(File) method, because I already have a DOM Tree in memory.

BUT now I receive the following error:

org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'catalogue'.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at org.apache.xerces.util.ErrorHandlerWrapper.error(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.beginNode(Unknown Source)
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)
at org.apache.xerces.jaxp.validation.DOMValidatorHelper.validate(Unknown Source)
at org.apache.xerces.jaxp.validation.XMLSchemaValidator.validate(Unknown Source)
at javax.xml.validation.Validator.validate(Unknown Source)

catalogue is my rootElement.

I'm using jdk 1.4.

I also tried to use JAXP 1.4.2 and I also added following:
dbFactory.setNamespaceAware(true);

But it still doesn't work.

Does somebody know how to solve this?

Thank you!
Katja
 

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,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top