use of javax.xml.validation.SchemaFactory in project ORCID-Source by ORCID.
the class ValidateV2SamplesTest method marshall.
private void marshall(Object object, String path) throws JAXBException, SAXException, URISyntaxException {
JAXBContext context = JAXBContext.newInstance(object.getClass());
Marshaller marshaller = context.createMarshaller();
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = sf.newSchema(new File(getClass().getResource(path).toURI()));
marshaller.setSchema(schema);
marshaller.marshal(object, System.out);
}
use of javax.xml.validation.SchemaFactory in project ORCID-Source by ORCID.
the class ValidateV2SamplesTest method unmarshall.
private Object unmarshall(Reader reader, Class<?> type, String schemaPath) throws SAXException, URISyntaxException {
try {
JAXBContext context = JAXBContext.newInstance(type);
Unmarshaller unmarshaller = context.createUnmarshaller();
if (schemaPath != null) {
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = sf.newSchema(new File(getClass().getResource(schemaPath).toURI()));
unmarshaller.setSchema(schema);
}
return unmarshaller.unmarshal(reader);
} catch (JAXBException e) {
throw new RuntimeException("Unable to unmarshall orcid message" + e);
}
}
use of javax.xml.validation.SchemaFactory in project ORCID-Source by ORCID.
the class ValidateV2RC1SamplesTest method getValidator.
public Validator getValidator(String name) throws SAXException {
SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
Schema schema = factory.newSchema(getClass().getResource("/record_2.0_rc1/" + name + "-2.0_rc1.xsd"));
Validator validator = schema.newValidator();
return validator;
}
use of javax.xml.validation.SchemaFactory in project ORCID-Source by ORCID.
the class ValidateV2IdentifiersTest method getValidator.
public Validator getValidator(String name) throws SAXException {
SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
Schema schema = factory.newSchema(getClass().getResource("/record_2.0/" + name + "-2.0.xsd"));
Validator validator = schema.newValidator();
return validator;
}
use of javax.xml.validation.SchemaFactory in project ORCID-Source by ORCID.
the class ValidateOrcidMessage method createValidator.
private static Validator createValidator() {
try {
SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
Schema schema = factory.newSchema(ValidateOrcidMessage.class.getResource("/orcid-message-" + OrcidMessage.DEFAULT_VERSION + ".xsd"));
return schema.newValidator();
} catch (SAXException e) {
throw new RuntimeException("Error reading ORCID client group schema", e);
}
}
Aggregations