I happen to have one in front of me right now. Note that there are at least five flavors of UUID - I chose to implement type-4.

(: this is a v4 UUID :)
define function generate-uuid-v4()
 as xs:string
{
  let $x := concat(
    xdmp:integer-to-hex(xdmp:random()),
    xdmp:integer-to-hex(xdmp:random())
  )
  return string-join((
    substring($x, 1, 8), substring($x, 9, 4),
    substring($x, 13, 4), substring($x, 17, 4), substring($x, 21, 14)
    ), '-'
  )
}

Ref: http://en.wikipedia.org/wiki/UUID

-- Mike

Gary Vidal wrote:
I was wondering if anybody has implemented a uuid (universally unique
identifier) function in Xquery.  I would like to use this to generate
id's or a comparable id generation scheme

Regards,

Gary Vidal

Sr. .Net Developer

Tel: 212-592-4946

[EMAIL PROTECTED]




------------------------------------------------------------------------

_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to