Package javax.xml.xpath

Examples of javax.xml.xpath.XPath.evaluate()


        int tcCount = 0, tcGenCount = 0;
        File testDestDir = new File(TEST_RESOURCE_DIR);
        assert (testDestDir.exists()) : testDestDir.getAbsolutePath();
        File destFile = new File(testDestDir, "TestCase.list");
        PrintWriter pw = new PrintWriter(destFile);
        NodeList rs = (NodeList) xpath.evaluate(ADDR_TEST_GROUPS, catalog, XPathConstants.NODESET);
        final int rslen = rs.getLength();
        for(int i = 0; i < rslen; i++) {
            final String ADDR_TEST_GROUP = '(' + ADDR_TEST_GROUPS + ")[" + (i + 1) + ']';
            Node testGroup = rs.item(i);
            assert (testGroup != null);
View Full Code Here


        for(int i = 0; i < rslen; i++) {
            final String ADDR_TEST_GROUP = '(' + ADDR_TEST_GROUPS + ")[" + (i + 1) + ']';
            Node testGroup = rs.item(i);
            assert (testGroup != null);
            assert (testGroup.hasAttributes());
            String filepath = (String) xpath.evaluate("ns:test-case[1]/@FilePath", testGroup, XPathConstants.STRING);
            if(filepath == null || filepath.length() == 0) {
                // test-group might have no test-case
                continue;
            }
            assert (filepath.endsWith("/")) : filepath;
View Full Code Here

                codeBuf.append(code, 0, code.lastIndexOf('}') - 1);
                final int count = countTests(TEST_PATH, catalog);
                assert (count >= 1) : count;
                String methodTmpl = IOUtils.toString(TestCodeGenerator.class.getResourceAsStream("TestMethod.template"));
                methodTmpl = methodTmpl.replace("$TIMEOUT", XQTSTestBase.XQTS_PROP.getProperty("test.timeout")).replace("$TESTPATH", TEST_PATH);
                NodeList methods = (NodeList) xpath.evaluate(TEST_PATH + "/@name", catalog, XPathConstants.NODESET);
                assert (count == methods.getLength());
                for(int j = 0; j < count; j++) {
                    String methodName = methods.item(j).getTextContent();
                    assert (methodName != null);
                    methodName = toClassName(methodName);
View Full Code Here

      try
      {
        if (xPathExpr != null)
        {
          XPath xPath = XPathFactory.newInstance().newXPath();
          String function = xPath.evaluate(xPathExpr, doc
              .getDocumentElement());
          function = XStringSupport.replaceAll(function, " ", "");
          setFunction(function);
        }
      }
View Full Code Here

    XPath namespaceXPath = xpathFact.newXPath();
    String namespaceXPathString = "//namespace::*";
   

    try {
      NodeList nlist = (NodeList) namespaceXPath.evaluate(
          namespaceXPathString, contextNode, XPathConstants.NODESET);
      for (int i = 0; i < nlist.getLength(); i++) {
        Node node = nlist.item(i);
        namespaces.put(node.getNodeName().substring("xmlns:".length()),
            node.getNodeValue());
View Full Code Here

   private String evaluateBody(InputStream body, String expression) {
       XPath xpath = XPathFactory.newInstance().newXPath();
       xpath.setNamespaceContext(new NamespaceContextImpl(
               Collections.singletonMap("ns", "http://org.jboss.com/resteasy/oauth")));
       try {
           Object result = (Object)xpath.evaluate(expression, new InputSource(body), XPathConstants.STRING);
           return (String)result;
       } catch (XPathExpressionException ex) {
           throw new IllegalArgumentException("Illegal XPath expression '" + expression + "'", ex);
       }
View Full Code Here

   private String evaluateBody(InputStream body, String expression) {
       XPath xpath = XPathFactory.newInstance().newXPath();
       xpath.setNamespaceContext(new NamespaceContextImpl(
               Collections.singletonMap("ns", "http://org.jboss.com/resteasy/oauth")));
       try {
           Object result = (Object)xpath.evaluate(expression, new InputSource(body), XPathConstants.STRING);
           return (String)result;
       } catch (XPathExpressionException ex) {
           throw new IllegalArgumentException("Illegal XPath expression '" + expression + "'", ex);
       }
View Full Code Here


    public static NodeList nodeListXpath(Node baseNode, String xpathExpression) {
        try {
            XPath xpath = XPathFactory.newInstance().newXPath();
            return (NodeList)xpath.evaluate( xpathExpression, baseNode, XPathConstants.NODESET );
        } catch (XPathExpressionException x) { throw new XmlException( x ); }   // Programmfehler
    }


    public static String xmlQuoted(String value) {
View Full Code Here

                    String pkElement = XMLUtils.getElementNameForMember(pkmmd, FieldRole.ROLE_FIELD);
                    Object obj = ec.getApiAdapter().getTargetKeyForSingleFieldIdentity(id);
                    expression += "/" + pkElement + "/text()='" + obj.toString() + "'";
                }

                if ((Boolean)xpath.evaluate(expression, doc, XPathConstants.BOOLEAN))
                {
                    return possibleNames[i];
                }
            }
        }
View Full Code Here

            }
            else
            {
                try
                {
                    el = (Element) xpath.evaluate(expression, doc, XPathConstants.NODE);
                }
                catch (XPathExpressionException e)
                {
                    e.printStackTrace();
                }
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.