![]() |
SaxonC 13.0.0
Saxon Processor library for C/C++, PHP and Python
|
#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. | |
| XsdSchema * | compileFromString (const char *source, const char *encoding=nullptr) |
| Set the ErrorReporter to be used while loading and validating schema documents. | |
| XsdSchema * | compileFromFiles (const std::vector< std::string > &filenames) |
| Load a schema document from a given File or set of files as a vector. | |
| XsdSchema * | compileFromFiles (std::initializer_list< std::string > filenamesList) |
| Load a schema document from a given File or set of files as a list. | |
| XsdSchema * | compileFromFiles (const char **filenames, int count) |
| Load a schema document from a given File or set of files as a vector. | |
| XsdSchema * | compileFromFile (const char *filename) |
| Load a schema document from a given File or set of files. | |
| XsdSchema * | compileFromNode (XdmNode *node) |
| Load a schema document from Node. | |
| XsdSchema * | combine (XsdSchema **schemas, int num_schemas) |
| Combine a set of schemas into one. | |
| XsdSchema * | emptySchema () |
| Return an empty schema. | |
| XsdSchema * | importComponents (const char *filename) |
| Import a precompiled Schema Component Model from a given Source. | |
| XsdSchema * | importComponentsFromNode (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 |
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).
| XsdCompiler::XsdCompiler | ( | ) |
Default constructor.
Creates a Schema Validator
| SaxonApiException |
| 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.
| proc | - pointer to the SaxonProcessor object |
| cwd | - the current working directory |
| SaxonApiException |
| XsdCompiler::XsdCompiler | ( | const XsdCompiler & | other | ) |
XsdCompiler copy constructor.
| other | - XsdCompiler |
Combine a set of schemas into one.
| schemas | the input schemas. These are not modified. |
| SaxonApiException | if the schemas are not compatible, for example if they contain duplicate names. |
| 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.
| filename | the 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) |
| SaxonApiException | if the schema document is not valid. |
| 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.
| filenames | of 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 |
| SaxonApiException | if the schema document is not valid. |
| 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.
| filenames | of 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) |
| SaxonApiException | if the schema document is not valid. |
| 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.
| filenamesList | |
| filenames | of 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) |
| SaxonApiException | if the schema document is not valid. |
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.
| 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) |
| SaxonApiException | if the schema document is not valid. |
| XsdSchema * XsdCompiler::compileFromString | ( | const char * | source, |
| const char * | encoding = nullptr ) |
Set the ErrorReporter to be used while loading and validating schema documents.
| reporter | The 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 |
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.
| source | the 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. |
| SaxonApiException | if any of the schema documents is not valid, or if there are conflicts between the schema documents. |
| 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
| const char * XsdCompiler::getcwd | ( | ) |
Get the current working directory set on this validator.
Memory deallocation is handled internally.
| const char * XsdCompiler::getXsdVersion | ( | ) |
Get the version of XSD in use for this schema.
The value will be "1.0" or "1.1"
| 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
| source | the XML file containing the schema component model, as generated by a previous call on XsdSchema#exportComponents |
| SaxonApiException |
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
| source | the XML file containing the schema component model, as generated by a previous call on XsdSchema#exportComponents |
| SaxonApiException |
| void XsdCompiler::setcwd | ( | const char * | cwd | ) |
The copy assignment= operator.
Create a copy of the XsdCompiler.
| 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. |
| 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".
| version | the version of the XSD specification/language: either "1.0" or "1.1". |