Hi Jamin,
> I tried a query using a combination of cts:search,
> cts:and-query, cts:element-attribute-value-query and I get
> the entire XML file as a result which is not necessary for
> me. I just need only the element and its contents.
Using the Xpath expression suggested by Ken is the most straight-forward way of
doing it. But here some cts:search samples that should work as well, just
cut-n-paste as one big query into CQ:
xquery version "1.0-ml";
xdmp:document-insert("/bookstore.xml", <bookstore>
<book lang="English">Learning XQuery </book>
<book lang="English">Learning MarkLogic Server </book>
<book lang="French">French Culture</book>
<book lang="Italian">Italian Food</book>
<book lang="Italian">Italian XQuery</book>
</bookstore>
);
xquery version "1.0-ml";
"Any book containing 'XQuery':",
cts:search(doc()//book, "XQuery"),
"
Only English books:",
cts:search(doc()//book, cts:element-attribute-value-query(xs:QName("book"),
xs:QName("lang"), "English")),
"
Only English books about 'XQuery':",
cts:search(doc()//book,
cts:and-query((cts:element-attribute-value-query(xs:QName("book"),
xs:QName("lang"), "English"), "XQuery"))),
"
More restrictive way of finding only English books about 'XQuery':",
cts:search(doc()//book, cts:element-query(xs:QName("book"),
cts:and-query((cts:element-attribute-value-query(xs:QName("book"),
xs:QName("lang"), "English"), "XQuery"))))
Kind regards,
Geert
Drs. G.P.H. Josten
Consultant
http://www.daidalos.nl/
Daidalos BV
Source of Innovation
Hoekeindsehof 1-4
2665 JZ Bleiswijk
Tel.: +31 (0) 10 850 1200
Fax: +31 (0) 10 850 1199
http://www.daidalos.nl/
KvK 27164984
De informatie - verzonden in of met dit emailbericht - is afkomstig van
Daidalos BV en is uitsluitend bestemd voor de geadresseerde. Indien u dit
bericht onbedoeld hebt ontvangen, verzoeken wij u het te verwijderen. Aan dit
bericht kunnen geen rechten worden ontleend.
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general