corben
corben

Reputation: 1

How to escape square bracket, curly bracket for "contains text" query in xQuery (BaseX)?

I'm working with a BaseX in which we integrate TEI files.

We are looking for results that contain items with the following text:

"{AAXX}".

The braces are part of the text. (Note that sometimes there are also brackets or chevrons, we have same problems).

I have tried several types of queries to find the text in braces (with braces), but nothing works.

Below is a piece of the query:

/p[. contains text {"{AAXXXX}"} all words using case insensitive using wildcards  ]

How to escape braces, square brackets or chevrons? I tried to encode the braces in several ways, to double them, to escape them with a backslash but nothing helps, the results don't take the braces into account (just to mention this case)

Thank you

Upvotes: 0

Views: 413

Answers (1)

Andy Bunce
Andy Bunce

Reputation: 306

It can't be done. The contains text syntax is part of XQuery and XPath Full Text. This is concerned with searching for words and phrases and not symbols. The BaseX function ft:tokenize can be used to see how your search string is interpreted :

ft:tokenize("word 1.3 +, {AAXXXX}")
word
1
3
aaxxxx

The symbols are just ignored. You could use full text to search for the 'AAXXXX' and then additional XQuery code to look at the surrounding context.

Upvotes: 2

Related Questions