Conclusions

In this chapter we illustrated the benefits of static typing for a small but nontrivial XQuery application and then explained how XQuery infers the type for each expression during static analysis. Along the way, we learned about the many common errors that can be detected by static typing, including misspelled names in path expressions and constructors, and the use of an expression whose type is not compatible with the type required by the context in which the expression is used. We also showed how to compensate for the limitations of static typing, such as refining the cardinality of a type.

We expect that the benefits of static typing will increase with the size of XQuery applications. Like other modern languages, XQuery supports ...

Get XQuery from the Experts: A Guide to the W3C XML Query Language now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.