xmlschemas.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  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. } xmlSchemaValidError;
  49. /*
  50. * ATTENTION: Change xmlSchemaSetValidOptions's check
  51. * for invalid values, if adding to the validation
  52. * options below.
  53. */
  54. /**
  55. * xmlSchemaValidOption:
  56. *
  57. * This is the set of XML Schema validation options.
  58. */
  59. typedef enum {
  60. XML_SCHEMA_VAL_VC_I_CREATE = 1<<0
  61. /* Default/fixed: create an attribute node
  62. * or an element's text node on the instance.
  63. */
  64. } xmlSchemaValidOption;
  65. /*
  66. XML_SCHEMA_VAL_XSI_ASSEMBLE = 1<<1,
  67. * assemble schemata using
  68. * xsi:schemaLocation and
  69. * xsi:noNamespaceSchemaLocation
  70. */
  71. /**
  72. * The schemas related types are kept internal
  73. */
  74. typedef struct _xmlSchema xmlSchema;
  75. typedef xmlSchema *xmlSchemaPtr;
  76. /**
  77. * xmlSchemaValidityErrorFunc:
  78. * @ctx: the validation context
  79. * @msg: the message
  80. * @...: extra arguments
  81. *
  82. * Signature of an error callback from an XSD validation
  83. */
  84. typedef void (XMLCDECL *xmlSchemaValidityErrorFunc)
  85. (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)
  95. (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
  96. /**
  97. * A schemas validation context
  98. */
  99. typedef struct _xmlSchemaParserCtxt xmlSchemaParserCtxt;
  100. typedef xmlSchemaParserCtxt *xmlSchemaParserCtxtPtr;
  101. typedef struct _xmlSchemaValidCtxt xmlSchemaValidCtxt;
  102. typedef xmlSchemaValidCtxt *xmlSchemaValidCtxtPtr;
  103. /**
  104. * xmlSchemaValidityLocatorFunc:
  105. * @ctx: user provided context
  106. * @file: returned file information
  107. * @line: returned line information
  108. *
  109. * A schemas validation locator, a callback called by the validator.
  110. * This is used when file or node information are not available
  111. * to find out what file and line number are affected
  112. *
  113. * Returns: 0 in case of success and -1 in case of error
  114. */
  115. typedef int (XMLCDECL *xmlSchemaValidityLocatorFunc) (void *ctx,
  116. const char **file, unsigned long *line);
  117. /*
  118. * Interfaces for parsing.
  119. */
  120. XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL
  121. xmlSchemaNewParserCtxt (const char *URL);
  122. XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL
  123. xmlSchemaNewMemParserCtxt (const char *buffer,
  124. int size);
  125. XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL
  126. xmlSchemaNewDocParserCtxt (xmlDocPtr doc);
  127. XMLPUBFUN void XMLCALL
  128. xmlSchemaFreeParserCtxt (xmlSchemaParserCtxtPtr ctxt);
  129. XMLPUBFUN void XMLCALL
  130. xmlSchemaSetParserErrors (xmlSchemaParserCtxtPtr ctxt,
  131. xmlSchemaValidityErrorFunc err,
  132. xmlSchemaValidityWarningFunc warn,
  133. void *ctx);
  134. XMLPUBFUN void XMLCALL
  135. xmlSchemaSetParserStructuredErrors(xmlSchemaParserCtxtPtr ctxt,
  136. xmlStructuredErrorFunc serror,
  137. void *ctx);
  138. XMLPUBFUN int XMLCALL
  139. xmlSchemaGetParserErrors(xmlSchemaParserCtxtPtr ctxt,
  140. xmlSchemaValidityErrorFunc * err,
  141. xmlSchemaValidityWarningFunc * warn,
  142. void **ctx);
  143. XMLPUBFUN int XMLCALL
  144. xmlSchemaIsValid (xmlSchemaValidCtxtPtr ctxt);
  145. XMLPUBFUN xmlSchemaPtr XMLCALL
  146. xmlSchemaParse (xmlSchemaParserCtxtPtr ctxt);
  147. XMLPUBFUN void XMLCALL
  148. xmlSchemaFree (xmlSchemaPtr schema);
  149. #ifdef LIBXML_OUTPUT_ENABLED
  150. XMLPUBFUN void XMLCALL
  151. xmlSchemaDump (FILE *output,
  152. xmlSchemaPtr schema);
  153. #endif /* LIBXML_OUTPUT_ENABLED */
  154. /*
  155. * Interfaces for validating
  156. */
  157. XMLPUBFUN void XMLCALL
  158. xmlSchemaSetValidErrors (xmlSchemaValidCtxtPtr ctxt,
  159. xmlSchemaValidityErrorFunc err,
  160. xmlSchemaValidityWarningFunc warn,
  161. void *ctx);
  162. XMLPUBFUN void XMLCALL
  163. xmlSchemaSetValidStructuredErrors(xmlSchemaValidCtxtPtr ctxt,
  164. xmlStructuredErrorFunc serror,
  165. void *ctx);
  166. XMLPUBFUN int XMLCALL
  167. xmlSchemaGetValidErrors (xmlSchemaValidCtxtPtr ctxt,
  168. xmlSchemaValidityErrorFunc *err,
  169. xmlSchemaValidityWarningFunc *warn,
  170. void **ctx);
  171. XMLPUBFUN int XMLCALL
  172. xmlSchemaSetValidOptions (xmlSchemaValidCtxtPtr ctxt,
  173. int options);
  174. XMLPUBFUN void XMLCALL
  175. xmlSchemaValidateSetFilename(xmlSchemaValidCtxtPtr vctxt,
  176. const char *filename);
  177. XMLPUBFUN int XMLCALL
  178. xmlSchemaValidCtxtGetOptions(xmlSchemaValidCtxtPtr ctxt);
  179. XMLPUBFUN xmlSchemaValidCtxtPtr XMLCALL
  180. xmlSchemaNewValidCtxt (xmlSchemaPtr schema);
  181. XMLPUBFUN void XMLCALL
  182. xmlSchemaFreeValidCtxt (xmlSchemaValidCtxtPtr ctxt);
  183. XMLPUBFUN int XMLCALL
  184. xmlSchemaValidateDoc (xmlSchemaValidCtxtPtr ctxt,
  185. xmlDocPtr instance);
  186. XMLPUBFUN int XMLCALL
  187. xmlSchemaValidateOneElement (xmlSchemaValidCtxtPtr ctxt,
  188. xmlNodePtr elem);
  189. XMLPUBFUN int XMLCALL
  190. xmlSchemaValidateStream (xmlSchemaValidCtxtPtr ctxt,
  191. xmlParserInputBufferPtr input,
  192. xmlCharEncoding enc,
  193. xmlSAXHandlerPtr sax,
  194. void *user_data);
  195. XMLPUBFUN int XMLCALL
  196. xmlSchemaValidateFile (xmlSchemaValidCtxtPtr ctxt,
  197. const char * filename,
  198. int options);
  199. XMLPUBFUN xmlParserCtxtPtr XMLCALL
  200. xmlSchemaValidCtxtGetParserCtxt(xmlSchemaValidCtxtPtr ctxt);
  201. /*
  202. * Interface to insert Schemas SAX validation in a SAX stream
  203. */
  204. typedef struct _xmlSchemaSAXPlug xmlSchemaSAXPlugStruct;
  205. typedef xmlSchemaSAXPlugStruct *xmlSchemaSAXPlugPtr;
  206. XMLPUBFUN xmlSchemaSAXPlugPtr XMLCALL
  207. xmlSchemaSAXPlug (xmlSchemaValidCtxtPtr ctxt,
  208. xmlSAXHandlerPtr *sax,
  209. void **user_data);
  210. XMLPUBFUN int XMLCALL
  211. xmlSchemaSAXUnplug (xmlSchemaSAXPlugPtr plug);
  212. XMLPUBFUN void XMLCALL
  213. xmlSchemaValidateSetLocator (xmlSchemaValidCtxtPtr vctxt,
  214. xmlSchemaValidityLocatorFunc f,
  215. void *ctxt);
  216. #ifdef __cplusplus
  217. }
  218. #endif
  219. #endif /* LIBXML_SCHEMAS_ENABLED */
  220. #endif /* __XML_SCHEMA_H__ */