O'Reilly logo

XQuery by Priscilla Walmsley

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

In-Scope Schema Definitions

In any module, there is a set of in-scope schema definitions (ISSDs) that can be referenced within the query. This includes type definitions, element declarations and attribute declarations. They can describe the input documents, the result XML, or both. You may want to reference schema definitions for a number of reasons, such as:

  • To write functions that only accept values of a certain user-defined type. For example, a function that queries sleeve length might accept only elements of type ShirtType.

  • To validate a node that you constructed in your query. For example, you used constructors to create a product element and its children, and you want to ensure that it is valid according to ProductType.

  • To determine whether a value is an instance of a particular user-defined type in order to decide how to process it. For example, if the size value is an instance of ShirtSizeType, you want to call one function, whereas if it is a value of HatSizeType, you want to call a different function.

  • You want to perform static type analysis and you want the schema definitions to be taken into account.

If you don't need to do any of these things, you are not required to include your schemas in the in-scope schema definitions. This is true even if your input document was validated against a schema.

Where Do In-Scope Schema Definitions Come from?

Definitions for the built-in types are automatically included in the ISSD. A processor may include additional schema declarations and ...

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