Wolfgang,
unfortunately that's exactly our problem. We set the schema on the
unmarshaller to enable validation, but do not receive an exception when
unmarshalling.
Gernot
Wolfgang Laun-2 wrote:
>
> If you set the schema and unmarshal, you should see an error resulting
> from
> the validation
> done during unmarshalling. (There isn't a separate validation.) Here's the
> code
> to use:
>
> JAXBContext jc = JAXBContext.newInstance( PACKAGE );
> Unmarshaller m = jc.createUnmarshaller();
> //assign a schema to the unmarshaller
> SchemaFactory factory =
> SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
> try{
> Schema schema = factory.newSchema( new File( SCHEMA ));
> m.setSchema(schema);
> } catch(SAXException e) {
> e.printStackTrace();
> // return or whatever
> }
>
> Person obj = null;
> try {
> obj = (Person)m.unmarshal( new File( XMLIN ) );
> System.out.println( obj.getVorname() );
> System.out.println( obj.getNachname() );
> System.out.println( obj.getTyp() ); }
> catch( Exception e ){
> System.err.println( "-----------------unmarshal error" );
> e.printStackTrace();
> }
>
--
View this message in context: http://old.nabble.com/Unmarshalling-of-enums-with-whitespace-characters-tp30398383p30403910.html
Sent from the java.net - jaxb users mailing list archive at Nabble.com.