Friday 11 June 2010

MarkLogic: XCC/J: Passing a node() into a Query as an external variable

I'd noticed that the MarkLogic XCC drivers don't appear (at first glance) to allow you to pass an Object as a node() into a query. From a bit of research and some testing, I'd found that it would allow you to pass a String (as an xs:string) as an external variable - and from there - this can be converted into a document-node() using xdmp:unquote()

So if you're using XCC/J with MarkLogic and you want to pass a node() into a Query, here's a brief example of how you could achieve such a thing:

Some example XML:

Some example XQuery:

And putting it all together, one Java class containing everything:

In your MarkLogic ErrorLog.txt, you should something like this:

No comments: