Package org.jaxen.dom

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


    try
    {
      DOMXPath xPath = new DOMXPath(nodeSelector);
      for (String prefix : resource.getNamespaceContext().keySet())
        xPath.addNamespace(prefix, resource.getNamespaceContext().get(prefix));
      Node node = (Node) xPath.selectSingleNode(resource.getDocument().getDom());
      if (node == null)
        return null;
      return new XpathXmlResource(node);
    }
    catch (JaxenException e)
View Full Code Here


    Element returnResult = ((Document)domResult.getNode())
        .getDocumentElement();

    XPath xpath = new DOMXPath("/BLUB/root/element1");
    Element element1
        = (Element)xpath.selectSingleNode(returnResult);
    String value1 = element1.getAttribute("attr1");
    // check testXSLT.xml for the expected result
    assertTrue(value1.equals("42"));

    xpath = new DOMXPath("/BLUB/root/element2");
View Full Code Here

    // check testXSLT.xml for the expected result
    assertTrue(value1.equals("42"));

    xpath = new DOMXPath("/BLUB/root/element2");
    Element element2
        = (Element)xpath.selectSingleNode(returnResult);
    String value2 = element2.getAttribute("attr2");
    // check testXSLT.xml for the expected result
    assertTrue(value2.equals("66"));

      }
View Full Code Here

    String value2 = xpath.stringValueOf(returnResult);
    assertTrue(value2.equals("I'm number one"));


    XPath xpath2 = new DOMXPath("/parent/thirdChild");
    Element child = (Element)xpath2.selectSingleNode(returnResult);
    System.out.println("child = " + child.getClass());
     org.jdom.Element child2 = new org.jdom.input.DOMBuilder().build(child);
     org.jdom.output.XMLOutputter output= new org.jdom.output.XMLOutputter();
     java.io.StringWriter sw = new java.io.StringWriter();
     output.output(child2, sw);
View Full Code Here

    Element returnResult = ((Document)domResult.getNode())
        .getDocumentElement();

    XPath xpath1 = new DOMXPath("/painters/table[1]/row[1]");
    Element painter1
        = (Element)xpath1.selectSingleNode(returnResult);
    String value1 = painter1.getAttribute("painter");
    // check testXSLT.xml for the expected result
    assertTrue(value1.equals("Matisse, Henri"));

    XPath xpath2 = new DOMXPath("/painters/table[2]/row[2]");
View Full Code Here

    // check testXSLT.xml for the expected result
    assertTrue(value1.equals("Matisse, Henri"));

    XPath xpath2 = new DOMXPath("/painters/table[2]/row[2]");
    Element painter2
        = (Element)xpath2.selectSingleNode(returnResult);
    String value2 = painter2.getAttribute("painter");
    // check testXSLT.xml for the expected result
    assertTrue(value2.equals("Monet, Claude"));
      }
  }
View Full Code Here

    Element returnResult = ((Document)domResult.getNode())
        .getDocumentElement();

    XPath xpath = new DOMXPath("/painters/table[3]/row[3]");
    Element painter
        = (Element)xpath.selectSingleNode(returnResult);
    String value = painter.getAttribute("title");
    // check testXSLT.xml for the expected result
    assertTrue(value.equals("Poplars along the River Epte, Autumn"));
      }
  }
View Full Code Here

//             (new javax.xml.transform.dom.DOMSource(returnResult),
//           streamResult);

    XPath xpath = new DOMXPath("/row");
    Element painter
        = (Element)xpath.selectSingleNode(returnResult);
    String value = painter.getAttribute("title");
    // check testXSLT.xml for the expected result
    assertTrue(value.equals("La Musique"));
      }
  }
View Full Code Here

        Element root = doc.createElement("root");
        doc.appendChild(root);
        Element child = doc.createElement("child");
        root.appendChild(child);
       
        assertEquals(child, xpath.selectSingleNode(doc));
       
    }
   
   
    public void testEvaluateWithMultiNodeAnswer() throws JaxenException {
View Full Code Here

      throws JaxenException {
       
        BaseXPath xpath = new DOMXPath("id('p1')");
        org.w3c.dom.Element a = doc.createElementNS("", "a");
        doc.appendChild(a);
        Object result = xpath.selectSingleNode(doc);
        assertNull(result);
       
   
   
    public void testSAXPathExceptionThrownFromConstructor() {
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.