[xsl] Marshalling data (function parameters) into XSLT

Subject: [xsl] Marshalling data (function parameters) into XSLT
From: Justin Johansson <procode@xxxxxxxxxxx>
Date: Fri, 26 Sep 2008 00:23:30 +0900
Hello XSLT List,

Given a scenario of using XSLT as a generic functional computation engine,
(and thereby invoking an XSLT transform to implement the internals of a
function,
say, in the same way as one might use the Java Native Interface (JNI) to
implement a function in C++) ...

What is the most efficient was to marshall external data into the transform
engine as "parameters to the XSLT-implemented function"?

Me thinks there are only two ways and please correct me if I am wrong :-

1) Serialize the function parameters into an XML formatted character stream
and feed this into the transform as the source document
2) Pass the parameters into the transform via Transform.setParameter
(perhaps using an empty source document to satisfy the XSLT Transformer
need for a source document)

There is an obvious overhead in serializing using (1) if the parameters
already exist as native Java types.

Using (2) requires that the external (Java) driver can supply data types
directly to Transform.setParameter, and this sounds like a more efficient
way (to save the serializing overhead of 1).

To reduce the assumptions that this question might pose, let's assume a use
case in the first instance,

Use case A:
	Use XSLT to implement a simple arithmetic addition of two integers
predisposed as Java int's.

Use case B:
	Use XSLT to implement a reduce (or fold), in functional parlance, a
sequence of values predisposed as, say, a Java Vector<double>.

Thanks for the list's consideration of my question,

Justin Johansson

Current Thread