Mostly continued with this question: XSLT: CSV (or flat file or plain text) in XML
So, I have XSLT from here: http://andrewjwelch.com/code/xslt/csv/csv-to-xml_v2.html
And it converts the CSV file to an XML document. This is done when used with the following command on the command line:
java -jar saxon9he.jar -xsl: csv-to-xml.csv -it: main -o: output.xml
So, now the question becomes: How do I do this in my Java code?
Now I have a code that looks like this:
TransformerFactory transformerFactory = TransformerFactory.newInstance();
StreamSource xsltSource = new StreamSource(new File("location/of/csv-to-xml.xsl"));
Transformer transformer = transformerFactory.newTransformer(xsltSource);
StringWriter stringWriter = new StringWriter();
transformer.transform(documentSource, new StreamResult(stringWriter));
String transformedDocument = stringWriter.toString().trim();
( Transformeris an instance net.sf.saxon.Controller.)
"-it: main", XSLT. , "-s".
Java. / "-it: main"? XSLT, ? XSLT "main"? Transformer.transform(), , , , ?
: , s9api saxon9he.jar, - .