Package org.apache.axiom.om.xpath

Examples of org.apache.axiom.om.xpath.AXIOMXPath


        // set the schema url, source xpath and any name spaces
        List keys = new ArrayList();
        keys.add("xsd-key-1");
        validate.setSchemaKeys(keys);
        AXIOMXPath source = new AXIOMXPath("//m0:CheckPriceRequest");
        source.addNamespace("m0", "http://www.apache-synapse.org/test");
        validate.setSource(source);

        // set dummy mediator to be called on fail
        validate.addChild(testMediator);
View Full Code Here


        // set the schema url, source xpath and any name spaces
        List keys = new ArrayList();
        keys.add("xsd-key-1");
        validate.setSchemaKeys(keys);
        AXIOMXPath source = new AXIOMXPath("//m0:CheckPriceRequest");
        source.addNamespace("m0", "http://www.apache-synapse.org/test");
        validate.setSource(source);

        // set dummy mediator to be called on fail
        validate.addChild(testMediator);
View Full Code Here

        // set the schema url, source xpath and any name spaces
        List keys = new ArrayList();
        keys.add("xsd-key-1");
        validate.setSchemaKeys(keys);
        AXIOMXPath source = new AXIOMXPath("//m0:CheckPriceRequest");
        source.addNamespace("m0", "http://www.apache-synapse.org/test");
        validate.setSource(source);

        // set dummy mediator to be called on fail
        validate.removeChild(0);
        validate.addChild(testMediator);
