eXist is an XML database, that is, it allows us to store XML documents as well as to store another kind of documents, such as :XQuery Query documents (. xq), XQuery Module documents (. xqm), stylesheet documents (.xslt), etc… in a binary way. In this post, I will show an XQuery code to retrieve the textual information from a binary document stored in eXist.
let $binary := util:binary-doc("/db/queries/query.xq")
let $text := util:binary-to-string($binary) //Convertir binario a texto
return $text
where the binary document (query.xq) is stored in the /db/queries collection. In case you want to retrieve a binary document from an external eXist database, you should use the following URL in the previous binary-doc function:
xmldb:exist://HOST:PORT/db/queries/vdoc2doc.xq