public class AbstractBuilderTest extends HelpMethods {
public void renderDiagram(Diagram d) throws IOException {
Method m = StackHelp.getAnnotatedMethod(Test.class);
XMLHelper helper = new XMLHelper();
String xml = helper.toXML(d);
DiagramTestingEngine.writeOutput(this.getClass(), m.getName(), "diagram.xml", xml);
System.out.println(xml);
try {
// validate the xml against the schema
InputSource is = new InputSource(new StringReader(xml));
SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
// load a WXS schema, represented by a Schema instance
Source schemaFile = new StreamSource(Diagram.class.getResourceAsStream("/adl_1.0.xsd"));
Schema schema = factory.newSchema(schemaFile);
Validator validator = schema.newValidator();
SAXSource source = new SAXSource(is);
validator.validate(source);
helper.fromXML(xml);
} catch (SAXParseException e) {
e.printStackTrace();
Assert.fail("Line: "+ e.getLineNumber()+" Failed validation: " + e.getMessage() + "\n" + xml);
} catch (SAXException e) {
e.printStackTrace();