saxon:schema

Returns information about the schema.

schema() ➔ function(*)?

There are no arguments

Result

function(*)?

schema($kind as xs:string, $name as xs:QName) ➔ function(*)?

Arguments

 

$kind

xs:string

The kind of component required

 

$name

xs:QName

The name of the component required

Result

function(*)?

Namespace

http://saxon.sf.net/

Details

In a non-schema-aware configuration, both functions return the empty sequence.

In a schema-aware configuration, the first function returns the schema component representing the "schema as a whole", that is, the schema components from all the schema documents that have been loaded into the Configuration. The second function returns a specific named schema component, for example an element declaration.

With the two-argument function, the first argument must be one of "type definition", "attribute declaration", "element declaration", "attribute group definition", "model group definition", "notation declaration", or "identity-constraint definition"; the second argument is the QName identifying the component by its target namespace and local name properties.

The returned schema component is represented as a function. This function accepts a property name as a string argument, and returns the value of the property. The value of the property may be a simple value such as a boolean or a string, or it may be a sequence of such values. In some cases the value of a property is another schema component; this will be returned as a function item, which can be dynamically invoked to determine its properties, and so on. ('Property records' in the schema component model are represented in exactly the same way as schema components.)

The model is faithful to the specification of the schema component model as it appears in the XSD 1.1 specification from W3C. There are a few small variations:

  1. Saxon currently does not provide access to annotations (they are discarded at schema processing time)

  2. One or two other properties are not fully implemented, for example, {context} and {fundamental facets}

  3. The types available directly from the Schema do not include built-in types

  4. Saxon represents multiple patterns and assertions of a simple type as multiple facet objects rather than a single facet object

  5. There's one property that's hard to represent directly in the XDM data model: the value of the enumeration facet is a sequence of sequences. So Saxon is currently exposing the enumeration values as string values rather than typed values.

Every component has an additional property class which tells you what kind of schema component it is. This is particularly necessary for the components representing facets, where the class is the only way of telling, for example, whether you have a minInclusive or a maxExclusive facet.

Most components have an additional property implementation whose value is the wrapped Java object representing the component in Saxon's implementation. For example, for an element declaration the implementation property returns an object of Java type com.saxonica.ee.schema.ElementDecl whose methods can be used using the normal facilities for reflexive extension functions.

Here's a simple example that tests whether a particular element has element-only content:

let $bookDecl := saxon:schema('element declaration', QName('', 'book')) return if ($bookDecl('type definition')('variety') = 'element-only') then ... else ...