This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes JAXB Validation Issue - [org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of el Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "JAXB Validation Issue - [org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of el" Watch "JAXB Validation Issue - [org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of el" New topic
Author

JAXB Validation Issue - [org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of el

Ganesh Gowtham
Ranch Hand

Joined: Mar 30, 2005
Posts: 225

Hi Friends ,

I am trying to write the schema (XSD) to validate my XML using JAXB .

UnMarshalling is working fine , when we dont validate aganist schema .

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Message xmlns:xsd="http://yyy.xxx.com"> </Message>
javax.xml.bind.UnmarshalException
- with linked exception:
[org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'Message'.]
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.createUnmarshalException(AbstractUnmarshallerImpl.java:315)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.createUnmarshalException(UnmarshallerImpl.java:476)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal0(UnmarshallerImpl.java:198)
at com.sun.xml.bind.v2.runtime.unmarshaller.UnmarshallerImpl.unmarshal(UnmarshallerImpl.java:167)
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:137)
at javax.xml.bind.helpers.AbstractUnmarshallerImpl.unmarshal(AbstractUnmarshallerImpl.java:194)
at com.gs.ti.tisd.inventory.is.test.util.MessageTransformerTest.transformXMLToMessage(MessageTransformerTest.java:154)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
The moment i validate with schema, i am getting following exception


XSD


Sample XML which needs to validated


Java Code


When we comment unmarshaller.setSchema(schemaMessage);
it works , which means if without schema validation un marshalling ishappending

Any thoughts Pleasesuggest me .


Thanks, Ganesh Gowtham
http://ganesh.gowtham.googlepages.com
 
 
subject: JAXB Validation Issue - [org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of el
 
Similar Threads
JaxB unexpected element (uri:"", local:"Installer")
xml validation with the java 5
How to use DomParser.parse() to parse an XML String instead of the XML location?
XML Validation
xml validation failure