Package org.apache.abdera.xpath

Examples of org.apache.abdera.xpath.XPath


      "http://verisignlabs.com/tg/verify",
      bre, reqoptions);
    assertEquals(response.getStatus(),200);
    Document<Element> result = response.getDocument();
   
    XPath xpath = abdera.getXPath();
    assertTrue(
      xpath.booleanValueOf(
        "/Result/SignatureVerifies[text()='true']",
        result));

  }
View Full Code Here


  public void testXPath() throws Exception {
   
    InputStream in = FOMTest.class.getResourceAsStream("/simple.xml");
    Document<Feed> doc = getParser().parse(in);
    Feed feed = doc.getRoot();
    XPath xpath = getXPath();
    assertEquals(xpath.evaluate("count(/a:feed)", feed), 1.0d);
    assertTrue(xpath.booleanValueOf("/a:feed/a:entry", feed));
    assertEquals(xpath.numericValueOf("count(/a:feed)", feed), 1.0d);
    assertEquals(xpath.valueOf("/a:feed/a:entry/a:title", feed), "Atom-Powered Robots Run Amok");
    assertEquals(xpath.selectNodes("/a:feed/a:entry", feed).size(), 1);
    assertTrue(xpath.selectSingleNode("/a:feed", feed) instanceof Feed);
    assertEquals(xpath.selectSingleNode("..", feed.getTitleElement()), feed);
    assertEquals(xpath.selectSingleNode("ancestor::*", feed.getEntries().get(0)), feed);
    assertEquals(xpath.valueOf("concat('The feed is is ',/a:feed/a:id)", feed), "The feed is is urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6");
   
  }
View Full Code Here

    // add additional feed metadata
    Entry entry = feed.addEntry();
    // add additional feed metadata
    entry.addLink("alternate.xml")// relative URI
   
    XPath xpath = abdera.getXPath();
    System.out.println(xpath.valueOf("abdera:resolve(/a:feed/a:entry/a:link/@href)",feed));
   
   
    // You can add your own xpath functions.
    FOMXPath fxpath = (FOMXPath) xpath;
    Map<QName,Function> functions = fxpath.getDefaultFunctions();
View Full Code Here

  public void testXPath() throws Exception {
   
    InputStream in = FOMTest.class.getResourceAsStream("/simple.xml");
    Document<Feed> doc = getParser().parse(in);
    Feed feed = doc.getRoot();
    XPath xpath = getXPath();
    assertEquals(xpath.evaluate("count(/a:feed)", feed), 1.0d);
    assertTrue(xpath.booleanValueOf("/a:feed/a:entry", feed));
    assertEquals(xpath.numericValueOf("count(/a:feed)", feed), 1.0d);
    assertEquals(xpath.valueOf("/a:feed/a:entry/a:title", feed), "Atom-Powered Robots Run Amok");
    assertEquals(xpath.selectNodes("/a:feed/a:entry", feed).size(), 1);
    assertTrue(xpath.selectSingleNode("/a:feed", feed) instanceof Feed);
    assertEquals(xpath.selectSingleNode("..", feed.getTitleElement()), feed);
    assertEquals(xpath.selectSingleNode("ancestor::*", feed.getEntries().get(0)), feed);
    assertEquals(xpath.valueOf("concat('The feed is is ',/a:feed/a:id)", feed), "The feed is is urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6");
   
  }
