Skip to Content.
Sympa Menu

xom-interest - [XOM-interest] XSLTransform setParameter

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Elliotte Harold <elharo AT metalab.unc.edu>
  • To: xom-interest <xom-interest AT lists.ibiblio.org>
  • Subject: [XOM-interest] XSLTransform setParameter
  • Date: Thu, 10 Feb 2005 07:05:25 -0500

I've added some API to the XSLTransform class to allow clients to pass parameters (values that override xsl:param elements) to XSL engines and stylesheets. The API is fairly simple:

public void setParameter(String name, Object value)
public void setParameter(String name, String namespace, Object value)

Passing a null value removes the parameter. There's not currently any getParameter method. I can add one if anybody ever needs it, or if there's a compelling use case. However, I just prefer not to clutter the API until I know there's a need.

I don't think the name is currently checked in any way to see if it's a legal NCName. I need to explore what it would mean to pass a non-name as a param value. i.e. what would the stylesheet engine do in that case.

The one thing I really agonized over was what the type of the value should be. Possibilities include:

1. A String, which most stylesheet engines can convert to numbers; but not booleans; at least not in an obvious way. That is, "false" is true.

2. Separate methods for String, boolean, and double; thereby covering three of the four XPath types.

3. Object, which avoids method proliferation and allows other types to be passed in if needed by extension functions. Also, at least some XPath engines will call toString on unexpected types like java.util.Date so they can process them as a string.

I'm about 80% convinced that Object is the right type here, but if anyone wants to argue otherwise, go ahead. I might still be convinced otherwise. I still don't like the idea of passing in an arbitrary object that the stylesheet might not be prepared to handle. And of course if anybody else spots any other problem with this API that I haven't yet seen, holler. These are just my initial thoughts. None of this is written in stone yet.

--
Elliotte Rusty Harold elharo AT metalab.unc.edu
XML in a Nutshell 3rd Edition Just Published!
http://www.cafeconleche.org/books/xian3/
http://www.amazon.com/exec/obidos/ISBN=0596007647/cafeaulaitA/ref=nosim





Archive powered by MHonArc 2.6.24.

Top of Page