关于 XQuery 中 contains() 格式的问题

发布于 2024-10-08 03:31:26 字数 290 浏览 0 评论 0原文

我的 XQuery 工作得很好,但我总是使用精确匹配,例如:

concat(' and title ="',$title,'"')

但是,这在现实世界中不起作用,因为我们需要更改精确匹配以包含。

在本例中,标题是一个 XML 元素,$title 是 XQuery 中定义的变量,我们想要的不仅仅是使用等号,而是测试标题是否包含子字符串 $title。

我已经尝试过该语法,但仍然失败,任何人都可以帮助我获得将“=”更改为包含的正确语法吗?

提前致谢。

my XQuery worked perferctly, but I've always used exact match, like:

concat(' and title ="',$title,'"')

However, this is not going to work in real world, since we need to change the exact match to contain.

In this case, the title is an XML element, $title is the variable defined in the XQuery, what we want is to do not just use equal sign but test whether the title contains the substring $title.

I've played around with the syntax but still failed, could anyone help me on getting the right syntax for changing the "=" to the contains?

Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

故乡的云 2024-10-15 03:31:26

使用

concat(' and title[contains(.,"', $title, '")]')

Use:

concat(' and title[contains(.,"', $title, '")]')
椵侞 2024-10-15 03:31:26
and title = $title

应该变成

and contains(title, $title)

但我真的不明白你想用 concat 做什么。您是否尝试使用 XQuery 生成 XQuery 表达式?在这种情况下你可以

concat(' and title = "', $title, '"')

改为

concat(' and contains(title, "', $title, '")')
and title = $title

should become

and contains(title, $title)

But I don't understand really what you're trying to do with concat. Are you trying to generate an XQuery expression using XQuery? In that case you could change

concat(' and title = "', $title, '"')

to

concat(' and contains(title, "', $title, '")')
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文