Re: [xsl] Sequential numbers in pure xslt, breaking the no-side-effect rule

Subject: Re: [xsl] Sequential numbers in pure xslt, breaking the no-side-effect rule
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Fri, 16 Mar 2007 16:13:48 +0100
David Carlisle wrote:
a fourth would be to use doc() to some web server that returned the next
number in sequence, given some URI that uniquely identified this
"session". You'd have to tack on some (ignorable) junk to ensure unique
URIs or use an option to turn off document stability, to allow you to
get a different value from the same URI.

That could be done by using the generate-id() function with a dynamic node. But it is not a trivial solution, though it is easier to make it cross-processor.



Or of course rewrite your algorithm in a functional style so this isn't needed (you know that's the right thing to to:-)

I would like to, but, I didn't invent the algorithm. The idea was this: make a UUID from within XLST (i.e., portable xslt). The timestamp part of any UUID, is defined as: "the current timestamp, but if multiple UUIDs are requested withing the current granularity, add 1 to each new timestamp to make them unique".


It's not my algorithm. And yes, I know, UUID are not the type of thing you would want to create using XSLT. I just took up the challenge and hoped to find something "well enough to suit for everyday use".

Another situation where consecutive numbers are useful is in outputting '001, 002, 003, 004' etc at the beginning of each and every xsl:message, making it easy to follow the execution order (and not sure if that can be done in functional style).

-- Abel

Current Thread