deps/src/libxml2-2.9.1/doc/devhelp/libxml2-relaxng.html
| | | | | libxml2 Reference Manual |
relaxng - implementation of the Relax-NG validation
implementation of the Relax-NG validation
Author(s): Daniel Veillard
typedef struct _xmlRelaxNG[xmlRelaxNG](#xmlRelaxNG);
typedef[xmlRelaxNG](libxml2-relaxng.html#xmlRelaxNG)*[xmlRelaxNGPtr](#xmlRelaxNGPtr);
typedef enum[xmlRelaxNGValidErr](#xmlRelaxNGValidErr);
typedef struct _xmlRelaxNGParserCtxt[xmlRelaxNGParserCtxt](#xmlRelaxNGParserCtxt);
typedef[xmlRelaxNGParserCtxt](libxml2-relaxng.html#xmlRelaxNGParserCtxt)*[xmlRelaxNGParserCtxtPtr](#xmlRelaxNGParserCtxtPtr);
typedef enum[xmlRelaxNGParserFlag](#xmlRelaxNGParserFlag);
typedef struct _xmlRelaxNGValidCtxt[xmlRelaxNGValidCtxt](#xmlRelaxNGValidCtxt);
typedef[xmlRelaxNGValidCtxt](libxml2-relaxng.html#xmlRelaxNGValidCtxt)*[xmlRelaxNGValidCtxtPtr](#xmlRelaxNGValidCtxtPtr);
void[xmlRelaxNGFreeValidCtxt](#xmlRelaxNGFreeValidCtxt)([xmlRelaxNGValidCtxtPtr](libxml2-relaxng.html#xmlRelaxNGValidCtxtPtr)ctxt);[xmlRelaxNGParserCtxtPtr](libxml2-relaxng.html#xmlRelaxNGParserCtxtPtr)[xmlRelaxNGNewDocParserCtxt](#xmlRelaxNGNewDocParserCtxt)([xmlDocPtr](libxml2-tree.html#xmlDocPtr)doc);
void[xmlRelaxNGSetValidErrors](#xmlRelaxNGSetValidErrors)([xmlRelaxNGValidCtxtPtr](libxml2-relaxng.html#xmlRelaxNGValidCtxtPtr)ctxt,
[xmlRelaxNGValidityErrorFunc](libxml2-relaxng.html#xmlRelaxNGValidityErrorFunc)err,
[xmlRelaxNGValidityWarningFunc](libxml2-relaxng.html#xmlRelaxNGValidityWarningFunc)warn,
void * ctx);[xmlRelaxNGParserCtxtPtr](libxml2-relaxng.html#xmlRelaxNGParserCtxtPtr)[xmlRelaxNGNewParserCtxt](#xmlRelaxNGNewParserCtxt)(const char * URL);
int[xmlRelaxNGGetParserErrors](#xmlRelaxNGGetParserErrors)([xmlRelaxNGParserCtxtPtr](libxml2-relaxng.html#xmlRelaxNGParserCtxtPtr)ctxt,
[xmlRelaxNGValidityErrorFunc](libxml2-relaxng.html#xmlRelaxNGValidityErrorFunc)* err,
[xmlRelaxNGValidityWarningFunc](libxml2-relaxng.html#xmlRelaxNGValidityWarningFunc)* warn,
void ** ctx);
int[xmlRelaxNGValidatePopElement](#xmlRelaxNGValidatePopElement)([xmlRelaxNGValidCtxtPtr](libxml2-relaxng.html#xmlRelaxNGValidCtxtPtr)ctxt,
[xmlDocPtr](libxml2-tree.html#xmlDocPtr)doc,
[xmlNodePtr](libxml2-tree.html#xmlNodePtr)elem);[xmlRelaxNGValidCtxtPtr](libxml2-relaxng.html#xmlRelaxNGValidCtxtPtr)[xmlRelaxNGNewValidCtxt](#xmlRelaxNGNewValidCtxt)([xmlRelaxNGPtr](libxml2-relaxng.html#xmlRelaxNGPtr)schema);[xmlRelaxNGParserCtxtPtr](libxml2-relaxng.html#xmlRelaxNGParserCtxtPtr)[xmlRelaxNGNewMemParserCtxt](#xmlRelaxNGNewMemParserCtxt)(const char * buffer,
int size);
void[xmlRelaxNGDump](#xmlRelaxNGDump)(FILE * output,
[xmlRelaxNGPtr](libxml2-relaxng.html#xmlRelaxNGPtr)schema);
void[xmlRelaxNGSetParserErrors](#xmlRelaxNGSetParserErrors)([xmlRelaxNGParserCtxtPtr](libxml2-relaxng.html#xmlRelaxNGParserCtxtPtr)ctxt,
[xmlRelaxNGValidityErrorFunc](libxml2-relaxng.html#xmlRelaxNGValidityErrorFunc)err,
[xmlRelaxNGValidityWarningFunc](libxml2-relaxng.html#xmlRelaxNGValidityWarningFunc)warn,
void * ctx);[xmlRelaxNGPtr](libxml2-relaxng.html#xmlRelaxNGPtr)[xmlRelaxNGParse](#xmlRelaxNGParse)([xmlRelaxNGParserCtxtPtr](libxml2-relaxng.html#xmlRelaxNGParserCtxtPtr)ctxt);
void[xmlRelaxNGSetParserStructuredErrors](#xmlRelaxNGSetParserStructuredErrors)([xmlRelaxNGParserCtxtPtr](libxml2-relaxng.html#xmlRelaxNGParserCtxtPtr)ctxt,
[xmlStructuredErrorFunc](libxml2-xmlerror.html#xmlStructuredErrorFunc)serror,
void * ctx);
int[xmlRelaxNGValidateFullElement](#xmlRelaxNGValidateFullElement)([xmlRelaxNGValidCtxtPtr](libxml2-relaxng.html#xmlRelaxNGValidCtxtPtr)ctxt,
[xmlDocPtr](libxml2-tree.html#xmlDocPtr)doc,
[xmlNodePtr](libxml2-tree.html#xmlNodePtr)elem);
typedef void[xmlRelaxNGValidityErrorFunc](#xmlRelaxNGValidityErrorFunc)(void * ctx,
const char * msg,
... ...);
int[xmlRelaxNGValidatePushElement](#xmlRelaxNGValidatePushElement)([xmlRelaxNGValidCtxtPtr](libxml2-relaxng.html#xmlRelaxNGValidCtxtPtr)ctxt,
[xmlDocPtr](libxml2-tree.html#xmlDocPtr)doc,
[xmlNodePtr](libxml2-tree.html#xmlNodePtr)elem);
void[xmlRelaxNGFree](#xmlRelaxNGFree)([xmlRelaxNGPtr](libxml2-relaxng.html#xmlRelaxNGPtr)schema);
int[xmlRelaxNGValidateDoc](#xmlRelaxNGValidateDoc)([xmlRelaxNGValidCtxtPtr](libxml2-relaxng.html#xmlRelaxNGValidCtxtPtr)ctxt,
[xmlDocPtr](libxml2-tree.html#xmlDocPtr)doc);
void[xmlRelaxNGSetValidStructuredErrors](#xmlRelaxNGSetValidStructuredErrors)([xmlRelaxNGValidCtxtPtr](libxml2-relaxng.html#xmlRelaxNGValidCtxtPtr)ctxt,
[xmlStructuredErrorFunc](libxml2-xmlerror.html#xmlStructuredErrorFunc)serror,
void * ctx);
void[xmlRelaxNGFreeParserCtxt](#xmlRelaxNGFreeParserCtxt)([xmlRelaxNGParserCtxtPtr](libxml2-relaxng.html#xmlRelaxNGParserCtxtPtr)ctxt);
int[xmlRelaxNGGetValidErrors](#xmlRelaxNGGetValidErrors)([xmlRelaxNGValidCtxtPtr](libxml2-relaxng.html#xmlRelaxNGValidCtxtPtr)ctxt,
[xmlRelaxNGValidityErrorFunc](libxml2-relaxng.html#xmlRelaxNGValidityErrorFunc)* err,
[xmlRelaxNGValidityWarningFunc](libxml2-relaxng.html#xmlRelaxNGValidityWarningFunc)* warn,
void ** ctx);
int[xmlRelaxNGInitTypes](#xmlRelaxNGInitTypes)(void);
void[xmlRelaxNGDumpTree](#xmlRelaxNGDumpTree)(FILE * output,
[xmlRelaxNGPtr](libxml2-relaxng.html#xmlRelaxNGPtr)schema);
void[xmlRelaxNGCleanupTypes](#xmlRelaxNGCleanupTypes)(void);
int[xmlRelaxNGValidatePushCData](#xmlRelaxNGValidatePushCData)([xmlRelaxNGValidCtxtPtr](libxml2-relaxng.html#xmlRelaxNGValidCtxtPtr)ctxt,
const[xmlChar](libxml2-xmlstring.html#xmlChar)* data,
int len);
int[xmlRelaxParserSetFlag](#xmlRelaxParserSetFlag)([xmlRelaxNGParserCtxtPtr](libxml2-relaxng.html#xmlRelaxNGParserCtxtPtr)ctxt,
int flags);
typedef void[xmlRelaxNGValidityWarningFunc](#xmlRelaxNGValidityWarningFunc)(void * ctx,
const char * msg,
... ...);
struct _xmlRelaxNG {
The content of this structure is not made public by the API.
} xmlRelaxNG;
struct _xmlRelaxNGParserCtxt {
The content of this structure is not made public by the API.
} xmlRelaxNGParserCtxt;
[xmlRelaxNGParserCtxt](libxml2-relaxng.html#xmlRelaxNGParserCtxt)* xmlRelaxNGParserCtxtPtr;
enum[xmlRelaxNGParserFlag](#xmlRelaxNGParserFlag){XML\_RELAXNGP\_NONE= 0XML\_RELAXNGP\_FREE\_DOC= 1XML\_RELAXNGP\_CRNG= 2
};
[xmlRelaxNG](libxml2-relaxng.html#xmlRelaxNG)* xmlRelaxNGPtr;
struct _xmlRelaxNGValidCtxt {
The content of this structure is not made public by the API.
} xmlRelaxNGValidCtxt;
[xmlRelaxNGValidCtxt](libxml2-relaxng.html#xmlRelaxNGValidCtxt)* xmlRelaxNGValidCtxtPtr;
enum[xmlRelaxNGValidErr](#xmlRelaxNGValidErr){XML\_RELAXNG\_OK= 0XML\_RELAXNG\_ERR\_MEMORY= 1XML\_RELAXNG\_ERR\_TYPE= 2XML\_RELAXNG\_ERR\_TYPEVAL= 3XML\_RELAXNG\_ERR\_DUPID= 4XML\_RELAXNG\_ERR\_TYPECMP= 5XML\_RELAXNG\_ERR\_NOSTATE= 6XML\_RELAXNG\_ERR\_NODEFINE= 7XML\_RELAXNG\_ERR\_LISTEXTRA= 8XML\_RELAXNG\_ERR\_LISTEMPTY= 9XML\_RELAXNG\_ERR\_INTERNODATA= 10XML\_RELAXNG\_ERR\_INTERSEQ= 11XML\_RELAXNG\_ERR\_INTEREXTRA= 12XML\_RELAXNG\_ERR\_ELEMNAME= 13XML\_RELAXNG\_ERR\_ATTRNAME= 14XML\_RELAXNG\_ERR\_ELEMNONS= 15XML\_RELAXNG\_ERR\_ATTRNONS= 16XML\_RELAXNG\_ERR\_ELEMWRONGNS= 17XML\_RELAXNG\_ERR\_ATTRWRONGNS= 18XML\_RELAXNG\_ERR\_ELEMEXTRANS= 19XML\_RELAXNG\_ERR\_ATTREXTRANS= 20XML\_RELAXNG\_ERR\_ELEMNOTEMPTY= 21XML\_RELAXNG\_ERR\_NOELEM= 22XML\_RELAXNG\_ERR\_NOTELEM= 23XML\_RELAXNG\_ERR\_ATTRVALID= 24XML\_RELAXNG\_ERR\_CONTENTVALID= 25XML\_RELAXNG\_ERR\_EXTRACONTENT= 26XML\_RELAXNG\_ERR\_INVALIDATTR= 27XML\_RELAXNG\_ERR\_DATAELEM= 28XML\_RELAXNG\_ERR\_VALELEM= 29XML\_RELAXNG\_ERR\_LISTELEM= 30XML\_RELAXNG\_ERR\_DATATYPE= 31XML\_RELAXNG\_ERR\_VALUE= 32XML\_RELAXNG\_ERR\_LIST= 33XML\_RELAXNG\_ERR\_NOGRAMMAR= 34XML\_RELAXNG\_ERR\_EXTRADATA= 35XML\_RELAXNG\_ERR\_LACKDATA= 36XML\_RELAXNG\_ERR\_INTERNAL= 37XML\_RELAXNG\_ERR\_ELEMWRONG= 38XML\_RELAXNG\_ERR\_TEXTWRONG= 39
};
void xmlRelaxNGValidityErrorFunc (void * ctx,
const char * msg,
... ...)
Signature of an error callback from a Relax-NG validation
| ctx: | the validation context | | msg: | the message | | ...: | extra arguments |
void xmlRelaxNGValidityWarningFunc (void * ctx,
const char * msg,
... ...)
Signature of a warning callback from a Relax-NG validation
| ctx: | the validation context | | msg: | the message | | ...: | extra arguments |
void xmlRelaxNGCleanupTypes (void)
Cleanup the default Schemas type library associated to RelaxNG
void xmlRelaxNGDump (FILE * output,
[xmlRelaxNGPtr](libxml2-relaxng.html#xmlRelaxNGPtr)schema)
Dump a RelaxNG structure back
| output: | the file output | | schema: | a schema structure |
void xmlRelaxNGDumpTree (FILE * output,
[xmlRelaxNGPtr](libxml2-relaxng.html#xmlRelaxNGPtr)schema)
Dump the transformed RelaxNG tree.
| output: | the file output | | schema: | a schema structure |
void xmlRelaxNGFree ([xmlRelaxNGPtr](libxml2-relaxng.html#xmlRelaxNGPtr)schema)
Deallocate a RelaxNG structure.
| schema: | a schema structure |
void xmlRelaxNGFreeParserCtxt ([xmlRelaxNGParserCtxtPtr](libxml2-relaxng.html#xmlRelaxNGParserCtxtPtr)ctxt)
Free the resources associated to the schema parser context
| ctxt: | the schema parser context |
void xmlRelaxNGFreeValidCtxt ([xmlRelaxNGValidCtxtPtr](libxml2-relaxng.html#xmlRelaxNGValidCtxtPtr)ctxt)
Free the resources associated to the schema validation context
| ctxt: | the schema validation context |
int xmlRelaxNGGetParserErrors ([xmlRelaxNGParserCtxtPtr](libxml2-relaxng.html#xmlRelaxNGParserCtxtPtr)ctxt,
[xmlRelaxNGValidityErrorFunc](libxml2-relaxng.html#xmlRelaxNGValidityErrorFunc)* err,
[xmlRelaxNGValidityWarningFunc](libxml2-relaxng.html#xmlRelaxNGValidityWarningFunc)* warn,
void ** ctx)
Get the callback information used to handle errors for a validation context
| 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. |
int xmlRelaxNGGetValidErrors ([xmlRelaxNGValidCtxtPtr](libxml2-relaxng.html#xmlRelaxNGValidCtxtPtr)ctxt,
[xmlRelaxNGValidityErrorFunc](libxml2-relaxng.html#xmlRelaxNGValidityErrorFunc)* err,
[xmlRelaxNGValidityWarningFunc](libxml2-relaxng.html#xmlRelaxNGValidityWarningFunc)* warn,
void ** ctx)
Get the error and warning callback informations
| 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 |
int xmlRelaxNGInitTypes (void)
Initilize the default type libraries.
| Returns: | 0 in case of success and -1 in case of error. |
[xmlRelaxNGParserCtxtPtr](libxml2-relaxng.html#xmlRelaxNGParserCtxtPtr)xmlRelaxNGNewDocParserCtxt ([xmlDocPtr](libxml2-tree.html#xmlDocPtr)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.
| doc: | a preparsed document tree | | Returns: | the parser context or NULL in case of error |
[xmlRelaxNGParserCtxtPtr](libxml2-relaxng.html#xmlRelaxNGParserCtxtPtr)xmlRelaxNGNewMemParserCtxt (const char * buffer,
int size)
Create an XML RelaxNGs parse context for that memory buffer expected to contain an XML RelaxNGs file.
| 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 |
[xmlRelaxNGParserCtxtPtr](libxml2-relaxng.html#xmlRelaxNGParserCtxtPtr)xmlRelaxNGNewParserCtxt (const char * URL)
Create an XML RelaxNGs parse context for that file/resource expected to contain an XML RelaxNGs file.
| URL: | the location of the schema | | Returns: | the parser context or NULL in case of error |
[xmlRelaxNGValidCtxtPtr](libxml2-relaxng.html#xmlRelaxNGValidCtxtPtr)xmlRelaxNGNewValidCtxt ([xmlRelaxNGPtr](libxml2-relaxng.html#xmlRelaxNGPtr)schema)
Create an XML RelaxNGs validation context based on the given schema
| schema: | a precompiled XML RelaxNGs | | Returns: | the validation context or NULL in case of error |
[xmlRelaxNGPtr](libxml2-relaxng.html#xmlRelaxNGPtr)xmlRelaxNGParse ([xmlRelaxNGParserCtxtPtr](libxml2-relaxng.html#xmlRelaxNGParserCtxtPtr)ctxt)
parse a schema definition resource and build an internal XML Shema struture which can be used to validate instances.
| ctxt: | a Relax-NG parser context | | Returns: | the internal XML RelaxNG structure built from the resource or NULL in case of error |
void xmlRelaxNGSetParserErrors ([xmlRelaxNGParserCtxtPtr](libxml2-relaxng.html#xmlRelaxNGParserCtxtPtr)ctxt,
[xmlRelaxNGValidityErrorFunc](libxml2-relaxng.html#xmlRelaxNGValidityErrorFunc)err,
[xmlRelaxNGValidityWarningFunc](libxml2-relaxng.html#xmlRelaxNGValidityWarningFunc)warn,
void * ctx)
Set the callback functions used to handle errors for a validation context
| ctxt: | a Relax-NG validation context | | err: | the error callback | | warn: | the warning callback | | ctx: | contextual data for the callbacks |
void xmlRelaxNGSetParserStructuredErrors ([xmlRelaxNGParserCtxtPtr](libxml2-relaxng.html#xmlRelaxNGParserCtxtPtr)ctxt,
[xmlStructuredErrorFunc](libxml2-xmlerror.html#xmlStructuredErrorFunc)serror,
void * ctx)
Set the callback functions used to handle errors for a parsing context
| ctxt: | a Relax-NG parser context | | serror: | the error callback | | ctx: | contextual data for the callbacks |
void xmlRelaxNGSetValidErrors ([xmlRelaxNGValidCtxtPtr](libxml2-relaxng.html#xmlRelaxNGValidCtxtPtr)ctxt,
[xmlRelaxNGValidityErrorFunc](libxml2-relaxng.html#xmlRelaxNGValidityErrorFunc)err,
[xmlRelaxNGValidityWarningFunc](libxml2-relaxng.html#xmlRelaxNGValidityWarningFunc)warn,
void * ctx)
Set the error and warning callback informations
| ctxt: | a Relax-NG validation context | | err: | the error function | | warn: | the warning function | | ctx: | the functions context |
void xmlRelaxNGSetValidStructuredErrors ([xmlRelaxNGValidCtxtPtr](libxml2-relaxng.html#xmlRelaxNGValidCtxtPtr)ctxt,
[xmlStructuredErrorFunc](libxml2-xmlerror.html#xmlStructuredErrorFunc)serror,
void * ctx)
Set the structured error callback
| ctxt: | a Relax-NG validation context | | serror: | the structured error function | | ctx: | the functions context |
int xmlRelaxNGValidateDoc ([xmlRelaxNGValidCtxtPtr](libxml2-relaxng.html#xmlRelaxNGValidCtxtPtr)ctxt,
[xmlDocPtr](libxml2-tree.html#xmlDocPtr)doc)
Validate a document tree in memory.
| 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. |
int xmlRelaxNGValidateFullElement ([xmlRelaxNGValidCtxtPtr](libxml2-relaxng.html#xmlRelaxNGValidCtxtPtr)ctxt,
[xmlDocPtr](libxml2-tree.html#xmlDocPtr)doc,
[xmlNodePtr](libxml2-tree.html#xmlNodePtr)elem)
Validate a full subtree when xmlRelaxNGValidatePushElement() returned 0 and the content of the node has been expanded.
| 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. |
int xmlRelaxNGValidatePopElement ([xmlRelaxNGValidCtxtPtr](libxml2-relaxng.html#xmlRelaxNGValidCtxtPtr)ctxt,
[xmlDocPtr](libxml2-tree.html#xmlDocPtr)doc,
[xmlNodePtr](libxml2-tree.html#xmlNodePtr)elem)
Pop the element end from the RelaxNG validation stack.
| ctxt: | the RelaxNG validation context | | doc: | a document instance | | elem: | an element instance | | Returns: | 1 if no validation problem was found or 0 otherwise |
int xmlRelaxNGValidatePushCData ([xmlRelaxNGValidCtxtPtr](libxml2-relaxng.html#xmlRelaxNGValidCtxtPtr)ctxt,
const[xmlChar](libxml2-xmlstring.html#xmlChar)* data,
int len)
check the CData parsed for validation in the current stack
| 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 |
int xmlRelaxNGValidatePushElement ([xmlRelaxNGValidCtxtPtr](libxml2-relaxng.html#xmlRelaxNGValidCtxtPtr)ctxt,
[xmlDocPtr](libxml2-tree.html#xmlDocPtr)doc,
[xmlNodePtr](libxml2-tree.html#xmlNodePtr)elem)
Push a new element start on the RelaxNG validation stack.
| 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. |
int xmlRelaxParserSetFlag ([xmlRelaxNGParserCtxtPtr](libxml2-relaxng.html#xmlRelaxNGParserCtxtPtr)ctxt,
int flags)
Semi private function used to pass informations to a parser context which are a combination of xmlRelaxNGParserFlag .
| ctxt: | a RelaxNG parser context | | flags: | a set of flags values | | Returns: | 0 if success and -1 in case of error |