libxml2
Loading...
Searching...
No Matches
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.
xmlRelaxNGParserCtxtxmlRelaxNGNewParserCtxt (const char *URL)
 Create an XML RelaxNGs parse context for that file/resource expected to contain an XML RelaxNGs file.
xmlRelaxNGParserCtxtxmlRelaxNGNewMemParserCtxt (const char *buffer, int size)
 Create an XML RelaxNGs parse context for that memory buffer expected to contain an XML RelaxNGs file.
xmlRelaxNGParserCtxtxmlRelaxNGNewDocParserCtxt (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.
xmlRelaxNGxmlRelaxNGParse (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.
xmlRelaxNGValidCtxtxmlRelaxNGNewValidCtxt (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

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
ctxthe validation context
msgthe message
...extra arguments

◆ xmlRelaxNGValidityWarningFunc

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

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

Parameters
ctxthe validation context
msgthe 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
outputthe file output
schemaa schema structure

◆ xmlRelaxNGDumpTree()

void xmlRelaxNGDumpTree ( FILE * output,
xmlRelaxNG * schema )

Dump the transformed RelaxNG tree.

Parameters
outputthe file output
schemaa schema structure

◆ xmlRelaxNGFree()

void xmlRelaxNGFree ( xmlRelaxNG * schema)

Deallocate a RelaxNG structure.

Parameters
schemaa schema structure

◆ xmlRelaxNGFreeParserCtxt()

void xmlRelaxNGFreeParserCtxt ( xmlRelaxNGParserCtxt * ctxt)

Free the resources associated to the schema parser context.

Parameters
ctxtthe schema parser context

◆ xmlRelaxNGFreeValidCtxt()

void xmlRelaxNGFreeValidCtxt ( xmlRelaxNGValidCtxt * ctxt)

Free the resources associated to the schema validation context.

Parameters
ctxtthe 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
ctxta Relax-NG validation context
errthe error callback result
warnthe warning callback result
ctxcontextual 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
ctxta Relax-NG validation context
errthe error function result
warnthe warning function result
ctxthe 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
doca 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
buffera pointer to a char array containing the schemas
sizethe 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
URLthe 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
schemaa 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
ctxta 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
ctxta Relax-NG validation context
errthe error callback
warnthe warning callback
ctxcontextual 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
ctxta Relax-NG parser context
serrorthe error callback
ctxcontextual data for the callbacks

◆ xmlRelaxNGSetResourceLoader()

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

Set the callback function used to load external resources.

Parameters
ctxta Relax-NG parser context
loaderthe callback
vctxtcontextual 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
ctxta Relax-NG validation context
errthe error function
warnthe warning function
ctxthe functions context

◆ xmlRelaxNGSetValidStructuredErrors()

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

Set the structured error callback.

Parameters
ctxta Relax-NG validation context
serrorthe structured error function
ctxthe functions context

◆ xmlRelaxNGValidateDoc()

int xmlRelaxNGValidateDoc ( xmlRelaxNGValidCtxt * ctxt,
xmlDoc * doc )

Validate a document tree in memory.

Parameters
ctxta Relax-NG validation context
doca 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
ctxtthe validation context
doca document instance
eleman 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
ctxtthe RelaxNG validation context
doca document instance
eleman 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
ctxtthe RelaxNG validation context
datasome character data read
lenthe 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
ctxtthe validation context
doca document instance
eleman 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
ctxtthe 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
ctxta RelaxNG parser context
flagsa set of flags values
Returns
0 if success and -1 in case of error