忽略 XQuery 中的大小写匹配

发布于 2024-10-09 18:47:39 字数 743 浏览 0 评论 0原文

我最初编写了一个简单的 XQuery 脚本:

$mediaNodes := doc('/db/portfolio/media_data_101109.xml'),
$query := concat('$mediaNodes//media[contains(@product,"',$product,'")'

基本上,它的作用是首先检索媒体记录的 xml 文件。然后,我建立了一个查询,搜索所有 mediaNode(xml 文件的元素),并将 @product 属性与用户在浏览器中提供的内容相匹配,并且我使用了 contains,因此无需执行精确的操作匹配。

现在我想稍微扩展一下,那就是忽略大小写。因此,无论用户在浏览器中输入的大小写,我都会将其转换为小写,并且我也会将节点文本也转换为小写。

我在网上搜索发现该函数小写,并相应地更改了我的代码:

$query := concat('$mediaNodes//media[contains(lower-case(@product),"',lower-case($product),'")',

但这不起作用,如果我执行查询,就会出现堆溢出。使用 Product=wborc 运行后得到的查询如下所示:

$mediaNodes//media[contains(lower-case(@product),"wborc")]

有人能帮我一点吗?我不确定我是否犯了语法错误或逻辑错误。提前致谢。

I originally had written a simple XQuery script:

$mediaNodes := doc('/db/portfolio/media_data_101109.xml'),
$query := concat('$mediaNodes//media[contains(@product,"',$product,'")'

Basically, what it does is to first retrieve the xml file for the media records. Then I built up a query that search through all of the mediaNodes (elements of the xml file), and matching the @product attribute with what the user has supplied in the browser, and I've used contain, so no need to do exact matching.

Now I want to extend this a little bit, which is to ignore the case. So no matter what case the user has typed in browser, I will convert it to lower case, and I will also convert the node text to lower case too.

I searched online and found the function lower-case, and changed my code accordingly:

$query := concat('$mediaNodes//media[contains(lower-case(@product),"',lower-case($product),'")',

but this doesn't work, if I execute the query, there will be a heap overflow. The query that I got after running with product=wborc looks like:

$mediaNodes//media[contains(lower-case(@product),"wborc")]

Could anybody help me a little bit? I am not sure whether I am making syntactic mistake or logic one. Thanks in advance.

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

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

发布评论

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

评论(1

合久必婚 2024-10-16 18:47:39

使用

concat('$vmediaNodes//media
        [contains(lower-case(@product),','lower-case("',$vProduct,'"))]')

Use:

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