XQuery-在单个节点下封闭元素序列

XQuery-在单个节点下封闭元素序列,xquery,basex,Xquery,Basex,我正在将xquery与BaseX结合使用,试图以我想要的格式从JMeter测试用例(.jmx文件)中检索信息。 这是我实际运行的代码(在BaseX GUI中): let$rlist:=db:list(“JMeter”) 对于$rlist中的$resource 让$rcontent:=db:open(“JMeter”,$resource) 让$ret:= { 对于$RCContent/jmeterTestPlan//HTTPSamplerProxy中的$item 返回 ( { $item/stri

我正在将xquery与BaseX结合使用,试图以我想要的格式从JMeter测试用例(.jmx文件)中检索信息。
这是我实际运行的代码(在BaseX GUI中):

let$rlist:=db:list(“JMeter”)
对于$rlist中的$resource
让$rcontent:=db:open(“JMeter”,$resource)
让$ret:=
{
对于$RCContent/jmeterTestPlan//HTTPSamplerProxy中的$item
返回
(
{
$item/stringProp[attribute()/string()=“HTTPSampler.method”]/text()
}
,
{
让$parse:=$item/stringProp[attribute()/string()=“HTTPSampler.path”]/text()
让$parse:=fn:replace($parse,“\?[^/]*”,“”)
让$parse:=fn:replace($parse,\$[^/]*,“\${}”)
让$parse:=fn:replace($parse,“[0-9]+”,“\${}”)
返回$parse
}
,
{
$resource
}
)
}
返回
{
$ret
}
生成的xml如下所示:

<HttpRequests>
  <HttpRequest>
    <method>POST</method>
    <path>/config</path>
    <resource>CentralConfiguration/Requests/addConfiguration.jmx</resource>
  </HttpRequest>
</HttpRequests>
<HttpRequests>
  <HttpRequest>
    <method>POST</method>
    <path>/propertyType</path>
    <resource>CentralConfiguration/Requests/addPropertyType.jmx</resource>
  </HttpRequest>
</HttpRequests>
...

邮递
/配置
CentralConfiguration/Requests/addConfiguration.jmx
邮递
/属性类型
CentralConfiguration/Requests/addPropertyType.jmx
...
这就是我所期望的结果:

<HttpRequests>
  <HttpRequest>
    <method>POST</method>
    <path>/config</path>
    <resource>CentralConfiguration/Requests/addConfiguration.jmx</resource>
  </HttpRequest>
  <HttpRequest>
    <method>POST</method>
    <path>/propertyType</path>
    <resource>CentralConfiguration/Requests/addPropertyType.jmx</resource>
  </HttpRequest>
  ...
</HttpRequests>

邮递
/配置
CentralConfiguration/Requests/addConfiguration.jmx
邮递
/属性类型
CentralConfiguration/Requests/addPropertyType.jmx
...

如果您能帮助我格式化xquery以获得预期结果,我将不胜感激。

将外部for循环放在第一个标签内,问题就解决了。

实际代码前面的示例没有帮助。删除它,并显示实际代码的输出和所需的输出。
<HttpRequests>
  <HttpRequest>
    <method>POST</method>
    <path>/config</path>
    <resource>CentralConfiguration/Requests/addConfiguration.jmx</resource>
  </HttpRequest>
  <HttpRequest>
    <method>POST</method>
    <path>/propertyType</path>
    <resource>CentralConfiguration/Requests/addPropertyType.jmx</resource>
  </HttpRequest>
  ...
</HttpRequests>