Validation error: cvc-elt.1: Cannot find the declaration of element

I use JAXP to do XML Parsing and validation. I use DOM and not SAX.

My code is as follows:

SchemaFactory schemaFactory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");

File schemaLocation =new File("C:\\config\\JMS_properties.xsd");

Schema schema = schemaFactory.newSchema(schemaLocation);

// Create the validator

Validator validator = schema.newValidator();

// Add an error handler to the validator

JMSErrorHandler errorHandler =new JMSErrorHandler();

validator.setErrorHandler(errorHandler);

// Create the dom factory

DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();

// Set the namespace property

domFactory.setNamespaceAware(true);

// Create the document builder

DocumentBuilder builder = domFactory.newDocumentBuilder();

// Parse the xml file

Document doc = builder.parse(xmlFile);

// Create the dom source and destination

// The destination will contain the doc augmented with the default attribute/element

DOMSource source =new DOMSource(doc);

DOMResult result =new DOMResult();

// Validate and augment the source

validator.validate(source, result);

// Error checking

if ( errorHandler.validationError ==true ){

// errors occured during the parsing

System.out.println("XML file is not valid");

System.exit(1);

}

// Get the augmented document

this.augmented = (Document) result.getNode();

When executing my code, I got:

Validation error: cvc-elt.1: Cannot find the declaration of element 'JMSProperties'

But the xml file has this element in it so I do not understand the meaning of that error.

?

[2498 byte] By [marlysaa] at [2007-10-3 4:03:42]
# 1
I finally found the problem. It was due to bad pointer to the xsd file.
marlysaa at 2007-7-14 22:02:45 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
could you please describe what resolved your error
pathaka at 2007-7-14 22:02:45 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3
I am also getting similar error: cvc-elt.1: Cannot find the declaration of element 'Domain'But I am getting this error only on AIX, I don't get this error when I test my code on Windows and Solaris.Can you tell me how did you resolve your problem?
ardnetiJa at 2007-7-14 22:02:45 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...