[jdom-interest] JDOMTransformer
Elliotte Rusty Harold
elharo at metalab.unc.edu
Sun May 4 11:29:42 PDT 2003
At 5:48 PM -0700 4/30/03, Jason Hunter wrote:
>I just checked in org.jdom.transform.JDOMTransformer to help with simple
>transformations. It's been a TODO item to make simple transformations
>into a "one-liner". I'm not sure I've got the best approach here, but
>best to check it in and get some review. I changed the
>samples/XSLTransform.java to use the new convenience class.
>
Looks good. Comparing to my original proposal for this from last
Spring,<http://cafeconleche.org/jdom/XSLTransform.java> I noticed a
few possible things we might want to add:
A constructor that takes a JDOM Document holding the stylesheet as an argument
public XSLTransform(Document stylesheet)
A constructor that takes a Reader for the stylesheet as an argument:
public XSLTransform(Reader stylesheet)
A constructor that takes a File as an argument:
public XSLTransform(File stylesheet)
I also think we make non-public the constructor that takes a TrAX
Source as an argument. The idea of this class is to not require the
user to know about TrAX. This also makes JDOM more easily portable to
different XSLT engines/APIs in the future.
I also suggest a toString method just on general principle. Something
like this will do:
/**
* <p>
* This returns a <code>String</code> form of this
* <code>XSLTransform</code>, suitable for debugging.
* </p>
*
* @return <code>String</code> - debugging string.
*/
public String toString() {
return "[JDOMTransform: " + templates + "]";
}
I originally included clone(), equals(), and hashCode() methods in my
version, but I now think we're probably better off without them.
Also, my original proposal included a special purpose XSLException as
a subclass of JDOMException, which you can still find at
http://cafeconleche.org/jdom/XSLException.java
I suggest using this instead of a generic JDOMexception.
--
Elliotte Rusty Harold
elharo at metalab.unc.edu
Processing XML with Java (Addison-Wesley, 2002)
http://www.cafeconleche.org/books/xmljava
http://www.amazon.com/exec/obidos/ISBN%3D0201771861/cafeaulaitA
More information about the jdom-interest
mailing list