gpt4 book ai didi

xml - 在哪里可以找到 BaseX 的逻辑运算符列表?

转载 作者:行者123 更新时间:2023-12-02 02:11:46 36 4
gpt4 key购买 nike

我使用的是官方文档:http://docs.basex.org/wiki/Commands#String_Syntax ,而且我一直无法找到逻辑运算符的列表。我希望能够查询 text contains 'A' or 'B'

按照同样的思路,我也在尝试弄清楚如何限制返回结果的数量,并且我正在尝试找到在 BaseX 中创建关系表的良好指南。

这就是我正在使用的....我已经想出了如何做“或”,但我还没有想出如何为不同的目标传递变量。

let $items := ('Creditcard', 'Money order')
for $item score $s in doc('xmark')//item
[payment contains text "$items" using stemming using case sensitive]
order by $s descending
return <item ranking= '{ $s }'>{ $item/payment/text() }</item>

-编辑-

现在看这段代码,它基于现有的答案:

let $items := ('Creditcard', 'Money order')
for $item in descendant::*:$item | descendant-or-self::*[text() contains text "$item"] | .//item//payment[descendant-or-self::node()/@*:lang = "bnt"][descendant-or-self::node()/@*:lang = "afr"][descendant-or-self::node()/@*:lang = "eng"][descendant-or-self::node()/@*:lang = "chi"]
return <payment>{ .//item//payment/text() }</payment>
<buyer_name>{ .//item//buyer/text() }</buyer_name>

-编辑-

另一个尝试:

let $list := doc('xmark')
return for $p in $list/payments/item/payment-method[text() = 'Creditcard']
return $p//text()

返回 0 个结果。只是试图从文本中获取“信用卡”,即“付款方式”的值。基本上,我没能找到一致或成功的例子。

-编辑-

最近的尝试非常接近;然而,当我将它应用到我实际尝试访问的数据库而不是 BaseX 示例数据库时,我得到了一个特殊的错误品牌:

通过http://basex.org/products/live-demo/

文档('测试') :=

<item>
<item_number>1171270</item_number>
<seller_info>
<seller_company_id>6356</seller_company_id>
<seller_rating>C31</seller_rating>
<seller_rating>T150 hr.</seller_rating>
</seller_info>
<product_info>
<unit>2022</unit>
<sinfo>55 cases</sinfo>
<sinfo>Yu-gi-oh trading card pack</sinfo>
<sinfo>.45kg per unit</sinfo>
<sinfo>24.7500kg shipment</sinfo>
</product_info>
<product_info>
<unit>9291</unit>
<sinfo>7 units</sinfo>
<sinfo>Naruto, Classic, action figure</sinfo>
<sinfo>1.8kg per unit</sinfo>
<sinfo>12.6kg shipment</sinfo>
</product_info>
</item>

0: 编写您自己的查询...:=

let $doc := doc('test') 
for $v in $doc//item
where contains($v//seller_rating,'C31')
return $v//product_info/sinfo

返回:

Error:
Stopped at line 3, column 39: [XPTY0004] Single item expected, (element seller_rating { ... }, element seller_rating { ... }) found.

我不能说我没想到会遇到这样的问题。不幸的是,我没有格式化 XML 文档,而且它的格式非常糟糕,就像这样,这是我试图访问它(重组它)的部分原因。 Next question即将到来:“how do I target same-node-having values in XQuery”?

最佳答案

恕我直言,这与您的问题最相似:

let $results := 
( (: Prepare a sequence of results for each $keyword in $keywords :)
let $keywords := ('Money order', 'Creditcard', 'Personal Check')
for $keyword in $keywords
(: see http://docs.basex.org/wiki/Full-Text#Scoring for information regarding
scores :)
for $item score $s in doc('xmark')//item[
payment contains text {$keyword} all words using stemming using case sensitive
]
order by $s descending
return <item ranking= '{ $s }'>{ $item/payment/text() }</item>
)
(: now sort and group these results, grouping is done to eliminate duplicate payment
methods that have been matched by two or more keywords :)
for $result in $results
group by $val := $result/text()
order by $result[1]/@ranking descending
return $result[1]

不过,我认为您可能对分数不感兴趣,但对包含您的关键字的不同支付方式的总数感兴趣,以下查询将为您提供这些数据:

let $keywords := ('Cash', 'Personal Check')
for $keyword in $keywords
return <keyword name="{$keyword}">
{
for $result in //item/payment
group by $payment-method := $result/text()
order by count($result) descending
return element {"item"} {
attribute {"count"} {count($result)},
$payment-method
}[. contains text {$keyword} phrase]
}</keyword>

我希望这对您有所帮助并回答您的问题,以防您无法随意寻求更多帮助:)

关于xml - 在哪里可以找到 BaseX 的逻辑运算符列表?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12434945/

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