SaxonC 13.0.0
Saxon Processor library for C/C++, PHP and Python
Loading...
Searching...
No Matches
XsdCompiler Class Reference

#include <XsdCompiler.h>

Public Member Functions

 XsdCompiler ()
 Default constructor.
 XsdCompiler (SaxonProcessor *proc, std::string cwd="")
 Constructor with the SaxonProcessor supplied.
 XsdCompiler (const XsdCompiler &other)
 XsdCompiler copy constructor.
 ~XsdCompiler ()
 Destructor method to clean up the XsdCompiler.
void setcwd (const char *cwd)
 The copy assignment= operator.
const char * getcwd ()
 Get the current working directory set on this validator.
void setXsdVersion (const char *version)
 Set the version of XSD in use for this schema.
const char * getXsdVersion ()
 Get the version of XSD in use for this schema.
XsdSchemacompileFromString (const char *source, const char *encoding=nullptr)
 Set the ErrorReporter to be used while loading and validating schema documents.
XsdSchemacompileFromFiles (const std::vector< std::string > &filenames)
 Load a schema document from a given File or set of files as a vector.
XsdSchemacompileFromFiles (std::initializer_list< std::string > filenamesList)
 Load a schema document from a given File or set of files as a list.
XsdSchemacompileFromFiles (const char **filenames, int count)
 Load a schema document from a given File or set of files as a vector.
XsdSchemacompileFromFile (const char *filename)
 Load a schema document from a given File or set of files.
XsdSchemacompileFromNode (XdmNode *node)
 Load a schema document from Node.
XsdSchemacombine (XsdSchema **schemas, int num_schemas)
 Combine a set of schemas into one.
XsdSchemaemptySchema ()
 Return an empty schema.
XsdSchemaimportComponents (const char *filename)
 Import a precompiled Schema Component Model from a given Source.
XsdSchemaimportComponentsFromNode (XdmNode *node)
 Import a precompiled Schema Component Model from a given Source.
void setProperty (const char *name, const char *value)
void clearProperties ()
 Clear configuration property values set.

Friends

class XsdSchema

Detailed Description

The XsdCompiler is used to load schema documents, and to set options for the way in which they are loaded.

The XsdCompiler is new in Saxon 13; it replaces the internal class SchemaManager which is retained (but deprecated) to provide a degree of backwards compatibility.

A schema, represented by an XsdSchema object, is a collection of schema components, which may come from one schema document or from a collection of schema documents. An XsdCompiler is used to create XsdSchema objects from source schema documents.

Schema processing requires Saxon-EE.

An XsdCompiler is created using the factory method SaxonProcessor.newXsdCompiler. The normal pattern of usage is to set options, then call compileFromFile(onst char * file...) or compileFromString(const char* content...) to compile one or more schema documents into a schema. The schema can be used to validate instance documents using the method XsdSchema.newValidator(), and it can be added to the static context of XQuery queries and XSLT stylesheets using the methods XQueryCompiler#useSchema(XsdSchema) and XsltCompiler#useSchema(XsdSchema).

Since
13.0

Constructor & Destructor Documentation

◆ XsdCompiler() [1/3]

XsdCompiler::XsdCompiler ( )

Default constructor.

Creates a Schema Validator

Exceptions
SaxonApiException

◆ XsdCompiler() [2/3]

XsdCompiler::XsdCompiler ( SaxonProcessor * proc,
std::string cwd = "" )

Constructor with the SaxonProcessor supplied.

The supplied processor should have license flag set to true for the Schema Validator to operate.

Parameters
proc- pointer to the SaxonProcessor object
cwd- the current working directory
Exceptions
SaxonApiException

◆ XsdCompiler() [3/3]

XsdCompiler::XsdCompiler ( const XsdCompiler & other)

XsdCompiler copy constructor.

Parameters
other- XsdCompiler

Member Function Documentation

◆ combine()

XsdSchema * XsdCompiler::combine ( XsdSchema ** schemas,
int num_schemas )

Combine a set of schemas into one.

Parameters
schemasthe input schemas. These are not modified.
Returns
the combined schema
Exceptions
SaxonApiExceptionif the schemas are not compatible, for example if they contain duplicate names.
Since
13.0

◆ compileFromFile()

XsdSchema * XsdCompiler::compileFromFile ( const char * filename)

Load a schema document from a given File or set of files.

The schema components derived from this schema document are retained by this SchemaManager as the current schema, and are also returned by the method as an XsdSchema object.

Parameters
filenamethe document containing the schema. The getSystemId() method applied to this Source must return a base URI suitable for resolving xs:include and xs:import directives. The document may be either a schema document in source XSD format, or a compiled schema in Saxon-defined SCM format (as produced using the -export option)
Returns
the resulting schema.
Exceptions
SaxonApiExceptionif the schema document is not valid.
Since
13.0

◆ compileFromFiles() [1/3]

XsdSchema * XsdCompiler::compileFromFiles ( const char ** filenames,
int count )

Load a schema document from a given File or set of files as a vector.

The schema components derived from this schema document are retained by this SchemaManager as the current schema, and are also returned by the method as an XsdSchema object.

Parameters
filenamesof the documentscontaining the schema as an array of const char. The getSystemId() method applied to this Source must return a base URI suitable for resolving xs:include and xs:import directives. The document may be either a schema document in source XSD format, or a compiled schema in Saxon-defined SCM format (as produced using the -export option)
count- number of items in the array
Returns
the resulting schema.
Exceptions
SaxonApiExceptionif the schema document is not valid.
Since
13.0

