de.julielab.xml.JulieXMLToolsCLIRecords Maven / Gradle / Ivy
package de.julielab.xml;
import org.apache.commons.lang3.StringUtils;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.util.*;
public class JulieXMLToolsCLIRecords {
public static void main(String[] args) {
if (args.length < 3) {
System.out
.println("Usage: "
+ JulieXMLToolsCLI.class.getName()
+ " *");
System.out.println("This tool is meant to extract particular fields of XML files representing a list of records. The result is a table where each field XPath expression is evaluated for one field.");
System.out.println("The record XPath expression must point to the list of records, i.e. typically a repeating path. The field XPath must be relative to the record XPath!");
System.out.println("If a field XPath may be evaluated multiple times, i.e. the element pointed to exists more than once (lists), all values will be concatenated with a comma by default. Set the system property de.julielab.xmltools.delim to another delimiter if required. The special value 'explode' on this property will cause the output of all combinations of all arrays elements with all other column values.");
System.exit(1);
}
String fileName = args[0];
String forEach = args[1];
String[] fieldPaths = new String[args.length - 2];
System.arraycopy(args, 2, fieldPaths, 0, fieldPaths.length);
String delimiter = System.getProperty("de.julielab.xmltools.delim");
System.out.println("Delimiter: " + delimiter);
List