Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] R: MOXy JAXB SAXSource unmarshall with validationdoes not work

Title: R: [eclipselink-users] MOXy JAXB SAXSource unmarshall with validationdoes not work

Hello,
i solved my problem using sax validation:

//set my schema for validation
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
spf.setSchema(mySchema);

//create my xml reader to handle sax events
XMLReader xmlReader = spf.newSAXParser().getXMLReader();
MyXmlReader myXmlReader = new MyXmlReader(xmlReader);
myXmlReader.setErrorHandler(myErrorHandler);

//unmarshall with saxSource
SAXSource saxSource = new SAXSource(myXmlReader, myFileInputSource);
Unmarshaller unmarshaller = moxyContext.createUnmarshaller();
unmarshaller.unmarshal(saxSource);

Its is also possible to use jaxb validation with moxy / sax?
Thank you,
Daniele

-----Messaggio originale-----
Da: eclipselink-users-bounces@xxxxxxxxxxx per conto di Adriano Daniele
Inviato: mar 25/01/2011 15.30
A: EclipseLink-users@xxxxxxxxxxx
Oggetto: [eclipselink-users] MOXy JAXB SAXSource unmarshall with validationdoes not work

Hello,
i have substituted jaxb impl with moxy but using unmarshall(Source) the validation does not work.

SAXSource saxSource = new SAXSource(myXmlReader, myFileInputSource);
Unmarshaller unmarshaller = moxyContext.createUnmarshaller();
unmarshaller.setSchema(mySchema);
unmarshaller.setEventHandler(myEventHandler);
unmarshaller.unmarshal(saxSource);

Using jaxbimplContext instead of moxyContext the validation will work.

The validation work too if i use moxyContext and unmarshal(InputStream).

Unfortunately i need sax events.
Can you help me to understand what is wrong in my example?

Thank you.
Daniele



Back to the top