Re: [xsl] Random UUID in pure XSLT?

Subject: Re: [xsl] Random UUID in pure XSLT?
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 10 Nov 2020 18:28:20 -0000
I was wondering about this requirement a few days ago, as it happens.

One approach might be to add an extra "method" to the object returned by
fn:random-number-generator.

If you don't like extension functions then an alternative now we have
first-class functions is to construct an XDM function object in the calling
application and pass it in to the stylesheet as a global stylesheet parameter.
The function in this case might be a function that takes a random xs:double
and delivers a random UUID. You could then call this function supplying random
numbers generated using fn:random-number-generator.

To construct your own XDM function object in the calling application,
implement net.sf.saxon.expr.Callable and wrap your implementation in a s9api
XdmFunctionItem.


Michael Kay
Saxonica

> On 10 Nov 2020, at 16:36, Piez, Wendell A. (Fed) wendell.piez@xxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> XSL Friends b
>
> Today I write from the day job, where I am researching the question of how
can I go about producing random UUIDs, in dozens or hundreds, inside an XSLT
pipeline, without extension functions in Saxon. The Java randomUUID() function
works nicely when itbs available, but I need to distribute the capability
for SaxonHE and eventually SaxonJS.
>
> We do not have an available implementation of RFC 4122 v4 brandom UUIDb
in pure XSLT do we, free to use (and study)? I know the functional nature of
the language makes randomness, um, problematic (when isnbt it?), which
sometimes means workarounds b thatbs all fine. Indeed so would calling out
to a web service if it is known to be reliable. I have thought about handing a
list of UUIDs in at runtime, but as I said, there may sometimes be hundreds
and perhaps thousands, which makes that approach seem a bit scary.
>
> Any thoughts or perspective would be most welcome.
>
> Thanks, Wendell
>
>
>
> XSL-List info and archive
> EasyUnsubscribe (by email)

Current Thread