Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JDOM User »

[jdom-interest] XML - XSL Transformations

Richard Forster

2004-10-16


Hello JDOM.

I have encapsulated the XSLTransform utility included as a contrib with
JDOM in a JavaBean to make life a little simpler for my beginning
students. Maybe some others could find this useful.

For those who haven't used it, XSLTransform demonstrates how to convert
an XML document to whatever you like with XSL. The actual transform
method in my 'XSLTransformBean' is called getHTMLfromXML() 'cos that's
my students do, but of course you aren't limited to HTML as output.

Here is a brief method summary.

void   setDocument(Document doc)
      Set a JDOM Document to be transformed
void   setStyleFile(String styleFile)
      Set the file name of an XSL stylesheet to use
void   setStyleURL(String styleURL)
      Set the URL of an XSL style sheet to use
void   setXMLFile(String xmlFile)
      Set the file name of an XML file to be transformed.
void   setXMLURL(String xmlURL)
      Set the URL of an XML file to be transformed
String   getHTMLfromXML()
      Do the XML to HTML translation and return the HTML as a String

Note that several of these methods are alternatives - you will either
want to transform a document OR a file OR a URL

The source code is downloadable from

http://cit.wta.swin.edu.au/cit/subjects/CITP0160S/topics/topic15/XSLTransformBean.java

and there is extended documentation at

http://cit.wta.swin.edu.au/cit/subjects/CITP0160S/topics/topic15/topic15.html

You want, you take.

And thankyou for empowering my students with JDOM!


Richard Forster
Swinburne University
Australia

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.