O'Reilly logo

XQuery from the Experts: A Guide to the W3C XML Query Language by Philip Wadler, Jim Tivy, Jérôme Siméon, Michael Rys, Jonathan Robie, Michael Kay, Mary Fernández, Denise Draper, Don Chamberlin, Howard Katz - Editor

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Validation Context

Validation makes sense only in a given context. Validating a name element inside a user element checks that it contains first and last elements; while validating a name element inside an article element checks that it contains a string.

In addition to keeping track of the types of variables, the static environment contains a validation context. Initially, this context is set to global. During static analysis, when an element constructor with a given name is entered, the context is extended by that element name within the constructor. For example, consider the query in Listing 4.10, which constructs a user element, omitting the first name if it is too long, or the rating if it is too low.

Listing 4.10. Validation Context Specified ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required