I am trying to ‘serialize’ an XML document to pass it’s contents as an arg to an external web service. I thought it would be straightforward with CTL2 using a RegEx, but have not been successful thus far. Here is how I am attempting to do it:
Your solution seems to be correct, there has to be only a minor change required. Here’s my suggestion:
I would use the UniversalDataReader to read the whole imput XML into single field of single record. This requires the output edge metadata to be properly configured: Create metadata with single field and clear value of the “Record delimiter” record metadata property. Also set the “EOF as delimiter” property of the single metadata field to true.
Then use the Reformatter with replace function to strip the new line characters…
Attached is a demo graph which strips the new lines of the read XML and prints the result into the log using the Trash component.
just one note - you need to be careful about the size of the XML. The whole XML content needs to fit into the edges, so the size is limited by the Record.MAX_RECORD_SIZE property, see documentation here. The current default of MAX_RECORD_SIZE is 64KB, so you might need to modify it depending on your data - however, increasing the value increases memory consumption of the graph.
In CloverETL 3.2 we’ll have edges that can “grow” dynamically as needed, so they’ll be more suitable to transport large data in each record. They’ll have a default maximum size of 32MB.