de.julielab.xml.JulieXMLToolsCLIRecords Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of julie-xml-tools Show documentation
Show all versions of julie-xml-tools Show documentation
Reads XML using the VTD parser.
package de.julielab.xml;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
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.");
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");
List