Child pages
  • XML to CSV Algorithm

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

This algorithm converts a given xml file to a csv file using a corresponding xslt style sheet that resides in the project. It takes in the XML file and maps the content to a csv according to the styling information provided by xslt style sheet.

Pros & Cons

This algorithm facilitates conversion of xml file to a csv file but have the listed limitations.

  1. Uses a xslt style sheet that needs to be added to the project that corresponds with the xml schema that is being uploaded.
  2. Current xslt style sheet is written to exact NAS fields from a given NAS xml file.
  3. The csv file will be created in the same location as the xml file with the same name as the xml file except for the file extension.

This algorithm can be used to convert a xml file to a csv file using a given xslt style sheet.

Implementation Details

The algorithm takes in the input xml file and uses the existing xslt style sheet inside the XSLT folder to extract csv file. Java built in transformation library methods are used to construct the csv file using the xml & xslt files. The new csv file is then copied to the same location as the xml file.

The detail of the algorithm is shown as following,

  • XMLConverterAlgorithm class defines the functions to get the input data, extract file locations, trasform xml to csv, create the csv file , initialize logger functionality and displaying the results.
  • getCSVString method in XMLConverterAlgorithm class invokes the Transform method in javax.xml.transform.TransformerFactory package with xml file & the xslt file parameters in-order to retrieve the string containing the csv result.
  • The string obtained from the above method is then written to the file as the csv file.
Usage Hints

Listed are the steps for using the plug in

  1. Make sure you are connected to the internet.
  2. Select 'File' -> 'Load' from the menu bar.
  3. Load the xml file, select format 'XML File' from the format seletor pop up window.
  4. If the file loaded successfully, Select 'Data Preparation' -> 'Extract NAS fields from XML' from the Menu.
  5. View the resulted csv file.
See Also

Incoming Links