Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XSLT generate UUID

Tags:

uuid

xslt

How can I generate a UUID with pure XSLT? Basically looking for a way to create unique sequences with XSLT. The sequence can be any length.

I'm using XSLT 2.0.

like image 829
Ayyoudy Avatar asked Nov 14 '11 19:11

Ayyoudy


1 Answers

Here's a good example. Basically you set up an extension that points to the java UUID class, and then reference it in the XSL:

<xsl:stylesheet version="2.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:uuid="java:java.util.UUID">
<xsl:template match="/">
  <xsl:variable name="uid" select="uuid:randomUUID()"/>
  <xsl:value-of select="$uid"/>
</xsl:template>
like image 105
Jacob Mattison Avatar answered Sep 21 '22 17:09

Jacob Mattison