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

Part 3 Other Application Developments> Chapter 12 XML Conversion Function> 12.5 Designing Applications> 12.5.2 Processing Procedure of Applications that Use the XML Conversion Function

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]

  1. Create CSVSource object.
    Create the CSVSource object from the specified CSV file name.

  2. Set CSV file information
    Specify the following items for the created CSVSource object:

    1. 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.

    2. 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 (,).

    3. 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.

    4. 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.

    5. 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).

    6. 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.

    7. 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

  3. Create CSVResultSet object
    Obtain CSVResultSet from the created CSVSource object.

  4. Create GeneratorMap object
    Specify a mapping rules file and create the GeneratorMap object.

  5. Create XMLGenerator object
    Create the XMLGenerator object.

  6. 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.

  7. 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.

  8. Output XML documentsInvoke the document extraction method for the DocumentFountain object, getXMLDocument(). Receive the XML documents in one of the following formats:

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.

Contents Index PreviousNext

All Rights Reserved, Copyright(C) FUJITSU LIMITED 2006