>>>>>   PrintWriter out;

>>>   transformer = factory.newTransformer(new StreamSource
                             (new java.net.URL(xslFile).openStream());


>>>>>>>      // Perform the transformation, sending the output to the
response.
                transformer.transform(xmlFile,
                           new StreamResult(out));

Try this. It works for me.


I am not too sure if ur class path is set right. It might be worthwhile
checking it.




-----Original Message-----
From: Bruce E. Sturgen [mailto:[EMAIL PROTECTED]]
Sent: 21 August 2001 15:41
To: [EMAIL PROTECTED]
Subject: Problem switching from Xalan-j 1 to Xalan-j 2


Yesterday I started upgrading a framework I maintain from Xalan 1 to
Xalan 2 (2.2.D9). Everything went just fine until I started replacing my
XSLTInputSource usage. I'm sure this is merely user error on my part,
but I'm having a hard time figuring out where the problem is.

Basically, I am trying to load the file
http://localhost:8000/servlet/ui.xsl.

Using Xalan 1 I would parse the XSL file into a DOM tree, then use the
DOM tree later to generate HTML. Loading my XSL file in Xalan 1 looked
like:

       String xslFile =

event.getConfig().getServletContext().getInitParameter("xsl.document");
       DOMParser parser = new DOMParser();
       parser.parse(new XSLTInputSource(xslFile));
       xslDocument = parser.getDocument();

Moving to Xalan 2 I now use StreamSource, Transformer, and
TransformerFactory. My code for loading the XSL file looks like:

       String xslFile =

event.getConfig().getServletContext().getInitParameter("xsl.document");
       TransformerFactory factory = TransformerFactory.newInstance();
       transformer = factory.newTransformer(new StreamSource(xslFile));

My source code using Xalan 1 works fine, and has for about 8 months.
With Xalan 2, OTOH, I get the following error:

javax.xml.parsers.ParserConfigurationException: Namespace not supported
by SAXParser
        at com.sun.xml.parser.SAXParserImpl.<init>(SAXParserImpl.java:60)
        at
com.sun.xml.parser.SAXParserFactoryImpl.newSAXParser
(SAXParserFactoryImpl.java:57)
        at
org.apache.xalan.processor.TransformerFactoryImpl.newTemplates
(TransformerFactoryImpl.java:896)
        at
org.apache.xalan.processor.TransformerFactoryImpl.newTransformer
(TransformerFactoryImpl.java:747)
        at
org.titanomachia.servlet.view.Translator.getTransformer(Translator.java:169)
        at
org.titanomachia.servlet.view.Translator.processView(Translator.java:152)
        <snip>

I am confused by the error. I think what the error is reporting is the
fact that StreamSource cannot load http: protocols. That, or I am doing
something wrong. In either case, after several hours debugging, the
clue-o-meter is still dangerously close to zero, so any help would be
appreciated. TIA.

_________________________________
Bruce E. Sturgen
Think Different!
ICQ: 91145892

immoderation on behalf of a good cause is how saints are made -- larry
wall, inventor of Perl

Reply via email to