Hi,
'retrieve' command works to retrieve binary resource which is stored in the database (with 'store' command).
if you add a document with 'add' command, you can access that document in your collection with 'position()' function.
eg:
$ ls raw-xml/
new.xml test.xml
$ ls raw-binary/
BaseX_64px.png
$ basex -c "create db test raw-xml/test.xml" <-- create test database with initial document from test.xml
$ basex -c "open test; add raw-xml/new.xml" <-- add new.xml to test database
$ basex -c "open test; store raw-binary/BaseX_64px.png" <-- store BaseX_64px.png to test database
$ basex -q "db:open('test')[position() = 2]"
<new/>
$ basex -q "db:open('test')[position() = 1]"
<test/>
$ basex -c "open test; retrieve BaseX_64px.png"
...
Hope it helps,
-andria