Package javax.xml.xpath

Examples of javax.xml.xpath.XPath


      replyTo += "&xoauth_end_user_decision=" + decision.toLowerCase();
      return confirmAuthorization(replyTo);
   }
  
   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


      replyTo += "&xoauth_end_user_decision=" + decision.toLowerCase();
      return confirmAuthorization(replyTo);
   }
  
   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

    try
    {
      columnTypes = new ArrayList();
      columnNames = new ArrayList();

      final XPath xPath = XPathFactory.newInstance().newXPath();
      xPath.setXPathVariableResolver(new InternalXPathVariableResolver(parameters));

      // load metadata (number of rows, row names, row types)

      final String nodeValue = computeColDeclaration(xmlResource, resourceManager, xPath);
      if (nodeValue != null)
View Full Code Here

    throws XPathExpressionException
  {
    XPathExpression expression = xPathExpressions.get(sExpression);
    if (null == expression)
    {
      XPath xPath = xPathFactory.newXPath();
      expression = xPath.compile(sExpression);
      xPathExpressions.put(sExpression, expression);
    }
    return expression;
  }
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
    }
View Full Code Here

        try
        {
            Document doc = (Document) mconn.getConnection();

            ClassLoaderResolver clr = ec.getClassLoaderResolver();
            XPath xpath = XPathFactory.newInstance().newXPath();
            for (int i=0;i<possibleNames.length;i++)
            {
                // Try to find an object of this possible class with the id
                AbstractClassMetaData acmd = getMetaDataManager().getMetaDataForClass(possibleNames[i], clr);
                expression = XMLUtils.getXPathForClass(acmd);
                if (expression == null)
                {
                    if (doc.getDocumentElement() != null)
                    {
                        expression = "/" + doc.getDocumentElement().getNodeName();
                    }
                    else
                    {
                        // No root, so can't have an object
                        continue;
                    }
                }
                expression += "/" + XMLUtils.getElementNameForClass(acmd);
                String[] pk = acmd.getPrimaryKeyMemberNames();
                for (int j=0; j<pk.length; j++)
                {
                    AbstractMemberMetaData pkmmd = acmd.getMetaDataForMember(pk[j]);
                    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

        this.mconn = mconn;
        this.ignoreCache = ignoreCache;

        // Count the instances per class by scanning the associated worksheets
        Document doc = (Document) mconn.getConnection();
        XPath xpath = XPathFactory.newInstance().newXPath();
        numberInstancesPerClass = new ArrayList<Integer>();
        Iterator<AbstractClassMetaData> cmdIter = cmds.iterator();
        while (cmdIter.hasNext())
        {
            AbstractClassMetaData cmd = cmdIter.next();

            Element el = null;
            String expression = XMLUtils.getXPathForClass(cmd);
            if (expression == null)
            {
                el = doc.getDocumentElement();
            }
            else
            {
                try
                {
                    el = (Element) xpath.evaluate(expression, doc, XPathConstants.NODE);
                }
                catch (XPathExpressionException e)
                {
                    e.printStackTrace();
                }
View Full Code Here

        {
            throw new NoSuchElementException();
        }

        Document doc = (Document) mconn.getConnection();
        XPath xpath = XPathFactory.newInstance().newXPath();
        Iterator<AbstractClassMetaData> cmdIter = cmds.iterator();
        Iterator<Integer> numIter = numberInstancesPerClass.iterator();
        int first = 0;
        int last = -1;
        while (cmdIter.hasNext())
        {
            final AbstractClassMetaData cmd = cmdIter.next();
            int number = numIter.next();
            last = first+number;

            if (index >= first && index < last)
            {
                // Object is of this candidate type, so find the object
                ClassLoaderResolver clr = ec.getClassLoaderResolver();
                int current = first;
                Element el = null;
                String expression = XMLUtils.getXPathForClass(cmd);
                if (expression == null)
                {
                    el = doc.getDocumentElement();
                }
                else
                {
                    try
                    {
                        el = (Element) xpath.evaluate(expression, doc, XPathConstants.NODE);
                    }
                    catch (XPathExpressionException e)
                    {
                        e.printStackTrace();
                    }
View Full Code Here

        }
        Element root = document.getDocumentElement();
        root.appendChild(sig.getElement());

        XPathFactory xpf = XPathFactory.newInstance();
        XPath xpath = xpf.newXPath();
        xpath.setNamespaceContext(new DSNamespaceContext());

        for (String localName : localNames) {
            String expression = "//*[local-name()='" + localName + "']";
            NodeList elementsToSign =
                    (NodeList) xpath.evaluate(expression, document, XPathConstants.NODESET);
            for (int i = 0; i < elementsToSign.getLength(); i++) {
                Element elementToSign = (Element)elementsToSign.item(i);
                Assert.assertNotNull(elementToSign);
                String id = UUID.randomUUID().toString();
                elementToSign.setAttributeNS(null, "Id", id);
                elementToSign.setIdAttributeNS(null, "Id", true);

                Transforms transforms = new Transforms(document);
                transforms.addTransform(referenceC14NMethod);
                sig.addDocument("#" + id, transforms, digestMethod);
            }
        }

        if (additionalReferences != null) {
            for (int i = 0; i < additionalReferences.size(); i++) {
                ReferenceInfo referenceInfo = additionalReferences.get(i);
                if (referenceInfo.isBinary()) {
                    sig.addDocument(referenceInfo.getResource(), null, referenceInfo.getDigestMethod());
                } else {
                    Transforms transforms = new Transforms(document);
                    for (int j = 0; j < referenceInfo.getC14NMethod().length; j++) {
                        String transform = referenceInfo.getC14NMethod()[j];
                        transforms.addTransform(transform);
                    }
                    sig.addDocument(referenceInfo.getResource(), transforms, referenceInfo.getDigestMethod());
                }
            }
        }

        sig.sign(signingKey);

        String expression = "//ds:Signature[1]";
        Element sigElement =
                (Element) xpath.evaluate(expression, document, XPathConstants.NODE);
        Assert.assertNotNull(sigElement);

        return sig;
    }
View Full Code Here

            builderKeyInfo.add(encryptedKey);
        }
       
        XPathFactory xpf = XPathFactory.newInstance();
        XPath xpath = xpf.newXPath();
        xpath.setNamespaceContext(new DSNamespaceContext());

        for (String localName : localNames) {
            String expression = "//*[local-name()='" + localName + "']";
            Element elementToEncrypt =
                    (Element) xpath.evaluate(expression, document, XPathConstants.NODE);
            Assert.assertNotNull(elementToEncrypt);

            document = cipher.doFinal(document, elementToEncrypt, content);
        }
       
View Full Code Here

TOP

Related Classes of javax.xml.xpath.XPath

Copyright © 2018 www.massapicom. 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.