libxml2: xmlschemas.h File Reference

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
xmlSchemaParserCtxt * | xmlSchemaNewParserCtxt (const char *URL)
| Create an XML Schemas parse context for that file/resource expected to contain an XML Schemas file.
xmlSchemaParserCtxt * | xmlSchemaNewMemParserCtxt (const char *buffer, int size)
| Create an XML Schemas parse context for that memory buffer expected to contain an XML Schemas file.
xmlSchemaParserCtxt * | xmlSchemaNewDocParserCtxt (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.
xmlSchema * | xmlSchemaParse (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.
xmlSchemaValidCtxt * | xmlSchemaNewValidCtxt (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.
xmlParserCtxt * | xmlSchemaValidCtxtGetParserCtxt (xmlSchemaValidCtxt *ctxt)
| allow access to the parser context of the schema validation context
xmlSchemaSAXPlugStruct * | xmlSchemaSAXPlug (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.

Copyright
  See Copyright for the status of this software.

Author
  Daniel Veillard

## Typedef Documentation

## ◆ xmlSchemaValidityErrorFunc

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

Signature of an error callback from an XSD validation.

Parameters

  ctx | the validation context
  msg | the 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

  ctx | user provided context
  file | returned file information
  line | returned 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

  ctx | the validation context
  msg | the message
  ... | extra arguments

## Function Documentation

## ◆ xmlSchemaDump()

void xmlSchemaDump | ( | FILE * | output,
|  | xmlSchema * | schema )

Dump a Schema structure.

Parameters

  output | the file output
  schema | a schema structure

## ◆ xmlSchemaFree()

void xmlSchemaFree | ( | xmlSchema * | schema | ) |

Deallocate a Schema structure.

Parameters

  schema | a schema structure

## ◆ xmlSchemaFreeParserCtxt()

void xmlSchemaFreeParserCtxt | ( | xmlSchemaParserCtxt * | ctxt | ) |

Free the resources associated to the schema parser context.

Parameters

  ctxt | the schema parser context

## ◆ xmlSchemaFreeValidCtxt()

void xmlSchemaFreeValidCtxt | ( | xmlSchemaValidCtxt * | ctxt | ) |

Free the resources associated to the schema validation context.

Parameters

  ctxt | the 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

  ctxt | a XMl-Schema parser context
  err | the error callback result
  warn | the warning callback result
  ctx | contextual 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

  ctxt | a XML-Schema validation context
  err | the error function result
  warn | the warning function result
  ctx | the 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

  ctxt | the 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

  doc | a 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

  buffer | a pointer to a char array containing the schemas
  size | the 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

  URL | the 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

  schema | a 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

  ctxt | a 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

  ctxt | a schema validation context
  sax | a pointer to the original xmlSAXHandler
  user_data | a 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

  plug | a 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

  ctxt | a schema validation context
  err | the error callback
  warn | the warning callback
  ctx | contextual data for the callbacks

## ◆ xmlSchemaSetParserStructuredErrors()

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

Set the structured error callback.

Parameters

  ctxt | a schema parser context
  serror | the structured error function
  ctx | the 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

  ctxt | schema parser
  loader | resource loader
  data | user 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

  ctxt | a schema validation context
  err | the error function
  warn | the warning function
  ctx | the functions context

## ◆ xmlSchemaSetValidOptions()

int xmlSchemaSetValidOptions | ( | xmlSchemaValidCtxt * | ctxt,
|  | int | options )

Sets the options to be used during the validation.

Parameters

  ctxt | a schema validation context
  options | a 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

  ctxt | a schema validation context
  serror | the structured error function
  ctx | the functions context

## ◆ xmlSchemaValidateDoc()

int xmlSchemaValidateDoc | ( | xmlSchemaValidCtxt * | ctxt,
|  | xmlDoc * | doc )

Validate a document tree in memory.

Parameters

  ctxt | a schema validation context
  doc | a 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

  ctxt | a schema validation context
  filename | the URI of the instance
  options | a 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

  ctxt | a schema validation context
  elem | an 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

  vctxt | the schema validation context
  filename | the 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

  vctxt | a schema validation context
  f | the locator function pointer
  ctxt | the 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

  ctxt | a schema validation context
  input | the input to use for reading the data
  enc | an optional encoding information
  sax | a SAX handler for the resulting events
  user_data | the 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

  ctxt | a 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

  ctxt | a schema validation context

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