Package nu.xom

Examples of nu.xom.Element.insertChild()



    public void testInsertString() {
       
        Element element = new Element("test");
        element.insertChild("test", 0);

        String s = null;
        try {
            element.insertChild(s, 0);
            fail("Inserted string as null");
View Full Code Here


        Element element = new Element("test");
        element.insertChild("test", 0);

        String s = null;
        try {
            element.insertChild(s, 0);
            fail("Inserted string as null");
        }
        catch (NullPointerException success) {
            // success
        }
View Full Code Here

        }
        catch (NullPointerException success) {
            // success
        }
       
        element.insertChild("" , 0);
        // empty node should be created
        assertEquals(2, element.getChildCount());  

    }
   
View Full Code Here

    throws InvalidDDMSException {
    if (affiliations == null)
      affiliations = Collections.emptyList();
    Element element = getXOMElement();
    if (getDDMSVersion().isAtLeast("4.0.1")) {
      element.insertChild(Util.buildDDMSElement(SURNAME_NAME, surname), insertIndex);
      if (!Util.isEmpty(userID))
        element.appendChild(Util.buildDDMSElement(USERID_NAME, userID));
      for (String affiliation : affiliations)
        element.appendChild(Util.buildDDMSElement(AFFILIATION_NAME, affiliation));
    }
View Full Code Here

    }
    else {
      // Inserting in reverse order allow the same index to be reused. Later inserts will "push" the early ones
      // forward.
      for (String affiliation : affiliations)
        element.insertChild(Util.buildDDMSElement(AFFILIATION_NAME, affiliation), insertIndex);
      if (!Util.isEmpty(userID))
        element.insertChild(Util.buildDDMSElement(USERID_NAME, userID), insertIndex);
      element.insertChild(Util.buildDDMSElement(SURNAME_NAME, surname), insertIndex);
    }
    _affiliations = affiliations;
View Full Code Here

      // Inserting in reverse order allow the same index to be reused. Later inserts will "push" the early ones
      // forward.
      for (String affiliation : affiliations)
        element.insertChild(Util.buildDDMSElement(AFFILIATION_NAME, affiliation), insertIndex);
      if (!Util.isEmpty(userID))
        element.insertChild(Util.buildDDMSElement(USERID_NAME, userID), insertIndex);
      element.insertChild(Util.buildDDMSElement(SURNAME_NAME, surname), insertIndex);
    }
    _affiliations = affiliations;
  }
View Full Code Here

      // forward.
      for (String affiliation : affiliations)
        element.insertChild(Util.buildDDMSElement(AFFILIATION_NAME, affiliation), insertIndex);
      if (!Util.isEmpty(userID))
        element.insertChild(Util.buildDDMSElement(USERID_NAME, userID), insertIndex);
      element.insertChild(Util.buildDDMSElement(SURNAME_NAME, surname), insertIndex);
    }
    _affiliations = affiliations;
  }

  /**
 
View Full Code Here

        if(e.getValue().trim().length() == 0) {
          System.out.println("Skipping");
          continue;
        }
        e.setLocalName("P");
        e.insertChild(name + ":" + i + ": ", 0);
        XOMTools.normalise(e);
        e.detach();
        elems.add(e);
      }
    }
View Full Code Here

            parent.appendChild(textNode);
          } else if(parent.getChild(index+1) instanceof Text) {
            Text nextText = (Text)parent.getChild(index+1);
            nextText.setValue(m.group(2) + nextText.getValue());
          } else {
            parent.insertChild(new Text(m.group(2)), index+1);
            //neElem.removeChildren();
            //neElem.appendChild(m.group(1));
          }
        }
        System.out.println(neNodes.get(j).toXML());       
View Full Code Here

        Comment c4 = new Comment("c4");
       
        doc.insertChild(c1, 0);
        grandparent.insertChild(c2, 0);
        parent.insertChild(c3, 0);
        child.insertChild(c4, 0);
       
        Nodes result = doc.query("descendant::comment()");
        assertEquals(4, result.size());
        assertEquals(c1, result.get(0));  
        assertEquals(c2, result.get(1));
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.