relaxng.h 6.2 KB

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