Ignoring case matching in XQuery
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),"',开发者_JAVA百科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.
Use:
concat('$vmediaNodes//media
[contains(lower-case(@product),','lower-case("',$vProduct,'"))]')
精彩评论