libxml2
Loading...
Searching...
No Matches
Typedefs | Enumerations | Functions
xmlschemas.h File Reference

incomplete XML Schemas structure implementation More...

Typedefs

typedef struct _xmlSchema xmlSchema
 XML schema.
 
typedef void(* xmlSchemaValidityErrorFunc) (void *ctx, const char *msg,...)
 Signature of an error callback from an XSD validation.
 
typedef void(* xmlSchemaValidityWarningFunc) (void *ctx, const char *msg,...)
 Signature of a warning callback from an XSD validation.
 
typedef struct _xmlSchemaParserCtxt xmlSchemaParserCtxt
 Schema parser context.
 
typedef struct _xmlSchemaValidCtxt xmlSchemaValidCtxt
 Schema validation context.
 
typedef int(* xmlSchemaValidityLocatorFunc) (void *ctx, const char **file, unsigned long *line)
 A schemas validation locator, a callback called by the validator.
 
typedef struct _xmlSchemaSAXPlug xmlSchemaSAXPlugStruct
 Interface to insert Schemas SAX validation in a SAX stream.
 

Enumerations

enum  xmlSchemaValidError
 This error codes are obsolete; not used any more.
 
enum  xmlSchemaValidOption
 This is the set of XML Schema validation options.
 

Functions

xmlSchemaParserCtxtxmlSchemaNewParserCtxt (const char *URL)
 Create an XML Schemas parse context for that file/resource expected to contain an XML Schemas file.
 
xmlSchemaParserCtxtxmlSchemaNewMemParserCtxt (const char *buffer, int size)
 Create an XML Schemas parse context for that memory buffer expected to contain an XML Schemas file.
 
xmlSchemaParserCtxtxmlSchemaNewDocParserCtxt (xmlDoc *doc)
 Create an XML Schemas parse context for that document.
 
void xmlSchemaFreeParserCtxt (xmlSchemaParserCtxt *ctxt)
 Free the resources associated to the schema parser context.
 
void xmlSchemaSetParserErrors (xmlSchemaParserCtxt *ctxt, xmlSchemaValidityErrorFunc err, xmlSchemaValidityWarningFunc warn, void *ctx)
 Set the callback functions used to handle errors for a validation context.
 
void xmlSchemaSetParserStructuredErrors (xmlSchemaParserCtxt *ctxt, xmlStructuredErrorFunc serror, void *ctx)
 Set the structured error callback.
 
int xmlSchemaGetParserErrors (xmlSchemaParserCtxt *ctxt, xmlSchemaValidityErrorFunc *err, xmlSchemaValidityWarningFunc *warn, void **ctx)
 Get the callback information used to handle errors for a parser context.
 
void xmlSchemaSetResourceLoader (xmlSchemaParserCtxt *ctxt, xmlResourceLoader loader, void *data)
 Register a callback function that will be called to load documents or external entities.
 
int xmlSchemaIsValid (xmlSchemaValidCtxt *ctxt)
 Check if any error was detected during validation.
 
xmlSchemaxmlSchemaParse (xmlSchemaParserCtxt *ctxt)
 parse a schema definition resource and build an internal XML Schema structure which can be used to validate instances.
 
void xmlSchemaFree (xmlSchema *schema)
 Deallocate a Schema structure.
 
void xmlSchemaDump (FILE *output, xmlSchema *schema)
 Dump a Schema structure.
 
void xmlSchemaSetValidErrors (xmlSchemaValidCtxt *ctxt, xmlSchemaValidityErrorFunc err, xmlSchemaValidityWarningFunc warn, void *ctx)
 Set the error and warning callback information.
 
void xmlSchemaSetValidStructuredErrors (xmlSchemaValidCtxt *ctxt, xmlStructuredErrorFunc serror, void *ctx)
 Set the structured error callback.
 
int xmlSchemaGetValidErrors (xmlSchemaValidCtxt *ctxt, xmlSchemaValidityErrorFunc *err, xmlSchemaValidityWarningFunc *warn, void **ctx)
 Get the error and warning callback information.
 
int xmlSchemaSetValidOptions (xmlSchemaValidCtxt *ctxt, int options)
 Sets the options to be used during the validation.
 
void xmlSchemaValidateSetFilename (xmlSchemaValidCtxt *vctxt, const char *filename)
 Workaround to provide file error reporting information when this is not provided by current APIs.
 
int xmlSchemaValidCtxtGetOptions (xmlSchemaValidCtxt *ctxt)
 Get the validation context options.
 
