FOR, SOME, EVERY, quantifiers in Xquery : Marklogic Quantified Expressions
Let below XML file is stored in Marklogic DB.
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
FOR statement: For statement is used to iterate over to sequence items. In our XML case, if we want to iterate on each product element of this XML.
We can write the query below in Marklogic:
for $each in fn:doc("catalog.xml)/catalog return $each
SOME Statement: If we want to check whether an item is available on a particular path or not, we can use the below query, It doesn't return any iterate item as like in FOR statement. It always returns the xs:boolean value "True" or "False". Look like some statement works as the "OR" operator, If any single condition will match the checking string, it will return TRUE.
some $dept in fn:doc("catalog.xml")/catalog/product/@dept satisfies ($dept = "ACC")
The above statement will return the "True" result.
As the catalog XML has the value "ACC" in the @dept attribute.
EVERY Statement: If we want to check all conditions should be matched or true, then we should need to use the EVERY statement of Xquery.
every $dept in fn:doc("catalog.xml")/catalog/product/@dept satisfies ($dept = "ACC")
Comments
Post a Comment