Skip to Content.
Sympa Menu

xom-interest - [XOM-interest] Re: XSLTransform(Templates templates)

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Wolfgang Hoschek <whoschek AT lbl.gov>
  • To: Wolfgang Hoschek <whoschek AT lbl.gov>
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: [XOM-interest] Re: XSLTransform(Templates templates)
  • Date: Tue, 7 Sep 2004 13:24:47 -0700

Thinking about this some more, a better way would probably be to give as as input a TransformerFactory rather than a Templates. This would be straightforward once the deprecated methods are fully removed, along the following lines:

public XSLTransform(Document stylesheet) throws XSLException {
//this(new XOMSource(stylesheet));
this(stylesheet, null);
}


public XSLTransform(Document stylesheet, TransformerFactory factory) throws XSLException {
if (factory == null) {
try {
factory = TransformerFactory.newInstance();
} catch (TransformerFactoryConfigurationError error) {
throw new XSLException(
"Could not locate a TrAX
TransformerFactory", error);
}
}

try {
this.templates = factory.newTemplates(new
XOMSource(stylesheet));
} catch (TransformerConfigurationException ex) {
throw new XSLException("Syntax error in stylesheet",
ex);
}
}

On Sep 6, 2004, at 9:01 PM, Wolfgang Hoschek wrote:


Perhaps another (fourth) option would be to add a XSLTransform(import javax.xml.transform.Templates) constructor similar in spirit to Builder(XMLReader). That way the other discussed methods could possibly go away, yet advanced/fully configured usage would become possible (for those who make sure that things works as intended in their context). Such stuff is needed to configure variables, functions and other transformer specific options. Currently the XOM XSLTransform really can't be used if such configuration is required by the app.

That sounds like a separate issue, though one worth considering. I don't think I'll address it for 1.0, but I will add it to the list to be considered for future releases.



With b4 it's as simple as adding a constructor along the following lines:

public XSLTransform(Templates templates) {
if (templates == null) throw new IllegalArgumentException();
this.templates = templates;
}



-----------------------------------------------------------------------
Wolfgang Hoschek | email: whoschek AT lbl.gov
Distributed Systems Department | phone: (415)-533-7610
Berkeley Laboratory | http://dsd.lbl.gov/~hoschek/
-----------------------------------------------------------------------





Archive powered by MHonArc 2.6.24.

Top of Page