Package nu.xom

Examples of nu.xom.Element.detach()


            current = null;
        }
        else {
            Nodes nodes = factory.finishMakingElement(element);
            ParentNode parent = element.getParent();
            element.detach();
            for (int i = 0; i < nodes.size(); i++) {
                Node node = nodes.get(i);
                if (node instanceof Attribute) {
                    ((Element) parent).addAttribute((Attribute) node);
                }
View Full Code Here


       
        Element child = new Element("test");
        empty.appendChild(child);
        assertEquals(1, empty.getChildCount());
        assertEquals(empty.getChild(0), child);
        child.detach();
       
        notEmpty.appendChild(child);
        assertTrue(!notEmpty.getChild(0).equals(child));
        assertTrue(notEmpty.getChild(1).equals(child));
       
View Full Code Here

          "http://staff.science.uva.nl/~francesc/xpathmark/benchmark_canon.xml"
        );
        Element root = doc.getRootElement();
        Elements inputs = root.getChildElements("document");
        Element input = inputs.get(0).getFirstChildElement("site");
        input.detach();
       
        Nodes doc1Queries = root.query("child::query[starts-with(@id, 'Q')]");
       
        for (int i = 0; i < doc1Queries.size(); i++) {
            Element query = (Element) doc1Queries.get(i);
View Full Code Here

   
        Element root = new Element("root");
        Document doc = new Document(root);

        try {
            root.detach();
            fail("detached root element");
        }  
        catch (WellformednessException success) {
            assertNotNull(success.getMessage());
        }
View Full Code Here

      Elements toplevel = oldRoot.getChildElements();
      for (int i = 0; i < toplevel.size(); i++) {
        Element element = toplevel.get(i);
        Element link = element.getFirstChildElement("link",
          "http://my.netscape.com/rdf/simple/0.9/");
        link.detach();
        newRoot.appendChild(link);
      }
      System.out.println(newRoot.toXML());
    }
    catch (ParsingException ex) {
View Full Code Here

        Element root = new Element("root");
        Document doc = new Document(root);
        doc.setBaseURI("http://www.example.com");
        Element child = new Element("child");
        root.appendChild(child);
        child.detach();
        assertEquals("http://www.example.com", child.getBaseURI());
       
    }
   
   
View Full Code Here

        Elements tests = doc.getRootElement().getChildElements("test");
        int size = tests.size();
        for (int i = 0; i < size; i++) {
            // System.out.println(i);
            Element test = tests.get(i);
            test.detach();
            Document testdoc = new Document(test);
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            Serializer serializer = new Serializer(out);
            serializer.setUnicodeNormalizationFormC(true);
            serializer.write(testdoc);
View Full Code Here

 
  public void deleteScrap(String sid) throws Exception {
    Nodes n = doc.query("//snippet[@id='" + sid +"']");
    if(n.size() == 1) {
      Element p = (Element)n.get(0).getParent();
      p.detach();
      writeScrapBook();
    }
  }

  public void setSnippetProperty(String sid, String property, String propertyName) throws Exception {
View Full Code Here

 
  private void refreshNavElements() {
    Nodes n = doc.query("//scrapbook");
    Element nav = (Element)n.get(0);
    XOMTools.insertAfter(nav, makeNavElement("show"));
    nav.detach();
  }
 
}
View Full Code Here

          continue;
        }
        e.setLocalName("P");
        e.insertChild(name + ":" + i + ": ", 0);
        XOMTools.normalise(e);
        e.detach();
        elems.add(e);
      }
    }
       
    Collections.shuffle(elems);
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.