Saxon.Api

 

 

Saxon.Api

Class XsdCompiler


public abstract class XsdCompiler

An XsdCompiler object allows XSD schema documents to be compiled. The compiler holds information options controlling how the schema is compiled.

To construct an XsdCompiler, use the factory method NewXsdCompiler on the XsdCompiler.Processor object.

An XsdCompiler may be used repeatedly to compile multiple schemas. Any changes made to the XsdCompiler do not affect schemas that have already been compiled. An XsdCompiler may be used concurrently in multiple threads, but it should not then be modified once initialized.

The abstract XsdCompiler class is included in all Saxon editions, but the concrete subclass that does real schema processing is available only in Saxon-EE.

Nested Classes

class XsdCompiler.SchemaSource

Embedded class defining the source for a particular schema document.

 

Property Summary

 ErrorReporter ErrorReporter

The ErrorReporter to be used when compiling schema documents.

 Processor Processor

The Processor that was used to create this XsdCompiler

 SchemaResolver SchemaResolver

The SchemaResolver to be used when resolving references to schema documents.

 string XsdVersion

The version of the W3C XML Schema Specification handled by this XsdCompiler.

 

Method Summary

 XsdSchema Combine (XsdSchema[] schemas)

Combine a set of schemas into one

 XsdSchema Compile (XsdCompiler.SchemaSource[] sources)

Load a schema document from a given SchemaSource, or from a set of SchemaSources. The schema components are returned by the method as an XsdSchema object.

 XsdSchema Compile (Stream input)

Compile a schema supplied as a Stream. The resulting schema components are added to the cache. The base URI of the schema document is taken as the current working directory.

 XsdSchema Compile (Stream input, Uri baseUri)

Compile a schema supplied as a Stream. The resulting schema components are added to the cache.

 XsdSchema Compile (TextReader input, Uri baseUri)

Compile a schema supplied as a TextReader. The resulting schema components are added to the cache.

 XsdSchema Compile (TextReader reader)

Compile a schema supplied as a TextReader. The base URI of the schema document is taken as the current working directory.

 XsdSchema Compile (Uri uri)

Compile a schema, retrieving the source using a URI.

 XsdSchema Compile (FileInfo file)

Compile a schema, retrieving the source from a given file.

 XsdSchema Compile (XmlReader reader)

Compile a schema, retrieving the source from a supplied XML reader (that is, an XML parser). The base URI of the document is taken from the BaseUri property of the XmlReader.

 XsdSchema Compile (XdmNode node)

Compile a schema, retrieving the source from a supplied XDM node. This may be a document node whose child is an xs:schema element, or it may be the xs:schema element itself. The base URI of the document is taken from the BaseUri property of the XdmNode.

 XsdSchema EmptySchema ()

Return an empty schema. This may be useful for validating instance documents when all the actual schema definitions are linked from the instance document using {@code xsi:schemaLocation} and {@code xsi:noNamespaceSchemaLocation} attributes

 XsdSchema ImportComponents (XsdCompiler.SchemaSource source)

Import a precompiled Schema Component Model from a given Source. The schema components derived from this schema document are added to the cache of schema components maintained by this XsdCompiler

 

Property Detail

ErrorReporter

public abstract ErrorReporter ErrorReporter {get; set; }

The ErrorReporter to be used when compiling schema documents.

Processor

public abstract Processor Processor {get; }

The Processor that was used to create this XsdCompiler

SchemaResolver

public abstract SchemaResolver SchemaResolver {set; }

The SchemaResolver to be used when resolving references to schema documents.

XsdVersion

public abstract string XsdVersion {get; set; }

The version of the W3C XML Schema Specification handled by this XsdCompiler.

The value must be "1.0" (indicating XML Schema 1.0) or "1.1" (indicating XML Schema 1.1). The default is "1.0". New constructs defined in XSD 1.1 are rejected unless this property is set to "1.1" before compiling the schema.

Method Detail

Combine

public abstract XsdSchema Combine(XsdSchema[] schemas)

Combine a set of schemas into one

Parameters:

schemas - The schemas to be combined

Returns:

The combined schema

Compile

public abstract XsdSchema Compile(XsdCompiler.SchemaSource[] sources)

Load a schema document from a given SchemaSource, or from a set of SchemaSources. The schema components are returned by the method as an XsdSchema object.

Parameters:

sources - A set of SchemaSources.

Returns:

The schema constructed from the supplied SchemaSources.

Compile

public XsdSchema Compile(Stream input)

Compile a schema supplied as a Stream. The resulting schema components are added to the cache. The base URI of the schema document is taken as the current working directory.

Parameters:

input - A stream containing the source text of the schema. This method will consume the supplied stream. It is the caller's responsibility to close the stream after use.

Returns:

The schema constructed from this input document.

Compile

public XsdSchema Compile(Stream input,
Uri baseUri)

Compile a schema supplied as a Stream. The resulting schema components are added to the cache.

Parameters:

input - A stream containing the source text of the schema. This method will consume the supplied stream. It is the caller's responsibility to close the stream after use.
baseUri - The base URI of the schema document, for resolving any references to other schema documents

Returns:

The schema constructed from this input document.

Compile

public XsdSchema Compile(TextReader input,
Uri baseUri)

Compile a schema supplied as a TextReader. The resulting schema components are added to the cache.

Parameters:

input - A TextReader that supplies the source text of the schema. This method will consume the supplied stream. It is the caller's responsibility to close the reader after use.
baseUri - The base URI of the schema document, for resolving any references to other schema documents

Returns:

The schema constructed from this input document.

Compile

public XsdSchema Compile(TextReader reader)

Compile a schema supplied as a TextReader. The base URI of the schema document is taken as the current working directory.

Parameters:

reader - A TextReader that supplies the source text of the schema. This method will consume the supplied stream. It is the caller's responsibility to close the reader after use.

Returns:

The schema constructed from this input document.

Compile

public XsdSchema Compile(Uri uri)

Compile a schema, retrieving the source using a URI.

The document located via the URI is parsed using the System.Xml parser.

Parameters:

uri - The URI identifying the location where the schema document can be found

Returns:

The schema constructed from this input document.

Compile

public XsdSchema Compile(FileInfo file)

Compile a schema, retrieving the source from a given file.

The content of the file is parsed using the System.Xml parser.

Parameters:

file - The file where the schema document can be found

Returns:

The schema constructed from this input document.

Compile

public XsdSchema Compile(XmlReader reader)

Compile a schema, retrieving the source from a supplied XML reader (that is, an XML parser). The base URI of the document is taken from the BaseUri property of the XmlReader.

Parameters:

reader - The XML reader supplying the schema document

Returns:

The schema constructed from this input document.

Compile

public XsdSchema Compile(XdmNode node)

Compile a schema, retrieving the source from a supplied XDM node. This may be a document node whose child is an xs:schema element, or it may be the xs:schema element itself. The base URI of the document is taken from the BaseUri property of the XdmNode.

Parameters:

node - The XML reader supplying the schema document

Returns:

The schema constructed from this input document.

EmptySchema

public abstract XsdSchema EmptySchema()

Return an empty schema. This may be useful for validating instance documents when all the actual schema definitions are linked from the instance document using {@code xsi:schemaLocation} and {@code xsi:noNamespaceSchemaLocation} attributes

Returns:

An empty schema

ImportComponents

public abstract XsdSchema ImportComponents(XsdCompiler.SchemaSource source)

Import a precompiled Schema Component Model from a given Source. The schema components derived from this schema document are added to the cache of schema components maintained by this XsdCompiler

Parameters:

source - The XML file containing the schema component model, as generated by a previous call on XsdSchema#exportComponents

Returns:

The schema produced by processing the supplied schema component model export file