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
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