Xalan transformation using xsl files within the war
James Smith <[email protected]>
| Newsgroups | gmane.comp.java.sun.servlet |
|---|---|
| Message-ID | <[email protected]> |
Hi
I'm developing a web application. I have one servlet that generates xml
responses and another servlet transform the xml to wml using xsl files
located within the war.
It's absolutely necesary to have the transformation process on the server
side 'cause phones (or wml browsers) doesn't support transformations as
browsers (explorer) with html.
Anybody have any goog idea how to do it, any experience ???
To make the transformation I'm doing something like
File xml = new File(xmlFile);
File xslt = new File(xslFile);
Source xmlSource = new StreamSource(xml);
Source xsltSource = new StreamSource(xslt);
TransformerFactory transFact = TransformerFactory.newInstance();
Transformer trans = transFact.newTransformer(xsltSource);
PrintWriter out = res.getWriter();
trans.transform(xmlSource, new StreamResult(out));
The problem here's that the xslFile (s) are looked up outside the war file,
then Xalan can't find them.
One solution could be get the file as a InputStream using URL
(this.getClass().getClassLoader().getResource("")), and this way Xalan find
the xsl file, but one of the xsl files use include directive and therefore
the included file cannot be found.
Any ideas ???
Thanx
___________________________________________________________________________
To unsubscribe, send email to [email protected] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html