9
9
public class Main {
10
10
/**
11
11
* Executes the CSV to XML conversion
12
- * @param args file input and output
13
- *
12
+ * @author Daniel Apesteguia Timoner
13
+ * @param args Input file, output file and elements names.
14
14
*/
15
15
public static void main (String [] args ){
16
16
//Arg validator
@@ -24,14 +24,21 @@ public static void main(String[] args){
24
24
//Vars Initialization
25
25
String csvFile = args [0 ];
26
26
String xmlFile = args [1 ];
27
- String elementName = args [2 ];
27
+ String elementName ;
28
+ try {
29
+ elementName = args [2 ];}
30
+ catch (ArrayIndexOutOfBoundsException e ){
31
+ System .out .println ("You didn't especify any element so we will fix 'element' as parental node." );
32
+ elementName = "element" ;
33
+ }
34
+
28
35
29
36
//ArrayList of ArrayStrings Generation with CSV
30
- ArrayList <String []> elements = null ;
37
+ ArrayList <String []> elements ;
31
38
elements = new Reader ().CSVtoArrayList (csvFile );
32
39
33
40
//XML Doc Generation with ArrayList
34
- Document xmlDoc = null ;
41
+ Document xmlDoc ;
35
42
xmlDoc = new TabularToXMLConverter ().docBuilder (elements ,elementName );
36
43
TabularToXMLConverter .transformDocToFile (xmlDoc ,xmlFile );
37
44
@@ -40,7 +47,7 @@ public static void main(String[] args){
40
47
System .out .println ("File wasn't found, error: " +e );
41
48
}
42
49
catch (TransformerException e ){
43
- System .out .println ("Transformer error: " +e );;
50
+ System .out .println ("Transformer error: " +e );
44
51
}
45
52
catch (ParserConfigurationException e ) {
46
53
System .out .println ("Configuration error: " +e );
0 commit comments