xmlSchemaValidCtxtxmlSchemaNewValidCtxt (xmlSchema *schema)
 Create an XML Schemas validation context based on the given schema.
 
void xmlSchemaFreeValidCtxt (xmlSchemaValidCtxt *ctxt)
 Free the resources associated to the schema validation context.
 
int xmlSchemaValidateDoc (xmlSchemaValidCtxt *ctxt, xmlDoc *instance)
 Validate a document tree in memory.
 
int xmlSchemaValidateOneElement (xmlSchemaValidCtxt *ctxt, xmlNode *elem)
 Validate a branch of a tree, starting with the given elem.
 
int xmlSchemaValidateStream (xmlSchemaValidCtxt *ctxt, xmlParserInputBuffer *input, xmlCharEncoding enc, const xmlSAXHandler *sax, void *user_data)
 Validate an input based on a flow of SAX event from the parser and forward the events to the sax handler with the provided user_data the user provided sax handler must be a SAX2 one.
 
int xmlSchemaValidateFile (xmlSchemaValidCtxt *ctxt, const char *filename, int options)
 Do a schemas validation of the given resource, it will use the SAX streamable validation internally.
 
xmlParserCtxtxmlSchemaValidCtxtGetParserCtxt (xmlSchemaValidCtxt *ctxt)
 allow access to the parser context of the schema validation context
 
xmlSchemaSAXPlugStructxmlSchemaSAXPlug (xmlSchemaValidCtxt *ctxt, xmlSAXHandler **sax, void **user_data)
 Plug a SAX based validation layer in a SAX parsing event flow.
 
int xmlSchemaSAXUnplug (xmlSchemaSAXPlugStruct *plug)
 Unplug a SAX based validation layer in a SAX parsing event flow.
 
void xmlSchemaValidateSetLocator (xmlSchemaValidCtxt *vctxt, xmlSchemaValidityLocatorFunc f, void *ctxt)
 Allows to set a locator function to the validation context, which will be used to provide file and line information since those are not provided as part of the SAX validation flow Setting f to NULL disable the locator.
 

Detailed Description

incomplete XML Schemas structure implementation

interface to the XML Schemas handling and schema validity checking, it is incomplete right now.

Author
Daniel Veillard

Typedef Documentation

◆ xmlSchemaValidityErrorFunc

typedef void(* xmlSchemaValidityErrorFunc) (void *ctx, const char *msg,...)

Signature of an error callback from an XSD validation.

Parameters
ctxthe validation context
msgthe message
...extra arguments

◆ xmlSchemaValidityLocatorFunc

typedef int(* xmlSchemaValidityLocatorFunc) (void *ctx, const char **file, unsigned long *line)

A schemas validation locator, a callback called by the validator.

This is used when file or node information are not available to find out what file and line number are affected

Parameters
ctxuser provided context
filereturned file information
linereturned line information
Returns
0 in case of success and -1 in case of error

◆ xmlSchemaValidityWarningFunc

typedef void(* xmlSchemaValidityWarningFunc) (void *ctx, const char *msg,...)

Signature of a warning callback from an XSD validation.

Parameters
ctxthe validation context
msgthe message
...extra arguments

Function Documentation

◆ xmlSchemaDump()

void xmlSchemaDump ( FILE *  output,
xmlSchema schema 
)

Dump a Schema structure.

Parameters
outputthe file output
schemaa schema structure

◆ xmlSchemaFree()

void xmlSchemaFree ( xmlSchema schema)

Deallocate a Schema structure.

Parameters
schemaa schema structure

◆ xmlSchemaFreeParserCtxt()

void xmlSchemaFreeParserCtxt ( xmlSchemaParserCtxt ctxt)

Free the resources associated to the schema parser context.

Parameters
ctxtthe schema parser context

◆ xmlSchemaFreeValidCtxt()

void xmlSchemaFreeValidCtxt ( xmlSchemaValidCtxt ctxt)

Free the resources associated to the schema validation context.

Parameters
ctxtthe schema validation context

◆ xmlSchemaGetParserErrors()

int xmlSchemaGetParserErrors ( xmlSchemaParserCtxt ctxt,
xmlSchemaValidityErrorFunc err,
xmlSchemaValidityWarningFunc warn,
void **  ctx 
)

Get the callback information used to handle errors for a parser context.

Parameters
ctxta XMl-Schema parser context
errthe error callback result
warnthe warning callback result
ctxcontextual data for the callbacks result
Returns
-1 in case of failure, 0 otherwise

