public DcsXstreamStaxModelBuilder() { x = XStreamFactory.newInstance(); }
/** * Constructs a builder that will perform validation when de-serializing XML streams if <code>isValidating</code> * is <code>true</code>. The schema used for validation is the DCP 1.0 schema. * <p/> * <strong><em>N.B.</em></strong>: currently this class will only validate incoming DCP SIPs (it will <em>not</em> * validate entities). At a later time this implementation may be updated to validate entities as well. * * @param isValidating flag indicating whether or not validation should be enabled * @throws IllegalStateException if the DCP schema cannot be resolved or parsed */ public DcsXstreamStaxModelBuilder(boolean isValidating) { this.validating = isValidating; x = XStreamFactory.newInstance(); try { InputStream schemaIn = this.getClass().getResourceAsStream(DCP_SCHEMA); if (schemaIn == null) { throw new IllegalStateException("Unable to initialize " + this.getClass().getName() + ": class path " + "resource " + DCP_SCHEMA + " could not be found."); } schema = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI).newSchema(new StreamSource(schemaIn)); } catch (SAXException e) { throw new IllegalStateException("Unable to initialize " + this.getClass().getName() + ": error retrieving " + " or parsing class path resource " + DCP_SCHEMA + ": " + e.getMessage(), e); } }