Package nu.xom

Examples of nu.xom.ProcessingInstruction


   
    // This can't be round-tripped
    public void testNoInitialWhiteSpace() {
       
        try {
            new ProcessingInstruction("target", "   initial spaces");
            fail("allowed processing instruction data with leading space");
        }
        catch (IllegalDataException success) {
            assertEquals("   initial spaces", success.getData());
            assertNotNull(success.getMessage());  
        }  
       
        try {
            new ProcessingInstruction("target", "\tinitial tab");
            fail("allowed processing instruction data with leading space");
        }
        catch (IllegalDataException success) {
            assertEquals("\tinitial tab", success.getData());
            assertNotNull(success.getMessage());  
        }  
       
        try {
            new ProcessingInstruction("target", "\ninitial linefeed");
            fail("allowed processing instruction data with leading space");
        }
        catch (IllegalDataException success) {
            assertEquals("\ninitial linefeed", success.getData());
            assertNotNull(success.getMessage());  
        }  
       
        try {
            new ProcessingInstruction("target", "\r initial carriage return");
            fail("allowed processing instruction data with leading space");
        }
        catch (IllegalDataException success) {
            assertEquals("\r initial carriage return", success.getData());
            assertNotNull(success.getMessage());  
View Full Code Here


   
   
    public void testNoXMLTargets() {

        try {
            new ProcessingInstruction("xml", "data");
            fail("allowed processing instruction with target xml");
        }
        catch (IllegalTargetException success) {
            assertEquals("xml", success.getData());
            assertNotNull(success.getMessage());  
        }

        try {
            new ProcessingInstruction("XML", "data");
            fail("allowed processing instruction with target XML");
        }
        catch (IllegalTargetException success) {
            assertEquals("XML", success.getData());
            assertNotNull(success.getMessage());  
        }

        try {
            new ProcessingInstruction("Xml", "data");
            fail("allowed processing instruction with target Xml");
        }
        catch (IllegalTargetException success) {
            assertEquals("Xml", success.getData());
            assertNotNull(success.getMessage());  
View Full Code Here

   
    public void testColonsNotAllowedInTargets() {

        try {
            new ProcessingInstruction("pre:target", "data");
            fail("allowed processing instruction with target that uses a prefixed name");
        }
        catch (IllegalTargetException success) {
            assertEquals("pre:target", success.getData());
            assertNotNull(success.getMessage());  
        }

        try {
            new ProcessingInstruction("pre:", "data");
            fail("allowed processing instruction with trailing colon in target");
        }
        catch (IllegalTargetException success) {
            assertEquals("pre:", success.getData());
            assertNotNull(success.getMessage());  
        }

        try {
            new ProcessingInstruction(":target", "data");
            fail("allowed processing instruction with initial colon in target");
        }
        catch (IllegalTargetException success) {
            assertEquals(":target", success.getData());
            assertNotNull(success.getMessage());  
View Full Code Here

            String data = node.getValue();
            contentHandler.characters(
              data.toCharArray(), 0, data.length());
        }
        else if (node instanceof ProcessingInstruction) {
            ProcessingInstruction instruction
              = (ProcessingInstruction) node;
           
            contentHandler.processingInstruction(
              instruction.getTarget(), instruction.getValue());
        }
        else if (node instanceof Comment && lexicalHandler != null) {
            String data = node.getValue();
            lexicalHandler.comment(
              data.toCharArray(), 0, data.length());           
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

     * @throws XMLException if the DOM <code>ProcessingInstruction</code>
     *     is not a well-formed XML processing instruction
     */
    public static ProcessingInstruction convert(
        org.w3c.dom.ProcessingInstruction pi) {
        return new ProcessingInstruction(
          pi.getTarget(), pi.getNodeValue());
    }
View Full Code Here

        DocType type = new DocType("test");
        Element root = new Element("test");         
        xomDocument = new Document(root);
        xomDocument.insertChild(type, 0);
        xomDocument.insertChild(new ProcessingInstruction(
         "xml-stylesheet", "href=\"file.css\" type=\"text/css\""), 1);
        xomDocument.insertChild(new Comment(" test "), 2);
        xomDocument.appendChild(new Comment("epilog"));
        root.addNamespaceDeclaration("xlink",
          "http://www.w3.org/TR/1999/xlink");
View Full Code Here

        org.w3c.dom.Document doc = builder.parse(new ByteArrayInputStream(data));
         
        org.w3c.dom.Element root = doc.getDocumentElement();
        org.w3c.dom.ProcessingInstruction node
          = (org.w3c.dom.ProcessingInstruction) (root.getChildNodes().item(0));
        ProcessingInstruction pi = DOMConverter.convert(node);
        assertEquals(node.getNodeValue(), pi.getValue());
        assertEquals(node.getTarget(), pi.getTarget());
                
    }
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.