[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Random UUID in pure XSLT?
> Except that if you make the call in a loop, Saxon will probably loop-lift it, thus becoming conformant and making your code deliver a stream of identical UUIDs. Oxygen's XPath/XQuery Builder, when running with XPath 3.1 SA, produces all different results when evaluating this: for $i in 1 to 5 return unparsed-text("https://uuidgen.org/api/v/4") Result: ["79ed57c2-14ec-4894-a93f-a6c7ee404000"] ["d3644d86-2f36-4ec6-b384-bda1772f508b"] ["cf974c15-9658-4f53-9a30-b6f526a8d2d9"] ["a1c96481-0d11-4624-a0d8-0d683ce3f8fc"] ["f897e396-71c1-4139-b0e7-155833abad43"] The produced results are all different regardless of which of the following is used: XPath 2.0, XPath 2.0 SA, XPath 3.1, XPath 3.1 SA, Saxon-HE XQuery 9.9.1.7, Saxon-PE XQuery 9.9.1.7, Saxon-EE XQuery 9.9.1.7 . On Wed, Nov 11, 2020 at 11:19 AM Michael Kay mike@xxxxxxxxxxxx < xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > According to the spec, unparsed-text() is deterministic, which means that > two calls with the same argument should return the same result. You're > relying on a Saxon non-conformance, I fear! > > Except that if you make the call in a loop, Saxon will probably loop-lift > it, thus becoming conformant and making your code deliver a stream of > identical UUIDs. > > You can probably get round it by using *unparsed-text("https://uuidgen.org/api/v/4 > <https://uuidgen.org/api/v/4>?x=" || position())* > > Michael Kay > Saxonica > > On 11 Nov 2020, at 18:32, Dimitre Novatchev dnovatchev@xxxxxxxxx < > xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote: > > > how can I go about producing random UUIDs, in dozens or hundreds, > inside an XSLT pipeline, without extension functions in Saxon. > > This is actually very easy and doesn't require the use of any extension > functions: > > *unparsed-text("https://uuidgen.org/api/v/4 > <https://uuidgen.org/api/v/4>")* > > or if you need N of them: > > *for $i in 1 to $N* > * return unparsed-text("https://uuidgen.org/api/v/4 > <https://uuidgen.org/api/v/4>") * > > > > p > > HTH, Dimitre > > On Tue, Nov 10, 2020 at 8:36 AM 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 <http://www.mulberrytech.com/xsl/xsl-list> >> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/782854> (by >> email) >> > > > -- > Cheers, > Dimitre Novatchev > --------------------------------------- > Truly great madness cannot be achieved without significant intelligence. > --------------------------------------- > To invent, you need a good imagination and a pile of junk > ------------------------------------- > Never fight an inanimate object > ------------------------------------- > To avoid situations in which you might make mistakes may be the > biggest mistake of all > ------------------------------------ > Quality means doing it right when no one is looking. > ------------------------------------- > You've achieved success in your field when you don't know whether what > you're doing is work or play > ------------------------------------- > To achieve the impossible dream, try going to sleep. > ------------------------------------- > Facts do not cease to exist because they are ignored. > ------------------------------------- > Typing monkeys will write all Shakespeare's works in 200yrs.Will they > write all patents, too? :) > ------------------------------------- > Sanity is madness put to good use. > ------------------------------------- > I finally figured out the only reason to be alive is to enjoy it. > > XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list> > EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/293509> (by > email) > > > XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list> > EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/782854> (by > email <>) > -- Cheers, Dimitre Novatchev --------------------------------------- Truly great madness cannot be achieved without significant intelligence. --------------------------------------- To invent, you need a good imagination and a pile of junk ------------------------------------- Never fight an inanimate object ------------------------------------- To avoid situations in which you might make mistakes may be the biggest mistake of all ------------------------------------ Quality means doing it right when no one is looking. ------------------------------------- You've achieved success in your field when you don't know whether what you're doing is work or play ------------------------------------- To achieve the impossible dream, try going to sleep. ------------------------------------- Facts do not cease to exist because they are ignored. ------------------------------------- Typing monkeys will write all Shakespeare's works in 200yrs.Will they write all patents, too? :) ------------------------------------- Sanity is madness put to good use. ------------------------------------- I finally figured out the only reason to be alive is to enjoy it.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|