Home | History | Annotate | Download | only in libxml
      1 /*
      2  * Summary: implementation of the Relax-NG validation
      3  * Description: implementation of the Relax-NG validation
      4  *
      5  * Copy: See Copyright for the status of this software.
      6  *
      7  * Author: Daniel Veillard
      8  */
      9 
     10 #ifndef __XML_RELAX_NG__
     11 #define __XML_RELAX_NG__
     12 
     13 #include <libxml/xmlversion.h>
     14 #include <libxml/hash.h>
     15 #include <libxml/xmlstring.h>
     16 
     17 #ifdef LIBXML_SCHEMAS_ENABLED
     18 
     19 #ifdef __cplusplus
     20 extern "C" {
     21 #endif
     22 
     23 typedef struct _xmlRelaxNG xmlRelaxNG;
     24 typedef xmlRelaxNG *xmlRelaxNGPtr;
     25 
     26 
     27 /**
     28  * xmlRelaxNGValidityErrorFunc:
     29  * @ctx: the validation context
     30  * @msg: the message
     31  * @...: extra arguments
     32  *
     33  * Signature of an error callback from a Relax-NG validation
     34  */
     35 typedef void (XMLCDECL *xmlRelaxNGValidityErrorFunc) (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
     36 
     37 /**
     38  * xmlRelaxNGValidityWarningFunc:
     39  * @ctx: the validation context
     40  * @msg: the message
     41  * @...: extra arguments
     42  *
     43  * Signature of a warning callback from a Relax-NG validation
     44  */
     45 typedef void (XMLCDECL *xmlRelaxNGValidityWarningFunc) (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
     46 
     47 /**
     48  * A schemas validation context
     49  */
     50 typedef struct _xmlRelaxNGParserCtxt xmlRelaxNGParserCtxt;
     51 typedef xmlRelaxNGParserCtxt *xmlRelaxNGParserCtxtPtr;
     52 
     53 typedef struct _xmlRelaxNGValidCtxt xmlRelaxNGValidCtxt;
     54 typedef xmlRelaxNGValidCtxt *xmlRelaxNGValidCtxtPtr;
     55 
     56 /*
     57  * xmlRelaxNGValidErr:
     58  *
     59  * List of possible Relax NG validation errors
     60  */
     61 typedef enum {
     62     XML_RELAXNG_OK = 0,
     63     XML_RELAXNG_ERR_MEMORY,
     64     XML_RELAXNG_ERR_TYPE,
     65     XML_RELAXNG_ERR_TYPEVAL,
     66     XML_RELAXNG_ERR_DUPID,
     67     XML_RELAXNG_ERR_TYPECMP,
     68     XML_RELAXNG_ERR_NOSTATE,
     69     XML_RELAXNG_ERR_NODEFINE,
     70     XML_RELAXNG_ERR_LISTEXTRA,
     71     XML_RELAXNG_ERR_LISTEMPTY,
     72     XML_RELAXNG_ERR_INTERNODATA,
     73     XML_RELAXNG_ERR_INTERSEQ,
     74     XML_RELAXNG_ERR_INTEREXTRA,
     75     XML_RELAXNG_ERR_ELEMNAME,
     76     XML_RELAXNG_ERR_ATTRNAME,
     77     XML_RELAXNG_ERR_ELEMNONS,
     78     XML_RELAXNG_ERR_ATTRNONS,
     79     XML_RELAXNG_ERR_ELEMWRONGNS,
     80     XML_RELAXNG_ERR_ATTRWRONGNS,
     81     XML_RELAXNG_ERR_ELEMEXTRANS,
     82     XML_RELAXNG_ERR_ATTREXTRANS,
     83     XML_RELAXNG_ERR_ELEMNOTEMPTY,
     84     XML_RELAXNG_ERR_NOELEM,
     85     XML_RELAXNG_ERR_NOTELEM,
     86     XML_RELAXNG_ERR_ATTRVALID,
     87     XML_RELAXNG_ERR_CONTENTVALID,
     88     XML_RELAXNG_ERR_EXTRACONTENT,
     89     XML_RELAXNG_ERR_INVALIDATTR,
     90     XML_RELAXNG_ERR_DATAELEM,
     91     XML_RELAXNG_ERR_VALELEM,
     92     XML_RELAXNG_ERR_LISTELEM,
     93     XML_RELAXNG_ERR_DATATYPE,
     94     XML_RELAXNG_ERR_VALUE,
     95     XML_RELAXNG_ERR_LIST,
     96     XML_RELAXNG_ERR_NOGRAMMAR,
     97     XML_RELAXNG_ERR_EXTRADATA,
     98     XML_RELAXNG_ERR_LACKDATA,
     99     XML_RELAXNG_ERR_INTERNAL,
    100     XML_RELAXNG_ERR_ELEMWRONG,
    101     XML_RELAXNG_ERR_TEXTWRONG
    102 } xmlRelaxNGValidErr;
    103 
    104 /*
    105  * xmlRelaxNGParserFlags:
    106  *
    107  * List of possible Relax NG Parser flags
    108  */
    109 typedef enum {
    110     XML_RELAXNGP_NONE = 0,
    111     XML_RELAXNGP_FREE_DOC = 1,
    112     XML_RELAXNGP_CRNG = 2
    113 } xmlRelaxNGParserFlag;
    114 
    115 XMLPUBFUN int XMLCALL
    116 		    xmlRelaxNGInitTypes		(void);
    117 XMLPUBFUN void XMLCALL
    118 		    xmlRelaxNGCleanupTypes	(void);
    119 
    120 /*
    121  * Interfaces for parsing.
    122  */
    123 XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL
    124 		    xmlRelaxNGNewParserCtxt	(const char *URL);
    125 XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL
    126 		    xmlRelaxNGNewMemParserCtxt	(const char *buffer,
    127 						 int size);
    128 XMLPUBFUN xmlRelaxNGParserCtxtPtr XMLCALL
    129 		    xmlRelaxNGNewDocParserCtxt	(xmlDocPtr doc);
    130 
    131 XMLPUBFUN int XMLCALL
    132 		    xmlRelaxParserSetFlag	(xmlRelaxNGParserCtxtPtr ctxt,
    133 						 int flag);
    134 
    135 XMLPUBFUN void XMLCALL
    136 		    xmlRelaxNGFreeParserCtxt	(xmlRelaxNGParserCtxtPtr ctxt);
    137 XMLPUBFUN void XMLCALL
    138 		    xmlRelaxNGSetParserErrors(xmlRelaxNGParserCtxtPtr ctxt,
    139 					 xmlRelaxNGValidityErrorFunc err,
    140 					 xmlRelaxNGValidityWarningFunc warn,
    141 					 void *ctx);
    142 XMLPUBFUN int XMLCALL
    143 		    xmlRelaxNGGetParserErrors(xmlRelaxNGParserCtxtPtr ctxt,
    144 					 xmlRelaxNGValidityErrorFunc *err,
    145 					 xmlRelaxNGValidityWarningFunc *warn,
    146 					 void **ctx);
    147 XMLPUBFUN void XMLCALL
    148 		    xmlRelaxNGSetParserStructuredErrors(
    149 					 xmlRelaxNGParserCtxtPtr ctxt,
    150 					 xmlStructuredErrorFunc serror,
    151 					 void *ctx);
    152 XMLPUBFUN xmlRelaxNGPtr XMLCALL
    153 		    xmlRelaxNGParse		(xmlRelaxNGParserCtxtPtr ctxt);
    154 XMLPUBFUN void XMLCALL
    155 		    xmlRelaxNGFree		(xmlRelaxNGPtr schema);
    156 #ifdef LIBXML_OUTPUT_ENABLED
    157 XMLPUBFUN void XMLCALL
    158 		    xmlRelaxNGDump		(FILE *output,
    159 					 xmlRelaxNGPtr schema);
    160 XMLPUBFUN void XMLCALL
    161 		    xmlRelaxNGDumpTree	(FILE * output,
    162 					 xmlRelaxNGPtr schema);
    163 #endif /* LIBXML_OUTPUT_ENABLED */
    164 /*
    165  * Interfaces for validating
    166  */
    167 XMLPUBFUN void XMLCALL
    168 		    xmlRelaxNGSetValidErrors(xmlRelaxNGValidCtxtPtr ctxt,
    169 					 xmlRelaxNGValidityErrorFunc err,
    170 					 xmlRelaxNGValidityWarningFunc warn,
    171 					 void *ctx);
    172 XMLPUBFUN int XMLCALL
    173 		    xmlRelaxNGGetValidErrors(xmlRelaxNGValidCtxtPtr ctxt,
    174 					 xmlRelaxNGValidityErrorFunc *err,
    175 					 xmlRelaxNGValidityWarningFunc *warn,
    176 					 void **ctx);
    177 XMLPUBFUN void XMLCALL
    178 			xmlRelaxNGSetValidStructuredErrors(xmlRelaxNGValidCtxtPtr ctxt,
    179 					  xmlStructuredErrorFunc serror, void *ctx);
    180 XMLPUBFUN xmlRelaxNGValidCtxtPtr XMLCALL
    181 		    xmlRelaxNGNewValidCtxt	(xmlRelaxNGPtr schema);
    182 XMLPUBFUN void XMLCALL
    183 		    xmlRelaxNGFreeValidCtxt	(xmlRelaxNGValidCtxtPtr ctxt);
    184 XMLPUBFUN int XMLCALL
    185 		    xmlRelaxNGValidateDoc	(xmlRelaxNGValidCtxtPtr ctxt,
    186 						 xmlDocPtr doc);
    187 /*
    188  * Interfaces for progressive validation when possible
    189  */
    190 XMLPUBFUN int XMLCALL
    191 		    xmlRelaxNGValidatePushElement	(xmlRelaxNGValidCtxtPtr ctxt,
    192 					 xmlDocPtr doc,
    193 					 xmlNodePtr elem);
    194 XMLPUBFUN int XMLCALL
    195 		    xmlRelaxNGValidatePushCData	(xmlRelaxNGValidCtxtPtr ctxt,
    196 					 const xmlChar *data,
    197 					 int len);
    198 XMLPUBFUN int XMLCALL
    199 		    xmlRelaxNGValidatePopElement	(xmlRelaxNGValidCtxtPtr ctxt,
    200 					 xmlDocPtr doc,
    201 					 xmlNodePtr elem);
    202 XMLPUBFUN int XMLCALL
    203 		    xmlRelaxNGValidateFullElement	(xmlRelaxNGValidCtxtPtr ctxt,
    204 					 xmlDocPtr doc,
    205 					 xmlNodePtr elem);
    206 
    207 #ifdef __cplusplus
    208 }
    209 #endif
    210 
    211 #endif /* LIBXML_SCHEMAS_ENABLED */
    212 
    213 #endif /* __XML_RELAX_NG__ */
    214