Package nu.xom

Examples of nu.xom.ProcessingInstruction


    public void testToDocumentWithAttribute() {
    
        Nodes input = new Nodes();
        Element root = new Element("root");
        Comment comment = new Comment("data");
        ProcessingInstruction pi = new ProcessingInstruction("target", "data");
        input.append(comment);
        input.append(root);
        input.append(pi);
        input.append(new Attribute("name", "text"));
        try {
View Full Code Here


    
        Nodes input = new Nodes();
        Element root = new Element("root");
        DocType doctype = new DocType("root");
        Comment comment = new Comment("data");
        ProcessingInstruction pi = new ProcessingInstruction("target", "data");
        input.append(comment);
        input.append(doctype);
        input.append(root);
        input.append(pi);
        Document output = XSLTransform.toDocument(input);
View Full Code Here

    
        Nodes input = new Nodes();
        Element root = new Element("root");
        DocType doctype = new DocType("root");
        Comment comment = new Comment("data");
        ProcessingInstruction pi = new ProcessingInstruction("target", "data");
        input.append(comment);
        input.append(root);
        input.append(doctype);
        input.append(pi);
        try {
View Full Code Here

    public void testToDocumentWithPrologAndEpilog() {
    
        Nodes input = new Nodes();
        Element root = new Element("root");
        Comment comment = new Comment("data");
        ProcessingInstruction pi = new ProcessingInstruction("target", "data");
        input.append(comment);
        input.append(root);
        input.append(pi);
        Document output = XSLTransform.toDocument(input);
        assertEquals(root, output.getRootElement());
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

        assertEquals(3, doc.getChildCount());
        assertTrue(doc.getChild(0) instanceof Comment);
        assertTrue(doc.getChild(1) instanceof Element);
        assertTrue(doc.getChild(2) instanceof Comment);

        doc.insertChild(new ProcessingInstruction("target", "data"),1);
        assertTrue(doc.getChild(0) instanceof Comment);
        assertTrue(doc.getChild(1) instanceof ProcessingInstruction);
        assertTrue(doc.getChild(2) instanceof Element);
        assertTrue(doc.getChild(3) instanceof Comment);

        doc.insertChild(new ProcessingInstruction("epilog", "data"),3);
        assertTrue(doc.getChild(0) instanceof Comment);
        assertTrue(doc.getChild(1) instanceof ProcessingInstruction);
        assertTrue(doc.getChild(2) instanceof Element);
        assertTrue(doc.getChild(3) instanceof ProcessingInstruction);
        assertTrue(doc.getChild(4) instanceof Comment);
View Full Code Here

   
   
    public void testCopyConstructor() {
       
        doc.insertChild(new Comment("text"), 0);
        doc.insertChild(new ProcessingInstruction("text", "data"), 1);
        doc.insertChild(new DocType("text"), 2);
        root.appendChild("some data");
        doc.appendChild(new Comment("after"));
        doc.appendChild(new ProcessingInstruction("text", "after"));
       
        Document doc2 = new Document(doc);
        assertEquals(doc, doc2);
       
    }
View Full Code Here

   
   
    public void testCopy() {
       
        doc.insertChild(new Comment("text"), 0);
        doc.insertChild(new ProcessingInstruction("text", "data"), 1);
        doc.insertChild(new DocType("text"), 2);
        root.appendChild("some data");
        doc.appendChild(new Comment("after"));
        doc.appendChild(new ProcessingInstruction("text", "after"));
       
        Document doc2 = (Document) doc.copy();
        assertEquals(doc, doc2);
       
    }
View Full Code Here

    public void testCanonicalizePrologAndEpilog() throws IOException {
       
        Element pdu = new Element("doc");
       
        Document doc = new Document(pdu);
        doc.insertChild(new ProcessingInstruction("target", "value"), 0);
        doc.insertChild(new Comment("comment 2"), 1);
        doc.appendChild(new Comment("comment 3"));
        doc.appendChild(new ProcessingInstruction("target", "value"));
       
        String expected = "<?target value?>\n<!--comment 2-->\n<doc></doc>\n<!--comment 3-->\n<?target value?>";
       
        canonicalizer.write(doc)
       
View Full Code Here

    }

   
    public void testCanonicalizeProcessingInstruction() throws IOException {
    
        ProcessingInstruction pi = new ProcessingInstruction("target", "value \n value");
        try {
            Canonicalizer serializer = new Canonicalizer(out);
            serializer.write(pi);
        }
        finally {
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.