libxml2: relaxng.h File Reference

libxml2

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

implementation of the Relax-NG validation More...

## Typedefs
typedef struct _xmlRelaxNG | xmlRelaxNG
| RelaxNG schema.
typedef void(* | xmlRelaxNGValidityErrorFunc) (void *ctx, const char *msg,...)
| Signature of an error callback from a Relax-NG validation.
typedef void(* | xmlRelaxNGValidityWarningFunc) (void *ctx, const char *msg,...)
| Signature of a warning callback from a Relax-NG validation.
typedef struct _xmlRelaxNGParserCtxt | xmlRelaxNGParserCtxt
| RelaxNG parser context.
typedef struct _xmlRelaxNGValidCtxt | xmlRelaxNGValidCtxt
| RelaxNG validation context.

## Enumerations
enum | xmlRelaxNGValidErr
| List of possible Relax NG validation errors.
enum | xmlRelaxNGParserFlag
| List of possible Relax NG Parser flags.

## Functions
int | xmlRelaxNGInitTypes (void)
| Initialize the default type libraries.
void | xmlRelaxNGCleanupTypes (void)
| Cleanup the default Schemas type library associated to RelaxNG.
xmlRelaxNGParserCtxt * | xmlRelaxNGNewParserCtxt (const char *URL)
| Create an XML RelaxNGs parse context for that file/resource expected to contain an XML RelaxNGs file.
xmlRelaxNGParserCtxt * | xmlRelaxNGNewMemParserCtxt (const char *buffer, int size)
| Create an XML RelaxNGs parse context for that memory buffer expected to contain an XML RelaxNGs file.
xmlRelaxNGParserCtxt * | xmlRelaxNGNewDocParserCtxt (xmlDoc *doc)
| Create an XML RelaxNGs parser context for that document.
int | xmlRelaxParserSetFlag (xmlRelaxNGParserCtxt *ctxt, int flag)
| Semi private function used to pass information to a parser context which are a combination of xmlRelaxNGParserFlag .
void | xmlRelaxNGFreeParserCtxt (xmlRelaxNGParserCtxt *ctxt)
| Free the resources associated to the schema parser context.
void | xmlRelaxNGSetParserErrors (xmlRelaxNGParserCtxt *ctxt, xmlRelaxNGValidityErrorFunc err, xmlRelaxNGValidityWarningFunc warn, void *ctx)
| Set the callback functions used to handle errors for a validation context.
int | xmlRelaxNGGetParserErrors (xmlRelaxNGParserCtxt *ctxt, xmlRelaxNGValidityErrorFunc *err, xmlRelaxNGValidityWarningFunc *warn, void **ctx)
| Get the callback information used to handle errors for a validation context.
void | xmlRelaxNGSetParserStructuredErrors (xmlRelaxNGParserCtxt *ctxt, xmlStructuredErrorFunc serror, void *ctx)
| Set the callback functions used to handle errors for a parsing context.
void | xmlRelaxNGSetResourceLoader (xmlRelaxNGParserCtxt *ctxt, xmlResourceLoader loader, void *vctxt)
| Set the callback function used to load external resources.
xmlRelaxNG * | xmlRelaxNGParse (xmlRelaxNGParserCtxt *ctxt)
| parse a schema definition resource and build an internal XML Schema structure which can be used to validate instances.
void | xmlRelaxNGFree (xmlRelaxNG *schema)
| Deallocate a RelaxNG structure.
void | xmlRelaxNGDump (FILE *output, xmlRelaxNG *schema)
| Dump a RelaxNG structure back.
void | xmlRelaxNGDumpTree (FILE *output, xmlRelaxNG *schema)
| Dump the transformed RelaxNG tree.
void | xmlRelaxNGSetValidErrors (xmlRelaxNGValidCtxt *ctxt, xmlRelaxNGValidityErrorFunc err, xmlRelaxNGValidityWarningFunc warn, void *ctx)
| Set the error and warning callback information.
int | xmlRelaxNGGetValidErrors (xmlRelaxNGValidCtxt *ctxt, xmlRelaxNGValidityErrorFunc *err, xmlRelaxNGValidityWarningFunc *warn, void **ctx)
| Get the error and warning callback information.
void | xmlRelaxNGSetValidStructuredErrors (xmlRelaxNGValidCtxt *ctxt, xmlStructuredErrorFunc serror, void *ctx)
| Set the structured error callback.
xmlRelaxNGValidCtxt * | xmlRelaxNGNewValidCtxt (xmlRelaxNG *schema)
| Create an XML RelaxNGs validation context based on the given schema.
void | xmlRelaxNGFreeValidCtxt (xmlRelaxNGValidCtxt *ctxt)
| Free the resources associated to the schema validation context.
int | xmlRelaxNGValidateDoc (xmlRelaxNGValidCtxt *ctxt, xmlDoc *doc)
| Validate a document tree in memory.
int | xmlRelaxNGValidatePushElement (xmlRelaxNGValidCtxt *ctxt, xmlDoc *doc, xmlNode *elem)
| Push a new element start on the RelaxNG validation stack.
int | xmlRelaxNGValidatePushCData (xmlRelaxNGValidCtxt *ctxt, const xmlChar *data, int len)
| check the CData parsed for validation in the current stack
int | xmlRelaxNGValidatePopElement (xmlRelaxNGValidCtxt *ctxt, xmlDoc *doc, xmlNode *elem)
| Pop the element end from the RelaxNG validation stack.
int | xmlRelaxNGValidateFullElement (xmlRelaxNGValidCtxt *ctxt, xmlDoc *doc, xmlNode *elem)
| Validate a full subtree when xmlRelaxNGValidatePushElement returned 0 and the content of the node has been expanded.
void | xmlRelaxNGValidCtxtClearErrors (xmlRelaxNGValidCtxt *ctxt)
| Clear errors in the context, allowing to recover from errors during streaming validation and continue it.

