I am trying to understand difference between cts:element-query
, cts:element-value-query
and cts:element-word-query
using cts:search()
.
When someone can achieve the same thing using all three why did they created these many?
I am sure I am missing something here to understand. I have following data:
<CATALOG>
<CD>
<TITLE>Empire Burlesque</TITLE>
<ARTIST>Bob Dylan</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>10.90</PRICE>
<YEAR>1985</YEAR>
</CD>
<CD>
<TITLE>Hide your heart</TITLE>
<ARTIST>Bonnie Tyler</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>CBS Records</COMPANY>
<PRICE>9.90</PRICE>
<YEAR>1988</YEAR>
</CD>
<CD>
<TITLE>Greatest Hits</TITLE>
<ARTIST>Dolly Parton</ARTIST>
<COUNTRY>EU</COUNTRY>
<COMPANY>RCA</COMPANY>
<PRICE>9.90</PRICE>
<YEAR>1982</YEAR>
</CD>
</CATALOG>
I want to filter the data for country say "EU". I can achieve the same thing with any query listed below.
-
cts:search(//CD,cts:element-query(xs:QName("COUNTRY"),"EU"))
-
cts:search(//CD,cts:element-value-query(xs:QName("COUNTRY"),"EU"))
-
cts:search(//CD,cts:element-word-query(xs:QName("COUNTRY"),"EU"))
So what is the difference? When to use what? Can someone help me understand?
My understand was to use cts:search
with cts:element-query
. I was researching with the other queries if I can get the same thing using other queries too. (I have gone thru the documentation I still don't understand). Can someone please give me a simple explanation?
question from:
https://stackoverflow.com/questions/65648018/trouble-understanding-cts-queries-using-xquery-in-marklogic 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…