I am trying to transforming XML into HTML at the server side. I'm using the following code:
com.lotus.xml.xml4j2dom.XML4JLiaison4dom pl = new com.lotus.xml.xml4j2dom.XML4JLiaison4dom();
com.lotus.xsl.XSLProcessor processor = new com.lotus.xsl.XSLProcessor(pl);
InputSource xmlSource = new InputSource(new ByteArrayInputStream(xml.getBytes()));
File xslFile = new File(stylesheetLocation);
InputSource xslSource = new InputSource(new FileInputStream(xslFile));
com.lotus.xsl.XSLTResultTarget xsltresult = new XSLTResultTarget(results);
processor.process(xmlSource, xslSource, xsltresult);
Where xml is a string containing the xml input, and stylesheetLocation is the path of the xsl file. I got javax.xml.transform.TransformerException: SAX Exception, can someone tell me what is wrong here??
Can you provide the error message / stack trace of the SAXException? (Or at least that part of the stack trace which is relevant, if you don't want to give away information). A "SAXException" is pretty broad and can mean almost anything. To quote the documentation:
public class SAXException extends java.lang.Exception
Encapsulate a general SAX error or warning.
This class can contain basic error or warning information from either the XML parser or the application: a parser writer or application writer can subclass it to provide additional functionality. SAX handlers may throw this exception or any exception subclassed from it.
Oops! Sorry, I should have read your message more carefully before replying: I see that you actually got a TransformerException with the description "SAX Exception". It would still be useful to have a stack trace, though; the documentation for TransformerException is even more vague:
public class TransformerException extends Exception
This class specifies an exceptional condition that occured during the transformation process.
You might also try calling getCause() on the exception and see if it returns further description.
Actually I think the problem is in somewhere else. I tried a very simple sample code from lotusxsl, something like this:
XSLProcessor processor = new XSLProcessor();
It ran ok in the DOS command shell, or Visual J++, but when I ran it in JCreator, Eclipse, I got this error:
==== simpleTransform ====
SystemId Unknown; Line 0; Column 0; javax.xml.transform.TransformerException: SAX Exception
I had the same classpaths and the classes are in the same sequence. What could be wrong?
This is the exception I received, when trying to format xml string using xsl.
I am using Websphere Server 4.0
can anyone help?
SystemId Unknown; Line 0; Column 0; SystemId Unknown; Line 0; Column 0; javax.xml.transform.TransformerException: SAX Exception