View Full Code Here

  public void testXPath() throws Exception {
   
    InputStream in = FOMTest.class.getResourceAsStream("/simple.xml");
    Document<Feed> doc = getParser().parse(in);
    Feed feed = doc.getRoot();
    XPath xpath = getXPath();
    assertEquals(xpath.evaluate("count(/a:feed)", feed), 1.0d);
    assertTrue(xpath.booleanValueOf("/a:feed/a:entry", feed));
    assertEquals(xpath.numericValueOf("count(/a:feed)", feed), 1.0d);
    assertEquals(xpath.valueOf("/a:feed/a:entry/a:title", feed), "Atom-Powered Robots Run Amok");
    assertEquals(xpath.selectNodes("/a:feed/a:entry", feed).size(), 1);
    assertTrue(xpath.selectSingleNode("/a:feed", feed) instanceof Feed);
    assertEquals(xpath.selectSingleNode("..", feed.getTitleElement()), feed);
    assertEquals(xpath.selectSingleNode("ancestor::*", feed.getEntries().get(0)), feed);
    assertEquals(xpath.valueOf("concat('The feed is is ',/a:feed/a:id)", feed), "The feed is is urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6");
   
  }
View Full Code Here

  @Test
  public void testXPath() throws IOException {
    Feed f = Abdera.getInstance().newFeed();
    IntegerElement ext = f.addExtension(OpenSearchConstants.START_INDEX);
    ext.setValue(101);
    XPath path = Abdera.getNewXPath();
    List result = path.selectNodes("node()", ext);
    assertTrue(result.size() > 0);
  }
View Full Code Here

  public void testXPath() throws Exception {
   
    InputStream in = FOMTest.class.getResourceAsStream("/simple.xml");
    Document<Feed> doc = getParser().parse(in);
    Feed feed = doc.getRoot();
    XPath xpath = getXPath();
    assertEquals(xpath.evaluate("count(/a:feed)", feed), 1.0d);
    assertTrue(xpath.booleanValueOf("/a:feed/a:entry", feed));
    assertEquals(xpath.numericValueOf("count(/a:feed)", feed), 1.0d);
    assertEquals(xpath.valueOf("/a:feed/a:entry/a:title", feed), "Atom-Powered Robots Run Amok");
    assertEquals(xpath.selectNodes("/a:feed/a:entry", feed).size(), 1);
    assertTrue(xpath.selectSingleNode("/a:feed", feed) instanceof Feed);
    assertEquals(xpath.selectSingleNode("..", feed.getTitleElement()), feed);
    assertEquals(xpath.selectSingleNode("ancestor::*", feed.getEntries().get(0)), feed);
    assertEquals(xpath.valueOf("concat('The feed is is ',/a:feed/a:id)", feed), "The feed is is urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6");
   
  }
View Full Code Here

    throw new UnsupportedOperationException("Modifications are not allowed");
  }

  private Element locate(String path) throws XPathException {
    Abdera abdera = this.getFactory().getAbdera();
    XPath xpath = abdera.getXPath();
    Map<String,String> ns = xpath.getDefaultNamespaces();
    ns.put("rdf", RssConstants.RDF_NS);
    ns.put("rss", RssConstants.RSS1_NS);
    Element el = getDocument().getRoot();
    if (el instanceof ElementWrapper) {
      el = ((ElementWrapper)el).getInternal();
    }
    return (Element) xpath.selectSingleNode(path,el,ns);
  }
View Full Code Here

        Document<Element> doc = parser.parse(new StringReader(html));
        Element root = doc.getRoot();
        root.writeTo(System.out);
        System.out.println();

        XPath xpath = abdera.getXPath();
        List<Element> list = xpath.selectNodes("//i", doc.getRoot());
        for (Element element : list)
            System.out.println(element);
    }
View Full Code Here

        throw new UnsupportedOperationException("Modifications are not allowed");
    }

    private Element locate(String path) throws XPathException {
        Abdera abdera = this.getFactory().getAbdera();
        XPath xpath = abdera.getXPath();
        Map<String, String> ns = xpath.getDefaultNamespaces();
        ns.put("rdf", RssConstants.RDF_NS);
        ns.put("rss", RssConstants.RSS1_NS);
        Element el = getDocument().getRoot();
        if (el instanceof ElementWrapper) {
            el = ((ElementWrapper)el).getInternal();
        }
        return (Element)xpath.selectSingleNode(path, el, ns);
    }
View Full Code Here

TOP

Related Classes of org.apache.abdera.xpath.XPath

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.