Hello,
I would like to know best practices for using RESTXQ for pure XML Web services, in my case AtomPub. First I was surprised that using "rest:produces" in the following line did not produces the specified media-type. But instead "application/xml"
%rest:produces("application/atomsvc+xml")
What was necessary was to use 'output:media-type("application/atomsvc+xml")' in addition. Why that?
Here is the working annotation and code I am talking about:
declare %rest:path("/service") %rest:GET %rest:produces("application/atomsvc+xml") %output:method("xml") %output:omit-xml-declaration("no") %output:media-type("application/atomsvc+xml") function page:service() { <service xmlns="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom"> <workspace> </workspace> </service> };
I would like to know if I should not use the namespace "page" in order to generate my responses knowing that I will produce only XML responses. Is it appropriate for XML services? Would it be better to create a namespace or a XQuery module in order not to repeat myself in the many annotations I will have to create?
I would not know where to start in order to use RESTXQ with my own module or namespace. Any suggestions are welcome. Thanks,
- Philippe
Hi Philippe,
I would like to know best practices for using RESTXQ for pure XML Web services, in my case AtomPub.
as RESTXQ is still pretty fresh, and as BaseX is still the first implementation (the one from eXist will follow soon, thanks to Adam!), it’s probably too early to talk about best practices. Still, comments from other users are welcome of course!
First I was surprised that using "rest:produces" in the following line did not produces the specified media-type. But instead "application/xml" rest:produces("application/atomsvc+xml") What was necessary was to use 'output:media-type("application/atomsvc+xml")' in addition. Why that?
I agree that the meaning of "produces" can be misleading. This is actually caused by the original HTTP specification, and not RESTXQ itself. I've revised some paragraphs of our still sketchy documentation to make this more explicit. Next, I have added a section which demonstrates the use of serialization parameters within RESTXQ function calls [1].
I would like to know if I should not use the namespace "page" in order to generate my responses knowing that I will produce only XML responses.
The module namespace and its prefix is completely arbitrary; it can even equal the "rest" namespace.
Many BaseX distributions (such as the ZIP package) include some simple RESTXQ example code, which you may use as inspiration. For further information, please consult Adam’s original RESTXQ papers and slides, which are linked from our RESTXQ documentation.
Hope this helps, Christian
Hello Christian,
Looks enough for me to start my work. I'm quite excited by the technology. And you guys seem quite active on RESTXQ. Thanks.
Many BaseX distributions (such as the ZIP package) include some simple RESTXQ example code, which you may use as inspiration. For further information, please consult Adam’s original RESTXQ papers and slides, which are linked from our RESTXQ documentation.
Are you talking about the restxq.xqm "Helo World" example? Or are there more examples somewhere else, apart from the wiki and Adam's pdfs?
basex-talk@mailman.uni-konstanz.de