Package org.jaxen.dom

Examples of org.jaxen.dom.DOMXPath.selectNodes()


          XPath implicitCast = new DOMXPath("//lat[(comment() >= 37)]");
          XPath explicitCast = new DOMXPath("//lat[(number(comment()) >= 37)]");
          DocumentBuilder builder = factory.newDocumentBuilder();
          ByteArrayInputStream in = new ByteArrayInputStream("<geo><lat><!--39--></lat></geo>".getBytes("UTF-8"));
          Document document = builder.parse(in);
          List result = explicitCast.selectNodes(document);
          assertEquals(1, result.size());
          result = implicitCast.selectNodes(document);
          assertEquals(1, result.size());
    }
 
View Full Code Here


        XPath implicitCast = new DOMXPath("//lat[(processing-instruction() >= 37)]");
        XPath explicitCast = new DOMXPath("//lat[(number(processing-instruction()) >= 37)]");
        DocumentBuilder builder = factory.newDocumentBuilder();
        ByteArrayInputStream in = new ByteArrayInputStream("<geo><lat><?test 39?></lat></geo>".getBytes("UTF-8"));
        Document document = builder.parse(in);
        List result = explicitCast.selectNodes(document);
        assertEquals(1, result.size());
        result = implicitCast.selectNodes(document);
        assertEquals(1, result.size());
    }
   
View Full Code Here

        Element b = doc.createElement("b");
        root.appendChild(b);
        Element c = doc.createElement("c");
        a.appendChild(c);
       
        List result = xpath.selectNodes(b);
        assertEquals(2, result.size());
        assertEquals(a, result.get(0));
        assertEquals(c, result.get(1));
    }
   
View Full Code Here

     *            An XPath expression describing the expected child element.
     */
    public void shouldContainElement(String message, String xpathExpression) {
        try {
            DOMXPath xpath = new DOMXPath(xpathExpression);
            List matchingNodes = xpath.selectNodes(context);
            Assert.assertFalse(message, matchingNodes.isEmpty());
        } catch (JaxenException e) {
            throw new RuntimeException(e);
        }
    }
View Full Code Here

 
  public static List parseXPath(Node node, String xpathStr) {
    List retVal = new ArrayList();
    try {
      XPath xpath = new DOMXPath(xpathStr);
      retVal = xpath.selectNodes(node);
    }
    catch (Exception ex) {
      throw new RuntimeException(ex);
    }
      return retVal;
View Full Code Here

    {
        try
        {
            final DOMXPath path = new DOMXPath( str );
            path.setNamespaceContext( new JaxenResolver(resolver) );
            final List list = path.selectNodes( contextNode );
            return new SimpleNodeList( list );
        }
        catch( final Exception e )
        {
            if (getLogger().isDebugEnabled()) {
View Full Code Here

    /*
     * NodeList elencoNodi = XPathAPI.selectNodeList(DomDocument, xPath); if (elencoNodi != null) { iNodi = elencoNodi.getLength(); }
     */
    try {
      XPath xpath = new DOMXPath(xPath);
      List results = (List) xpath.selectNodes(DomDocument);
      if (results != null) {
        iNodi = results.size();
      }
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

  private String getValore(String xPath) throws TransformerException, UnsupportedEncodingException {
    String ilValore = "";
    try {
      XPath xpath = new DOMXPath(xPath);
      if (xPath.endsWith("/text()")) {
        List elencoNodi = (List) xpath.selectNodes(DomDocument);
        for (int i = 0; i < elencoNodi.size(); i++) {
          try {
            ilValore += ((Node) elencoNodi.get(i)).getNodeValue() + "\n";
          } catch (NullPointerException exc) {
          }
View Full Code Here

       */
    public NodeList selectNodeList(Node contextNode, String str)
    {
        try {
            DOMXPath path = new DOMXPath(str);
            List list = path.selectNodes((Object)contextNode);
            return new NodeListEx(list);
        } catch (Exception e){
            // ignore it
        }
        return new NodeListEx();
View Full Code Here

    public void testNamespaceURIOfNumber() throws JaxenException
    {
        try
        {
            XPath xpath = new DOMXPath( "namespace-uri(3)" );
            xpath.selectNodes( doc );
            fail("namespace-uri of non-node-set");
        }
        catch (FunctionCallException e)
        {
           assertEquals("The argument to the namespace-uri function must be a node-set", e.getMessage());
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.