The FOR field function evaluates an expression and assigns a resulting value of TRUE, FALSE, or UNKNOWN
FOR enables you to write an expression that iterates over all instances of a repeating field. For each instance it processes a boolean expression and collates the results.
FOR ALL Body.Invoice.Purchases."Item"[] AS I (I.Quantity <= 50)
In some cases, this syntax appears unnecessary, because you can get that information from the context, but it is done for consistency with other pieces of syntax.
The ASclause associates the name I in the field reference with the current instance of the repeating field. This is similar to the concept of iterator classes used in some object oriented languages such as C++. The expression in parentheses is a predicate that is evaluated for each instance of the Item field.
FOR ANY Body.Invoice.Purchases."Item"[] AS I (I.Title = 'The XML Companion')the sub-predicate evaluates to TRUE. However, this next expression returns FALSE:
FOR ANY Body.Invoice.Purchases."Item"[] AS I (I.Title = 'C Primer')because the C Primer is not included on this invoice. If in this instance some of the items in the invoice do not include a book title field, the sub-predicate returns UNKNOWN, and the quantified predicate returns the value UNKNOWN.
FOR ANY Body.Invoice.Purchases."Item"[] AS I (I.Book IS NOT NULL AND I.Book.Title = 'C Primer')The IS NOT NULL predicate ensures that, if an Item field does not contain a Book, a FALSE value is returned from the sub-predicate.
Notices |
Trademarks |
Downloads |
Library |
Support |
Feedback
![]() ![]() |
ak18490_ |