◆ compileFromFiles() [2/3]

XsdSchema * XsdCompiler::compileFromFiles ( const std::vector< std::string > & filenames)

Load a schema document from a given File or set of files as a vector.

The schema components derived from this schema document are retained by this SchemaManager as the current schema, and are also returned by the method as an XsdSchema object.

Parameters
filenamesof the documentscontaining the schema as a vector. The getSystemId() method applied to this Source must return a base URI suitable for resolving xs:include and xs:import directives. The document may be either a schema document in source XSD format, or a compiled schema in Saxon-defined SCM format (as produced using the -export option)
Returns
the resulting schema.
Exceptions
SaxonApiExceptionif the schema document is not valid.
Since
13.0

◆ compileFromFiles() [3/3]

XsdSchema * XsdCompiler::compileFromFiles ( std::initializer_list< std::string > filenamesList)

Load a schema document from a given File or set of files as a list.

The schema components derived from this schema document are retained by this SchemaManager as the current schema, and are also returned by the method as an XsdSchema object.

Parameters
filenamesList
filenamesof the documentscontaining the schema as a list. The getSystemId() method applied to this Source must return a base URI suitable for resolving xs:include and xs:import directives. The document may be either a schema document in source XSD format, or a compiled schema in Saxon-defined SCM format (as produced using the -export option)
Returns
the resulting schema.
Exceptions
SaxonApiExceptionif the schema document is not valid.
Since
13.0

◆ compileFromNode()

XsdSchema * XsdCompiler::compileFromNode ( XdmNode * node)

Load a schema document from Node.

The schema components derived from this schema document are retained by this SchemaManager as the current schema, and are also returned by the method as an XsdSchema object.

Parameters
node- the node containing the schema. The getSystemId() method applied to this Source must return a base URI suitable for resolving xs:include and xs:import directives. The document may be either a schema document in source XSD format, or a compiled schema in Saxon-defined SCM format (as produced using the -export option)
Returns
the resulting schema.
Exceptions
SaxonApiExceptionif the schema document is not valid.
Since
13.0

◆ compileFromString()

XsdSchema * XsdCompiler::compileFromString ( const char * source,
const char * encoding = nullptr )

Set the ErrorReporter to be used while loading and validating schema documents.

Parameters
reporterThe error reporter to be used. This is notified of all errors detected during the compilation. May be set to null to revert to the default ErrorReporter. Get the ErrorReporter being used while loading and validating schema documents
Returns
reporter The error reporter in use. This is notified of all errors detected during the compilation. Returns null if no user-supplied ErrorReporter has been set. Load a schema document from a given Source. The schema components derived from this schema document are retained by this SchemaManager as the current schema, and are also returned by the method as an XsdSchema object.

This method can only be called once on a given SchemaManager object.

If the source is a StreamSource or a SAXSource with no user-supplied XmlReader, then Saxon will allocate and configure an XmlReader. This will NOT take account of any configuration level parser settings (such as DTD validation, XInclude processing, and so on). The recommended way to customise parsing options is by creating an XmlReader and supplying this as a property of a SAXSource. For options when parsing included or imported stylesheet modules, it is possible to do the same in the SchemaURIResolver set using the setSchemaURIResolver(SchemaURIResolver) method.

Parameters
sourcethe documents containing the schema. The getSystemId() method applied to each Source must return a base URI suitable for resolving xs:include and xs:import directives. The document may be either a schema document in source XSD format, or a compiled schema in Saxon-defined SCM format.
encoding- the encoding of the stylesheet string. If not specified then the platform default encoding is used.
Returns
the resulting schema.
Exceptions
SaxonApiExceptionif any of the schema documents is not valid, or if there are conflicts between the schema documents.

◆ emptySchema()

XsdSchema * XsdCompiler::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 xsi:schemaLocation and xsi:noNamespaceSchemaLocation attributes

Returns
an empty schema

◆ getcwd()

const char * XsdCompiler::getcwd ( )

Get the current working directory set on this validator.

Memory deallocation is handled internally.

Returns
Current working directory. Memory deallocation is handled internally.

◆ getXsdVersion()

const char * XsdCompiler::getXsdVersion ( )

Get the version of XSD in use for this schema.

The value will be "1.0" or "1.1"

Returns
the version of XSD in use.

◆ importComponents()

XsdSchema * XsdCompiler::importComponents ( const char * filename)

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 SchemaManager

Parameters
sourcethe 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
Exceptions
SaxonApiException

◆ importComponentsFromNode()

XsdSchema * XsdCompiler::importComponentsFromNode ( XdmNode * node)

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 SchemaManager

Parameters
sourcethe 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
Exceptions
SaxonApiException

◆ setcwd()

void XsdCompiler::setcwd ( const char * cwd)

The copy assignment= operator.

Create a copy of the XsdCompiler.

Parameters
other- XsdCompiler object Set the current working directory for the validator.
cwd- Supplied working directory which replaces any set cwd. Ignore if cwd is NULL.

◆ setXsdVersion()

void XsdCompiler::setXsdVersion ( const char * version)

Set the version of XSD in use for this schema.

The value must be "1.0" or "1.1". The default is taken from the configuration property Feature#XSD_VERSION at the time the XsdSchemaCompiler is instantiated. By default this is "1.1".

Parameters
versionthe version of the XSD specification/language: either "1.0" or "1.1".

The documentation for this class was generated from the following files: