Hi,
Since the queries to a collection over REST typically result in XML being returned, is there a way to turn off the wrapping of results in jax-rx:results and jax-rx;result elements?
Thanks.
On 01/27/2011 04:32 PM, software developer wrote:
Since the queries to a collection over REST typically result in XML being returned, is there a way to turn off the wrapping of results in jax-rx:results and jax-rx;result elements?
I have no idea regarding the question, but if so it might not be well formed XML since a root element always has to be in existence.
Thus I assume it's not possible, but I might be wrong. In case of other content-types (besides perhaps text/xml or whatever JAX-RX assumes per default) are possible like text/plain it should be possible or at least easily doable :-)
regards, Johannes
Since the queries to a collection over REST typically result in XML being returned, is there a way to turn off the wrapping of results in jax-rx:results and jax-rx;result elements?
No problem; try "wrap=no". More info at:
http://docs.basex.org/wiki/REST
C.
Brilliant, thanks. However, I also want to change the returned type to application/xml or text/xml and the parameter named output as documented does not appear to be supported in ver 6.5 on the maven repo
On Thu, Jan 27, 2011 at 4:08 PM, Christian Grün christian.gruen@gmail.comwrote:
Since the queries to a collection over REST typically result in XML being returned, is there a way to turn off the wrapping of results in jax-rx:results and jax-rx;result elements?
No problem; try "wrap=no". More info at:
http://docs.basex.org/wiki/REST
C.
Brilliant, thanks. However, I also want to change the returned type to application/xml or text/xml
As you correctly observed, the JAX-RX interface returns text/plain as return type if wrapping is turned off. This decision has been taken as it can't be assured that the result will be correct XML, or XML at all. See the following query as example:
http://localhost:8984/basex/jax-rx?wrap=no&query=1+to+10
and the parameter named output as documented does not appear to be supported in ver 6.5 on the maven repo
The "output" parameter has always been supported in BaseX; could you provide us with a query that demonstrates the problem?
Christian
Okay, I thought setting output to application/xml but wrap=no will mean the person writing the query is taking the responsibility that they do not want results to be wrapped but know the result is xml so forcing the output to be application/xml (so that the response mime-type is set to application/xml in this case)...what are the valid values for output parameter?
An invocation like http://localhost:8984/basex/jax-rx?wrap=no&query=1+to+10&output=text... or http://localhost:8984/basex/jax-rx?wrap=yes&query=1+to+10&output=tex... text%2Fxml) results in:
[SERE0000] Parameter "text/xml" is unknown.
What I am after is something akin to this (but with numerous <Data> elements, so do not want wrapping in jax-rx:result elements as that adds unnecessarily to payload (bytes transferred) when I do not need it): http://localhost:8984/basex/jax-rx?wrap=no&query=%3CData%3E1%20to%2010%3... with a return mime-type of text/xml or application/xml.
So, basically, I want to return an "XML" result without the enclosing jax-rx:results/jax-rx:result elements.
Perhaps I can just discard the jax-rx:results/jax-rx:result elements while parsing the response...I am alright with it even if BaseX does not cater to this scenario.
On Fri, Jan 28, 2011 at 4:43 PM, Christian Grün christian.gruen@gmail.comwrote:
Brilliant, thanks. However, I also want to change the returned type to application/xml or text/xml
As you correctly observed, the JAX-RX interface returns text/plain as return type if wrapping is turned off. This decision has been taken as it can't be assured that the result will be correct XML, or XML at all. See the following query as example:
http://localhost:8984/basex/jax-rx?wrap=no&query=1+to+10
and the parameter named output as documented does not appear to be supported in ver 6.5 on the maven repo
The "output" parameter has always been supported in BaseX; could you provide us with a query that demonstrates the problem?
Christian
Okay, I thought setting output to application/xml but wrap=no will mean the person writing the query is taking the responsibility that they do not want results to be wrapped but know the result is xml so forcing the output to be application/xml (so that the response mime-type is set to application/xml in this case)...what are the valid values for output parameter?
All parameters are defined in the W3 specs: http://www.w3.org/TR/xslt-xquery-serialization/
Please browse our JAX-RX docs for some usage examples: http://docs.basex.org/wiki/JAX-RX_API
An invocation like http://localhost:8984/basex/jax-rx?wrap=no&query=1+to+10&output=text... or http://localhost:8984/basex/jax-rx?wrap=yes&query=1+to+10&output=tex... (or text%2Fxml) results in:
Yes, I see that there's some need to work on the response media type. I have two solutions in mind:
a) All textual results of "query" and "run" could be returned as application/xml, no matter what value has been assigned to "wrap". This would mean that all non-XML query results (e.g., resulting from a XQuery like "1 to 10") would be handles as XML, too.
b) This is one is similar to your approach: an additional JAX-RX parameter could be introduced to explicitly overwrite the resulting media type. Example:
http://localhost:8984/basex/jax-rx?wrap=yes&query=1&media=applicatio...
What do you, and others, think?
Both changes are not BaseX-centric, but have to be made in the JAX-RX interface, so this might take some more time; but I'll definitely add this to our internal issue tracker.
Christian
The scope of this posting is only xquery.
output does allow media-type to be specified...
Thanks for the observation.. True, I overlooked this parameter. Currently, it is only used for adding a meta tag if "xhtml" or "html" is chosen as output method. An example:
curl -i "http://localhost:8984/basex/jax-rx?wrap=no&query=<head/>&output=method=xhtml&output=include-content-type=yes"
<head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </head>
…but it would perfectly make sense to adopt this parameter as general media type. Looks as if this will lead to some more changes, as the JAX-RX Interface passes on all output (serialization) parameters to the underlying implementation (BaseX) without touching them – but, nevertheless, it defines the media type of the result, depending on the value of the "wrap" parameter.
The JAX-RX Interface is currently implemented by at least two implementations (BaseX and TreeTank), so I'll have to check first when the extension can be integrated; we'll keep you updated.
Christian
Hi,
the choice of the response media type has been revised in the latest version of the JAX-RX interface, which you find here:
http://www.inf.uni-konstanz.de/dbis/basex/maven/org/jaxrx/jax-rx/1.2.9/
I've updated our documentation to reflect the changes; the single steps can be found here:
http://docs.basex.org/wiki/REST#Response_Media_Type
Hope this helps, Christian
On Mon, Jan 31, 2011 at 1:23 PM, Christian Grün christian.gruen@gmail.com wrote:
output does allow media-type to be specified...
Thanks for the observation.. True, I overlooked this parameter. Currently, it is only used for adding a meta tag if "xhtml" or "html" is chosen as output method. An example:
curl -i "http://localhost:8984/basex/jax-rx?wrap=no&query=<head/>&output=method=xhtml&output=include-content-type=yes"
<head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </head>
…but it would perfectly make sense to adopt this parameter as general media type. Looks as if this will lead to some more changes, as the JAX-RX Interface passes on all output (serialization) parameters to the underlying implementation (BaseX) without touching them – but, nevertheless, it defines the media type of the result, depending on the value of the "wrap" parameter.
The JAX-RX Interface is currently implemented by at least two implementations (BaseX and TreeTank), so I'll have to check first when the extension can be integrated; we'll keep you updated.
Christian
Hi,
Many thanks for the update.
Where is 6.5.1 available (not yet on Maven?) - I replaced the jax-rx jar manually for now, but is jax-rx jar a dependency of basex-api jar (so will be auto-updated with next revision of basex-api.jar)?
Also, because I upload data (initial creation of XML Collection and populating it) via the jax-rx interface, I end up with 3 documents with the same name in the same collection. I want to perform my queries on all those documents at once but do not want 3 top level elements (want just one). In other words, I want the following query to return one result (should one xquery like this not return one result, i.e., one top-level element?), not three results (i.e., not three APPLICATIONS elements): xquery version "1.0";
declare namespace fn="http://www.w3.org/2005/xpath-functions"; declare variable $region as xs:string external; declare variable $dataSet as xs:string external; declare variable $databaseName as xs:string external; let $finalURL := fn:concat($databaseName, "/",$dataSet,"/",$region,"/data.xml")
for $all in db:open($finalURL) let $count := count($all/APPLICATION) return <APPLICATIONS> { for $anApp in $all/APPLICATION let $appName := $anApp/NAME/text() let $appID := $anApp/ID/text() order by $appName return <APP count='{$count}'> <NAME>{$appName}</NAME> <ID>{$appID}</ID> </APP> } </APPLICATIONS>
On Sat, Feb 5, 2011 at 9:18 PM, Christian Grün christian.gruen@gmail.comwrote:
Hi,
the choice of the response media type has been revised in the latest version of the JAX-RX interface, which you find here:
http://www.inf.uni-konstanz.de/dbis/basex/maven/org/jaxrx/jax-rx/1.2.9/
I've updated our documentation to reflect the changes; the single steps can be found here:
http://docs.basex.org/wiki/REST#Response_Media_Type
Hope this helps, Christian
On Mon, Jan 31, 2011 at 1:23 PM, Christian Grün christian.gruen@gmail.com wrote:
output does allow media-type to be specified...
Thanks for the observation.. True, I overlooked this parameter. Currently, it is only used for adding a meta tag if "xhtml" or "html" is chosen as output method. An example:
<head/>&output=method=xhtml&output=include-content-type=yes" > > <head> > <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> > </head> > > …but it would perfectly make sense to adopt this parameter as general > media type. Looks as if this will lead to some more changes, as the > JAX-RX Interface passes on all output (serialization) parameters to > the underlying implementation (BaseX) without touching them – but, > nevertheless, it defines the media type of the result, depending on > the value of the "wrap" parameter. > > The JAX-RX Interface is currently implemented by at least two > implementations (BaseX and TreeTank), so I'll have to check first when > the extension can be integrated; we'll keep you updated. > > Christian >
Hi,
Solved by modifying the xquery as follows: declare namespace fn="http://www.w3.org/2005/xpath-functions"; declare variable $region as xs:string external; declare variable $dataSet as xs:string external; declare variable $databaseName as xs:string external; let $finalURL := fn:concat($databaseName, "/",$dataSet,"/",$region,"/data.xml") return <APPLICATIONS> {
for $all in db:open($finalURL) let $count := count($all/APPLICATION) for $anApp in $all/APPLICATION let $appName := $anApp/NAME/text() let $appID := $anApp/ID/text() order by $appName return <APP count='{$count}'> <NAME>{$appName}</NAME> <ID>{$appID}</ID> </APP>
}
</APPLICATIONS>
I realize this is not an xquery guidance mailing list, so my apologies.
Thanks.
On Tue, Feb 8, 2011 at 2:53 PM, software developer < computer.software.developer@gmail.com> wrote:
Hi,
Many thanks for the update.
Where is 6.5.1 available (not yet on Maven?) - I replaced the jax-rx jar manually for now, but is jax-rx jar a dependency of basex-api jar (so will be auto-updated with next revision of basex-api.jar)?
Also, because I upload data (initial creation of XML Collection and populating it) via the jax-rx interface, I end up with 3 documents with the same name in the same collection. I want to perform my queries on all those documents at once but do not want 3 top level elements (want just one). In other words, I want the following query to return one result (should one xquery like this not return one result, i.e., one top-level element?), not three results (i.e., not three APPLICATIONS elements): xquery version "1.0";
declare namespace fn="http://www.w3.org/2005/xpath-functions"; declare variable $region as xs:string external; declare variable $dataSet as xs:string external; declare variable $databaseName as xs:string external; let $finalURL := fn:concat($databaseName, "/",$dataSet,"/",$region,"/data.xml")
for $all in db:open($finalURL) let $count := count($all/APPLICATION) return <APPLICATIONS> { for $anApp in $all/APPLICATION let $appName := $anApp/NAME/text() let $appID := $anApp/ID/text() order by $appName return <APP count='{$count}'> <NAME>{$appName}</NAME> <ID>{$appID}</ID> </APP> } </APPLICATIONS>
On Sat, Feb 5, 2011 at 9:18 PM, Christian Grün christian.gruen@gmail.comwrote:
Hi,
the choice of the response media type has been revised in the latest version of the JAX-RX interface, which you find here:
http://www.inf.uni-konstanz.de/dbis/basex/maven/org/jaxrx/jax-rx/1.2.9/
I've updated our documentation to reflect the changes; the single steps can be found here:
http://docs.basex.org/wiki/REST#Response_Media_Type
Hope this helps, Christian
On Mon, Jan 31, 2011 at 1:23 PM, Christian Grün christian.gruen@gmail.com wrote:
output does allow media-type to be specified...
Thanks for the observation.. True, I overlooked this parameter. Currently, it is only used for adding a meta tag if "xhtml" or "html" is chosen as output method. An example:
<head/>&output=method=xhtml&output=include-content-type=yes" > > <head> > <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> > </head> > > …but it would perfectly make sense to adopt this parameter as general > media type. Looks as if this will lead to some more changes, as the > JAX-RX Interface passes on all output (serialization) parameters to > the underlying implementation (BaseX) without touching them – but, > nevertheless, it defines the media type of the result, depending on > the value of the "wrap" parameter. > > The JAX-RX Interface is currently implemented by at least two > implementations (BaseX and TreeTank), so I'll have to check first when > the extension can be integrated; we'll keep you updated. > > Christian >
Where is 6.5.1 available (not yet on Maven?)
Version 6.5.1 is still beta, so it's only available via our Subversion repository. In near future, we'll also be offering a snapshot of the latest build via Maven.
I replaced the jax-rx jar manually for now, but is jax-rx jar a dependency of basex-api jar (so will be auto-updated with next revision of basex-api.jar)?
…exactly. Christian
basex-talk@mailman.uni-konstanz.de