Package nu.xom

Examples of nu.xom.Text


        assertTrue(Attribute.Type.ID != Attribute.Type.NMTOKENS);
        assertTrue(Attribute.Type.UNDECLARED != Attribute.Type.CDATA);
        assertTrue(Attribute.Type.NMTOKEN != Attribute.Type.CDATA);
       
        assertFalse(Attribute.Type.CDATA.equals(new Integer(1)));
        assertFalse(Attribute.Type.CDATA.equals(new Text("data")));
    }
View Full Code Here


    }

   
    public void testCanonicalizeText() throws IOException {
    
        Text c = new Text("  pre:foo \n  ");
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {
            Canonicalizer serializer = new Canonicalizer(out);
            serializer.write(c);
        }
View Full Code Here

   
    private Text leaf;
   
   
    protected void setUp() {
        leaf = new Text("parent");
    }
View Full Code Here

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

        try {
            doc.appendChild(new Text("test"));
            fail("appended string");
        }  
        catch (IllegalAddException success) {
            assertNotNull(success.getMessage());
        }
       
        try {
            doc.appendChild(new Text("    "));
            fail("appended white space");
        }  
        catch (IllegalAddException success) {
            assertNotNull(success.getMessage());
        }
       
        try {
            doc.appendChild(new Text("test"));
            fail("appended Text");
        }  
        catch (IllegalAddException success) {
            assertNotNull(success.getMessage());
        }
View Full Code Here

     *
     * @throws XMLException if the DOM text is not a well-formed
     *     XML text
     */
    public static Text convert(org.w3c.dom.Text text) {      
        return new Text(text.getNodeValue());      
    }
View Full Code Here

        byte[] data = "<element> here's the text </element>".getBytes();
        org.w3c.dom.Document doc = builder.parse(new ByteArrayInputStream(data));
         
        org.w3c.dom.Element root = doc.getDocumentElement();
        org.w3c.dom.Text node = (org.w3c.dom.Text) (root.getChildNodes().item(0));
        Text text = DOMConverter.convert(node);
        assertEquals(node.getNodeValue(), text.getValue());
                
    }
View Full Code Here

        byte[] data = "<element><![CDATA[ here's the text ]]></element>".getBytes();
        org.w3c.dom.Document doc = builder.parse(new ByteArrayInputStream(data));
         
        org.w3c.dom.Element root = doc.getDocumentElement();
        CDATASection node = (CDATASection) (root.getChildNodes().item(0));
        Text text = DOMConverter.convert(node);
        assertEquals(node.getNodeValue(), text.getValue());  
       
        // Now test indirect conversion
        Document xomDoc = DOMConverter.convert(doc);
        assertEquals(node.getNodeValue(), xomDoc.getValue());
                
View Full Code Here

        assertEquals("value", first.getAttribute("name").getValue());
       
        Comment second = (Comment) result.get(1);
        assertEquals("data", second.getValue());
       
        Text third = (Text) result.get(2);
        assertEquals("text", third.getValue());
       
    }
View Full Code Here

            System.out.println("    comment = new Comment(\""
             + javaEscape(comment.getValue()) + "\");");
            System.out.println("    " + parent + ".appendChild(comment);");   
        }
        else if (node instanceof Text) {
            Text text = (Text) node;
            System.out.println("    text = new Text(\""
             + javaEscape(text.getValue()) + "\");");
            System.out.println("    " + parent + ".appendChild(text);");   
        }
        else if (node instanceof DocType) {
            DocType doctype = (DocType) node;
            String publicID = doctype.getPublicID();
View Full Code Here

    // note use of recursion
    public static void encode(Node node) {
   
        if (node instanceof Text) {
          Text text = (Text) node;
          String data = text.getValue();
          text.setValue(rot13(data));
        }
       
        // recurse the children
        for (int i = 0; i < node.getChildCount(); i++) {
            encode(node.getChild(i));
View Full Code Here

TOP

Related Classes of nu.xom.Text

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.