View Full Code Here

        }

        saveTracingState(xquery, queryMediator);

        AXIOMXPath targetXPath = queryMediator.getTarget();
        if (targetXPath != null &&
            !XQueryMediator.DEFAULT_XPATH.toString().equals(targetXPath.toString())) {
            xquery.addAttribute(fac.createOMAttribute(
                "target", nullNS, targetXPath.toString()));
            serializeNamespaces(xquery, targetXPath);
        }

        List pros = queryMediator.getDataSourceProperties();
        if (pros != null && !pros.isEmpty()) {
            OMElement dataSource = fac.createOMElement("dataSource", synNS);
            serializeProperties(dataSource, pros);
            xquery.addChild(dataSource);
        }

        List list = queryMediator.getVariables();
        if (list != null && !list.isEmpty()) {
            for (int i = 0; i < list.size(); i++) {
                Object o = list.get(i);
                if (o instanceof MediatorBaseVariable) {
                    MediatorBaseVariable variable = (MediatorBaseVariable) o;
                    QName name = variable.getName();
                    Object value = variable.getValue();
                    if (name != null && value != null) {
                        OMElement baseElement = fac.createOMElement("variable", synNS);
                        baseElement.addAttribute(fac.createOMAttribute(
                            "name", nullNS, name.getLocalPart()));
                        baseElement.addAttribute(fac.createOMAttribute(
                            "value", nullNS, (String) value));
                        String type = null;
                        int varibelType = variable.getType();
                        if (XQItemType.XQBASETYPE_INT == varibelType) {
                            type = "INT";
                        } else if (XQItemType.XQBASETYPE_INTEGER == varibelType) {
                            type = "INTEGER";
                        } else if (XQItemType.XQBASETYPE_BOOLEAN == varibelType) {
                            type = "BOOLEAN";
                        } else if (XQItemType.XQBASETYPE_BYTE == varibelType) {
                            type = "BYTE";
                        } else if (XQItemType.XQBASETYPE_DOUBLE == varibelType) {
                            type = "DOUBLE";
                        } else if (XQItemType.XQBASETYPE_SHORT == varibelType) {
                            type = "SHORT";
                        } else if (XQItemType.XQBASETYPE_LONG == varibelType) {
                            type = "LONG";
                        } else if (XQItemType.XQBASETYPE_FLOAT == varibelType) {
                            type = "FLOAT";
                        } else if (XQItemType.XQBASETYPE_STRING == varibelType) {
                            type = "STRING";
                        } else if (XQItemType.XQITEMKIND_DOCUMENT == varibelType) {
                            type = "DOCUMENT";
                        } else if (XQItemType.XQITEMKIND_DOCUMENT_ELEMENT == varibelType) {
                            type = "DOCUMENT_ELEMENT";
                        } else if (XQItemType.XQITEMKIND_ELEMENT == varibelType) {
                            type = "ELEMENT";
                        } else {
                            handleException("Unknown Type " + varibelType);
                        }
                        if (type != null) {
                            baseElement.addAttribute(fac.createOMAttribute(
                                "type", nullNS, type));

                        }
                        xquery.addChild(baseElement);
                    }
                } else if (o instanceof MediatorCustomVariable) {
                    MediatorCustomVariable variable = (MediatorCustomVariable) o;
                    QName name = variable.getName();
                    if (name != null) {
                        OMElement customElement = fac.createOMElement("variable", synNS);
                        customElement.addAttribute(fac.createOMAttribute(
                            "name", nullNS, name.getLocalPart()));
                        String regkey = variable.getRegKey();
                        if (regkey != null) {
                            customElement.addAttribute(fac.createOMAttribute(
                                "key", nullNS, regkey));
                        }
                        AXIOMXPath expression = variable.getExpression();
                        if (expression != null && !XQueryMediator.DEFAULT_XPATH.toString().
                            equals(expression.toString())) {
                            customElement.addAttribute(fac.createOMAttribute(
                                "expression", nullNS, expression.toString()));
                            serializeNamespaces(customElement, expression);
                        }
                        String type = null;
                        int varibelType = variable.getType();
                        if (XQItemType.XQITEMKIND_DOCUMENT == varibelType) {
View Full Code Here

    public MediatorCustomVariable(QName name) {
        super(name);
        // create the default XPath
        try {
            this.expression = new AXIOMXPath(DEFAULT_XPATH);
            this.expression.addNamespace("s11", SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
            this.expression.addNamespace("s12", SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
        } catch (JaxenException e) {
            handleException("Error creating source XPath expression", e);
        }
View Full Code Here

        "s12:Body/child::*[position()=1]";
   
    public ValidateMediator() {
        // create the default XPath
        try {
            this.source = new AXIOMXPath(DEFAULT_XPATH);
            this.source.addNamespace("s11", SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI);
            this.source.addNamespace("s12", SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);
        } catch (JaxenException e) {
            String msg = "Error creating default source XPath expression : " + DEFAULT_XPATH;
            log.error(msg, e);
View Full Code Here

        }
        if (attrTarget != null) {
            String targetValue = attrTarget.getAttributeValue();
            if (targetValue != null) {
                try {
                    AXIOMXPath xp = new AXIOMXPath(targetValue.trim());
                    OMElementUtils.addNameSpaces(xp, elem, log);
                    xQueryMediator.setTarget(xp);
                } catch (JaxenException e) {
                    handleException("Invalid XPath specified for the target attribute : " +
                        targetValue);
                }
            }
        }
        // after successfully creating the mediator
        // set its common attributes such as tracing etc
        processTraceState(xQueryMediator, elem);
        OMElement dataSource = elem.getFirstChildWithName(
            new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "dataSource"));
        if (dataSource != null) {
            xQueryMediator.addAllDataSoureProperties(
                MediatorPropertyFactory.getMediatorProperties(dataSource));
        }

        Iterator it = elem.getChildrenWithName(new QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "variable"));
        while (it.hasNext()) {
            OMElement variableOM = (OMElement) it.next();
            String name = variableOM.getAttributeValue(ATT_NAME_Q);
            if (name != null && !"".equals(name)) {
                String type = variableOM.getAttributeValue(ATT_TYPE_Q);
                if (type != null && !"".equals(type)) {
                    String value = variableOM.getAttributeValue(ATT_VALUE_Q);
                    MediatorVariable variable;
                    if (value != null && !"".equals(value)) {
                        variable = new MediatorBaseVariable(
                            new QName(name.trim()));
                        variable.setValue(value.trim());
                    } else {
                        String key = variableOM.getAttributeValue(ATT_KEY_Q);
                        String expr = variableOM.getAttributeValue(ATT_EXPR_Q);
                        variable = new MediatorCustomVariable(
                            new QName(name.trim()));
                        if (key != null) {
                            ((MediatorCustomVariable) variable).setRegKey(key.trim());
                        }
                        if (expr != null && !"".equals(expr)) {
                            try {
                                AXIOMXPath xp = new AXIOMXPath(expr.trim());
                                OMElementUtils.addNameSpaces(xp, variableOM, log);
                                ((MediatorCustomVariable) variable).setExpression(xp);

                            } catch (JaxenException e) {
                                handleException("Invalid XPath specified for" +
View Full Code Here

            pojoCommand.addChild(prop);
        }

        for (Iterator itr = mediator.getDynamicProps().keySet().iterator(); itr.hasNext(); ) {
            String propName = (String) itr.next();
            AXIOMXPath exprn = (AXIOMXPath) mediator.getDynamicProps().get(propName);
            OMElement prop = fac.createOMElement(PROP_Q);
            prop.addAttribute(fac.createOMAttribute("name", nullNS, propName));
            prop.addAttribute(fac.createOMAttribute("expression", nullNS,
                exprn.toString()));
            serializeNamespaces(prop, exprn);
            pojoCommand.addChild(prop);
        }

        if (parent != null) {
View Full Code Here

        if (value != null && value.getAttributeValue() != null) {
            headerMediator.setValue(value.getAttributeValue());

        } else if (exprn != null && exprn.getAttributeValue() != null) {
            try {
                AXIOMXPath xp = new AXIOMXPath(exprn.getAttributeValue());
                OMElementUtils.addNameSpaces(xp, elem, log);
                headerMediator.setExpression(xp);
            } catch (JaxenException je) {
                String msg = "Invalid XPath expression : " + exprn.getAttributeValue();
                log.error(msg);
View Full Code Here

        // now set the any dynamic properties evaluating XPath's on the current message
        for (Iterator iter = dynamicProps.keySet().iterator(); iter.hasNext(); ) {

            String name = (String) iter.next();
            AXIOMXPath xpath = (AXIOMXPath) dynamicProps.get(name);
            String value = Axis2MessageContext.getStringValue(xpath, synCtx);

            setInstanceProperty(name, value, commandObject, synCtx);
        }
View Full Code Here

TOP

Related Classes of org.apache.axiom.om.xpath.AXIOMXPath

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.