Package org.jdom2

Examples of org.jdom2.Element


  @Test
  public void testOutputElementMixedMultiCDATA() {
    // this test has mixed content (text-type and not text type).
    // and, it has a multi-text-type at the end.
    Element root = new Element("root");
    root.addContent(new Comment("Boo"));
    root.addContent(new Text(" "));
    root.addContent(new CDATA("A"));
    FormatSetup fs = new FormatSetup() {
      @Override
      public void setup(Format fmt) {
        fmt.setExpandEmptyElements(true);
      }
View Full Code Here


  @Test
  public void testOutputElementMixedMultiEntityRef() {
    // this test has mixed content (text-type and not text type).
    // and, it has a multi-text-type at the end.
    Element root = new Element("root");
    root.addContent(new Comment("Boo"));
    root.addContent(new Text(" "));
    root.addContent(new EntityRef("aer"));
    FormatSetup fs = new FormatSetup() {
      @Override
      public void setup(Format fmt) {
        fmt.setExpandEmptyElements(true);
      }
View Full Code Here

  @Test
  public void testOutputElementMixedMultiText() {
    // this test has mixed content (text-type and not text type).
    // and, it has a multi-text-type at the end.
    Element root = new Element("root");
    root.addContent(new Comment("Boo"));
    root.addContent(new Text(" "));
    root.addContent(new Text("txt"));
    FormatSetup fs = new FormatSetup() {
      @Override
      public void setup(Format fmt) {
        fmt.setExpandEmptyElements(true);
      }
View Full Code Here

  @Test
  public void testOutputElementMixedMultiZeroText() {
    // this test has mixed content (text-type and not text type).
    // and, it has a multi-text-type at the end.
    Element root = new Element("root");
    root.addContent(new Comment("Boo"));
    root.addContent(new Text(""));
    root.addContent(new Text(" "));
    root.addContent(new Text(""));
    root.addContent(new Text("txt"));
    root.addContent(new Text(""));
    FormatSetup fs = new FormatSetup() {
      @Override
      public void setup(Format fmt) {
        fmt.setExpandEmptyElements(true);
      }
View Full Code Here

  @Test
  public void testOutputElementInterleavedEmptyText() {
    // this is to test issue #72
    // Compact format only prints first child.
    // and, it has a multi-text-type at the end.
    Element root = new Element("root");
    root.addContent(new Text(" "));
    root.addContent(new Comment("Boo"));
    root.addContent(new Text(" "));
    root.addContent(new Element("child"));
    root.addContent(new Text(" "));
    root.addContent(new ProcessingInstruction("pitarget"));
    root.addContent(new Text(" "));
    checkOutput(root, 
        "<root> <!--Boo--> <child /> <?pitarget?> </root>",
        "<root><!--Boo--><child /><?pitarget?></root>",
        "<root>\n  <!--Boo-->\n  <child />\n  <?pitarget?>\n</root>",
        "<root>\n  <!--Boo-->\n  <child />\n  <?pitarget?>\n</root>",
View Full Code Here

        "<root>\n  <!--Boo-->\n  <child />\n  <?pitarget?>\n</root>");
  }

  @Test
  public void testOutputElementMultiEntityLeftRight() {
    Element root = new Element("root");
    root.addContent(new EntityRef("erl"));
    root.addContent(new Text(" "));
    root.addContent(new Text("    "));
    root.addContent(new EntityRef("err"));
    checkOutput(root,
        "<root>&erl;     &err;</root>",
        "<root>&erl; &err;</root>",
        "<root>&erl;     &err;</root>",
        "<root>&erl;     &err;</root>",
View Full Code Here

        "<root>&erl;     &err;</root>");
  }

  @Test
  public void testOutputElementMultiTrimLeftRight() {
    Element root = new Element("root");
    root.addContent(new Text(" tl "));
    root.addContent(new Text(" mid "));
    root.addContent(new Text(" tr "));
    checkOutput(root,
        "<root> tl  mid  tr </root>",
        "<root>tl mid tr</root>",
        "<root>tl  mid  tr</root>",
        "<root>tl  mid  tr</root>",
View Full Code Here

        "<root> tl  mid  tr </root>");
  }

  @Test
  public void testOutputElementMultiCDATALeftRight() {
    Element root = new Element("root");
    root.addContent(new CDATA(" tl "));
    root.addContent(new Text(" mid "));
    root.addContent(new CDATA(" tr "));
    checkOutput(root,
        "<root><![CDATA[ tl ]]> mid <![CDATA[ tr ]]></root>",
        "<root><![CDATA[tl]]> mid <![CDATA[tr]]></root>",
        "<root><![CDATA[tl ]]> mid <![CDATA[ tr]]></root>",
        "<root><![CDATA[tl ]]> mid <![CDATA[ tr]]></root>",
View Full Code Here

 
 
  @Test
  public void testOutputElementNamespaces() {
    String txt = "<ns:root xmlns:ns=\"myns\" xmlns:ans=\"attributens\" xmlns:two=\"two\" ans:att=\"val\"/>";
    Element emt = new Element("root", Namespace.getNamespace("ns", "myns"));
    Namespace ans = Namespace.getNamespace("ans", "attributens");
    emt.setAttribute(new Attribute("att", "val", ans));
    emt.addNamespaceDeclaration(Namespace.getNamespace("two", "two"));
    checkOutput(emt,
        txt, txt,txt, txt, txt);
  }
View Full Code Here

  }

  @Test
  public void testOutputDocumentSimple() {
    Document doc = new Document();
    doc.addContent(new Element("root"));
    String xmldec = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
    String rtdec = "<root />";
    checkOutput(doc,
        xmldec + "\n" + rtdec + "\n",
        xmldec + "\n" + rtdec + "\n",
View Full Code Here

TOP

Related Classes of org.jdom2.Element

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.