File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes XML Transformation error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML Transformation error" Watch "XML Transformation error" New topic

XML Transformation error

Latha setty

Joined: Feb 05, 2003
Posts: 10

I am using XSLT to transform a XML into another XML and running into the following error.

javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet
at com.filter.XMLFilter.transformXMLFile(
at com.filter.XMLFilter.Run(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(

and goes on..........

I have been trying to resolve this from morning but of no use. Could someone help me in resolving this.

Here is my transformation code

TransformerFactory tFactory =TransformerFactory.newInstance();
StreamSource stylesource = new StreamSource(stylesource);
transformer = tFactory.newTransformer(stylesource); // This line is giveing the exception
DOMSource source = new DOMSource(document);
File f = new File(origFileName + "-transform.xml");
StreamResult result = new StreamResult(f);
transformer.transform(source, result);

Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

Does your code REALLY say

"StreamSource stylesource = new StreamSource(stylesource);"


I suppose that might compile, and if it does I suppose it's equivalent to

"StreamSource stylesource = new StreamSource(null);"

That would definitely cause the transformer to fail.
Latha setty

Joined: Feb 05, 2003
Posts: 10

I pasted it wrong.

The line actually is

StreamSource stylesource = new StreamSource(stylesheet);

Any idea why it is failing?

I agree. Here's the link:
subject: XML Transformation error
It's not a secret anymore!