简体   繁体   English

如何使用BaseX RESTXQ获取整个查询字符串?

[英]How to get the whole query string using BaseX RESTXQ?

I'm using a BaseX RESTXQ .xqm script to get an HTTP query parameter price from a URI, eg; 我正在使用BaseX RESTXQ .xqm脚本从URI获取HTTP查询参数price ,例如;

URI:    /foo/?price=20
Result: <price>20</price>

This is the .xqm code; 这是.xqm代码;

declare
  %rest:path("foo")
  %rest:query-param("price", "{$price}")
  function page:foo($price) {
    <price>{$price}</price>
  };

However, how can I get the whole query? 但是,如何获取整个查询? Eg; 例如;

URI:     /foo/?hello=world&this=that&foo=bar
Result:  <query>hello=world&this=that&foo=bar</query>

My problem is that I don't know how many params the query will have or what those params might be called. 我的问题是我不知道查询将包含多少个参数或这些参数可能被调用什么。 There might be any number of params (zero to n) and they might be called anything at all. 可能有任意数量的参数(零到n),并且它们可能被称为任何东西。 Being able to get the whole query as a single string would solve my problem. 能够将整个查询作为单个字符串来解决我的问题。

Can this be done? 能做到吗?

The current RESTXQ draft provides no solution for dynamically requesting query parameters. 当前的RESTXQ草案没有提供用于动态请求查询参数的解决方案。

In the related JAX-RS specification, several Context annotations exist to make additional request information available to a Java function (see an example ). 在相关的JAX-RS规范中,存在几个Context批注,以使其他请求信息可用于Java函数(请参见示例 )。 Newer versions of BaseX will provide a Request Module , which could be extended to provide dynamical access to all query parameters. 较新版本的BaseX将提供一个Request Module ,可以对其进行扩展以提供对所有查询参数的动态访问。 You may want to write to the basex-talk mailing list or to Adam Retter (the inventor of RESTXQ) to further motivate such an extension. 您可能想写信给basex-talk邮件列表或写给 Adam Retter(RESTXQ的发明者),以进一步激发这种扩展。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM