EXPath Binary Module 4.0 for eXist-db — binary data manipulation functions.
This package implements the EXPath Binary Module 4.0 specification as a standalone XAR package for eXist-db.
| Section | Functions |
|---|---|
| Conversions | bin:hex, bin:bin, bin:octal, bin:to-octets, bin:from-octets |
| Basic Operations | bin:length, bin:part, bin:join, bin:insert-before, bin:pad-left, bin:pad-right, bin:find |
| Text Encoding | bin:decode-string, bin:encode-string |
| Numeric Packing | bin:pack-double, bin:pack-float, bin:pack-integer, bin:unpack-double, bin:unpack-float, bin:unpack-integer, bin:unpack-unsigned-integer |
| Bitwise Operations | bin:or, bin:xor, bin:and, bin:not, bin:shift |
- eXist-db 6.0.0 or later
From a GitHub release:
xst package install https://github.com/joewiz/exist-binary/releases/download/v0.9.0-SNAPSHOT/exist-binary-0.9.0-SNAPSHOT.xarFrom a local build:
mvn package -DskipTests
xst package install target/exist-binary-0.9.0-SNAPSHOT.xarimport module namespace bin = "http://expath.org/ns/binary";
(: Convert hex string to binary :)
let $data := bin:hex("DEADBEEF")
(: Get length in octets :)
let $len := bin:length($data) (: 4 :)
(: Extract a part :)
let $part := bin:part($data, 1, 2) (: bytes at positions 1-2 :)
(: Encode/decode strings :)
let $encoded := bin:encode-string("Hello, World!")
let $decoded := bin:decode-string($encoded) (: "Hello, World!" :)
(: Pack/unpack numbers :)
let $packed := bin:pack-double(3.14)
let $value := bin:unpack-double($packed, 0) (: 3.14 :)
return $decoded96% (183/190) of EXPath Binary Module test cases pass in the QT4 XQTS test suite.
If you previously used the in-tree Binary Module from eXist-db PR #6101, this standalone XAR is a drop-in replacement. The namespace (http://expath.org/ns/binary) and function signatures are identical.
To migrate:
- Remove the
<module uri="http://expath.org/ns/binary" .../>line from yourconf.xml(if present) - Install this XAR package
- No changes needed in your XQuery code
LGPL 2.1 — same as eXist-db.