Package nu.xom

Examples of nu.xom.ProcessingInstruction


            }
             
            
        }
        else if (node instanceof ProcessingInstruction) {
            ProcessingInstruction pi = (ProcessingInstruction) node;
            System.out.println("    pi = new ProcessingInstruction(\"" +
              pi.getTarget() + "\", \"" + javaEscape(pi.getValue()) + "\");");
            System.out.println("    " + parent + ".appendChild(pi);");   
        }
        else if (node instanceof Comment) {
            Comment comment = (Comment) node;
            System.out.println("    comment = new Comment(\""
View Full Code Here


            boolean index = true;
            for (int i = 0; i < doc.getChildCount(); i++) {
                Node child = doc.getChild(i);
                if (child instanceof Element) break
                if (child instanceof ProcessingInstruction){
                    ProcessingInstruction instruction
                      = (ProcessingInstruction) child;
                    if (instruction.getTarget().equals("robots")) {
                        Element data
                          = PseudoAttributes.getAttributes(instruction);
                        Attribute indexAtt = data.getAttribute("index");
                        if (indexAtt != null) {
                            String value = indexAtt.getValue().trim();
View Full Code Here

        return new Nodes(new Attribute(name, namespace, rot13(value), type))
    }

    public Nodes makeProcessingInstruction(
      String target, String data) {
        return new Nodes(new ProcessingInstruction(rot13(target), rot13(data)));
    }
View Full Code Here

        Element parent = new Element("Test");
        Element child = new Element("child");
        parent.appendChild(child);
        grandparent.appendChild(parent);
       
        ProcessingInstruction p1 = new ProcessingInstruction("c1", "1");
        ProcessingInstruction p2 = new ProcessingInstruction("c1", "2");
        ProcessingInstruction p3 = new ProcessingInstruction("c1", "3");
        ProcessingInstruction p4 = new ProcessingInstruction("c1", "4");
       
        doc.insertChild(p1, 0);
        grandparent.insertChild(p2, 0);
        parent.insertChild(p3, 0);
        child.insertChild(p4, 0);
View Full Code Here

       
        doc.insertChild(c1, 0);
        grandparent.insertChild(c2, 0);
        parent.insertChild(c3, 0);
        child.insertChild(c4, 0);
        ProcessingInstruction pi = new ProcessingInstruction("appendix", "text");
        doc.appendChild(pi);
        ProcessingInstruction pi2 = new ProcessingInstruction("test", "text");
        parent.appendChild(pi2);
       
        Nodes result = doc.query("descendant::processing-instruction('test')");
        assertEquals(1, result.size());
        assertEquals(pi2, result.get(0));
View Full Code Here

        e.appendChild(new Text(" moredata"));
        assertEquals(e.getValue(), "data moredata");
        e.appendChild(new Comment(" moredata"));
        assertEquals(e.getValue(), "data moredata");
        e.appendChild(
          new ProcessingInstruction("target", "moredata"));
        assertEquals(e.getValue(), "data moredata");
       
        Element e2 = new Element("child");
        e.appendChild(e2);
        assertEquals("data moredata", e.getValue());
View Full Code Here

        Attribute a1 = new Attribute("test", "test");      
        parent.addAttribute(a1);
       
        Node child1 = new Text("http://www.mauve.com");
        parent.appendChild(child1);
        Node child2 = new ProcessingInstruction(
          "child", "http://www.mauve.com");
        parent.appendChild(child2);
        Node child3 = new Comment("http://www.mauve.com");
        parent.appendChild(child3);
 
        assertEquals(parent, child3.getParent());
        assertEquals(parent, child1.getParent());
        assertEquals(parent, child2.getParent());
      
        Nodes result = parent.removeChildren();
        assertEquals(0, parent.getChildCount());
        assertNull(child1.getParent());
        assertNull(child2.getParent());
        assertNull(child3.getParent());
        assertEquals(parent, a1.getParent());
       
        assertEquals(3, result.size());
        assertEquals(child1, result.get(0));
View Full Code Here

   
    public void testProcessingInstruction()
      throws IOException, ParsingException {
       
        String data = "<>&amp;&entity; test   \n  hello again";
        root.appendChild(new ProcessingInstruction("target", data));
        serializeParseAndCompare(doc);
       
    }
View Full Code Here

        doc.insertChild(new Comment("Hello"), 0);
        serializeParseAndCompare(doc);   
        doc.insertChild(new DocType("root"), 0);
        serializeParseAndCompare(doc);   
        doc.insertChild(new ProcessingInstruction("test", "some data"),
          0);
        serializeParseAndCompare(doc);   
        doc.insertChild(new Comment("Goodbye"), 0);
        serializeParseAndCompare(doc);   
        doc.insertChild(
          new ProcessingInstruction("goodbye", "some data"), 0);
        serializeParseAndCompare(doc);   
        doc.appendChild(new Comment("Hello"));
        serializeParseAndCompare(doc);   
        doc.appendChild(
          new ProcessingInstruction("test", "some data"));
        serializeParseAndCompare(doc);   
       
    }
View Full Code Here

   
    public void testIndentAndBreakBeforeProcessingInstruction()
      throws IOException {
       
        Element items = new Element("itemSet");
        items.appendChild(new ProcessingInstruction("target", "value"));
        Document doc = new Document(items);
        Serializer serializer = new Serializer(out);
        serializer.setIndent(4);
        serializer.write(doc);
        serializer.flush();
View Full Code Here

TOP

Related Classes of nu.xom.ProcessingInstruction

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.