[jdom-interest] Using XSL with stylesheet coming from a URL
Stefan Schoenmackers
stef at cparity.com
Fri Feb 28 18:00:37 PST 2003
Somebody correct me if I'm wrong, but you should be able to pass an
InputStream to StreamSource (instead of the File as you are currently
passing) .
Somthing along the lines of:
java.net.URL url = new java.net.URL(page);
InputStream input = url.openStream();
Transformer transformer = TransformerFactory.newInstance()
.newTransformer(new StreamSource(input));
That's pretty much from memory, so the methods may not be exact, but it
should be similar. I forget if there is a convenience method that loads
the stylesheet directly from a url, but it's not a lot of overhead either
way :) .
--Stef Sch...
p.s. To everyone who's helped out making JDOM, thanks, it's an awesome
package, and has helped me out tremendously.
On Fri, 28 Feb 2003, Jason Long wrote:
> I have been using the following function to do XSL transform with JDOM.
> Could someone please point me to an example of how to do this if the XSL is
> generaled by JSP and needs to be read from a URL?
>
> public static Document transform(Document in, String stylesheet)
> throws JDOMException, Exception {
> try {
> Transformer transformer =
> TransformerFactory.newInstance().newTransformer(new StreamSource(new
> File(stylesheet)));
> JDOMResult out = new JDOMResult();
> transformer.transform(new JDOMSource(in), out);
> return out.getDocument();
> } catch (Exception e) {
> throw new JDOMException("XSLT Transformation failed", e);
> }
> }
>
> Jason Long - CEO and Chief Software Engineer
> Supernova Software - supernovasoftware.com
> BS Physics, MS Chemical Engineering
>
>
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com
>
More information about the jdom-interest
mailing list