title: How to transform XML with XSL using Java
body: <p>I am currently using the standard javax.xml.transform library to transform my XML to CSV using XSL.  My XSL file is large - at around 950 lines.  My XML files can be quite large also.</p>
  
  <p>It was working fine in the prototype stage with a fraction of the XSL in place at around 50 lines or so.  Now in the 'final system' when it performs the transform it comes up with the error <strong>Branch target offset too large for short</strong>.</p>
  
  <pre><code>private String transformXML() {
      String formattedOutput = "";
      try {
  
          TransformerFactory tFactory = TransformerFactory.newInstance();            
          Transformer transformer =
                  tFactory.newTransformer( new StreamSource( xslFilename ) );
  
          StreamSource xmlSource = new StreamSource(new ByteArrayInputStream( xmlString.getBytes() ) );
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          transformer.transform( xmlSource, new StreamResult( baos ) );
  
          formattedOutput = baos.toString();
  
      } catch( Exception e ) {
          e.printStackTrace();
      }
  
      return formattedOutput;
  }
  </code></pre>
  
  <p>I came across a few postings on this error but not too sure what to do.<br>
  Am I doing anything wrong code wise?
  Are there any alternative 3rd Party transformers available that could do this?</p>
  
  <p>Thanks,</p>
  
  <p>Andez</p>