xmlschemas.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. /*
  2. * Summary: incomplete XML Schemas structure implementation
  3. * Description: interface to the XML Schemas handling and schema validity
  4. * checking, it is incomplete right now.
  5. *
  6. * Copy: See Copyright for the status of this software.
  7. *
  8. * Author: Daniel Veillard
  9. */
  10. #ifndef __XML_SCHEMA_H__
  11. #define __XML_SCHEMA_H__
  12. #include <libxml/xmlversion.h>
  13. #ifdef LIBXML_SCHEMAS_ENABLED
  14. #include <libxml/tree.h>
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. /**
  19. * This error codes are obsolete; not used any more.
  20. */
  21. typedef enum {
  22. XML_SCHEMAS_ERR_OK = 0,
  23. XML_SCHEMAS_ERR_NOROOT = 1,
  24. XML_SCHEMAS_ERR_UNDECLAREDELEM,
  25. XML_SCHEMAS_ERR_NOTTOPLEVEL,
  26. XML_SCHEMAS_ERR_MISSING,
  27. XML_SCHEMAS_ERR_WRONGELEM,
  28. XML_SCHEMAS_ERR_NOTYPE,
  29. XML_SCHEMAS_ERR_NOROLLBACK,
  30. XML_SCHEMAS_ERR_ISABSTRACT,
  31. XML_SCHEMAS_ERR_NOTEMPTY,
  32. XML_SCHEMAS_ERR_ELEMCONT,
  33. XML_SCHEMAS_ERR_HAVEDEFAULT,
  34. XML_SCHEMAS_ERR_NOTNILLABLE,
  35. XML_SCHEMAS_ERR_EXTRACONTENT,
  36. XML_SCHEMAS_ERR_INVALIDATTR,
  37. XML_SCHEMAS_ERR_INVALIDELEM,
  38. XML_SCHEMAS_ERR_NOTDETERMINIST,
  39. XML_SCHEMAS_ERR_CONSTRUCT,
  40. XML_SCHEMAS_ERR_INTERNAL,
  41. XML_SCHEMAS_ERR_NOTSIMPLE,
  42. XML_SCHEMAS_ERR_ATTRUNKNOWN,
  43. XML_SCHEMAS_ERR_ATTRINVALID,
  44. XML_SCHEMAS_ERR_VALUE,
  45. XML_SCHEMAS_ERR_FACET,
  46. XML_SCHEMAS_ERR_,
  47. XML_SCHEMAS_ERR_XXX
  48. }
  49. xmlSchemaValidError;
  50. /*
  51. * ATTENTION: Change xmlSchemaSetValidOptions's check
  52. * for invalid values, if adding to the validation
  53. * options below.
  54. */
  55. /**
  56. * xmlSchemaValidOption:
  57. *
  58. * This is the set of XML Schema validation options.
  59. */
  60. typedef enum {
  61. XML_SCHEMA_VAL_VC_I_CREATE = 1<<0
  62. /* Default/fixed: create an attribute node
  63. * or an element's text node on the instance.
  64. */
  65. } xmlSchemaValidOption;
  66. /*
  67. XML_SCHEMA_VAL_XSI_ASSEMBLE = 1<<1,
  68. * assemble schemata using
  69. * xsi:schemaLocation and
  70. * xsi:noNamespaceSchemaLocation
  71. */
  72. /**
  73. * The schemas related types are kept internal
  74. */
  75. typedef struct _xmlSchema xmlSchema;
  76. typedef xmlSchema *xmlSchemaPtr;
  77. /**
  78. * xmlSchemaValidityErrorFunc:
  79. * @ctx: the validation context
  80. * @msg: the message
  81. * @...: extra arguments
  82. *
  83. * Signature of an error callback from an XSD validation
  84. */
  85. typedef void (XMLCDECL *xmlSchemaValidityErrorFunc) (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
  86. /**
  87. * xmlSchemaValidityWarningFunc:
  88. * @ctx: the validation context
  89. * @msg: the message
  90. * @...: extra arguments
  91. *
  92. * Signature of a warning callback from an XSD validation
  93. */
  94. typedef void (XMLCDECL *xmlSchemaValidityWarningFunc) (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
  95. /**
  96. * A schemas validation context
  97. */
  98. typedef struct _xmlSchemaParserCtxt xmlSchemaParserCtxt;
  99. typedef xmlSchemaParserCtxt *xmlSchemaParserCtxtPtr;
  100. typedef struct _xmlSchemaValidCtxt xmlSchemaValidCtxt;
  101. typedef xmlSchemaValidCtxt *xmlSchemaValidCtxtPtr;
  102. /*
  103. * Interfaces for parsing.
  104. */
  105. XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL
  106. xmlSchemaNewParserCtxt (const char *URL);
  107. XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL
  108. xmlSchemaNewMemParserCtxt (const char *buffer,
  109. int size);
  110. XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL
  111. xmlSchemaNewDocParserCtxt (xmlDocPtr doc);
  112. XMLPUBFUN void XMLCALL
  113. xmlSchemaFreeParserCtxt (xmlSchemaParserCtxtPtr ctxt);
  114. XMLPUBFUN void XMLCALL
  115. xmlSchemaSetParserErrors (xmlSchemaParserCtxtPtr ctxt,
  116. xmlSchemaValidityErrorFunc err,
  117. xmlSchemaValidityWarningFunc warn,
  118. void *ctx);
  119. XMLPUBFUN void XMLCALL
  120. xmlSchemaSetParserStructuredErrors(xmlSchemaParserCtxtPtr ctxt,
  121. xmlStructuredErrorFunc serror,
  122. void *ctx);
  123. XMLPUBFUN int XMLCALL
  124. xmlSchemaGetParserErrors(xmlSchemaParserCtxtPtr ctxt,
  125. xmlSchemaValidityErrorFunc * err,
  126. xmlSchemaValidityWarningFunc * warn,
  127. void **ctx);
  128. XMLPUBFUN int XMLCALL
  129. xmlSchemaIsValid (xmlSchemaValidCtxtPtr ctxt);
  130. XMLPUBFUN xmlSchemaPtr XMLCALL
  131. xmlSchemaParse (xmlSchemaParserCtxtPtr ctxt);
  132. XMLPUBFUN void XMLCALL
  133. xmlSchemaFree (xmlSchemaPtr schema);
  134. #ifdef LIBXML_OUTPUT_ENABLED
  135. XMLPUBFUN void XMLCALL
  136. xmlSchemaDump (FILE *output,
  137. xmlSchemaPtr schema);
  138. #endif /* LIBXML_OUTPUT_ENABLED */
  139. /*
  140. * Interfaces for validating
  141. */
  142. XMLPUBFUN void XMLCALL
  143. xmlSchemaSetValidErrors (xmlSchemaValidCtxtPtr ctxt,
  144. xmlSchemaValidityErrorFunc err,
  145. xmlSchemaValidityWarningFunc warn,
  146. void *ctx);
  147. XMLPUBFUN void XMLCALL
  148. xmlSchemaSetValidStructuredErrors(xmlSchemaValidCtxtPtr ctxt,
  149. xmlStructuredErrorFunc serror,
  150. void *ctx);
  151. XMLPUBFUN int XMLCALL
  152. xmlSchemaGetValidErrors (xmlSchemaValidCtxtPtr ctxt,
  153. xmlSchemaValidityErrorFunc *err,
  154. xmlSchemaValidityWarningFunc *warn,
  155. void **ctx);
  156. XMLPUBFUN int XMLCALL
  157. xmlSchemaSetValidOptions (xmlSchemaValidCtxtPtr ctxt,
  158. int options);
  159. XMLPUBFUN int XMLCALL
  160. xmlSchemaValidCtxtGetOptions(xmlSchemaValidCtxtPtr ctxt);
  161. XMLPUBFUN xmlSchemaValidCtxtPtr XMLCALL
  162. xmlSchemaNewValidCtxt (xmlSchemaPtr schema);
  163. XMLPUBFUN void XMLCALL
  164. xmlSchemaFreeValidCtxt (xmlSchemaValidCtxtPtr ctxt);
  165. XMLPUBFUN int XMLCALL
  166. xmlSchemaValidateDoc (xmlSchemaValidCtxtPtr ctxt,
  167. xmlDocPtr instance);
  168. XMLPUBFUN int XMLCALL
  169. xmlSchemaValidateOneElement (xmlSchemaValidCtxtPtr ctxt,
  170. xmlNodePtr elem);
  171. XMLPUBFUN int XMLCALL
  172. xmlSchemaValidateStream (xmlSchemaValidCtxtPtr ctxt,
  173. xmlParserInputBufferPtr input,
  174. xmlCharEncoding enc,
  175. xmlSAXHandlerPtr sax,
  176. void *user_data);
  177. XMLPUBFUN int XMLCALL
  178. xmlSchemaValidateFile (xmlSchemaValidCtxtPtr ctxt,
  179. const char * filename,
  180. int options);
  181. XMLPUBFUN xmlParserCtxtPtr XMLCALL
  182. xmlSchemaValidCtxtGetParserCtxt(xmlSchemaValidCtxtPtr ctxt);
  183. /*
  184. * Interface to insert Schemas SAX validation in a SAX stream
  185. */
  186. typedef struct _xmlSchemaSAXPlug xmlSchemaSAXPlugStruct;
  187. typedef xmlSchemaSAXPlugStruct *xmlSchemaSAXPlugPtr;
  188. XMLPUBFUN xmlSchemaSAXPlugPtr XMLCALL
  189. xmlSchemaSAXPlug (xmlSchemaValidCtxtPtr ctxt,
  190. xmlSAXHandlerPtr *sax,
  191. void **user_data);
  192. XMLPUBFUN int XMLCALL
  193. xmlSchemaSAXUnplug (xmlSchemaSAXPlugPtr plug);
  194. #ifdef __cplusplus
  195. }
  196. #endif
  197. #endif /* LIBXML_SCHEMAS_ENABLED */
  198. #endif /* __XML_SCHEMA_H__ */