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