title: Getting "UTFDataFormatException: encoded string too long" while doing XML transform
body: <p>I am trying generate an HTML file using XML transform (I have an XSL and XML files as input). I am using the standard API (javax.xml.transform.*) from Java 8 to initialize the transformer:</p>
  
  <pre><code>    String xslFile = "my_file.xsl";
  
      // Create transformer factory
      TransformerFactory factory = TransformerFactory.newInstance();
  
      // Use the factory to create a template containing the xsl file
      Templates template = factory.newTemplates(new StreamSource(
              new FileInputStream(xslFile)));
  </code></pre>
  
  <p>When the XSL file is small, everything works fine. But when I embed a lot of javascript inside the XSL file, I get to following exception on the <code>factory.newTemplates()</code> line :</p>
  
  <pre><code>java.io.UTFDataFormatException: encoded string too long: 98793 bytes
  at java.io.DataOutputStream.writeUTF(DataOutputStream.java:364)
  at java.io.DataOutputStream.writeUTF(DataOutputStream.java:323)
  at com.sun.org.apache.bcel.internal.classfile.ConstantUtf8.dump(ConstantUtf8.java:128)
  at com.sun.org.apache.bcel.internal.classfile.ConstantPool.dump(ConstantPool.java:233)
  at com.sun.org.apache.bcel.internal.classfile.JavaClass.dump(JavaClass.java:327)
  at com.sun.org.apache.bcel.internal.classfile.JavaClass.dump(JavaClass.java:312)
  at com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC.dumpClass(XSLTC.java:905)
  at com.sun.org.apache.xalan.internal.xsltc.compiler.Stylesheet.translate(Stylesheet.java:739)
  at com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC.compile(XSLTC.java:493)
  at com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC.compile(XSLTC.java:568)
  at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:977)
  at gov.nasa.gsfc.drl.rtstps.report.ReportUtil.main(ReportUtil.java:158)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at java.lang.reflect.Method.invoke(Method.java:497)
  at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
  </code></pre>
  
  <p>Any ideas what is the problem here and are there any workarounds?</p>