1

Is there a way to have the below code working?

let $node := 'childnode'
return
cts:search(/root/$node, 
    cts:and-query((
        cts:collection-query('collection')
        
    ))
  )
Mads Hansen
  • 63,927
  • 12
  • 112
  • 147
anuj_gupta
  • 131
  • 4

1 Answers1

0

One way to dynamically build and execute the XPath for the cts:search $expression parameter is to generate the search expression as a string and then use xdmp:value() to parse and execute:

let $node := 'childnode'  
let $expression:= "/doc/" || $node
let $query as cts:query := cts:and-query((
        cts:collection-query('collection')
    ))
return xdmp:value("cts:search("||$expression||"," ||$query||")")
Mads Hansen
  • 63,927
  • 12
  • 112
  • 147