Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xpath 抛出错误:XDMP-UNEXPECTED:(错误:XPST0003)意外的令牌语法错误、意外的For、预期的Order或Return或Stable__Xpath_Xquery_Marklogic - Fatal编程技术网

Xpath 抛出错误:XDMP-UNEXPECTED:(错误:XPST0003)意外的令牌语法错误、意外的For、预期的Order或Return或Stable_

Xpath 抛出错误:XDMP-UNEXPECTED:(错误:XPST0003)意外的令牌语法错误、意外的For、预期的Order或Return或Stable_,xpath,xquery,marklogic,Xpath,Xquery,Marklogic,一旦在qconsole Marklogic中运行下面的代码,我就会得到下面的错误 XDMP-EXPENTED:(错误:XPST0003)意外令牌语法错误, 意外,期望订单或退货或稳定_ let$prices:=fn:doc('/training/prices.xml')/prices 让$order:=fn:doc('/training/order.xml')/order 其中$prices/priceList/prod[@num=$order/item/@num] 对于$kk,以$prices

一旦在qconsole Marklogic中运行下面的代码,我就会得到下面的错误

XDMP-EXPENTED:(错误:XPST0003)意外令牌语法错误, 意外,期望订单或退货或稳定_

let$prices:=fn:doc('/training/prices.xml')/prices
让$order:=fn:doc('/training/order.xml')/order
其中$prices/priceList/prod[@num=$order/item/@num]
对于$kk,以$prices/priceList/prod[@num=$order/item/@num]表示
返回
{$kk}

谢谢..

在XQuery 1.0中,在
where
子句之后不允许再使用
for
子句。在Marklogic中,您可能需要在查询字符串前面加上3.0版本声明:

xquery version "3.0";

这不需要XQuery 3。只需在
where
和下一个
for
之间添加一个额外的
return

let $prices := fn:doc('/training/prices.xml')/prices
let $order := fn:doc('/training/order.xml')/order
where $prices/priceList/prod[@num=$order/item/@num]
return
for $kk in $prices/priceList/prod[@num=$order/item/@num]
return 
<item>
{$kk}
</item>
甚至更短:

let $prices := fn:doc('/training/prices.xml')/prices
let $order := fn:doc('/training/order.xml')/order
return
    $order/item[@num = $prices/priceList/prod/@num]

谢谢,数据库服务器出现问题,因为它只允许“1.0”,请参见下面的[1.0-ml]XDMP-XQUERYVERSION:(err:XQST0031)XDMP:eval(“xquery版本”3.0-ml; ;let$prices:=fn:doc('/t…,(),10600756150967678487448…)——无法识别xquery版本:“3.0-ml”(必须是“0.9-ml”、“1.0”或“1.0-ml”)在这种情况下,对于您的特定查询,在
where
子句之后再添加一个
return
将完成此任务。或者,只需将最后一个“for”子句移到“where”子句之前。如何对元素应用所有属性,我正在这样做,但不工作,请指导我{$order/item/@*}无需重新构建订单项,只需按原样返回即可。请参见上面的编辑。我的预期输出是,我希望使用all属性打印元素下的信息,如下所示:29.99 10.00请打开一个新问题。这为您提供了更多的空间来写下您希望实现的内容以及您迄今为止尝试的内容。。
let $prices := fn:doc('/training/prices.xml')/prices
let $order := fn:doc('/training/order.xml')/order
for $item in $order/item
where $prices/priceList/prod[@num = $item/@num]
return
    $item
let $prices := fn:doc('/training/prices.xml')/prices
let $order := fn:doc('/training/order.xml')/order
return
    $order/item[@num = $prices/priceList/prod/@num]