xquery/rxq — pull request #20 by cfoster (2014-09-05 19:07:53+00:00)
Title: Supporting XSLT and XQuery Serialization 3.0

This pull request adds XSLT/XQuery Serialization 3.0 support to RXQ.

Almost all of the XSLT and XQuery Serialization 3.0 specification should be supported. Whatever MarkLogic doesn't natively support will not be supported, for instance "item-separator" and XML version "1.1" as far as I'm aware will not work.

Sometimes when producing HTML `` tags with MarkLogic, MarkLogic will shorten it to a `` element (without a closing element) which can cause major problems for browsers rendering the page.

The following snippet gives an idea of how to use the new features.

```xquery
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";

declare
%rxq:GET
%rxq:path('/address/id/(.*)')
%rxq:produces('text/html')
%output:method('html')
%output:indent('yes')
function addr:get-address($id){
....
};
```

In terms of implementation, if a user does not use a `%output:*` annotation on a function, the custom serialiser will not intervene and RXQ will behave just as it did before. But **if** the user has specified that they wish to take control of the serialization by including an `%output:*` annotation on a function, the function's result is then piped through the `rxq:serialise` function which serialises according to the given annotations.