Package org.jdom2

Examples of org.jdom2.Element.addContent()


    Element root = new Element("root");
    root.addContent(new CDATA(" "));
    root.addContent(new Text(" "));
    root.addContent(new Text("    "));
    root.addContent(new Text(""));
    root.addContent(new Text("X"));
    root.addContent(new Text("  \n \n "));
    root.addContent(new Text("  \t "));
    root.addContent(new Text("  "));
    assertEquals(expect("<root><![CDATA[ ]]>     X  \n \n   \t   </root>"),
        outputString(fraw,     root));
View Full Code Here


    root.addContent(new CDATA(" "));
    root.addContent(new Text(" "));
    root.addContent(new Text("    "));
    root.addContent(new Text(""));
    root.addContent(new Text("X"));
    root.addContent(new Text("  \n \n "));
    root.addContent(new Text("  \t "));
    root.addContent(new Text("  "));
    assertEquals(expect("<root><![CDATA[ ]]>     X  \n \n   \t   </root>"),
        outputString(fraw,     root));
    assertEquals(expect("<root>X</root>"),
View Full Code Here

    root.addContent(new Text(" "));
    root.addContent(new Text("    "));
    root.addContent(new Text(""));
    root.addContent(new Text("X"));
    root.addContent(new Text("  \n \n "));
    root.addContent(new Text("  \t "));
    root.addContent(new Text("  "));
    assertEquals(expect("<root><![CDATA[ ]]>     X  \n \n   \t   </root>"),
        outputString(fraw,     root));
    assertEquals(expect("<root>X</root>"),
        outputString(fcompact, root));
View Full Code Here

    root.addContent(new Text("    "));
    root.addContent(new Text(""));
    root.addContent(new Text("X"));
    root.addContent(new Text("  \n \n "));
    root.addContent(new Text("  \t "));
    root.addContent(new Text("  "));
    assertEquals(expect("<root><![CDATA[ ]]>     X  \n \n   \t   </root>"),
        outputString(fraw,     root));
    assertEquals(expect("<root>X</root>"),
        outputString(fcompact, root));
    assertEquals(expect("<root>X</root>"),
View Full Code Here

  @Test
  public void testOutputElementCDATA() {
    String txt = "<root><![CDATA[xx]]></root>";
    Element root = new Element("root");
    root.addContent(new CDATA("xx"));
    checkOutput(root, txt, txt, txt, txt, txt);
  }

  @Test
  public void testOutputElementExpandEmpty() {
View Full Code Here

  @Test
  public void testOutputElementPreserveSpace() {
    String txt = "<root xml:space=\"preserve\">    <child xml:space=\"default\">abc</child> </root>";
    Element root = new Element("root");
    root.setAttribute("space", "preserve", Namespace.XML_NAMESPACE);
    root.addContent("    ");
    Element child = new Element("child");
    child.setAttribute("space", "default", Namespace.XML_NAMESPACE);
    child.addContent("abc");
    root.addContent(child);
    root.addContent(" ");
View Full Code Here

    Element root = new Element("root");
    root.setAttribute("space", "preserve", Namespace.XML_NAMESPACE);
    root.addContent("    ");
    Element child = new Element("child");
    child.setAttribute("space", "default", Namespace.XML_NAMESPACE);
    child.addContent("abc");
    root.addContent(child);
    root.addContent(" ");
    checkOutput(root, txt, txt, txt, txt, txt);
  }
 
View Full Code Here

   
    // this is essentially a test of the FormatStack code....

    Element tst = new Element("child");
    Comment cmt = new Comment("comment");
    tst.addContent(cmt);
    String spaced = "  <child>\n    <!--comment-->\n  </child>\n";
    String compact = "<child><!--comment--></child>";
    String preserved = "<child xml:space=\"preserve\"><!--comment--></child>";
    Element root = new Element("root");
    root.addContent(tst.clone());
View Full Code Here

    tst.addContent(cmt);
    String spaced = "  <child>\n    <!--comment-->\n  </child>\n";
    String compact = "<child><!--comment--></child>";
    String preserved = "<child xml:space=\"preserve\"><!--comment--></child>";
    Element root = new Element("root");
    root.addContent(tst.clone());
    root.addContent(tst.clone().setAttribute("space", "preserve", Namespace.XML_NAMESPACE));
    root.addContent(tst.clone());
    String rawcompact = "<root>" + compact + preserved + compact + "</root>";
    String pretty = "<root>\n" + spaced + "  " + preserved + "\n" + spaced + "</root>";
    checkOutput(root, rawcompact, rawcompact, pretty, pretty, pretty);
View Full Code Here

    String spaced = "  <child>\n    <!--comment-->\n  </child>\n";
    String compact = "<child><!--comment--></child>";
    String preserved = "<child xml:space=\"preserve\"><!--comment--></child>";
    Element root = new Element("root");
    root.addContent(tst.clone());
    root.addContent(tst.clone().setAttribute("space", "preserve", Namespace.XML_NAMESPACE));
    root.addContent(tst.clone());
    String rawcompact = "<root>" + compact + preserved + compact + "</root>";
    String pretty = "<root>\n" + spaced + "  " + preserved + "\n" + spaced + "</root>";
    checkOutput(root, rawcompact, rawcompact, pretty, pretty, pretty);
  }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.