[英]How to root element dynamically provide in cts:search using Marklogic
After using the below mentioned Xquery I am getting the output correctly.使用下面提到的 Xquery 后,我得到了正确的输出。
let $element :="Name"
let $value := "Antony"
let $op := cts:search(//root, cts:element-value-query( xs:QName($element),$value))
return $op
But I am getting error while using " root " value in variable.但是在变量中使用“ root ”值时出现错误。 Please suggest me, if any other options?
请建议我,如果有其他选择吗?
let $element := "Name"
let $value := "Antony"
let $root := "root"
let $op := cts:search(//$root, cts:element-value-query( xs:QName($element),$value))
return $op
Error :错误 :
[1.0-ml] XDMP-UNSEARCHABLE: cts:search(fn:collection()/descendant-or-self::node()/"root", cts:element-value-query(fn:QName("","Name"), "Antony", ("lang=en"), 1)) -- Expression is unsearchable
Stack Trace
At line 16 column 23:
In xdmp:eval("(: let $uri := cts:element-value-query( xs:QName("file...", (), <options xmlns="xdmp:eval"><database>8922589838473153050</database><root>/marklogic/poc/</r...</options>)
$element := "Name"
$value := "Antony"
$root := "root"
14. let $value := "Antony"
15. let $root :="root"
16. **let $op := cts:search(//$root, cts:element-value-query( xs:QName($element),$value))**
17. return $op
Example data:示例数据:
<root processtype="sample">
<title series="hk">
<Name>Antony</Name>
</title>
</root>
you cannot use the $root
value in that way.. in order to match the $root
value you have to do the following //root[. = $root]
您不能以这种方式使用
$root
值.. 为了匹配$root
值,您必须执行以下操作//root[. = $root]
//root[. = $root]
let $element :="Name"
let $value := "Antony"
let $root :="root"
let $op := cts:search(//root[. = $root], cts:element-value-query( xs:QName($element),$value))
return $op
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.