# ## Module relaxng from libxml2

API Menu
Main Menu Developer Menu Code Examples API Menu Parser API Tree API Reader API XML Guidelines ChangeLog
API Indexes
Alphabetic Constructors Functions/Types Modules Symbols
Related links
Mail archive XSLT libxslt DOM gdome2 XML-DSig xmlsec FTP Windows binaries Solaris binaries MacOsX binaries lxml Python bindings Perl bindings C++ bindings PHP bindings Pascal bindings Ruby bindings Tcl bindings Bug Tracker
implementation of the Relax-NG validation ## Table of Contents
    Structure xmlRelaxNG
    struct _xmlRelaxNG
    The content of this structure is not made public by the API.
    Structure xmlRelaxNGParserCtxt
    struct _xmlRelaxNGParserCtxt
    The content of this structure is not made public by the API.
    Typedef xmlRelaxNGParserCtxt * xmlRelaxNGParserCtxtPtr
    Enum xmlRelaxNGParserFlag
    Typedef xmlRelaxNG * xmlRelaxNGPtr
    Structure xmlRelaxNGValidCtxt
    struct _xmlRelaxNGValidCtxt
    The content of this structure is not made public by the API.
    Typedef xmlRelaxNGValidCtxt * xmlRelaxNGValidCtxtPtr
    Enum xmlRelaxNGValidErr
    void	xmlRelaxNGCleanupTypes		(void)
    void	xmlRelaxNGDump			(FILE * output,
    					 xmlRelaxNGPtr schema)
    void	xmlRelaxNGDumpTree		(FILE * output,
    					 xmlRelaxNGPtr schema)
    void	xmlRelaxNGFree			(xmlRelaxNGPtr schema)
    void	xmlRelaxNGFreeParserCtxt	(xmlRelaxNGParserCtxtPtr ctxt)
    void	xmlRelaxNGFreeValidCtxt		(xmlRelaxNGValidCtxtPtr ctxt)
    int	xmlRelaxNGGetParserErrors	(xmlRelaxNGParserCtxtPtr ctxt,
    					 xmlRelaxNGValidityErrorFunc * err,
    					 xmlRelaxNGValidityWarningFunc * warn,
    					 void ** ctx)
    int	xmlRelaxNGGetValidErrors	(xmlRelaxNGValidCtxtPtr ctxt,
    					 xmlRelaxNGValidityErrorFunc * err,
    					 xmlRelaxNGValidityWarningFunc * warn,
    					 void ** ctx)
    int	xmlRelaxNGInitTypes		(void)
    xmlRelaxNGParserCtxtPtr	xmlRelaxNGNewDocParserCtxt	(xmlDocPtr doc)
    xmlRelaxNGParserCtxtPtr	xmlRelaxNGNewMemParserCtxt	(const char * buffer,
    							 int size)
    xmlRelaxNGParserCtxtPtr	xmlRelaxNGNewParserCtxt	(const char * URL)
    xmlRelaxNGValidCtxtPtr	xmlRelaxNGNewValidCtxt	(xmlRelaxNGPtr schema)
    xmlRelaxNGPtr	xmlRelaxNGParse		(xmlRelaxNGParserCtxtPtr ctxt)
    void	xmlRelaxNGSetParserErrors	(xmlRelaxNGParserCtxtPtr ctxt,
    					 xmlRelaxNGValidityErrorFunc err,
    					 xmlRelaxNGValidityWarningFunc warn,
    					 void * ctx)
    void	xmlRelaxNGSetParserStructuredErrors	(xmlRelaxNGParserCtxtPtr ctxt,
    						 xmlStructuredErrorFunc serror,
    						 void * ctx)
    void	xmlRelaxNGSetValidErrors	(xmlRelaxNGValidCtxtPtr ctxt,
    					 xmlRelaxNGValidityErrorFunc err,
    					 xmlRelaxNGValidityWarningFunc warn,
    					 void * ctx)
    void	xmlRelaxNGSetValidStructuredErrors	(xmlRelaxNGValidCtxtPtr ctxt,
    						 xmlStructuredErrorFunc serror,
    						 void * ctx)
    int	xmlRelaxNGValidateDoc		(xmlRelaxNGValidCtxtPtr ctxt,
    					 xmlDocPtr doc)
    int	xmlRelaxNGValidateFullElement	(xmlRelaxNGValidCtxtPtr ctxt,
    					 xmlDocPtr doc,
    					 xmlNodePtr elem)
    int	xmlRelaxNGValidatePopElement	(xmlRelaxNGValidCtxtPtr ctxt,
    					 xmlDocPtr doc,
    					 xmlNodePtr elem)
    int	xmlRelaxNGValidatePushCData	(xmlRelaxNGValidCtxtPtr ctxt,
    					 const xmlChar * data,
    					 int len)
    int	xmlRelaxNGValidatePushElement	(xmlRelaxNGValidCtxtPtr ctxt,
    					 xmlDocPtr doc,
    					 xmlNodePtr elem)
    Function type: xmlRelaxNGValidityErrorFunc
    void	xmlRelaxNGValidityErrorFunc	(void * ctx,
    					 const char * msg,
    					 ... ...)
    Function type: xmlRelaxNGValidityWarningFunc
    void	xmlRelaxNGValidityWarningFunc	(void * ctx,
    					 const char * msg,
    					 ... ...)
    int	xmlRelaxParserSetFlag		(xmlRelaxNGParserCtxtPtr ctxt,
    					 int flags)