## Detailed Description

implementation of the Relax-NG validation

implementation of the Relax-NG validation

Copyright
  See Copyright for the status of this software.

Author
  Daniel Veillard

## Typedef Documentation

## ◆ xmlRelaxNGValidityErrorFunc

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

Signature of an error callback from a Relax-NG validation.

Parameters

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

## ◆ xmlRelaxNGValidityWarningFunc

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

Signature of a warning callback from a Relax-NG validation.

Parameters

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

## Function Documentation

## ◆ xmlRelaxNGCleanupTypes()

void xmlRelaxNGCleanupTypes | ( | void |  | ) |

Cleanup the default Schemas type library associated to RelaxNG.

Deprecated
  This function will be made private. Call xmlCleanupParser to free global state but see the warnings there. xmlCleanupParser should be only called once at program exit. In most cases, you don't have call cleanup functions at all.

## ◆ xmlRelaxNGDump()

void xmlRelaxNGDump | ( | FILE * | output,
|  | xmlRelaxNG * | schema )

Dump a RelaxNG structure back.

Parameters

  output | the file output
  schema | a schema structure

## ◆ xmlRelaxNGDumpTree()

void xmlRelaxNGDumpTree | ( | FILE * | output,
|  | xmlRelaxNG * | schema )

Dump the transformed RelaxNG tree.

Parameters

  output | the file output
  schema | a schema structure

## ◆ xmlRelaxNGFree()

void xmlRelaxNGFree | ( | xmlRelaxNG * | schema | ) |

Deallocate a RelaxNG structure.

Parameters

  schema | a schema structure

## ◆ xmlRelaxNGFreeParserCtxt()

void xmlRelaxNGFreeParserCtxt | ( | xmlRelaxNGParserCtxt * | ctxt | ) |

Free the resources associated to the schema parser context.

Parameters

  ctxt | the schema parser context

## ◆ xmlRelaxNGFreeValidCtxt()

void xmlRelaxNGFreeValidCtxt | ( | xmlRelaxNGValidCtxt * | ctxt | ) |

