Package org.jaxen

Examples of org.jaxen.XPath.selectSingleNode()


                XMLStreamReader streamReader =
                        XMLInputFactory.newInstance().createXMLStreamReader(buildInputStream);
                StAXOMBuilder builder = new StAXOMBuilder(streamReader);
                XPath xp = new AXIOMXPath("/project/property[@name='name']");
                OMElement documentElement = builder.getDocumentElement();
                OMElement nameEle = (OMElement) xp.selectSingleNode(documentElement);
                if (nameEle != null) {
                    OMAttribute omAttribute = nameEle.getAttribute(new QName("value"));
                    String nameVal = omAttribute.getAttributeValue();
                    if (nameVal != null) {
                        name = nameVal;
View Full Code Here


    Map<QName,Function> functions,
    Map<QName,Object> variables) throws XPathException {
    try {
      base = getElementWrapped(base);
      XPath xpath = getXPath(path, namespaces, functions, variables);
      Object obj = xpath.selectSingleNode(base);
      if (obj instanceof OMAttribute) obj = new FOMAttribute((OMAttribute) obj);
      return obj;
    } catch (JaxenException e) {
      throw new XPathException(e);
    }
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

    sh.endElement ("", "temporary-root", "temporary-root");
    sh.endDocument();
    org.jdom.Element temporaryRoot = sh.getDocument().getRootElement();
    XPath xpath = new JDOMXPath("/temporary-root/row[2]");
    org.jdom.Element painter
        = (org.jdom.Element)xpath.selectSingleNode(temporaryRoot);
    String value = painter.getAttribute("title").getValue();
    // check testXSLT.xml for the expected result
    assertTrue(value.equals("The Artist's Garden at Vetheuil"));
      }
  }
View Full Code Here


    private OMElement getOMElement(String xpathString,
                                   OMElement parentElement) throws JaxenException {
        XPath xpath = getXPath(xpathString);
        return (OMElement) xpath.selectSingleNode(parentElement);
    }

    private XPath getXPath(String xpathString) throws JaxenException {
        SimpleNamespaceContext nsCtx = new SimpleNamespaceContext();
        nsCtx.addNamespace("ns", "http://geronimo.apache.org/xml/ns/j2ee/connector-1.1");
View Full Code Here

    Map<QName,Function> functions,
    Map<QName,Object> variables) throws XPathException {
    try {
      base = getElementWrapped(base);
      XPath xpath = getXPath(path, namespaces, functions, variables);
      Object obj = xpath.selectSingleNode(base);
      if (obj instanceof OMAttribute) obj = new FOMAttribute((OMAttribute) obj);
      return obj;
    } catch (JaxenException e) {
      throw new XPathException(e);
    }
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.