Interstage Shunsaku Data Manager Application Development Guide - Microsoft(R) Windows(R) 2000/ Microsoft(R) Windows Server(TM) 2003 - - UNIX -
|
Contents
Index

|
12.5.2.2 Procedure for Converting Data in a CSV File to an XML Document
The following figure shows the procedure used to convert data in a CSV file to an XML document.
[Figure 12-9 Procedure Used to Convert CSV File Data to XML Format]

- Create CSVSource object.
Create the CSVSource object from the specified CSV file name.
- Set CSV file information
Specify the following items for the created CSVSource object:
- Character code setting
Read the CSV file according to the specified character code and convert the content of the read CSV file to String type.
If the character code is not specified, the default code of the system will be assumed by default.
- Delimiter setting
Set the delimiter used within the CSV file.
A comma (,), a tab (\t) and a blank space ( ) can be specified.
The default is the comma (,).
- Quotation mark character setting
Set the quotation mark character used within the CSV file.
The single quote (\') and the double quotes (\") can be specified.
By default, no quotation mark character is specified.
- Setting the method for entering delimiters, quotation marks, and "\" as data
Set the method used to enter delimiter characters, quotation marks, and the backslash (\) as data. The default is to add a backslash (\) before each of the characters.
- Null character setting
Set the character that will be used within the CSV file to express a null value.
All the string characters that can be displayed except the blank space can be specified.
The default value is "" (blank character).
- Column name setting
Specify if the first row of a CSV file should be processed as the column name. By default, the first row is not designated as the column name.
- Data retention method setting
Set the method used to maintain data in CSVResultSet.
Either of the following two methods can be selected:
- Sequential reading
Memory consumption is small, but performance may be poor in some situations.
- Memory loading
Performance is good, but a large amount of memory may be consumed.
The default method is sequential reading
- Create CSVResultSet object
Obtain CSVResultSet from the created CSVSource object.
- Create GeneratorMap object
Specify a mapping rules file and create the GeneratorMap object.
- Create XMLGenerator object
Create the XMLGenerator object.
- Create DocumentFountain object
Invoke the document creation method for the XMLGenerator object, createDocumentFountain(). When doing so, specify the ResultSet object and the GeneratorMap object, the output format, and the information needed for the output format. This will cause the DocumentFountain object to be created and returned to the application. Note that the output format of the XML documents extracted from the DocumentFountain object is determined at this time.
- Set character code used during output
Invoke the character code setting method for the DocumentFountain object, setCode(), from the application. Specify the character code of the XML documents to be created.
When no character code is specified, the use of UTF-8 is assumed by default.
- Output XML documentsInvoke the document extraction method for the DocumentFountain object, getXMLDocument(). Receive the XML documents in one of the following formats:
- String
- Stream
- File
- DOM tree
- SAX
More than one set of XML documents can be created from a single ResultSet object by invoking the document extraction method, getXMLDocument(), more than once. The XML documents will be created and returned to the application in sequence.

Refer to 12.8 CSV Formats Supported by the XML Conversion Function for the CSV formats that are supported by the XML conversion function.
All Rights Reserved, Copyright(C) FUJITSU LIMITED 2006