Free the resources associated to the schema validation context.

Parameters

  ctxt | the schema validation context

## ◆ xmlRelaxNGGetParserErrors()

int xmlRelaxNGGetParserErrors | ( | xmlRelaxNGParserCtxt * | ctxt,
|  | xmlRelaxNGValidityErrorFunc * | err,
|  | xmlRelaxNGValidityWarningFunc * | warn,
|  | void ** | ctx )

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

Parameters

  ctxt | a Relax-NG validation 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.

## ◆ xmlRelaxNGGetValidErrors()

int xmlRelaxNGGetValidErrors | ( | xmlRelaxNGValidCtxt * | ctxt,
|  | xmlRelaxNGValidityErrorFunc * | err,
|  | xmlRelaxNGValidityWarningFunc * | warn,
|  | void ** | ctx )

Get the error and warning callback information.

Parameters

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

## ◆ xmlRelaxNGInitTypes()

int xmlRelaxNGInitTypes | ( | void |  | ) |

Initialize the default type libraries.

Returns
  0 in case of success and -1 in case of error.

## ◆ xmlRelaxNGNewDocParserCtxt()

xmlRelaxNGParserCtxt * xmlRelaxNGNewDocParserCtxt | ( | xmlDoc * | doc | ) |

Create an XML RelaxNGs parser context for that document.

Note: since the process of compiling a RelaxNG schemas modifies the document, the doc parameter is duplicated internally.

Parameters

  doc | a preparsed document tree

Returns
  the parser context or NULL in case of error

## ◆ xmlRelaxNGNewMemParserCtxt()

xmlRelaxNGParserCtxt * xmlRelaxNGNewMemParserCtxt | ( | const char * | buffer,
|  | int | size )

Create an XML RelaxNGs parse context for that memory buffer expected to contain an XML RelaxNGs 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

## ◆ xmlRelaxNGNewParserCtxt()

xmlRelaxNGParserCtxt * xmlRelaxNGNewParserCtxt | ( | const char * | URL | ) |

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

Parameters

  URL | the location of the schema

Returns
  the parser context or NULL in case of error

## ◆ xmlRelaxNGNewValidCtxt()

xmlRelaxNGValidCtxt * xmlRelaxNGNewValidCtxt | ( | xmlRelaxNG * | schema | ) |

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

Parameters

  schema | a precompiled XML RelaxNGs

Returns
  the validation context or NULL in case of error

## ◆ xmlRelaxNGParse()

xmlRelaxNG * xmlRelaxNGParse | ( | xmlRelaxNGParserCtxt * | ctxt | ) |

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

Parameters

  ctxt | a Relax-NG parser context

Returns
  the internal XML RelaxNG structure built from the resource or NULL in case of error

## ◆ xmlRelaxNGSetParserErrors()

void xmlRelaxNGSetParserErrors | ( | xmlRelaxNGParserCtxt * | ctxt,
|  | xmlRelaxNGValidityErrorFunc | err,
|  | xmlRelaxNGValidityWarningFunc | warn,
|  | void * | ctx )

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

Deprecated
  Use xmlRelaxNGSetParserStructuredErrors.

Parameters

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

## ◆ xmlRelaxNGSetParserStructuredErrors()

void xmlRelaxNGSetParserStructuredErrors | ( | xmlRelaxNGParserCtxt * | ctxt,
|  | xmlStructuredErrorFunc | serror,
|  | void * | ctx )

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

Parameters

  ctxt | a Relax-NG parser context
  serror | the error callback
  ctx | contextual data for the callbacks

## ◆ xmlRelaxNGSetResourceLoader()

void xmlRelaxNGSetResourceLoader | ( | xmlRelaxNGParserCtxt * | ctxt,
|  | xmlResourceLoader | loader,
|  | void * | vctxt )

Set the callback function used to load external resources.

Parameters

  ctxt | a Relax-NG parser context
  loader | the callback
  vctxt | contextual data for the callbacks

