Search in sources :

Example 16 with DocType

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;
}
Also used : Document(org.jdom2.Document) DocType(org.jdom2.DocType)

Example 17 with DocType

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;
}
Also used : Document(org.jdom2.Document)

Example 18 with DocType

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());
}
Also used : Element(org.jdom2.Element) Document(org.jdom2.Document) File(java.io.File) DocType(org.jdom2.DocType)

Example 19 with DocType

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());
}
Also used : Element(org.jdom2.Element) Document(org.jdom2.Document) DocType(org.jdom2.DocType)

Example 20 with DocType

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());
}
Also used : Element(org.jdom2.Element) Document(org.jdom2.Document) DocType(org.jdom2.DocType)

Aggregations

DocType (org.jdom2.DocType)24 Document (org.jdom2.Document)24 Element (org.jdom2.Element)19 File (java.io.File)4 SAXBuilder (org.jdom2.input.SAXBuilder)3 ParseException (java.text.ParseException)2 JLabel (javax.swing.JLabel)2 ProgDebugger (jmri.progdebugger.ProgDebugger)2 XMLFilter (plugin.overland.gui.XMLFilter)2 FileNotFoundException (java.io.FileNotFoundException)1 URL (java.net.URL)1 Vector (java.util.Vector)1 DataConversionException (org.jdom2.DataConversionException)1 Before (org.junit.Before)1 PairList (plugin.overland.util.PairList)1 RBCost (plugin.overland.util.RBCost)1