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 comment
10|10000 characters needed characters exceeded

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 comment
    10|10000 characters needed characters exceeded

    • Hi Komal,

      It seems like a classloader problem. Make sure you do not have another xml parser or a jar containing javax.xml.* interfaces inside your EAR file (or with a reference).

      If this is not your case, please create a CSS message

      Best regards,