title: how to convert a csv to xml through XSLT file using Java code and Saxon-HE Saxon-HE-9.5.1-5
body: <p>I'm trying to translate this command line code (which takes a .csv file and converts to xml through an xslt file and this works) to Java code:
  java -jar saxon9he.jar -xsl:"csv2xml.xslt" flatfile=input.csv -s:dummy.xml > output.txt</p>
  
  <p>//Java Code using Saxon-HE 9.5:
  public static void transformFileUsingStyleSheet(String csvFile, String xslID)
              throws TransformerException {</p>
  
  <pre><code>    // Create a transform factory instance.
      TransformerFactory tfactory = TransformerFactory.newInstance();
  
      // Create a transformer for the stylesheet.
      Transformer transformer =
          tfactory.newTransformer(new StreamSource(xslID));
  
      // Transform the source XML to System.out.
      transformer.transform(new StreamSource(csvFile),
                            new StreamResult(new File("ConvertedCSV2XML.xml")));
  
  }
  </code></pre>
  
  <p>But I'm getting this error when calling the above java method:  <strong>SXXP0003: Error reported by XML parser: Content is not allowed in prolog</strong> like this: transformFileUsingStyleSheet("input.csv","csv2xml.xslt.xslt");</p>