Package org.jdom2.input

Examples of org.jdom2.input.SAXBuilder


    }

    // Construct a raw surrogate pair character and confirm it outputs hex escaped, when UTF-8 too
    @Test
    public void test_RawSurrogatePairUTF8() throws JDOMException, IOException {
      SAXBuilder builder = new SAXBuilder();
      builder.setExpandEntities(true);
      Document doc = builder.build(new StringReader("<?xml version=\"1.0\"?><root>\uD800\uDC00</root>"));
      Format format = Format.getCompactFormat().setEncoding("UTF-8");
      XMLOutputter outputter = new XMLOutputter(format);
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      outputter.output(doc, baos);
      String xml = baos.toString();
View Full Code Here


    }

    // Construct illegal XML and check if the parser notices
    @Test
    public void test_ErrorSurrogatePair() throws JDOMException, IOException {
      SAXBuilder builder = new SAXBuilder();
      builder.setExpandEntities(true);
      Document doc = builder.build(new StringReader("<?xml version=\"1.0\"?><root></root>"));
      try {
        doc.getRootElement().setText("\uD800\uDBFF");
        fail("Illegal surrogate pair should have thrown an exception");
      }
      catch (IllegalDataException e) {
View Full Code Here

    }

    // Manually construct illegal XML and make sure the outputter notices
    @Test
    public void test_ErrorSurrogatePairOutput() throws JDOMException, IOException {
      SAXBuilder builder = new SAXBuilder();
      builder.setExpandEntities(true);
      Document doc = builder.build(new StringReader("<?xml version=\"1.0\"?><root></root>"));
      Text t = new UncheckedJDOMFactory().text("\uD800\uDBFF");
      doc.getRootElement().setContent(t);
      Format format = Format.getCompactFormat().setEncoding("ISO-8859-1");
      XMLOutputter outputter = new XMLOutputter(format);
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
View Full Code Here

    }

    /* Load the map. This is called in the main class upon game start */
    public void load(File loadFile) {
        try {
            SAXBuilder builder = new SAXBuilder();
            Document document = builder.build(loadFile);
            Element root = document.getRootElement();

            for (Element tile : root.getChildren()) {
                int x = (int) Double.parseDouble(tile.getAttributeValue("x"));
                int y = (int) Double.parseDouble(tile.getAttributeValue("y"));
View Full Code Here

    this.annotatorNames = annotatorNames;
  }

  public Collection<KnowtatorAnnotation> parse(URI knowtatorXML) throws JDOMException, IOException {

    Element annotationsElem = new SAXBuilder().build(knowtatorXML.toURL()).getRootElement();

    // parse <annotation> elements
    Set<String> ignoredAnnotators = new HashSet<String>();
    Map<String, KnowtatorAnnotation> annotations = new HashMap<String, KnowtatorAnnotation>();
    for (Element annotationElem : annotationsElem.getChildren("annotation")) {
View Full Code Here

    }

    private LinkedList<String> doFilter(String in, Set<String> xpaths) throws IOException {
        LinkedList<String> result = new LinkedList<String>();
        try {
            Document doc = new SAXBuilder(XMLReaders.NONVALIDATING).build(new StringReader(in));
            XMLOutputter out = new XMLOutputter();

            for (String xp : xpaths) {
                XPathExpression<Content> xpath = XPathFactory.instance().compile(xp, Filters.content());
                for (Content node : xpath.evaluate(doc)) {
View Full Code Here

  private static final String VALUE = "value";
  private static final String PLAYER = "player";
 
  public static Tree<String> buildDemoPokerTree() throws JDOMException, IOException {
    NodeMetaInfo<String> root = null;
    SAXBuilder parser = new SAXBuilder();
    Document doc = parser.build("/home/m1/programming/java/jPokerTreeView/data/large_tree.xml");
    Element data = doc.getRootElement().getChildren().get(0);
    root = convert(data);
    root.setChildren(convert(data.getChildren()));
   
    Tree<String> tree = new Tree<String>(root);
View Full Code Here

    return tree;
  }
 
  public static Tree<String> buildPokerTree(String filePath) throws JDOMException, IOException{
    NodeMetaInfo<String> root = null;
    SAXBuilder parser = new SAXBuilder();
    Document doc = parser.build(filePath);
    Element data = doc.getRootElement().getChildren().get(0);
    root = convert(data);
    root.setChildren(convert(data.getChildren()));
   
    Tree<String> tree = new Tree<String>(root);
View Full Code Here

    return tree;
  }
 
  public static Tree<String> buildDemoPokerSmallTree() throws JDOMException, IOException {
    NodeMetaInfo<String> root = null;
    SAXBuilder parser = new SAXBuilder();
    Document doc = parser.build("/home/m1/programming/java/jPokerTreeView/data/simple_tree.xml");
    Element data = doc.getRootElement().getChildren().get(0);
    root = convert(data);
    root.setChildren(convert(data.getChildren()));
    Tree<String> tree = new Tree<String>(root);
    return tree;
View Full Code Here

            throw new IllegalArgumentException("resultsDir must be a directory");

        // Extract from options XML file
        report(0.0, "Loading options file");

        SAXBuilder builder = new SAXBuilder();
        Element rootElement;
        try {
            rootElement = builder.build(optionsFile).getRootElement();
        } catch (JDOMException e) {
            throw new IOException(e);
        }

        OptionsExtractor extractor = new OptionsExtractor();
View Full Code Here

TOP

Related Classes of org.jdom2.input.SAXBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.