The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

bromose (5) [Avatar] Offline
#1
Hi
I have had big problems with the Splitter flow. I wanted to read from a file, split and write files. But I had big problems with the writing part - I got a serialized DOM - not a xml document. Finally I found a solution, but I don't understand why I works and why I need to use a "ref" transformer and why I can not use the transformer in the flow. Could you please explain it to me - here comes my configuration file:

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" >
xmlns:file="http://www.mulesoft.org/schema/mule/file" 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" version="CE-3.3.0"
xmlnssmiliesi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
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/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd ">

<mulexml:dom-to-xml-transformer name="domToXml"/>

<flow name="SplitterFlow1" doc:name="SplitterFlow1">
<file:inbound-endpoint path="CsmilieataMuleTestDataMuleInputSplitter" >
moveToDirectory="CsmilieataMuleTestDataMuleSafeSplitter"
responseTimeout="10000" doc:name="File" fileAge="200"/>
<byte-array-to-string-transformer doc:name="Byte Array to String"/>
<splitter evaluator="xpath" expression="/order/orderitems/item" >
doc:name="Splitter" />
<transformer ref="domToXml" doc:name="Transformer Reference"/>
<logger level="INFO" doc:name="Logger"/>
<file:outbound-endpoint path="CsmilieataMuleTestDataMuleOutputSplitter" >
outputPattern="#[function:dateStamp:dd-MM-yyyy-HH.mm.ss]-#[header:OUTBOUND:MULE_CORRELATION_SEQUENCE].xml"
responseTimeout="10000" doc:name="File"></file:outbound-endpoint>
</flow>
</mule>


Best regards, Kaj Bromose
David Dossot (233) [Avatar] Offline
#2
Re: Splitter
It doesn't make sense to me, you should be able to use the "mulexml:dom-to-xml-transformer" right in the flow. What error do you get when you do so?
bromose (5) [Avatar] Offline
#3
Re: Splitter
Thank you for your answer. I tried again and i worked (see the config below). I think I got tricked because there is no graphical component for the dom-to-xml in the designer. Sorry for stealing your time for a dumb question.

I am still a beginner smilie

But I think I am starting to get the idea - Is it so that the only made graphic components in the designer for the most common transformers, but you can use the full range by doing "xml by hand"?

My new config:

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" >
xmlns:file="http://www.mulesoft.org/schema/mule/file" 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" version="CE-3.3.0"
xmlnssmiliesi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
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/xml http://www.mulesoft.org/schema/mule/xml/current/mule-xml.xsd ">

<!-- <mulexml:dom-to-xml-transformer name="domToXml"/> -->

<flow name="SplitterFlow1" doc:name="SplitterFlow1">
<file:inbound-endpoint path="CsmilieataMuleTestDataMuleInputSplitter" >
moveToDirectory="CsmilieataMuleTestDataMuleSafeSplitter"
responseTimeout="10000" doc:name="File" fileAge="200"/>
<byte-array-to-string-transformer doc:name="Byte Array to String"/>
<splitter evaluator="xpath" expression="/order/orderitems/item" >
doc:name="Splitter" />
<mulexml:dom-to-xml-transformer name="domToXml"/>
<!-- <transformer ref="domToXml" doc:name="Transformer Reference"/> -->
<logger level="INFO" doc:name="Logger"/>
<file:outbound-endpoint path="CsmilieataMuleTestDataMuleOutputSplitter" >
outputPattern="#[function:dateStamp:dd-MM-yyyy-HH.mm.ss]-#[header:OUTBOUND:MULE_CORRELATION_SEQUENCE].xml"
responseTimeout="10000" doc:name="File"></file:outbound-endpoint>
</flow>
</mule>

Best regards
Kaj Bromose
David Dossot (233) [Avatar] Offline
#4
Re: Splitter
> Is it so that the only made graphic components in the designer for the most common transformers, but you can use the full range by doing "xml by hand"?

Exactly. The Mule XML configuration is extremely rich and powerful ; it's possible that Studio will one say fully support it graphically though I doubt it as it may lead to properties panes after properties panes of text boxes to fill.

So writing the XML configuration by hand is the way to go when you want access to the full Mule ESB capacities.

This is by the way why the book covers only the XML configuration: this is what Mule ESB understands, not mflow files, and this is what gives a direct access to all the features of Mule.