开发者

A question on contains() format in XQuery

开发者 https://www.devze.com 2023-01-31 03:53 出处:网络
my XQuery worked perferctly, but I\'ve always used exact match, like: concat(\' and title =\"\',$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, t开发者_开发技巧he 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.


Use:

concat(' and title[contains(.,"', $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, '")')
0

精彩评论

暂无评论...
验证码 换一张
取 消