◆ xmlSchemaGetValidErrors()

int xmlSchemaGetValidErrors ( xmlSchemaValidCtxt ctxt,
xmlSchemaValidityErrorFunc err,
xmlSchemaValidityWarningFunc warn,
void **  ctx 
)

Get the error and warning callback information.

Parameters
ctxta XML-Schema validation context
errthe error function result
warnthe warning function result
ctxthe functions context result
Returns
-1 in case of error and 0 otherwise

◆ xmlSchemaIsValid()

int xmlSchemaIsValid ( xmlSchemaValidCtxt ctxt)

Check if any error was detected during validation.

Parameters
ctxtthe schema validation context
Returns
1 if valid so far, 0 if errors were detected, and -1 in case of internal error.

◆ xmlSchemaNewDocParserCtxt()

xmlSchemaParserCtxt * xmlSchemaNewDocParserCtxt ( xmlDoc doc)

Create an XML Schemas parse context for that document.

NB. The document may be modified during the parsing process.

Parameters
doca preparsed document tree
Returns
the parser context or NULL in case of error

◆ xmlSchemaNewMemParserCtxt()

xmlSchemaParserCtxt * xmlSchemaNewMemParserCtxt ( const char *  buffer,
int  size 
)

Create an XML Schemas parse context for that memory buffer expected to contain an XML Schemas file.

Parameters
buffera pointer to a char array containing the schemas
sizethe size of the array
Returns
the parser context or NULL in case of error

◆ xmlSchemaNewParserCtxt()

xmlSchemaParserCtxt * xmlSchemaNewParserCtxt ( const char *  URL)

Create an XML Schemas parse context for that file/resource expected to contain an XML Schemas file.

Parameters
URLthe location of the schema
Returns
the parser context or NULL in case of error

◆ xmlSchemaNewValidCtxt()

xmlSchemaValidCtxt * xmlSchemaNewValidCtxt ( xmlSchema schema)

Create an XML Schemas validation context based on the given schema.

Parameters
schemaa precompiled XML Schemas
Returns
the validation context or NULL in case of error

◆ xmlSchemaParse()

xmlSchema * xmlSchemaParse ( xmlSchemaParserCtxt ctxt)

parse a schema definition resource and build an internal XML Schema structure which can be used to validate instances.

Parameters
ctxta schema validation context
Returns
the internal XML Schema structure built from the resource or NULL in case of error

◆ xmlSchemaSAXPlug()

xmlSchemaSAXPlugStruct * xmlSchemaSAXPlug ( xmlSchemaValidCtxt ctxt,
xmlSAXHandler **  sax,
void **  user_data 
)

Plug a SAX based validation layer in a SAX parsing event flow.

The original saxptr and dataptr data are replaced by new pointers but the calls to the original will be maintained.

Parameters
ctxta schema validation context
saxa pointer to the original xmlSAXHandler
user_dataa pointer to the original SAX user data pointer
Returns
a pointer to a data structure needed to unplug the validation layer or NULL in case of errors.

◆ xmlSchemaSAXUnplug()

int xmlSchemaSAXUnplug ( xmlSchemaSAXPlugStruct plug)

Unplug a SAX based validation layer in a SAX parsing event flow.

The original pointers used in the call are restored.

Parameters
pluga data structure returned by xmlSchemaSAXPlug
Returns
0 in case of success and -1 in case of failure.

◆ xmlSchemaSetParserErrors()

void xmlSchemaSetParserErrors ( xmlSchemaParserCtxt ctxt,
xmlSchemaValidityErrorFunc  err,
xmlSchemaValidityWarningFunc  warn,
void *  ctx 
)

Set the callback functions used to handle errors for a validation context.

Deprecated:
Use xmlSchemaSetParserStructuredErrors.
Parameters
ctxta schema validation context
errthe error callback
warnthe warning callback
ctxcontextual data for the callbacks

◆ xmlSchemaSetParserStructuredErrors()

void xmlSchemaSetParserStructuredErrors ( xmlSchemaParserCtxt ctxt,
xmlStructuredErrorFunc  serror,
void *  ctx 
)

Set the structured error callback.

Parameters
ctxta schema parser context
serrorthe structured error function
ctxthe functions context

◆ xmlSchemaSetResourceLoader()

void xmlSchemaSetResourceLoader ( xmlSchemaParserCtxt ctxt,
xmlResourceLoader  loader,
void *  data 
)

Register a callback function that will be called to load documents or external entities.