## Description ### Structure xmlRelaxNG
    Structure xmlRelaxNG
    struct _xmlRelaxNG {
    The content of this structure is not made public by the API.
    }
### Structure xmlRelaxNGParserCtxt
    Structure xmlRelaxNGParserCtxt
    struct _xmlRelaxNGParserCtxt {
    The content of this structure is not made public by the API.
    }
### Enum xmlRelaxNGParserFlag
    Enum xmlRelaxNGParserFlag {
        XML_RELAXNGP_NONE = 0
        XML_RELAXNGP_FREE_DOC = 1
        XML_RELAXNGP_CRNG = 2
    }
### Structure xmlRelaxNGValidCtxt
    Structure xmlRelaxNGValidCtxt
    struct _xmlRelaxNGValidCtxt {
    The content of this structure is not made public by the API.
    }
### Enum xmlRelaxNGValidErr
    Enum xmlRelaxNGValidErr {
        XML_RELAXNG_OK = 0
        XML_RELAXNG_ERR_MEMORY = 1
        XML_RELAXNG_ERR_TYPE = 2
        XML_RELAXNG_ERR_TYPEVAL = 3
        XML_RELAXNG_ERR_DUPID = 4
        XML_RELAXNG_ERR_TYPECMP = 5
        XML_RELAXNG_ERR_NOSTATE = 6
        XML_RELAXNG_ERR_NODEFINE = 7
        XML_RELAXNG_ERR_LISTEXTRA = 8
        XML_RELAXNG_ERR_LISTEMPTY = 9
        XML_RELAXNG_ERR_INTERNODATA = 10
        XML_RELAXNG_ERR_INTERSEQ = 11
        XML_RELAXNG_ERR_INTEREXTRA = 12
        XML_RELAXNG_ERR_ELEMNAME = 13
        XML_RELAXNG_ERR_ATTRNAME = 14
        XML_RELAXNG_ERR_ELEMNONS = 15
        XML_RELAXNG_ERR_ATTRNONS = 16
        XML_RELAXNG_ERR_ELEMWRONGNS = 17
        XML_RELAXNG_ERR_ATTRWRONGNS = 18
        XML_RELAXNG_ERR_ELEMEXTRANS = 19
        XML_RELAXNG_ERR_ATTREXTRANS = 20
        XML_RELAXNG_ERR_ELEMNOTEMPTY = 21
        XML_RELAXNG_ERR_NOELEM = 22
        XML_RELAXNG_ERR_NOTELEM = 23
        XML_RELAXNG_ERR_ATTRVALID = 24
        XML_RELAXNG_ERR_CONTENTVALID = 25
        XML_RELAXNG_ERR_EXTRACONTENT = 26
        XML_RELAXNG_ERR_INVALIDATTR = 27
        XML_RELAXNG_ERR_DATAELEM = 28
        XML_RELAXNG_ERR_VALELEM = 29
        XML_RELAXNG_ERR_LISTELEM = 30
        XML_RELAXNG_ERR_DATATYPE = 31
        XML_RELAXNG_ERR_VALUE = 32
        XML_RELAXNG_ERR_LIST = 33
        XML_RELAXNG_ERR_NOGRAMMAR = 34
        XML_RELAXNG_ERR_EXTRADATA = 35
        XML_RELAXNG_ERR_LACKDATA = 36
        XML_RELAXNG_ERR_INTERNAL = 37
        XML_RELAXNG_ERR_ELEMWRONG = 38
        XML_RELAXNG_ERR_TEXTWRONG = 39
    }
### Function: xmlRelaxNGCleanupTypes
    void	xmlRelaxNGCleanupTypes		(void)
Cleanup the default Schemas type library associated to RelaxNG ### Function: xmlRelaxNGDump
    void	xmlRelaxNGDump			(FILE * output,
    					 xmlRelaxNGPtr schema)
