Examples of JDOMXPath


Examples of org.jaxen.jdom.JDOMXPath

        {
            SAXBuilder builder = new SAXBuilder();
           
            Document doc = builder.build( args[0] );
           
            XPath xpath = new JDOMXPath( args[1] );
           
            List results = xpath.selectNodes( doc );
           
            Iterator resultIter = results.iterator();

            System.out.println("Document :: " + args[0] );
            System.out.println("   XPath :: " + args[1] );
View Full Code Here

Examples of org.jaxen.jdom.JDOMXPath

        Namespace my = Namespace.getNamespace("foo", "http://mynamespace.org/");
        Document doc = new Document();
        Element root = new Element("root", my);
        doc.setRootElement(root);
        XPath nullNamespacePath = new JDOMXPath("/root");
        List selectedNodes = nullNamespacePath.selectNodes(doc);
        assertEquals(0, selectedNodes.size());
       
    }
View Full Code Here

Examples of org.jaxen.jdom.JDOMXPath

        super( name );
    }

    public void testConstruction() throws JaxenException
    {
        new JDOMXPath( "/foo/bar/baz" );
    }
View Full Code Here

Examples of org.jaxen.jdom.JDOMXPath

        new JDOMXPath( "/foo/bar/baz" );
    }

    public void testSelection() throws JaxenException, JDOMException, IOException
    {
        XPath xpath = new JDOMXPath( "/foo/bar/baz" );

        SAXBuilder builder = new SAXBuilder();

        Document doc = builder.build( BASIC_XML );

        List results = xpath.selectNodes( doc );

        assertEquals( 3,
                      results.size() );

        Iterator iter = results.iterator();
View Full Code Here

Examples of org.jaxen.jdom.JDOMXPath

    }
   
   
    public void testGetDocumentNode() throws JaxenException, JDOMException, IOException
    {
        XPath xpath = new JDOMXPath( "/" );

        SAXBuilder builder = new SAXBuilder();

        Document doc = builder.build( BASIC_XML );

        Element root = doc.getRootElement();
        List results = xpath.selectNodes( root );

        assertEquals( 1,
                      results.size() );

        Iterator iter = results.iterator();
View Full Code Here

Examples of org.jaxen.jdom.JDOMXPath

        "</node></nodes></xml-document>";

        SAXBuilder builder = new SAXBuilder();
        Document document = builder.build( new InputSource( new StringReader(xml) ) );
       
        JDOMXPath x = new JDOMXPath("/xml-document/nodes/node/text()");
        Text t = (Text) x.selectSingleNode(document);
       
        assertEquals( "\ntest\n" , t.getText() );
       
    }
View Full Code Here

Examples of org.jaxen.jdom.JDOMXPath

    }
   
   
    public void testJaxen53Text() throws JaxenException, JDOMException, IOException
    {
        XPath xpath = new JDOMXPath( "//data/text() " );

        SAXBuilder builder = new SAXBuilder();

        Document doc = builder.build( new StringReader("<root>\n<data>1</data>\n</root>") );

        List results = xpath.selectNodes( doc );

        assertEquals( 1,
                      results.size() );

        Iterator iter = results.iterator();
View Full Code Here

Examples of org.jaxen.jdom.JDOMXPath

        Element element = new Element("test", ns1);
        Attribute attribute = new Attribute("foo", "bar", ns2);
        element.setAttribute(attribute);
        Document doc = new Document(element);
       
        XPath xpath = new JDOMXPath( "//namespace::node()" );

        List results = xpath.selectNodes( doc );

        assertEquals( 3,
                      results.size() );

    }
View Full Code Here

Examples of org.jaxen.jdom.JDOMXPath

        element.setAttribute(attribute);
        Element root = new Element("root", ns0);
        root.addContent(element);
        Document doc = new Document(root);
       
        XPath xpath = new JDOMXPath( "/*/*/namespace::node()" );

        List results = xpath.selectNodes( doc );

        assertEquals( 4, results.size() );

    }
View Full Code Here

Examples of org.jaxen.jdom.JDOMXPath

   
    public static void main(String[] args) {
        try {
            URL u = new URL("http://www.ibiblio.org/xml/examples/shakespeare/much_ado.xml");
            Document doc = new SAXBuilder().build(u);
            JDOMXPath xpath = new JDOMXPath("PLAY/ACT/SCENE/SPEECH/SPEAKER");
           
            long start = System.currentTimeMillis();
           
            int count = 0;
            for (int i = 0; i < 1000; i++) {
                Element speaker = (Element) xpath.selectSingleNode(doc);
                count += (speaker == null ? 0 : 1);
            }
           
            long end = System.currentTimeMillis();
            System.out.println((end - start));
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.