Ok, I tried it locally using oXygen, which comes with a built-in version of Saxon-EE. It looks like that site disabled extension functions, probably for security reasons (some can be dangerous). That is why you receive:
XTDE1425: Cannot find a matching 2-argument function named
{http://exslt.org/random}random-sequence(). There is no Saxon extension function with the
local name random-sequence
This error can also come from using a free version of Saxon, from a recent question I asked Michael Kay about it, he answered (full quote):
The general policy is that Saxon-HE supports the basic conformance levels of published recommendations: For Saxon 9.6 this means XPath 3.0 and XQuery 3.0 but not XSLT 3.0, and not XPath 3.1, and not optional features such as higher-order functions.
Extensions, including Saxon extensions as well as EXSLT and EXPath extensions, generally require Saxon-PE or higher.
In a follow-up he explains how you can use integrated extension functions created by yourself. This is true for the online version (where EE doesn't work) and possibly for your local version, unless you use PE or higher. If you get this error locally as well, upgrade Saxon, or use an alternative method (see bottom).
The following works, which will return the first item from the random sequence
random:random-sequence(10, 5987)[1]
Since you probably want a different number each time the correlationId
is matched, you can change this as follows:
<xsl:variable name="pos" select="position()" />
<xsl:value-of
select="concat(current-dateTime(), random:random-sequence(100, 5987)[$pos])" />
Note, you do not need to use concat
in XSLT 2.0 with xsl:value-of
, the same can be written as:
<xsl:value-of
select="current-dateTime(), random:random-sequence(100, 5987)[$pos]"
separator="" />
Note, your original code used:
<xsl:value-of select="concat(current-dateTime(),random:random-sequence)" />
This is nodetest (i.e. will return the value that is in the node random:random-sequence
). If you call a function, you must use parentheses, or the function will not be called. And in this case, the function needs two arguments, which you need to pass, and returns a sequence of numbers.
I have created a new code snippet here: http://xsltransform.net/3NzcBue (please do not update it, so that it can remain with this answer, create a new snippet if you need to).
Edit: from the comments.
If the requirement is to have a unique string which only needs to vary based on the current node and does not have to be globally unique or anything, the XSLT way of doing this is to use the generate-id()
function, which returns a guaranteed unique string within one execution of a stylesheet. If you add that to the current date-time, you will have a locally unique string.
XSLT 2.0, without extension functions:
<xsl:value-of select="concat(current-dateTime(), generate-id(.))" />