[xquery-talk] search hit count
Michael Kay
mhk at mhk.me.uk
Thu Jul 20 22:04:12 PDT 2006
> The XML structure is basic TEI.
There are many XML vocabularies and many of them are widely used, but it
would be a mistake to assume that readers of this list are familiar with all
of them.
> So, to get a more accurate
> count, I need to count all p, title, l, hi, etc.. tags that
> contain the keyword?
If you want to count the number of occurrences of $keyword anywhere within
element X, a close estimate would be
count(tokenize(X, $keyword))
(Not exact, because of occurrences that are adjacent to each other or to the
start or end).
Or you could do
(string-length(X) - string-length(replace(X, $keyword, ''))) div
string-length($keyword)
Michael Kay
http://www.saxonica.com/
More information about the talk
mailing list