0
votes

I am trying to split a xml and store it as different files. The files get stored correctly in .dat format if I dont specify anything in the File name/pattern option . But i want the files to be stored as something.xml format like a1.xml ,a2.xml ,a3.xml .

Here is the flow I am trying

            <?xml version="1.0" encoding="UTF-8"?>
            <mule
            xmlns:json="http://www.mulesoft.org/schema/mule/json"
            xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking"
            xmlns:file="http://www.mulesoft.org/schema/mule/file"
            xmlns:http="http://www.mulesoft.org/schema/mule/http"
            xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml"
            xmlns="http://www.mulesoft.org/schema/mule/core"
            xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
            xmlns:spring="http://www.springframework.org/schema/beans"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
            http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
            http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
            http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
            http://www.mulesoft.org/schema/mule/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd
            http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd
            http://www.mulesoft.org/schema/mule/json http://www.mulesoft.org/schema/mule/json/current/mule-json.xsd">
            <http:listener-config name="HTTP_Listener_Configuration" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
            <flow name="splitterprojectFlow">
            <http:listener config-ref="HTTP_Listener_Configuration" path="/splitter" allowedMethods="POST" doc:name="HTTP"/>
            <splitter expression="#[xpath('//Employee')]" doc:name="Splitter"></splitter>
            <mulexml:dom-to-xml-transformer doc:name="DOM to XML"/>
                    <file:outbound-endpoint path="src/test/resources" outputPattern=".xml" responseTimeout="10000" doc:name="File"/>
            </flow>
            </mule>
1

1 Answers

0
votes

Your outputPattern attribute is just ".xml". if you look in src/test/resources is suspect you will find a file called .xml containing the last split contents.

You need to proved an expression for the outputPattern attribute, something like:

<mulexml:dom-to-xml-transformer doc:name="DOM to XML"/>
   <file:outbound-endpoint path="src/test/resources" outputPattern="#[xpath3(&quot;//name&quot;,payload)].xml" responseTimeout="10000" doc:name="File"/>
</flow>