Package javax.xml.xpath

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


    XPathFactory factory = XPathFactory.newInstance();
    XPath xpath = factory.newXPath();
    Object result;
    try {
      XPathExpression expr =
        xpath.compile("/stratcon/iep/" + which + "/" + param + "/text()");
      result = expr.evaluate(doc, XPathConstants.NODESET);
    }
    catch(XPathExpressionException e) {
      System.err.println("Bad expression: " + e.getMessage());
      return null;
View Full Code Here


        final List<Field> fields = target.getModel().getField();
    String isModelArray = target.getModel().getIsArray();
    String modelXpath = target.getModel().getXpath();
    List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
    if ("1".equals(isModelArray) || "tre".equals(isModelArray)){
      XPathExpression expr = xpathParser.compile(modelXpath);
          Object result = expr.evaluate(doc, XPathConstants.NODESET);
//        listener.onInfo(Thread.currentThread(), "modelXpath -> " + modelXpath + " parse result -> " + result);
          if (result != null){
            NodeList nodes = (NodeList) result;
            if (nodes.getLength() > 0){
View Full Code Here

    }
    XPathFactory xpFactory = XPathFactory.newInstance();
    XPath xpath = xpFactory.newXPath();
    XPathExpression expr =null;
    try {
      expr = xpath.compile(xpathString);
    } catch (XPathExpressionException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    Element result = null;
View Full Code Here

        final NamespaceContext nsContext = this.getNamespaceContext();
        xpath.setNamespaceContext(nsContext);
       
        // Signature Algorithm
        final XPathExpression sigAlgoExpr =
            xpath.compile("/s:Envelope/s:Header/wsse:Security/ds:Signature/ds:SignedInfo"
                              + "/ds:SignatureMethod/@Algorithm");
       
        final String sigMethod =  (String) sigAlgoExpr.evaluate(signedDoc, XPathConstants.STRING);
        assertEquals(expectedSignatureMethod, sigMethod);
       
View Full Code Here

       
        final String sigMethod =  (String) sigAlgoExpr.evaluate(signedDoc, XPathConstants.STRING);
        assertEquals(expectedSignatureMethod, sigMethod);
       
        // Digest Method Algorithm
        final XPathExpression digestAlgoExpr = xpath.compile(
            "/s:Envelope/s:Header/wsse:Security/ds:Signature/ds:SignedInfo/ds:Reference/ds:DigestMethod");
       
        final NodeList digestMethodNodes =
            (NodeList) digestAlgoExpr.evaluate(signedDoc, XPathConstants.NODESET);
       
View Full Code Here

            assertEquals(expectedDigestAlgorithm, digestAlgorithm);
        }
       
        // Canonicalization Algorithm
        final XPathExpression canonAlgoExpr =
            xpath.compile("/s:Envelope/s:Header/wsse:Security/ds:Signature/ds:SignedInfo"
                              + "/ds:CanonicalizationMethod/@Algorithm");
        final String canonMethod =  (String) canonAlgoExpr.evaluate(signedDoc, XPathConstants.STRING);
        assertEquals(expectedCanonAlgorithm, canonMethod);
    }
   
View Full Code Here

        XPath xpath = factory.newXPath();
        final NamespaceContext nsContext = this.getNamespaceContext();
        xpath.setNamespaceContext(nsContext);
       
        // Find the SecurityTokenReference for the assertion
        final XPathExpression strExpr = xpath.compile(
            "/s:Envelope/s:Header/wsse:Security/wsse:SecurityTokenReference/wsse:KeyIdentifier");
       
        final NodeList strKeyIdNodes =
            (NodeList) strExpr.evaluate(signedDoc, XPathConstants.NODESET);
       
View Full Code Here

            }
        }
        assertNotNull("SecurityTokenReference for " + assertionId + " not found in security header.", strId);
       
        // Verify STR is included in the signature references
        final XPathExpression sigRefExpr = xpath.compile(
            "/s:Envelope/s:Header/wsse:Security/ds:Signature/ds:SignedInfo/ds:Reference");
       
        final NodeList sigReferenceNodes =
            (NodeList) sigRefExpr.evaluate(signedDoc, XPathConstants.NODESET);
       
View Full Code Here

    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document doc = builder.parse(stackMetainfoFile);
    XPathFactory xPathfactory = XPathFactory.newInstance();
    XPath xpath = xPathfactory.newXPath();
    XPathExpression schemaPath = xpath.compile("/metainfo/schemaVersion[1]");

    String value = schemaPath.evaluate(doc).trim();
    if ( "".equals(value) || // If schemaVersion is not defined
            AmbariMetaInfo.SCHEMA_VERSION_LEGACY.equals(value)) {
      return AmbariMetaInfo.SCHEMA_VERSION_LEGACY;
View Full Code Here

            String rateTable = entry.getSummary().getValue();

            Document doc = builder.parse(new ByteArrayInputStream(rateTable.getBytes()));
            Node node = doc.getDocumentElement();
            XPath path = XPathFactory.newInstance().newXPath();
            XPathExpression exp = path.compile("/TABLE/TR[TD[1]='" + currency.toUpperCase() + "']/TD[2]");
            Node rateNode = (Node)exp.evaluate(node, XPathConstants.NODE);
            double rate = Double.valueOf(rateNode.getTextContent().trim());
            System.out.println("Exchange rate: USD 1.0=" + currency + " " + rate);
            return rate;
        } catch (Exception 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.