You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Dudu Noy <du...@zapper.com> on 2000/07/27 10:36:48 UTC

SAXException on process()

Hi all, 
I have a beginner's question on XALAN:
I am trying to perform my first XSLT transform inside a java servlet.
I use the code:

import org.apache.xalan.xslt.XSLTProcessorFactory;
import org.apache.xalan.xslt.XSLTInputSource;
import org.apache.xalan.xslt.XSLTResultTarget;
import org.apache.xalan.xslt.XSLTProcessor;
import org.xml.sax.SAXException;

XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
XSLTInputSource inXml = new XSLTInputSource ("foo.xml");
XSLTInputSource inXsl = new XSLTInputSource ("foo.xsl");
XSLTResultTarget out = new XSLTResultTarget ("result.html");
processor.process(inXml, inXsl, out);

I get a SAXException on the process function.
I did manage to run the XALAN on the same foo.xml, foo.xsl from the command
line.
I added both xalan.jar and xerces.jar to the project's class path.

Any suggestions ?

Thanks a lot, 
Dudu

Re: SAXException on process()

Posted by Hans Gill <ha...@rhinosystemsinc.com>.
Hi DUDU,
    Does it say XSL ERROR? Its probably because it cant find the file.
give the full path to the file. For example if you have foo.xml and
foo.xsl in the c:\mysite\test\

then you would have the following code.

filepath= file///c:/mysite/test/
XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
XSLTInputSource inXml = new XSLTInputSource (filepath+"foo.xml");
XSLTInputSource inXsl = new XSLTInputSource (filepath+"foo.xsl");
XSLTResultTarget out = new XSLTResultTarget ("result.html");
processor.process(inXml, inXsl, out);

Try that see if it works.

Dudu Noy wrote:

>
>
> Hi all,
> I have a beginner's question on XALAN:
> I am trying to perform my first XSLT transform inside a java servlet.
> I use the code:
>
> import org.apache.xalan.xslt.XSLTProcessorFactory;
> import org.apache.xalan.xslt.XSLTInputSource;
> import org.apache.xalan.xslt.XSLTResultTarget;
> import org.apache.xalan.xslt.XSLTProcessor;
> import org.xml.sax.SAXException;
>
> XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
> XSLTInputSource inXml = new XSLTInputSource ("foo.xml");
> XSLTInputSource inXsl = new XSLTInputSource ("foo.xsl");
> XSLTResultTarget out = new XSLTResultTarget ("result.html");
> processor.process(inXml, inXsl, out);
>
> I get a SAXException on the process function.
> I did manage to run the XALAN on the same foo.xml, foo.xsl from the
> command line.
> I added both xalan.jar and xerces.jar to the project's class path.
>
> Any suggestions ?
>
> Thanks a lot,
> Dudu