Striim 3.9.7 documentation

XMLFormatter

Formats a writer's output as XML.

property

type

default value

notes

charset

java.lang.String

elementtuple

java.lang.String

defines the XML output

rootelement

java.lang.String

rowdelimiter

java.lang.String

\n

see Setting rowdelimiter values

For example, this variation on the PosApp sample application writes to a file using XMLFormatter:

CREATE source XMLFormatterTestSource USING FileReader (
  directory:'Samples/PosApp/appData',
  wildcard:'PosDataPreview.csv',
  blocksize: 10240,
  positionByEOF:false
)
PARSE USING DSVParser (
  header:Yes,
  trimquote:false
) OUTPUT TO XMLSource_Stream;

CREATE CQ CsvToPosData
INSERT INTO XMLTransformed_Stream
SELECT TO_STRING(data[0]),
  TO_STRING(data[1]),
  TO_DATEF(data[4],'yyyyMMddHHmmss'),
  DHOURS(TO_DATEF(data[4],'yyyyMMddHHmmss')),
  TO_DOUBLE(data[7]),
  TO_STRING(data[9])
FROM XMLSource_Stream;

CREATE TARGET XMLFormatterOut using FileWriter(
  filename:'XMLFormatterOutput')
FORMAT USING XMLFormatter (
  rootelement:'document',
  elementtuple:'MerchantName:merchantid:text=merchantname'
)
INPUT FROM XMLTransformed_Stream; 

The first lines of XMLFormatterOutput are:

<?xml version="1.0" encoding="UTF-8"?>
<document>
 <MerchantName merchantid="D6RJPwyuLXoLqQRQcOcouJ26KGxJSf6hgbu" > COMPANY 1 </MerchantName>
 <MerchantName merchantid="OFp6pKTMg26n1iiFY00M9uSqh9ZfMxMBRf1" > COMPANY 2 </MerchantName>
 <MerchantName merchantid="ljh71ujKshzWNfXMdQyN8O7vaNHlmPCCnAx" > COMPANY 3 </MerchantName>