Skip to main content

org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of ..

1 reply [Last post]
karaco
Offline
Joined: 2008-10-07
Points: 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.

Does somebody know how to solve this?

Thank you!
Katja

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
karaco
Offline
Joined: 2008-10-07
Points: 0

It is some bug and normally it it solved in jdk 1.5
see http://mail-archives.apache.org/mod_mbox/xerces-j-dev/200605.mbox/%3c326...

But I tried to use jdk 1.5 and I still receive this error!

Is there somebody who knows what to do?

Thanks in advance!