Extensible Common Data Adapter: Writing XML Files

<< Click to Display Table of Contents >>

Navigation:  Integrating Blaze with Other Systems > Writing Data Out of s-Server > Writing to Other Destinations > File Formats for Writing >

Extensible Common Data Adapter: Writing XML Files

Previous pageReturn to chapter overviewNext page

For XML files, the Extensible Common Data Adapter takes batches of rows and maps them to XML elements, depending on the options you specify.

If no value for DATA_ELEMENTS or <col_name>_ELEMENTS or <col_name>_ATTRIBUTES is specified, then the column name is used as an element name (not an <attribute> name).  So a column named foo would be in an XML element named /batch/row/foo if no values were specified.

Sample Foreign Stream Implementing ECD Adapter to Write XML Files

The following code uses the file system for output. To write data over other input/output systems, such as IBM MQ or AMQP, you would need to specify options for these formats. See Writing to Other Destinations for more details.

CREATE OR REPLACE FOREIGN STREAM "FileWriterStream"

("recNo" INTEGER,

"ts" TIMESTAMP NOT NULL,

"accountNumber" INTEGER,

"loginSuccessful" BOOLEAN,

"sourceIP" VARCHAR(32),

"destIP" VARCHAR(32),

"customerId" INTEGER,)

SERVER "FileWriterServer"

OPTIONS

(directory

'/path/to/myfile',

formatter 'XML',

filename_date_format 'yyyy-MM-dd-HH:mm:ss',

filename_prefix 'test-',

filename_suffix '.xml',

data_elements 'data',

character_encoding 'US-ASCII',

formatter_include_rowtime 'false',

max_bytes_per_file '1073741824');

 

To actually write to a file in path/to/myfile, you need to write a pump containing an INSERT statement along the following lines:

CREATE OR REPLACE PUMP "writerPump" STARTED AS

INSERT INTO "FileWriterStream"

SELECT STREAM "MyStream";

--where "MyStream" is a currently existing stream

 

Sample Properties File to Use ECD Agent to Write XML Files

The following code uses the file system for output. To write data over other input/output systems, such as IBM MQ or AMQP, you would need to specify options for these formats. See Writing to Other Destinations for more details.

#Column types for the source stream

ROWTYPE=RecordType(INTEGER COL1,TIMESTAMP COL2, INTEGER COL3, BOOLEAN COL4, VARCHAR(32) COL5, VARCHAR(32) COL6, INTEGER COL7)

DIRECTORY=/PATH/TO/MYFILE

FORMATTER=XML

FILENAME_DATE_FORMAT=YYYY-MM-DD-HH:MM:SS

FILENAME_PREFIX=TEST-

FILENAME_SUFFIX=.XML

DATA_ELEMENTS=DATA

CHARACTER_ENCODING=US-ASCII

FORMATTER_INCLUDE_ROWTIME=FALSE

MAX_BYTES_PER_FILE=1073741824