-1

I'm using xquery with BaseX to attempt to retrieve information from JMeter test cases (.jmx files) in a format I desire.
This is the code I'm actually running (inside BaseX GUI):

let $rlist := db:list("JMeter")
for $resource in $rlist
let $rcontent := db:open("JMeter", $resource)
let $ret :=
  <HttpRequest>
  {
    for $item in $rcontent/jmeterTestPlan//HTTPSamplerProxy
    return
      (<method>
      {
        $item/stringProp[attribute()/string() = "HTTPSampler.method"]/text()
      }
      </method>,
      <path>
      {
        let $parse := $item/stringProp[attribute()/string() = "HTTPSampler.path"]/text()
        let $parse := fn:replace($parse, "\?[^/]*", "")
        let $parse := fn:replace($parse, "\$[^/]*", "\${}")
        let $parse := fn:replace($parse, "[0-9]+", "\${}")
        return $parse
      }
      </path>,
      <resource>
      {
        $resource
      }
      </resource>)
  }
  </HttpRequest>

return
<HttpRequests>
{
  $ret
}
</HttpRequests>

The resulting xml looks like this:

<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>
...

This is what I expect the result to look like:

<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>

I'd much appreciate help in formatting my xquery to get the expected result, thanks

Cong Hui
  • 202
  • 5
  • 16
  • The example preceding your actual code is not helpful. Remove it and show the output you are getting with the actual code and the output you would like. – wst Mar 08 '17 at 18:01

1 Answers1

0

The problem was solved by placing the outside for loop inside the first label.

Cong Hui
  • 202
  • 5
  • 16