1
votes

I'm trying to do what i think should be a very simple task.

In a mule flow, read in an xml file, add a xml element at a particular location. and then write the xml to another file.

XSLT would be a pretty good tool here, however for my test i'm trying to avoid using xslt. I've thought about using a java or groovy transformer and a XML parser to do this and i can fall back on that if needed. however the simplest approach that i can think of XML-to-maps, then a script to update the value then maps-to-xml returns a completely empty record.

How can i do this without using xslt and preferably not using jaxb or another xml parser outside of what's built into mule?

EDIT: I've played with the data mapper a bit, but for xml-xml mapping it requires a schema, and i won't know this at run time

1
Can you share the failing config? The one that does "XML-to-maps, then a script to update the value then maps-to-xml returns a completely empty record". - David Dossot
Have you taken a look at XML slurper that-s built in on groovy for this? - Juan Alberto López Cavallotti

1 Answers

0
votes

The simplest approach will be XSLT, for example http://bushorn.com/xml-to-xml-transformation-in-mule/
But however if you want to avoid XSLT for any reason, yes, Groovy will be good enough XML Mapping in Mule
http://www.sixtree.com.au/articles/2013/data-mapping-with-groovy-part-1/
Custom Java class will also help you to do this