This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XML Transformation error" Watch "XML Transformation error" New topic
Author

XML Transformation error

Latha setty
Greenhorn

Joined: Feb 05, 2003
Posts: 10
Hi,

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.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:824)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:619)
at com.filter.XMLFilter.transformXMLFile(XMLFilter.java:183)
at com.filter.XMLFilter.Run(XMLFilter.java:101)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)

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);


latha
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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
Greenhorn

Joined: Feb 05, 2003
Posts: 10
Paul,

I pasted it wrong.

The line actually is

StreamSource stylesource = new StreamSource(stylesheet);

Any idea why it is failing?

Regards
 
 
subject: XML Transformation error
 
Similar Threads
DocumentBuilder.parse not working for String input
how to get information from a XML file?
Incorrect encoding in XML
What is the following XSLT program doing ?
Transformation Problem For Arabic/French Character : HTML to XML