<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesource.org/schema/mule/core/2.0"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:spring="http://www.springframework.org/schema/beans"
       xmlns:mxml="http://www.mulesource.org/schema/mule/xml/2.0"
       xmlns:vm="http://www.mulesource.org/schema/mule/vm/2.0"
    xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       http://www.mulesource.org/schema/mule/core/2.0 http://www.mulesource.org/schema/mule/core/2.0/mule.xsd
       http://www.mulesource.org/schema/mule/xml/2.0 http://www.mulesource.org/schema/mule/xml/2.0/mule-xml.xsd
       http://www.mulesource.org/schema/mule/vm/2.0 http://www.mulesource.org/schema/mule/vm/2.0/mule-vm.xsd">

    <vm:connector name="default">
        <custom-exception-strategy class="org.mule.module.xml.functional.HideExceptions"/>
    </vm:connector>

    <vm:connector name="queue" queueEvents="true">
        <custom-exception-strategy class="org.mule.module.xml.functional.HideExceptions"/>
    </vm:connector>

    <mxml:dom-to-xml-transformer name="domToXml"/>
    <mxml:xml-to-dom-transformer name="xmlToDom" returnClass="org.w3c.dom.Document"/>

    <mxml:jxpath-extractor-transformer name="jxpath" expression="count(//parent)"/>

    <mxml:object-to-xml-transformer name="objectToXml"/>
    <mxml:xml-to-object-transformer name="xmlToObject"/>

    <mxml:xslt-transformer name="xslt" returnClass="org.dom4j.Document">
        <mxml:xslt-text>
        <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
            <!-- test for this string in test -->
            <!-- Whenever you match any node or any attribute -->
            <xsl:template match="node()|@*">
                <!-- Copy the current node -->
                <xsl:copy>
                    <!-- don't copy inner contents -->
                </xsl:copy>
            </xsl:template>
        </xsl:stylesheet>
        </mxml:xslt-text>
    </mxml:xslt-transformer>

    <mxml:xslt-transformer name="xslt-string" returnClass="java.lang.String">
        <mxml:xslt-text>
        <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
            <!-- test for this string in test -->
            <!-- Whenever you match any node or any attribute -->
            <xsl:template match="node()|@*">
                <!-- Copy the current node -->
                <xsl:copy>
                    <!-- don't copy inner contents -->
                </xsl:copy>
            </xsl:template>
        </xsl:stylesheet>
        </mxml:xslt-text>
    </mxml:xslt-transformer>

    <endpoint name="xml-in" address="vm://xml-in" connector-ref="default"/>
    <vm:endpoint name="object-in" path="object-in" connector-ref="default"/>
    <endpoint name="object-in-2" address="vm://object-in-2" connector-ref="default"/>
    <vm:endpoint name="dom-in" address="vm://dom-in" connector-ref="default" transformer-refs="xmlToDom"/>

    <endpoint name="xml-out" address="vm://xml-out" connector-ref="queue"/>
    <vm:endpoint name="xml-xslt-out" path="xml-xslt-out" connector-ref="queue"/>
    <vm:endpoint name="xml-xslt-out-string" path="xml-xslt-out-string" connector-ref="queue"/>
    <endpoint name="xml-jxpath-out" address="vm://xml-jxpath-out" connector-ref="queue"/>
    <endpoint name="xml-dom-out" address="vm://xml-dom-out" connector-ref="queue"/>
    <vm:endpoint name="xml-object-out" address="vm://xml-object-out" connector-ref="queue"/>
    <endpoint name="object-out" address="vm://object-out" connector-ref="queue"/>
    <vm:endpoint name="object-xml-out" path="object-xml-out" connector-ref="queue"/>
    <endpoint name="dom-xml-out" address="vm://dom-xml-out" connector-ref="queue"/>

    <model name="xml transformer tests">

        <service name="xml to ...">
            <inbound>
                <inbound-endpoint ref="xml-in"/>
                <forwarding-router/>
            </inbound>
            <outbound>
                <multicasting-router>
                    <outbound-endpoint ref="xml-out" address="vm://xml-out" connector-ref="queue"/>
                    <vm:outbound-endpoint ref="xml-xslt-out" transformer-refs="xslt"/>
                    <vm:outbound-endpoint ref="xml-xslt-out-string" transformer-refs="xslt-string"/>
                    <outbound-endpoint ref="xml-jxpath-out" transformer-refs="jxpath"/>
                    <outbound-endpoint ref="xml-dom-out" transformer-refs="xmlToDom "/>
                    <vm:outbound-endpoint ref="xml-object-out" transformer-refs="xmlToObject"/>
                    <vm:outbound-endpoint ref="dom-in"/>
                </multicasting-router>
            </outbound>
        </service>

        <service name="object to xml">
            <inbound>
                <inbound-endpoint ref="object-in"/>
                <forwarding-router/>
            </inbound>
            <outbound>
                <multicasting-router>
                    <outbound-endpoint ref="object-out"/>
                    <vm:outbound-endpoint ref="object-xml-out" transformer-refs="objectToXml"/>
                    <outbound-endpoint ref="xml-in" transformer-refs="objectToXml"/>
                </multicasting-router>
            </outbound>
        </service>

        <service name="dom to xml">
            <inbound>
                <inbound-endpoint ref="dom-in"/>
                <forwarding-router/>
            </inbound>
            <outbound>
                <multicasting-router>
                    <outbound-endpoint ref="dom-xml-out" transformer-refs="domToXml"/>
                </multicasting-router>
            </outbound>
        </service>

    </model>

</mule>
