Package org.apache.synapse.mediators.transform

Examples of org.apache.synapse.mediators.transform.TransformMediator


        return LOG_Q;
    }

    public Mediator createMediator(OMElement elem) {

        TransformMediator transformMediator = new TransformMediator();

        OMAttribute attXslt   = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "xslt"));
        OMAttribute attXQuery = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "xquery"));
        OMAttribute attSource = elem.getAttribute(new QName(Constants.NULL_NAMESPACE, "source"));

        if (attXslt != null) {
            try {
                transformMediator.setXsltUrl(new URL(attXslt.getAttributeValue()));
            } catch (MalformedURLException e) {
                String msg = "Invalid URL specified for the xslt attribute : " + attXslt.getAttributeValue();
                log.error(msg);
                throw new SynapseException(msg);
            }

        } else  if (attXQuery != null) {
            try {
                transformMediator.setXQueryUrl(new URL(attXQuery.getAttributeValue()));
            } catch (MalformedURLException e) {
                String msg = "Invalid URL specified for the xquery attribute : " + attXQuery.getAttributeValue();
                log.error(msg);
                throw new SynapseException(msg);
            }

        } else {
            String msg = "The 'xslt' or 'xquery' attributes are required for the Transform mediator";
            log.error(msg);
            throw new SynapseException(msg);
        }

        if (attSource != null) {
            try {
                AXIOMXPath xp = new AXIOMXPath(attSource.getAttributeValue());
                Util.addNameSpaces(xp, elem, log);
                transformMediator.setSource(xp);

            } catch (JaxenException e) {
                String msg = "Invalid XPath specified for the source attribute : " + attSource.getAttributeValue();
                log.error(msg);
                throw new SynapseException(msg);
            }
        }

        transformMediator.addAllProperties(MediatorPropertyFactory.getMediatorProperties(elem));

        return transformMediator;
    }
View Full Code Here


    TransformMediator transformMediator = null;

    public void testTransformXSLTCustomSource() throws Exception {

        // create a new switch mediator
        transformMediator = new TransformMediator();

        // set xpath condition to select source
        AXIOMXPath xpath = new AXIOMXPath("//m0:CheckPriceRequest");
        xpath.addNamespace("m0", "http://www.apache-synapse.org/test");
        transformMediator.setSource(xpath);
View Full Code Here

     * @throws Exception
     */
    public void testTransformXSLTDefaultSource() throws Exception {

        // create a new switch mediator
        transformMediator = new TransformMediator();

        // set XSLT transformation URL
        transformMediator.setXsltUrl(
            new URL("file:///" + new File(".").getAbsolutePath() + "/../core/test-resources/misc/transform.xslt"));

View Full Code Here

    }

    public void testTransformXSLTCustomSourceNonMainElement() throws Exception {

        // create a new switch mediator
        transformMediator = new TransformMediator();

        // set xpath condition to select source
        AXIOMXPath xpath = new AXIOMXPath("//m0:CheckPriceRequest");
        xpath.addNamespace("m0", "http://www.apache-synapse.org/test");
        transformMediator.setSource(xpath);
View Full Code Here

TOP

Related Classes of org.apache.synapse.mediators.transform.TransformMediator

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.