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.
- Uses a xslt style sheet that needs to be added to the project that corresponds with the xml schema that is being uploaded.
- Current xslt style sheet is written to exact NAS fields from a given NAS xml file.
- 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.
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.
Listed are the steps for using the plug in
- Make sure you are connected to the internet.
- Select 'File' -> 'Load' from the menu bar.
- Load the xml file, select format 'XML File' from the format seletor pop up window.
- If the file loaded successfully, Select 'Data Preparation' -> 'Extract NAS fields from XML' from the Menu.
- View the resulted csv file.