Marklogic lexicons: understanding cts:element-values

109 Views Asked by At

I am trying to understand the usage of

cts:element-values($element-names as xs:QName*,[$start as xs:anyAtomicType?])

I was under the impression that the above function returns values from the specified element value lexicon, starting with $start. On Querying:

cts:element-values(xs:QName("ts:title"), "He")

I was expecting results starting with "He" only, but I have also got results such as:

(as I scroll down) I Feel Fine

I Get Around

I would like to know what exactly does $start specify ?

2

There are 2 best solutions below

2
On BEST ANSWER

Think of $start not as a starting prefix but as a starting location in the list. You're getting all the values from that point onward.

To limit by prefix you want to use cts:element-value-match which accepts a $pattern. http://docs.marklogic.com/cts:element-value-match

0
On

cts:element-values and the like return values greater or equal to $start value. It really is just a start place for all values, until limit is depleted.

If you are looking for a function that returns values matching a particular pattern, you probably want to use cts:element-value-match instead:

cts:element-value-match(xs:QName("title"), "He*")

HTH!