use of com.opensimulationplatform.modeldescription.xml.model.ObjectFactory in project osp-validator by open-simulation-platform.
the class OspModelDescriptionTypeFactoryTest method canCreate.
@Test
public void canCreate() throws Exception {
ModelDescriptionFactory factory = new ModelDescriptionFactory();
ModelDescription modelDescription = factory.create(TestResources.CRANE_CONTROLLER_XML, TestResources.CRANE_CONTROLLER_FMU.toURI());
OspModelDescriptionTypeFactory typeFactory = new OspModelDescriptionTypeFactory();
OspModelDescriptionType ospModelDescriptionType = typeFactory.create(modelDescription);
ObjectFactory objectFactory = new ObjectFactory();
JAXBContext jc = JAXBContext.newInstance(ospModelDescriptionType.getClass());
JAXBSource source = new JAXBSource(jc, objectFactory.createOspModelDescription(ospModelDescriptionType));
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = schemaFactory.newSchema(OspModelDescriptionParser.class.getResource("/OspModelDescription-1.0.0.xsd"));
Validator validator = schema.newValidator();
validator.setErrorHandler(new ErrorHandler() {
@Override
public void warning(SAXParseException exception) {
fail(exception.toString());
}
@Override
public void error(SAXParseException exception) {
fail(exception.toString());
}
@Override
public void fatalError(SAXParseException exception) {
fail(exception.toString());
}
});
validator.validate(source);
}
Aggregations