Java XML JAXB tips


Schema Validation and Formatted Output

Amplify’d from www.java-tips.org

   Marshaller m = jc.createMarshaller();
        m.setPropertyMarshaller.JAXB_FORMATTED_OUTPUT, 
              Boolean.TRUE );
        OutputStream os = new FileOutputStream
              "incorrectpo.xml" );
        m.marshal(po, os);


   SchemaFactory sf = SchemaFactory.newInstance(
      javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI);


   Schema schema = sf.newSchema(new File("po.xsd"));

Read more at www.java-tips.org

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s