Package javax.xml.xpath

Examples of javax.xml.xpath.XPath


      //
      ServletContext servletContext = getServletContext();

      // XPath expression for selecting the url pattern for this servlet instance
      String exprValue = "//servlet-mapping[servlet-name='" + servletName + "']/url-pattern";
      XPath xpath = XPathFactory.newInstance().newXPath();
      XPathExpression expr;
      try
      {
         expr = xpath.compile(exprValue);
      }
      catch (XPathExpressionException e)
      {
         throw new ServletException(e);
      }
View Full Code Here


        DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
        try {
            DocumentBuilder builder = domFactory.newDocumentBuilder();
            Document doc = builder.parse(procDefIS);

            XPath xpath = XPathFactory.newInstance().newXPath();

            NodeList nodeList = (NodeList) xpath.evaluate("//userTask | //serviceTask | //scriptTask", doc,
                    XPathConstants.NODESET);
            for (int i = 0; i < nodeList.getLength(); i++) {
                result.add(nodeList.item(i).getAttributes().getNamedItem("id").getNodeValue());
            }
        } catch (Exception e) {
View Full Code Here

    /**
     * Create the specified XPath expression with the namespaces added via
     * addNamespace().
     */
    public static XPath createXPath(Map<String, String> namespaces) throws Exception {
        XPath xpath = XPathFactory.newInstance().newXPath();

        if (namespaces != null) {
            xpath.setNamespaceContext(new MapNamespaceContext(namespaces));
        }

        return xpath;
    }
View Full Code Here

        List<WSEncryptionPart> result = new ArrayList<WSEncryptionPart>();
       
        if (xpaths != null && !xpaths.isEmpty()) {
            XPathFactory factory = XPathFactory.newInstance();
            for (String expression : xpaths) {
                XPath xpath = factory.newXPath();
                if (namespaces != null) {
                    xpath.setNamespaceContext(new MapNamespaceContext(namespaces));
                }
              
                NodeList list = (NodeList)xpath.evaluate(expression, saaj.getSOAPPart().getEnvelope(),
                                               XPathConstants.NODESET);
                for (int x = 0; x < list.getLength(); x++) {
                    Element el = (Element)list.item(x);
                   
                    if (!found.contains(el)) {
View Full Code Here

            try {
                StaxUtils.toNextTag(r);
                String s = r.getAttributeValue(null, "schemaLocation");
                if (StringUtils.isEmpty(s)) {
                    Document d = StaxUtils.read(r);
                    XPath p = XPathFactory.newInstance().newXPath();
                    p.setNamespaceContext(new W3CNamespaceContext(d.getDocumentElement()));
                    XPathExpression xpe = p.compile(d.getDocumentElement().getAttribute("node"));
                    for (XmlSchema schema : schemas.getXmlSchemas()) {
                        if (XMLConstants.W3C_XML_SCHEMA_NS_URI.equals(schema.getTargetNamespace())) {
                            continue;
                        }
                        Object src = getSchemaNode(schema, schemas);
View Full Code Here

                                    source = source.substring(index + 1);
                                    if ("".equals(source)) {
                                        source = ".";
                                    }
                                }
                                XPath xpath = xPathFactory.newXPath();
                                xpath.setNamespaceContext(reader.getNamespaceContext());
                                try {
                                    componentProperty.setSourceXPathExpression(xpath.compile(source));
                                } catch (XPathExpressionException e) {
                                  ContributionReadException ce = new ContributionReadException(e);
                                  error("ContributionReadException", xpath, ce);
                                    //throw ce;
                                }
View Full Code Here

        }
    }

    protected XPathExpression createXPathExpression() throws XPathExpressionException,
        XPathFactoryConfigurationException {
        XPath xPath = getXPathFactory().newXPath();

        // lets now clear any factory references to avoid keeping them around
        xpathFactory = null;

        xPath.setNamespaceContext(getNamespaceContext());

        xPath.setXPathVariableResolver(variableResolver);

        XPathFunctionResolver parentResolver = getFunctionResolver();
        if (parentResolver == null) {
            parentResolver = xPath.getXPathFunctionResolver();
        }
        xPath.setXPathFunctionResolver(createDefaultFunctionResolver(parentResolver));
        return xPath.compile(text);
    }
View Full Code Here

            if (!contentFilter.getDialect().equals(XPATH1_URI)) {
                throw new IllegalStateException("Unsupported dialect: " + contentFilter.getDialect());
            }
            try {
                XPathFactory xpfactory = XPathFactory.newInstance();
                XPath xpath = xpfactory.newXPath();
                XPathExpression exp = xpath.compile(contentFilter.getContent().get(0).toString());
                Boolean ret = (Boolean) exp.evaluate(content, XPathConstants.BOOLEAN);
                return ret.booleanValue();
            } catch (XPathExpressionException e) {
                log.warn("Could not filter notification", e);
            }
View Full Code Here

        Element soapEnvelope = soapHeader.getOwnerDocument().getDocumentElement();
        if (containsXPathPolicy(aim)) {
            // XPathFactory and XPath are not thread-safe so we must recreate them
            // each request.
            final XPathFactory factory = XPathFactory.newInstance();
            final XPath xpath = factory.newXPath();
           
            check &= assertXPathTokens(aim, SP12Constants.SIGNED_ELEMENTS, signed, soapEnvelope,
                    CoverageType.SIGNED, CoverageScope.ELEMENT, xpath);
            check &= assertXPathTokens(aim, SP12Constants.ENCRYPTED_ELEMENTS, encrypted, soapEnvelope,
                    CoverageType.ENCRYPTED, CoverageScope.ELEMENT, xpath);
View Full Code Here

                RequiredElements rp = (RequiredElements)ai.getAssertion();
                ai.setAsserted(true);
                Map<String, String> namespaces = rp.getDeclaredNamespaces();
                XPathFactory factory = XPathFactory.newInstance();
                for (String expression : rp.getXPathExpressions()) {
                    XPath xpath = factory.newXPath();
                    if (namespaces != null) {
                        xpath.setNamespaceContext(new MapNamespaceContext(namespaces));
                    }
                    NodeList list;
                    try {
                        list = (NodeList)xpath.evaluate(expression,
                                                                 header,
                                                                 XPathConstants.NODESET);
                        if (list.getLength() == 0) {
                            ai.setNotAsserted("No header element matching XPath " + expression + " found.");
                        }
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.