For the record, what I ended up going with was: https://github.com/openhie/openinfoman/blob/master/repo/csd_base_library.xqm... Lines 14-26.
...interesting!
Thanks for that, it did the trick. I am curious what I was doing wrong with the BigInteger attempt?
Right now, xs:integer values in BaseX are limited to signed long values, which is compliant with the XQuery spec, but which is also why the Java conversion of BigInteger will yield invalid values. There could be ways to improve the situation:
a) raise errors when a Java value is too large to be converted to a BaseX XQuery item b) allow integers larger than long values by representing BaseX xs:integer values as internal BigInteger instances c) avoid Java calls whenever possible...
Personally, I generally tend to recommend c); not just because it means least effort for us, but also because it's not possible to define a 100% mapping between XQuery and Java data types. Nevertheless, in parallel, I'll also think a bit more about options a) and b).
Hope this helps, Christian
Cheers, -carl
On Feb 13, 2014, at 7:10 AM, Christian Grün christian.gruen@gmail.com wrote:
Hi Carl,
Any suggestions?
there may be several solutions; one of them looks as follows:
let $uuid := xs:hexBinary(translate(random:uuid(),'-','')) let $bytes := convert:binary-to-bytes($uuid) ! xs:decimal(if(. < 0) then .+256 else .) return fold-left($bytes, 0, function($a, $b) { $a * 256 + $b })
Hope this helps, Christian
Cheers, -carl
declare namespace BI = "java:java.math.BigInteger";
declare function uuid_oid() { let $uuid := translate(random:uuid(),'-','') let $bigInt := concat('2.25.',BI:new($uuid, xs:int(16) )) return $bigInt
};
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk