Skip to Content
author's profile photo Former Member
Former Member

Error in transforming XML using Java


I am trying to transform a simple xml file using java.

Following is the code i am using

TransformerFactory factory = TransformerFactory.newInstance();

Transformer transformer = null;

Templates template = null;

StreamSource xmlSource = null;

StreamSource xslSource = null;

StreamResult result = null;

String msg = new String();

boolean support = false;

try {

xmlSource = new StreamSource("c:/abc.xml");

xslSource = new StreamSource("c:/abc.xsl");

File f = new File("c:/log/copy.xml");

result = new StreamResult(f);

template = factory.newTemplates(xmlSource);

transformer = template.newTransformer();

transformer.transform(xmlSource, result);

} catch (Exception ex) {

msg = ex.getMessage();


But it returns "Exceptionclass javax.xml.transform.TransformerConfigurationExceptionoccurred

Could not load stylesheet. javax.xml.transform.TransformerException: Unsupported Result object."

XML file i am using is as follows

<?xml version="1.0" encoding="ISO-8859-1"?>

<?xml-stylesheet type="text/xsl" href="c:\abc.xsl"?>



<title>Empire Burlesque</title>

<artist>Bob Dylan</artist>








<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:transform version="1.0"

xmlns: xsl="">

<xsl:template match="/">



<h2>My CD Collection</h2>

<table border="1">

<tr bgcolor="#9acd32">

<th align="left">Title</th>

<th align="left">Artist</th>


<xsl:for-each select="catalog/cd">


<td><xsl:value-of select="title"/></td>

<td><xsl:value-of select="artist"/></td>








Can anyone tell me what could be the reason of this error.



Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Feb 27, 2004 at 12:19 PM

    Could you tell me which product you are using and what system this happens in?



    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.