Package XMLDOM2

Examples of XMLDOM2.Document


    Namespace ans = Namespace.getNamespace("ans", "attributens");
    emt.addNamespaceDeclaration(ans);
    emt.addNamespaceDeclaration(Namespace.getNamespace("two", "two"));
    emt.setAttribute(new Attribute("att", "val", ans));
    emt.addContent(new Element("child", Namespace.getNamespace("", "childuri")));
    Document doc = new Document(emt);
    roundTripDocument(doc);
    }
View Full Code Here


        throw new SAXException("SHould not be reaching this, ever");
      }
    };
    SAXOutputter saxout = new SAXOutputter(handler, handler, handler, handler, handler);
   
    Document doc = null;
    Element emt = null;
    List<Content> list = null;
    List<Content> empty = new ArrayList<Content>();
    saxout.output(doc);
    saxout.output(emt);
View Full Code Here

            break;
        }
      } else if (ap instanceof Attribute) {
        compare ((Attribute)ap, (Attribute)bp);
      } else if (ap instanceof Document) {
        Document a = (Document)ap;
        Document b = (Document)bp;
        assertEquals(a.getBaseURI(), b.getBaseURI());
        final int sz = a.getContentSize();
        assertTrue(sz == b.getContentSize());
        for (int i = 0; i < sz; i++) {
          compare(a.getContent(i), b.getContent(i));
        }
      }
    }
View Full Code Here

            File f = FileManager.getAppFile(path);
            props.clear();
            if (!f.exists())
                return;
            SAXBuilder b = new SAXBuilder();
            Document d = b.build(f);

            Element root = d.getRootElement();

            // Get config
            props = loadConfig(root);
        } catch (Exception e) {
            throw new RuntimeException("Error loading config", e);
View Full Code Here

    }

    private void save() {
        File f = FileManager.getAppFile(path);
        Element root = new Element("config");
        Document d = new Document(root);
        storeConfig(root, props);
        XMLOutputter xo = new XMLOutputter(Format.getPrettyFormat());
        try {
            OutputStream os = new FileOutputStream(f);
            xo.output(d, os);
View Full Code Here

  @Test
    public void test_HighSurrogatePair() throws JDOMException, IOException {
      SAXBuilder builder = new SAXBuilder();
      builder.setExpandEntities(true);
      Document doc = builder.build(new StringReader("<?xml version=\"1.0\"?><root>&#x10000; &#x10000;</root>"));
      Format format = Format.getCompactFormat().setEncoding("ISO-8859-1");
      XMLOutputter outputter = new XMLOutputter(format);
      StringWriter sw = new StringWriter();
      outputter.output(doc, sw);
      String xml = sw.toString();
View Full Code Here

    @Test
    public void test_HighSurrogatePairDecimal() throws JDOMException, IOException {
      SAXBuilder builder = new SAXBuilder();
      builder.setExpandEntities(true);
      Document doc = builder.build(new StringReader("<?xml version=\"1.0\"?><root>&#x10000; &#65536;</root>"));
      Format format = Format.getCompactFormat().setEncoding("ISO-8859-1");
      XMLOutputter outputter = new XMLOutputter(format);
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      outputter.output(doc, baos);
      String xml = baos.toString();
View Full Code Here

    @Test
    public void test_HighSurrogateAttPair() throws JDOMException, IOException {
      SAXBuilder builder = new SAXBuilder();
      builder.setExpandEntities(true);
      Document doc = builder.build(new StringReader("<?xml version=\"1.0\"?><root att=\"&#x10000; &#x10000;\" />"));
      Format format = Format.getCompactFormat().setEncoding("ISO-8859-1");
      XMLOutputter outputter = new XMLOutputter(format);
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      outputter.output(doc, baos);
      String xml = baos.toString();
View Full Code Here

    @Test
    public void test_HighSurrogateAttPairDecimal() throws JDOMException, IOException {
      SAXBuilder builder = new SAXBuilder();
      builder.setExpandEntities(true);
      Document doc = builder.build(new StringReader("<?xml version=\"1.0\"?><root att=\"&#x10000; &#65536;\" />"));
      Format format = Format.getCompactFormat().setEncoding("ISO-8859-1");
      XMLOutputter outputter = new XMLOutputter(format);
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      outputter.output(doc, baos);
      String xml = baos.toString();
View Full Code Here

    // Construct a raw surrogate pair character and confirm it outputs hex escaped
    @Test
    public void test_RawSurrogatePair() 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("ISO-8859-1");
      XMLOutputter outputter = new XMLOutputter(format);
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      outputter.output(doc, baos);
      String xml = baos.toString();
View Full Code Here

TOP

Related Classes of XMLDOM2.Document

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.