## ◆ xmlRelaxNGSetValidErrors()

void xmlRelaxNGSetValidErrors | ( | xmlRelaxNGValidCtxt * | ctxt,
|  | xmlRelaxNGValidityErrorFunc | err,
|  | xmlRelaxNGValidityWarningFunc | warn,
|  | void * | ctx )

Set the error and warning callback information.

Deprecated
  Use xmlRelaxNGSetValidStructuredErrors.

Parameters

  ctxt | a Relax-NG validation context
  err | the error function
  warn | the warning function
  ctx | the functions context

## ◆ xmlRelaxNGSetValidStructuredErrors()

void xmlRelaxNGSetValidStructuredErrors | ( | xmlRelaxNGValidCtxt * | ctxt,
|  | xmlStructuredErrorFunc | serror,
|  | void * | ctx )

Set the structured error callback.

Parameters

  ctxt | a Relax-NG validation context
  serror | the structured error function
  ctx | the functions context

## ◆ xmlRelaxNGValidateDoc()

int xmlRelaxNGValidateDoc | ( | xmlRelaxNGValidCtxt * | ctxt,
|  | xmlDoc * | doc )

Validate a document tree in memory.

Parameters

  ctxt | a Relax-NG validation context
  doc | a parsed document tree

Returns
  0 if the document is valid, a positive error code number otherwise and -1 in case of internal or API error.

## ◆ xmlRelaxNGValidateFullElement()

int xmlRelaxNGValidateFullElement | ( | xmlRelaxNGValidCtxt * | ctxt,
|  | xmlDoc * | doc,
|  | xmlNode * | elem )

Validate a full subtree when xmlRelaxNGValidatePushElement returned 0 and the content of the node has been expanded.

Parameters

  ctxt | the validation context
  doc | a document instance
  elem | an element instance

Returns
  1 if no validation problem was found or -1 in case of error.

## ◆ xmlRelaxNGValidatePopElement()

int xmlRelaxNGValidatePopElement | ( | xmlRelaxNGValidCtxt * | ctxt,
|  | xmlDoc * | doc,
|  | xmlNode * | elem )

Pop the element end from the RelaxNG validation stack.

Parameters

  ctxt | the RelaxNG validation context
  doc | a document instance
  elem | an element instance

Returns
  1 if no validation problem was found or 0 otherwise

## ◆ xmlRelaxNGValidatePushCData()

int xmlRelaxNGValidatePushCData | ( | xmlRelaxNGValidCtxt * | ctxt,
|  | const xmlChar * | data,
|  | int | len )

check the CData parsed for validation in the current stack

Parameters

  ctxt | the RelaxNG validation context
  data | some character data read
  len | the length of the data

Returns
  1 if no validation problem was found or -1 otherwise

## ◆ xmlRelaxNGValidatePushElement()

int xmlRelaxNGValidatePushElement | ( | xmlRelaxNGValidCtxt * | ctxt,
|  | xmlDoc * | doc,
|  | xmlNode * | elem )

Push a new element start on the RelaxNG validation stack.

Parameters

  ctxt | the validation context
  doc | a document instance
  elem | an element instance

Returns
  1 if no validation problem was found or 0 if validating the element requires a full node, and -1 in case of error.

## ◆ xmlRelaxNGValidCtxtClearErrors()

void xmlRelaxNGValidCtxtClearErrors | ( | xmlRelaxNGValidCtxt * | ctxt | ) |

Clear errors in the context, allowing to recover from errors during streaming validation and continue it.

Remarks
  it doesn's reset the last internal libxml2 error

Parameters

  ctxt | the validation context

## ◆ xmlRelaxParserSetFlag()

int xmlRelaxParserSetFlag | ( | xmlRelaxNGParserCtxt * | ctxt,
|  | int | flags )

Semi private function used to pass information to a parser context which are a combination of xmlRelaxNGParserFlag .

Parameters

  ctxt | a RelaxNG parser context
  flags | a set of flags values

Returns
  0 if success and -1 in case of error