[jdom-interest] Using XSL with stylesheet coming from a URL

Jason Long jason at supernovasoftware.com
Fri Feb 28 18:01:53 PST 2003


I appoligize for posting such a trival question.  I am posting my solution
here in case others have the same question.

 public static Document transform(Document in, URL url)
    throws JDOMException, Exception {
   try {
    Transformer transformer =
TransformerFactory.newInstance().newTransformer(new
StreamSource(url.openStream()));
    JDOMResult out = new JDOMResult();
    transformer.transform(new JDOMSource(in), out);
    return out.getDocument();
  } catch (Exception e) {
    throw new JDOMException("XSLT Transformation failed", e);
  }
}

-----Original Message-----
From: jdom-interest-admin at jdom.org
[mailto:jdom-interest-admin at jdom.org]On Behalf Of Jason Long
Sent: Friday, February 28, 2003 6:36 PM
To: JDOM
Subject: [jdom-interest] Using XSL with stylesheet coming from a URL


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@yourhos
t.com





More information about the jdom-interest mailing list