Package org.jaxen

Examples of org.jaxen.XPath


        {
            throw new QueryEvaluationErrorException( MSG.getMessage( Keys.BAD_XPATH_NAMESPACE_CONTEXT ) );
        }
        try
        {
            XPath xpath = new DOMXPath( xpathExpr.getValue() );
            xpath.setNamespaceContext( new JaxenNamespaceContext( xpathExpr.getNamespaceContext() ) );
            return xpath.evaluate( evalContextNode );
        }
        catch ( JaxenException je )
        {
            throw new QueryEvaluationErrorException( MSG.getMessage( Keys.XPATH_FAILED, xpathExpr.getValue(),
                    je ) );
View Full Code Here


            if(dataRef == null || dataRef.getXpath() == null) {
                continue;
            }

            try {
                XPath xp = new AXIOMXPath(dataRef.getXpath());

                Iterator nsIter = namespaces.iterator();

                while (nsIter.hasNext())
                {
                    OMNamespace tmpNs = (OMNamespace)nsIter.next();
                    xp.addNamespace(tmpNs.getPrefix(), tmpNs.getNamespaceURI());
                }

                Iterator nodesIterator = xp.selectNodes(envelope).iterator();

                while (nodesIterator.hasNext()) {
                    decryptedElements.put(nodesIterator.next(), Boolean.valueOf(dataRef.isContent()));
                }


            } catch (JaxenException e) {
                // This has to be changed to propagate an instance of a RampartException up
                throw new RampartException("An error occurred while searching for decrypted elements.", e);
            }

        }

       
        //Check for encrypted body
        if(rpd.isEncryptBody()&& !rpd.isEncryptBodyOptional()) {
           
            if( !isRefIdPresent(encrRefs, data.getBodyEncrDataId())){
                throw new RampartException("encryptedPartMissing",
                        new String[]{data.getBodyEncrDataId()});
            }
        }

        for (int i = 0 ; i < encryptedParts.size() ; i++) {
           
            WSEncryptionPart encPart = (WSEncryptionPart)encryptedParts.get(i);
           
            //This is the encrypted Body and we already checked encrypted body
            if (encPart.getType() == WSConstants.PART_TYPE_BODY) {
                continue;
            }
           
            if ((WSConstants.SIG_LN.equals(encPart.getName()) &&
                    WSConstants.SIG_NS.equals(encPart.getNamespace()))
                   || encPart.getType() == WSConstants.PART_TYPE_HEADER ) {
                if (!isRefIdPresent(encrRefs, new QName(encPart.getNamespace(),encPart.getName()))) {
                    throw new RampartException("encryptedPartMissing",
                            new String[]{encPart.getNamespace()+":"+encPart.getName()});
                }
                continue;
            }

            // it is not a header or body part... verify encrypted xpath elements
            String xpath = encPart.getXpath();
            boolean found = false;
            try {
                XPath xp = new AXIOMXPath(xpath);
                Iterator nsIter = namespaces.iterator();

                while (nsIter.hasNext()) {
                    OMNamespace tmpNs = (OMNamespace) nsIter.next();
                    xp.addNamespace(tmpNs.getPrefix(), tmpNs.getNamespaceURI());
                }

                Iterator nodesIterator = xp.selectNodes(envelope).iterator();

                while (nodesIterator.hasNext()) {
                    Object result = decryptedElements.get(nodesIterator.next());
                    if (result != null &&
                            ("Element".equals(encPart.getEncModifier())
View Full Code Here

        Iterator elementsIter = elements.iterator();
        while (elementsIter.hasNext())
        {
                String expression = (String)elementsIter.next();
                try {
                                XPath xp = new AXIOMXPath(expression);
                                Iterator nsIter = namespaces.iterator();
                               
                                while (nsIter.hasNext())
                                {
                                        OMNamespace tmpNs = (OMNamespace)nsIter.next();
                                        xp.addNamespace(tmpNs.getPrefix(), tmpNs.getNamespaceURI());
                                }
                               
                                List selectedNodes = xp.selectNodes(envelope);
                               
                                Iterator nodesIter = selectedNodes.iterator();
                               
                            while (nodesIter.hasNext())
                            {
View Full Code Here

        Iterator elementsIter = elements.iterator();
        while (elementsIter.hasNext())
        {
          String expression = (String)elementsIter.next();
          try {
        XPath xp = new AXIOMXPath(expression);
        Iterator nsIter = namespaces.iterator();
       
        while (nsIter.hasNext())
        {
          OMNamespace tmpNs = (OMNamespace)nsIter.next();
          xp.addNamespace(tmpNs.getPrefix(), tmpNs.getNamespaceURI());
        }
       
        List selectedNodes = xp.selectNodes(envelope);
       
        Iterator nodesIter = selectedNodes.iterator();
          while (nodesIter.hasNext())
          {
            OMElement e = (OMElement)nodesIter.next();
View Full Code Here

        SOAPHeader header = envelope.getHeader();
       
        Set namespaces = findAllPrefixNamespaces(header, decNamespaces);

        try {
                        XPath xp = new AXIOMXPath(expression);
                        Iterator nsIter = namespaces.iterator();
                       
                        while (nsIter.hasNext())
                        {
                                OMNamespace tmpNs = (OMNamespace)nsIter.next();
                                xp.addNamespace(tmpNs.getPrefix(), tmpNs.getNamespaceURI());
                        }
                       
                        List selectedNodes = xp.selectNodes(header);
                       
                        if (selectedNodes.size() == 0 ) {
                            return false;
                        }
               
View Full Code Here

            xpathString = (String)arg;
        else
            xpathString = StringFunction.evaluate(arg, nav);

        try {
            XPath xpath = nav.parseXPath(xpathString);
            ContextSupport support = context.getContextSupport();
            xpath.setVariableContext( support.getVariableContext() );
            xpath.setFunctionContext( support.getFunctionContext() );
            xpath.setNamespaceContext( support.getNamespaceContext() );
            return xpath.selectNodes( context.duplicate() );
        }
        catch ( SAXPathException e ) {
            throw new FunctionCallException(e.toString());
        }
    }
View Full Code Here

                nsContext.addNamespace(NAMESPACE_PREFIX,
                                       root.getNamespaceURI());

                // Grab the message-store element to allow extraction of the
                // various attributes
                XPath xpath = new JDOMXPath("//" +
                                            NAMESPACE_PREFIX + ":" +
                                            MSS_CONFIG_MESSAGESTORE_ELEMENT);
                xpath.setNamespaceContext(nsContext);

                Element element = (Element) xpath.selectSingleNode(root);

                // Location
                config.setLocation(element.getAttributeValue(
                        MSS_CONFIG_LOCATION_ATTRIBUTE));

                // ID Size
                config.setIdSize(Integer.parseInt(element.getAttributeValue(
                        MSS_CONFIG_IDSIZE_ATTRIBUTE)));

                // Timeout
                String timeout = element.getAttributeValue(
                        MSS_CONFIG_TIMEOUT_ATTRIBUTE);
                if (timeout.equalsIgnoreCase(UNLIMITED)) {
                    config.setUnlimitedTimeout(true);
                } else {
                    config.setTimeout(Integer.parseInt(timeout));
                }

                // Validation
                String validate = element.getAttributeValue(
                        MSS_CONFIG_VALIDATE_ATTRIBUTE);
                config.setValidate(validate.equals("true"));

                // Get the environment element and extract the log4j attribute
                xpath = new JDOMXPath("//" +
                                      NAMESPACE_PREFIX + ":" +
                                      MSS_CONFIG_ENVIRONMENT_ELEMENT);
                xpath.setNamespaceContext(nsContext);

                element = (Element) xpath.selectSingleNode(root);
                config.setLog4jConfigurationFile(
                        element.getAttributeValue(MSS_CONFIG_LOG4J_ATTRIBUTE));
            } else {
                handleConfigError(null);
            }
View Full Code Here

        throw new AssertionError("UNREACHABLE");
    }

    public List evaluate(OExpression cexp, EvaluationContext ctx) throws FaultException, EvaluationException {
        try {
            XPath compiledXPath = compile((OXPath10Expression) cexp);
            Context context = createContext((OXPath10Expression) cexp, ctx);

            List retVal = compiledXPath.selectNodes(context);

            if ((retVal.size() == 1) && !(retVal.get(0) instanceof Node)) {
                Document d = DOMUtils.newDocument();
                // Giving our node a parent just in case it's an LValue
                // expression
View Full Code Here

        return jctx;
    }

    private XPath compile(OXPath10Expression exp) throws JaxenException {
        XPath xpath = _compiledExpressions.get(exp.xpath);
        if (xpath == null) {
            xpath = new DOMXPath(exp.xpath);
            synchronized (_compiledExpressions) {
                _compiledExpressions.put(exp.xpath, xpath);
            }
View Full Code Here

        Iterator elementsIter = elements.iterator();
        while (elementsIter.hasNext())
        {
                String expression = (String)elementsIter.next();
                try {
                                XPath xp = new AXIOMXPath(expression);
                                Iterator nsIter = namespaces.iterator();
                               
                                while (nsIter.hasNext())
                                {
                                        OMNamespace tmpNs = (OMNamespace)nsIter.next();
                                        xp.addNamespace(tmpNs.getPrefix(), tmpNs.getNamespaceURI());
                                }
                               
                                List selectedNodes = xp.selectNodes(envelope);
                               
                                Iterator nodesIter = selectedNodes.iterator();
                               
                            while (nodesIter.hasNext())
                            {
View Full Code Here

TOP

Related Classes of org.jaxen.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.