忽略 XQuery 中的大小写匹配
我最初编写了一个简单的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用:
Use: