XML File Writer Output Adapter

Introduction

The TIBCO StreamBase® XML File Writer is an embedded adapter suitable for streaming tuples to a text file formatted with XML tags.

The XML file created by this adapter does not contain a root node. Each tuple streamed by the adapter should be treated as an individual document. Input fields of type list or tuple are not supported.

Each field value can be optionally parsed for XML reserved characters such as <, >, and & in field values and XML-escaped if detected. Parsing for XML escaping incurs a performance penalty; disable this feature (the default) if you are sure your input data contains no XML reserved characters.

The adapter rolls over its output file when it reaches the size specified in the (optional) Max File Size parameter. When an output file is rolled over, the current File Name is appended with the current date, formatted as: yyyyMMddhhmmss. If an output file was already created with a particular date suffix, then subsequent log files are further appended with the suffix -0, -1, -2, and so on.

The adapter flushes writes to disk after every tuple unless Flush Interval is specified. If Flush Interval is specified, then a flush() is done asynchronously. Each flush and write to the output file is synchronized to prevent partial tuples from being written to disk.

Properties

The XML File Writer adapter is configured with the properties shown in the following table. Properties are set in the Properties view, Adapter Settings tab. In certain cases, properties can also be set in the StreamBase Server configuration file.

Property Description Default
File Name (string) The local file path. None
Use Default Charset (optional bool) Specifies whether the default Java platform character set should be used. If this check box is cleared, a valid character set name must be specified for the Character Set property. cleared
Character Set (optional string) The character set for the XML file you are writing.

Note

If you specify a non-ASCII character set such as UTF-8, remember that character mappings are not necessarily one byte to one byte in non-ASCII character sets.

The setting of the system property streambase.tuple-charset. US-ASCII if the property is not set.
TruncateFile (bool) If true, truncate log on startup. false, append
Max File Size (optional int) The maximum XML file size in bytes before roll; 0 = no roll. 0, unlimited
Buffer Size (optional int) The buffer size, which must be greater than 0; 0 = no buffer. 0, unlimited
Flush Interval (optional int) The frequency with which to force flush, in milliseconds; 0 = always flush. 0, write immediately
Escape (check box) If selected, characters in input tuples such as <, >, and & are XML encoded with &lt; &gt; &amp; respectively. If cleared, such characters are embedded in the resulting XML verbatim. cleared
Log Level Controls the level of verbosity the adapter uses to send notifications to the console. This setting can be higher than the containing application's log level. If set lower, the system log level will be used. Available values, in increasing order of verbosity, are: OFF, ERROR, WARN, INFO, DEBUG, TRACE, and ALL. INFO

XML Formatting

The XML file emitted from this adapter takes the following form for each input tuple:

<tuple>
    <FieldName1>FieldValue1</FieldName1>
    <FieldName2>FieldValue2</FieldName2>
    <FieldName3>FieldValue3</FieldName3>
    ...
</tuple>

Typechecking and Error Handling

Typechecking fails if the input tuple includes fields of type list or tuple, and if the following optional parameters are specified and do not meet the following conditions:

  • Max File Size must be greater than or equal to 0.

  • Flush Interval must be greater than or equal to 0.

  • Buffer Size must be greater than or equal to 0.

If specified and those conditions are not met, typechecking fails.

Suspend and Resume Behavior

On suspend, all tuples are written to disk and the currently open XML file is closed.

On resumption, caching is restarted. The first log message occurs at resume time + Flush Interval.