You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by "Eric J. Schwarzenbach" <Er...@wrycan.com> on 2007/05/24 22:16:25 UTC
Thoughts on Transformer parameter passing
Reading some of the recent messages about parameter passing, lead me to
considering some of my own parameter passing code habits, and to look at
the documentation again.
The Javadoc for javax.xml.transform.Transformer.setParameter(name,
value) says of value "This can be any valid Java object. It is up to the
processor to provide the proper object coersion or to simply pass the
object on for use in an extension." (It's not clear to me if it is
assumed there is a single "proper" mapping of Java objects to XSLT
constructs, or if that too is up to the implementation to decide.)
On the Xalan-Java site, the FAQ is silent on parameter passing, and the
Usage Patterns just refers to the UseStylesheetParam.java sample. That
sample shows only the simplest most obvious case, passing a String.
This topic seems to cry out for treatment in the FAQ. At the very least
shouldn't Xalan's mapping of Java objects to XSLT constructs be
documented somewhere?
Where I work, we typically pass XML fragments as parameters, by creating
a Document and the necessary Element, Atribute and Text nodes with a
DocumentBuilder, and then putting that into a NodeList (currently we
have a very simple ArrayList-based implementation of that interface that
we use for that purpose) and pass that. I cannot remember what
combination of trial and error and searching the web for random postings
on the matter that resulted in our arriving at this procedure, and I'm
by no means confident that this is the best way to go about it. I do
recall having seen it struggled with at several companies I've worked at
prior to getting into the XSLT side of things myself, due to the general
scarcity of good information on the topic.
Also, reading the recent posts and their references gives me no idea if
the practice I outlined above will continue to work if we start using
XSLTC, and if not, whether that should be considered a bug or simply a
limitation of the how this implementation chooses to do its object
coersion. Can someone tell me?
Eric
Re: Thoughts on Transformer parameter passing
Posted by ke...@us.ibm.com.
>(It's not clear to me if it is
>assumed there is a single "proper" mapping of Java objects to XSLT
>constructs, or if that too is up to the implementation to decide.)
Implementation-specific.
I believe Xalan treats these the same way it treats values returned from
extension functions (another implementation-specific detail); see the
documentation for those.
______________________________________
"... Three things see no end: A loop with exit code done wrong,
A semaphore untested, And the change that comes along. ..."
-- "Threes" Rev 1.1 - Duane Elms / Leslie Fish
(http://www.ovff.org/pegasus/songs/threes-rev-11.html)
Re: Thoughts on Transformer parameter passing
Posted by Dave Brosius <DB...@Primavera.com>.
I completely agree. It would great if a sample was available that showed
how to work with beans as parameters.
"Eric J. Schwarzenbach" <Er...@wrycan.com>
05/24/2007 04:16 PM
To
xalan-j-users@xml.apache.org
cc
Subject
Thoughts on Transformer parameter passing
Reading some of the recent messages about parameter passing, lead me to
considering some of my own parameter passing code habits, and to look at
the documentation again.
The Javadoc for javax.xml.transform.Transformer.setParameter(name,
value) says of value "This can be any valid Java object. It is up to the
processor to provide the proper object coersion or to simply pass the
object on for use in an extension." (It's not clear to me if it is
assumed there is a single "proper" mapping of Java objects to XSLT
constructs, or if that too is up to the implementation to decide.)
On the Xalan-Java site, the FAQ is silent on parameter passing, and the
Usage Patterns just refers to the UseStylesheetParam.java sample. That
sample shows only the simplest most obvious case, passing a String.
This topic seems to cry out for treatment in the FAQ. At the very least
shouldn't Xalan's mapping of Java objects to XSLT constructs be
documented somewhere?
Where I work, we typically pass XML fragments as parameters, by creating
a Document and the necessary Element, Atribute and Text nodes with a
DocumentBuilder, and then putting that into a NodeList (currently we
have a very simple ArrayList-based implementation of that interface that
we use for that purpose) and pass that. I cannot remember what
combination of trial and error and searching the web for random postings
on the matter that resulted in our arriving at this procedure, and I'm
by no means confident that this is the best way to go about it. I do
recall having seen it struggled with at several companies I've worked at
prior to getting into the XSLT side of things myself, due to the general
scarcity of good information on the topic.
Also, reading the recent posts and their references gives me no idea if
the practice I outlined above will continue to work if we start using
XSLTC, and if not, whether that should be considered a bug or simply a
limitation of the how this implementation chooses to do its object
coersion. Can someone tell me?
Eric