[MarkLogic Dev General] uuid implementation in Xquery
Michael Blakeley
michael.blakeley at marklogic.com
Fri Aug 10 16:01:21 PDT 2007
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
>
> gvidal at alm.com
>
>
>
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> General mailing list
> General at developer.marklogic.com
> http://xqzone.com/mailman/listinfo/general
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 4532 bytes
Desc: S/MIME Cryptographic Signature
Url : http://xqzone.marklogic.com/pipermail/general/attachments/20070810/53d31fba/smime.bin
More information about the General
mailing list