use of org.jdom2.DocType in project JMRI by JMRI.
the class XmlFile method newDocument.
/**
* Create the Document object to store a particular root Element.
*
* @param root Root element of the final document
* @param dtd name of an external DTD
* @return new Document, with root installed
*/
public static Document newDocument(Element root, String dtd) {
Document doc = new Document(root);
doc.setDocType(new DocType(root.getName(), dtd));
addDefaultInfo(root);
return doc;
}
use of org.jdom2.DocType in project JMRI by JMRI.
the class XmlFile method newDocument.
/**
* Create the Document object to store a particular root Element, without a
* DocType DTD (e.g. for using a schema)
*
* @param root Root element of the final document
* @return new Document, with root installed
*/
public static Document newDocument(Element root) {
Document doc = new Document(root);
addDefaultInfo(root);
return doc;
}
use of org.jdom2.DocType in project JMRI by JMRI.
the class XmlFileTest method testWriteFile.
public void testWriteFile() throws java.io.IOException {
XmlFile x = new XmlFile() {
};
// create a minimal XML file
Element root = new Element("decoder-config");
root.setAttribute("noNamespaceSchemaLocation", "http://jmri.org/xml/schema/decoder.xsd", org.jdom2.Namespace.getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance"));
Document doc = new Document(root);
doc.setDocType(new DocType("decoder-config", "decoder-config.dtd"));
// write it out
FileUtil.createDirectory("temp" + File.separator + "prefs");
File f = new File("temp" + File.separator + "prefs" + File.separator + "test.xml");
x.writeXML(f, doc);
Assert.assertTrue("File expected to be present", f.exists());
}
use of org.jdom2.DocType in project JMRI by JMRI.
the class QualifierAdderTest method testSingleQualifierOk.
public void testSingleQualifierOk() {
Element e = new Element("variable").addContent(new Element("qualifier").addContent(new Element("variableref").addContent("one")).addContent(new Element("relation").addContent("eq")).addContent(new Element("value").addContent("3")));
// create a JDOM tree with just some elements
Element root = new Element("decoder-config");
Document doc = new Document(root);
doc.setDocType(new DocType("decoder-config", "decoder-config.dtd"));
root.addContent(// the sites information here lists all relevant
new Element("decoder").addContent(new Element("variables").addContent(e)));
// test equal value qualifier
processModifierElements(e, v2);
v1.setIntValue(3);
Assert.assertTrue("should be true for 3", v2.getAvailable());
v1.setIntValue(5);
Assert.assertFalse("should be false for 5", v2.getAvailable());
}
use of org.jdom2.DocType in project JMRI by JMRI.
the class QualifierAdderTest method testExistsOk0.
public void testExistsOk0() {
Element e = new Element("variable").addContent(new Element("qualifier").addContent(new Element("variableref").addContent("none")).addContent(new Element("relation").addContent("exists")).addContent(new Element("value").addContent("0")));
// create a JDOM tree with just some elements
Element root = new Element("decoder-config");
Document doc = new Document(root);
doc.setDocType(new DocType("decoder-config", "decoder-config.dtd"));
root.addContent(// the sites information here lists all relevant
new Element("decoder").addContent(new Element("variables").addContent(e)));
// test Exists
processModifierElements(e, v2);
Assert.assertTrue(v2.getAvailable());
}
Aggregations