Search in sources :

Example 56 with SAXBuilder

use of org.jdom.input.SAXBuilder in project beast-mcmc by beast-dev.

the class AbstractPolygon2D method readKMLFile.

public static List<AbstractPolygon2D> readKMLFile(String fileName) {
    List<AbstractPolygon2D> polygons = new ArrayList<AbstractPolygon2D>();
    try {
        SAXBuilder builder = new SAXBuilder();
        builder.setValidation(false);
        builder.setIgnoringElementContentWhitespace(true);
        Document doc = builder.build(new File(fileName));
        Element root = doc.getRootElement();
        if (!root.getName().equalsIgnoreCase("KML"))
            throw new RuntimeException("Not a KML file");
        readKMLElement(root, polygons);
    } catch (IOException e) {
        e.printStackTrace();
    } catch (JDOMException e) {
        e.printStackTrace();
    }
    return polygons;
}
Also used : SAXBuilder(org.jdom.input.SAXBuilder) Element(org.jdom.Element) IOException(java.io.IOException) Document(org.jdom.Document) JDOMException(org.jdom.JDOMException) File(java.io.File)

Example 57 with SAXBuilder

use of org.jdom.input.SAXBuilder in project beast-mcmc by beast-dev.

the class XMLModelFile method main.

public static void main(String[] args) {
    //main method for debugging
    SAXBuilder parser = new SAXBuilder();
    Document doc;
    try {
        doc = parser.build(new File("testSimplePathSampling.xml"));
        XMLModelFile z = new XMLModelFile(doc.getRootElement());
        z.printIdentified();
        HashMap<String, String> hm = new HashMap<String, String>();
        hm.put("samplingMean", "samplingMean");
        z.prefixIdentifiedNames("model1.", hm, false);
        z.printIdentified();
    } catch (IOException e) {
    //
    } catch (JDOMException e) {
    //
    }
}
Also used : SAXBuilder(org.jdom.input.SAXBuilder) IOException(java.io.IOException) Document(org.jdom.Document) JDOMException(org.jdom.JDOMException) File(java.io.File)

Aggregations

SAXBuilder (org.jdom.input.SAXBuilder)57 Document (org.jdom.Document)40 Element (org.jdom.Element)40 IOException (java.io.IOException)22 JDOMException (org.jdom.JDOMException)19 InputStream (java.io.InputStream)17 StringReader (java.io.StringReader)11 HttpMethod (org.apache.commons.httpclient.HttpMethod)10 XPath (org.jdom.xpath.XPath)9 List (java.util.List)6 File (java.io.File)5 ArrayList (java.util.ArrayList)5 XMLOutputter (org.jdom.output.XMLOutputter)5 Nullable (org.jetbrains.annotations.Nullable)5 PostMethod (org.apache.commons.httpclient.methods.PostMethod)4 Xpp3Dom (org.codehaus.plexus.util.xml.Xpp3Dom)4 Format (org.jdom.output.Format)4 NotNull (org.jetbrains.annotations.NotNull)4 Logger (com.intellij.openapi.diagnostic.Logger)3 Comparing (com.intellij.openapi.util.Comparing)3