XML: Read From XML File

The Read From XML File adapter reads Rows from an XML file.

Property Name (screen)

Property Name (Attach Adapter)

Type

Description

Filename

Filename

String

The name and path of the XML file to read data from. You can specify a file name and path either by typing it in or by clicking on the Browse button for this field. By default, the path is relative to the server's adapters base folder and must be underneath that base folder, but you can use $ProjectFolder to specify a path relative to the current project folder. For more information, see Setting The Base Folder For File Input/Output Adapters. For details about the Browse and Edit buttons to the right of the filename, see the discussion following this table.

Loop Count

LoopCount

Integer Min: 0 Max: 2000000000 Default: 1

If the Loop Count is 1, the file is read only once and the adapter stops sending data once the end of file is reached. If the Loop Count is greater than 1, then the data will be sent the specified number of times after the adapter finishes reading the file, the adapter starts reading again from the beginning. If the Loop Count is 0, the adapter repeats indefinitely.

Rate

Rate

Float Min: 0.0000001 (if set to a number greater than zero)

If this property is non-zero, then the adapter reads data from the input file at the specified rate (per second). Any row timestamps in the input file are ignored. The default is to leave this unset, in which case the row timestamp determines when each row is sent.

Timestamp Base

TimestampBase

Timestamp

The point at which time "starts" for this adapter, relative to the file's first timestamp. For example, if Timestamp base is 0 and the first row's timestamp is 5000000 (in microseconds), the first row is sent 5 seconds (5000000 microseconds) after the module starts. If blank, the first row is sent immediately after the module starts.

Set Timestamp To Current Time

UseCurrentTimestamp

Boolean

If set to true, the adapter overrides the row timestamp specified in the file with the current system time. Defaults to false.

Note: Each input stream has a property (see the stream's Properties tab in Studio) that can specify whether to use the current server timestamp value instead of the row timestamp set by the adapter. If this stream property is set to true, it overrides any row timestamp set by the adapter.

A sample XML file with two rows is shown below:

<Tuple xmlns="http://www.sybase.com/cpx/2004/03/"
 Timestamp="946713600000001">
   <Field Name="ID">1</Field>
   <Field Name="BandName">Soft White Underbelly</Field>
</Tuple>
<Tuple xmlns="http://www.sybase.com/cpx/2004/03/"
 Timestamp="946713600000002">
   <Field Name="ID">2</Field>
   <Field Name="BandName">The Quarrymen</Field>
</Tuple>

The "http://www.sybase.com/cpx/2004/03/" part of the first line in each tuple should always be the same. Do not change the date.

The first tuple (row) is shown in lines 1-4, and the second tuple (row) is shown in lines 5-8.

The first line of each tuple contains the row timestamp, formatted as the number of microseconds since midnight January 1, 1970.

Lines two to three contain the field values for one row and lines 6-7 contain the field values for a separate row. Note also that the XML file is not necessarily formatted as shown in the example above because the usual format is more difficult to read.

Note: The values and column names are specified but the data types are not. The data must be appropriate for the data type of the column.

The ReadFromXMLFile adapter always has a 3-second startup delay before the first row is sent. If looping is used, the 3-second delay occurs only on the first iteration of the loop, not subsequent iterations.

Unless specified otherwise, the format of TIMESTAMP values, including the row timestamp, inside the file is a 64-bit signed integer representing the number of microseconds since the beginning of the epoch (midnight January 1, 1970 UTC/GMT). Unless you've specified otherwise for TIMESTAMP values, do not use formats such as "2007-01-09 12:30:34.567891 PDT" in the CSV file. For more information, see Reading, Writing, and Converting Timestamps.

The format of INTERVAL values inside the file may be any of the acceptable formats for INTERVAL values, including:

For a complete list of valid formats for INTERVAL values, see "INTERVAL Literals" in the Sybase CEP CCL Reference Guide .

Note:

Although CCL statements require the keyword INTERVAL prior to the value for some of these forms, no INTERVAL keyword is required when using such values in CSV or XML files.

The Adapter Properties screen in Sybase CEP Studio allows you to specify an input path and file name for the file by clicking the Browse button and identifying the file. The path is relative to the adapters base folder, either as specified for Sybase CEP Server running on the same computer as Sybase CEP Studio, or as specified in the preferences for Sybase CEP Studio. For more information, see Setting The Base Folder For File Input/Output Adapters. In order for this feature to work properly, make sure that the Adapter's Base Folder field in Sybase CEP Studio Settings is set to the same folder as the adapters base folder for Sybase CEP Server. The Base Folder setting for the Sybase CEP Server is specified during the installation process, and can also be changed in the Sybase CEP Server's c8-server.conf file. The base folder setting for Sybase CEP Studio can be set from the Tools->Settings command on the Sybase CEP Studio menu.

The Edit button opens an editor that will allow you to edit any file whose name you enter into the filename field. This allows you to correct errors in the data. If the file's extension is "csv" or "xml", Sybase CEP Studio opens the appropriate editor specified in the "External Tools" tab available from the menu item "Tools -> Settings". For files with other extensions, on Microsoft Windows the editor is the one specified by the operating system's file associations. On UNIX-like operating systems, Sybase CEP Studio opens the editor specified by the EDITOR environment variable.

Note:

When you click the Edit button, Sybase CEP Studio will look for the file in the SybaseC8Repository, even if the adapters base folder is set to another location. You may need to use the Browse button (adjacent to the Edit button) to navigate to the desired directory before you try to edit the file.