Dump a RelaxNG structure back
`output`: | the file output
`schema`: | a schema structure
### Function: xmlRelaxNGDumpTree
    void	xmlRelaxNGDumpTree		(FILE * output,
    					 xmlRelaxNGPtr schema)
Dump the transformed RelaxNG tree.
`output`: | the file output
`schema`: | a schema structure
### Function: xmlRelaxNGFree
    void	xmlRelaxNGFree			(xmlRelaxNGPtr schema)
Deallocate a RelaxNG structure.
`schema`: | a schema structure
### Function: xmlRelaxNGFreeParserCtxt
    void	xmlRelaxNGFreeParserCtxt	(xmlRelaxNGParserCtxtPtr ctxt)
Free the resources associated to the schema parser context
`ctxt`: | the schema parser context
### Function: xmlRelaxNGFreeValidCtxt
    void	xmlRelaxNGFreeValidCtxt		(xmlRelaxNGValidCtxtPtr ctxt)
Free the resources associated to the schema validation context
`ctxt`: | the schema validation context
### Function: xmlRelaxNGGetParserErrors
    int	xmlRelaxNGGetParserErrors	(xmlRelaxNGParserCtxtPtr ctxt,
    					 xmlRelaxNGValidityErrorFunc * err,
    					 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.
### Function: xmlRelaxNGGetValidErrors
    int	xmlRelaxNGGetValidErrors	(xmlRelaxNGValidCtxtPtr ctxt,
    					 xmlRelaxNGValidityErrorFunc * err,
    					 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
### Function: xmlRelaxNGInitTypes
    int	xmlRelaxNGInitTypes		(void)
Initilize the default type libraries.
`Returns`: | 0 in case of success and -1 in case of error.
### Function: xmlRelaxNGNewDocParserCtxt
    xmlRelaxNGParserCtxtPtr	xmlRelaxNGNewDocParserCtxt	(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
### Function: xmlRelaxNGNewMemParserCtxt
    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
### Function: xmlRelaxNGNewParserCtxt
    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
### Function: xmlRelaxNGNewValidCtxt
    xmlRelaxNGValidCtxtPtr	xmlRelaxNGNewValidCtxt	(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
### Function: xmlRelaxNGParse
    xmlRelaxNGPtr	xmlRelaxNGParse		(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
### Function: xmlRelaxNGSetParserErrors
    void	xmlRelaxNGSetParserErrors	(xmlRelaxNGParserCtxtPtr ctxt,
    					 xmlRelaxNGValidityErrorFunc err,
    					 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
### Function: xmlRelaxNGSetParserStructuredErrors
    void	xmlRelaxNGSetParserStructuredErrors	(xmlRelaxNGParserCtxtPtr ctxt,
    						 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
### Function: xmlRelaxNGSetValidErrors
    void	xmlRelaxNGSetValidErrors	(xmlRelaxNGValidCtxtPtr ctxt,
    					 xmlRelaxNGValidityErrorFunc err,
    					 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
### Function: xmlRelaxNGSetValidStructuredErrors
    void	xmlRelaxNGSetValidStructuredErrors	(xmlRelaxNGValidCtxtPtr ctxt,
    						 xmlStructuredErrorFunc serror,
    						 void * ctx)
Set the structured error callback
`ctxt`: | a Relax-NG validation context
`serror`: | the structured error function
`ctx`: | the functions context
### Function: xmlRelaxNGValidateDoc
    int	xmlRelaxNGValidateDoc		(xmlRelaxNGValidCtxtPtr ctxt,
    					 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.
### Function: xmlRelaxNGValidateFullElement
    int	xmlRelaxNGValidateFullElement	(xmlRelaxNGValidCtxtPtr ctxt,
    					 xmlDocPtr doc,
    					 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.
### Function: xmlRelaxNGValidatePopElement
    int	xmlRelaxNGValidatePopElement	(xmlRelaxNGValidCtxtPtr ctxt,
    					 xmlDocPtr doc,
    					 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
### Function: xmlRelaxNGValidatePushCData
    int	xmlRelaxNGValidatePushCData	(xmlRelaxNGValidCtxtPtr ctxt,
    					 const 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 lenght of the data
`Returns`: | 1 if no validation problem was found or -1 otherwise
### Function: xmlRelaxNGValidatePushElement
    int	xmlRelaxNGValidatePushElement	(xmlRelaxNGValidCtxtPtr ctxt,
    					 xmlDocPtr doc,
    					 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.
### Function type: xmlRelaxNGValidityErrorFunc
    Function type: xmlRelaxNGValidityErrorFunc
    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
### Function type: xmlRelaxNGValidityWarningFunc
    Function type: xmlRelaxNGValidityWarningFunc
    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
### Function: xmlRelaxParserSetFlag
    int	xmlRelaxParserSetFlag		(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
Daniel Veillard