ARRGGGH! As it turns out, the problem was classpath related. The version 
of Ant I was using had a different SAX/JAXP implementation than Xalan. 
By upgrading to Ant 1.4B2, the problem went away. I thought by putting 
xml.jar in my WAR file I would be "immune" to the classpath issue, but, 
from the FAQ:


> My servlet cannot find classes that implement extension functions or 
> elements. What can I do?�     
> If you install xalan.jar in the servlet engine's lib directory (e.g., 
> tomcat/lib), as opposed to the servlet's lib directory, then the Xalan 
> classes are loaded by a classloader that does not see the classes in 
> the servlet's classloader (i.e., the extension classes, if you placed 
> them there). The Xalan classes try to load the extension classes using 
> their own classloader, and that attempt fails.
>
> Workaround: place xalan.jar in the servlet's lib directory and NOT in 
> the servlet engine's lib directory. Another workaround is to place the 
> extension classes also in the servlet engine's lib directory, but you 
> generally want to avoid cluttering that directory.

However, on my system, I need to have the Ant jar files in 
JAVA_HOME/lib/ext, so I needed to upgrade Ant to support the newer 
version of JAXP/SAX. Go figure.

Thanks for the help.

On Tuesday, August 21, 2001, at 09:51 AM, gautam pachnanda wrote:

>
>
>
>
>
>
>>>>>>  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
>


_________________________________
Bruce E. Sturgen
Think Different!
ICQ: 91145892

The reasonable man adapts himself to his environment while the 
unreasonable man adapts his environment to himself. All progress is 
therefore dependent upon the unreasonable man. - George Bernard Shaw

Reply via email to