bosari
bosari

Reputation: 2000

Can you tell me how to make use of XQuery here?

let $db := xdmp:databases()[1]
let $db-name := xdmp:database-name($db)
let $db-forests := xdmp:database-forests($db, fn:false())
let $forests-name := xdmp:forest-name($db-forests) 
let $forests-name := for $f in xdmp:forest-name($db-forests) 
                        order by $f ascending
                      return $f
let $forest-status := xdmp:forest-status($db-forests)
let $map := map:map()
let $_ := for $f in $forests-name
            let $host-id := $forest-status/f:host-id/text() where ($forest-status/f:forest-name[. = $f] and ($forest-status/f:availablility/text() eq "online"))
            let $_ := if(map:contains(xdmp:host-name($host-id))) then() else()
          return $host-id
return $forest-status

I am getting error as I'm not using Xquery correctly. Please guide me.

Upvotes: 0

Views: 66

Answers (1)

  1. A FLWOR statement is not just the name - it is the order in which things need to be done. you have let-where-let in your FLWOR statement. Re-arrange it. It is upset about the second let statement because it comes after the where statement..
  2. Second - from a visual inspection, you seem to have no namespace binding for the prefix 'f'.
  3. Third - a visual inspection suggests that your map statement will fail because:
    • 1 the map never seems to have values
    • 2 the map:contains function does not have enough parameters..

Upvotes: 3

Related Questions