gpt4 book ai didi

xpath - 抛出错误 : XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected For, expecting Order or Return or Stable

转载 作者:行者123 更新时间:2023-12-01 16:49:37 26 4
gpt4 key购买 nike

一旦在 qconsole Marklogic 中运行以下代码,我就会遇到以下错误

XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected For_, expecting Order_ or Return_ or Stable_

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

谢谢..

最佳答案

为此不需要 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>

为了遵循 Michael 的出色建议,并优化以返回完整的项目,我将翻转 XPath,并直接返回订单项目。像这样的东西:

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]

喂!

关于xpath - 抛出错误 : XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected For, expecting Order or Return or Stable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59611613/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com