Since
2.14.0
Parameters
ctxtschema parser
loaderresource loader
datauser data which will be passed to the loader

◆ xmlSchemaSetValidErrors()

void xmlSchemaSetValidErrors ( xmlSchemaValidCtxt ctxt,
xmlSchemaValidityErrorFunc  err,
xmlSchemaValidityWarningFunc  warn,
void *  ctx 
)

Set the error and warning callback information.

Deprecated:
Use xmlSchemaSetValidStructuredErrors.
Parameters
ctxta schema validation context
errthe error function
warnthe warning function
ctxthe functions context

◆ xmlSchemaSetValidOptions()

int xmlSchemaSetValidOptions ( xmlSchemaValidCtxt ctxt,
int  options 
)

Sets the options to be used during the validation.

Parameters
ctxta schema validation context
optionsa combination of xmlSchemaValidOption
Returns
0 in case of success, -1 in case of an API error.

◆ xmlSchemaSetValidStructuredErrors()

void xmlSchemaSetValidStructuredErrors ( xmlSchemaValidCtxt ctxt,
xmlStructuredErrorFunc  serror,
void *  ctx 
)

Set the structured error callback.

Parameters
ctxta schema validation context
serrorthe structured error function
ctxthe functions context

◆ xmlSchemaValidateDoc()

int xmlSchemaValidateDoc ( xmlSchemaValidCtxt ctxt,
xmlDoc doc 
)

Validate a document tree in memory.

Parameters
ctxta schema validation context
doca parsed document tree
Returns
0 if the document is schemas valid, a positive error code number otherwise and -1 in case of internal or API error.

◆ xmlSchemaValidateFile()

int xmlSchemaValidateFile ( xmlSchemaValidCtxt ctxt,
const char *  filename,
int  options 
)

Do a schemas validation of the given resource, it will use the SAX streamable validation internally.

Parameters
ctxta schema validation context
filenamethe URI of the instance
optionsa future set of options, currently unused
Returns
0 if the document is valid, a positive error code number otherwise and -1 in case of an internal or API error.

◆ xmlSchemaValidateOneElement()

int xmlSchemaValidateOneElement ( xmlSchemaValidCtxt ctxt,
xmlNode elem 
)

Validate a branch of a tree, starting with the given elem.

Parameters
ctxta schema validation context
eleman element node
Returns
0 if the element and its subtree is valid, a positive error code number otherwise and -1 in case of an internal or API error.

◆ xmlSchemaValidateSetFilename()

void xmlSchemaValidateSetFilename ( xmlSchemaValidCtxt vctxt,
const char *  filename 
)

Workaround to provide file error reporting information when this is not provided by current APIs.

Parameters
vctxtthe schema validation context
filenamethe file name

◆ xmlSchemaValidateSetLocator()

void xmlSchemaValidateSetLocator ( xmlSchemaValidCtxt vctxt,
xmlSchemaValidityLocatorFunc  f,
void *  ctxt 
)

Allows to set a locator function to the validation context, which will be used to provide file and line information since those are not provided as part of the SAX validation flow Setting f to NULL disable the locator.

Parameters
vctxta schema validation context
fthe locator function pointer
ctxtthe locator context

◆ xmlSchemaValidateStream()

int xmlSchemaValidateStream ( xmlSchemaValidCtxt ctxt,
xmlParserInputBuffer input,
xmlCharEncoding  enc,
const xmlSAXHandler sax,
void *  user_data 
)

Validate an input based on a flow of SAX event from the parser and forward the events to the sax handler with the provided user_data the user provided sax handler must be a SAX2 one.

Parameters
ctxta schema validation context
inputthe input to use for reading the data
encan optional encoding information
saxa SAX handler for the resulting events
user_datathe context to provide to the SAX handler.
Returns
0 if the document is schemas valid, a positive error code number otherwise and -1 in case of internal or API error.

◆ xmlSchemaValidCtxtGetOptions()

int xmlSchemaValidCtxtGetOptions ( xmlSchemaValidCtxt ctxt)

Get the validation context options.

Parameters
ctxta schema validation context
Returns
the option combination or -1 on error.

◆ xmlSchemaValidCtxtGetParserCtxt()

xmlParserCtxt * xmlSchemaValidCtxtGetParserCtxt ( xmlSchemaValidCtxt ctxt)

allow access to the parser context of the schema validation context

Parameters
ctxta schema validation context
Returns
the parser context of the schema validation context or NULL in case of error.