"It's Java 1.5. I am using StAX parser in my code to parse the XML file. (As Java 1.5 does not have StAX parser API, I have included the jar sjsxp.jar) So normal parsing and all is working fine, Now I need to convert some of the content of the file to String. So I have written a code like: System.setProperty(&quot;javax.xml.transform.Trans formerFactory&quot;,&quot;com.sun.org.apache.xalan.internal.xsltc. trax.TransformerFactoryImpl&quot;); public static void getStringFromXML(XMLStreamReader r, Transformer t) { Source xmlsource = new StAXSource(r); SAXSource s = (SAXSource)xmlsource; try { StringWriter swriter = new StringWriter(); t.transform(xmlsource, new StreamResult(swriter)); System.out.println(swriter.toString()); } catch (TransformerException e) { e.printStackTrace(); } } But I am getting an error: ERROR: 'Source object passed to ''{0}'' has no contents.' javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: Source object passed to ''{0}'' has no contents. at com.sun.org.apache.xalan.internal.xsltc.trax.Transforme rImpl.transform(TransformerImpl.java:673) at com.sun.org.apache.xalan.internal.xsltc.trax.Transforme rImpl.transform(TransformerImpl.java:300) This error might be coming because I am using TransformerImpl class of 1.5 and not 1.6. In 1.5 StAXSource class was not present. So TransformerImpl will not have a code to handle StAXSource class object in its methods. Is there anyway I could get rid of the issue, while remaining on Java 1.5?"