xsl-list
[Top] [All Lists]

[xsl] Re: Saxon-CE -- Passing Data to a JS Function

2016-07-14 07:03:48
As you've already found, passing data from Saxon-CE XSLT to a JS
function requires some extra care. Firstly, it really helps to
explicitly cast a value to the type expected in the JS function,
either by passing in a typed variable (as you've done) or wrapping the
argument in a cast expression - e.g. xs:string(@value).

There shouldn't be a problem passing an XML node, or sequence of nodes
to a JS function. Saxon-CE (if memory serves) manages nodes internally
as compatible DOM nodes, these are just wrapped for the purpose of
XSLT processing.

One suggestion - it is possible to pass JS object literals back and
forth from Saxon-CE to JS functions. This might be easier than
constructing a JSON string.

Note that you may experience problems when passing empty sequences as
JS function parameters, to avoid confusion I often deliberately add a
dummy item to the start of a sequence in Saxon-CE, and then simply
ignore this first item on the JS side.

Phil Fearon
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>