xmlschemas.h 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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)
  86. (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
  87. /**
  88. * xmlSchemaValidityWarningFunc:
  89. * @ctx: the validation context
  90. * @msg: the message
  91. * @...: extra arguments
  92. *
  93. * Signature of a warning callback from an XSD validation
  94. */
  95. typedef void (XMLCDECL *xmlSchemaValidityWarningFunc)
  96. (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
  97. /**
  98. * A schemas validation context
  99. */
  100. typedef struct _xmlSchemaParserCtxt xmlSchemaParserCtxt;
  101. typedef xmlSchemaParserCtxt *xmlSchemaParserCtxtPtr;
  102. typedef struct _xmlSchemaValidCtxt xmlSchemaValidCtxt;
  103. typedef xmlSchemaValidCtxt *xmlSchemaValidCtxtPtr;
  104. /**
  105. * xmlSchemaValidityLocatorFunc:
  106. * @ctx: user provided context
  107. * @file: returned file information
  108. * @line: returned line information
  109. *
  110. * A schemas validation locator, a callback called by the validator.
  111. * This is used when file or node informations are not available
  112. * to find out what file and line number are affected
  113. *
  114. * Returns: 0 in case of success and -1 in case of error
  115. */
  116. typedef int (XMLCDECL *xmlSchemaValidityLocatorFunc) (void *ctx,
  117. const char **file, unsigned long *line);
  118. /*
  119. * Interfaces for parsing.
  120. */
  121. XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL
  122. xmlSchemaNewParserCtxt (const char *URL);
  123. XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL
  124. xmlSchemaNewMemParserCtxt (const char *buffer,
  125. int size);
  126. XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL
  127. xmlSchemaNewDocParserCtxt (xmlDocPtr doc);
  128. XMLPUBFUN void XMLCALL
  129. xmlSchemaFreeParserCtxt (xmlSchemaParserCtxtPtr ctxt);
  130. XMLPUBFUN void XMLCALL
  131. xmlSchemaSetParserErrors (xmlSchemaParserCtxtPtr ctxt,
  132. xmlSchemaValidityErrorFunc err,
  133. xmlSchemaValidityWarningFunc warn,
  134. void *ctx);
  135. XMLPUBFUN void XMLCALL
  136. xmlSchemaSetParserStructuredErrors(xmlSchemaParserCtxtPtr ctxt,
  137. xmlStructuredErrorFunc serror,
  138. void *ctx);
  139. XMLPUBFUN int XMLCALL
  140. xmlSchemaGetParserErrors(xmlSchemaParserCtxtPtr ctxt,
  141. xmlSchemaValidityErrorFunc * err,
  142. xmlSchemaValidityWarningFunc * warn,
  143. void **ctx);
  144. XMLPUBFUN int XMLCALL
  145. xmlSchemaIsValid (xmlSchemaValidCtxtPtr ctxt);
  146. XMLPUBFUN xmlSchemaPtr XMLCALL
  147. xmlSchemaParse (xmlSchemaParserCtxtPtr ctxt);
  148. XMLPUBFUN void XMLCALL
  149. xmlSchemaFree (xmlSchemaPtr schema);
  150. #ifdef LIBXML_OUTPUT_ENABLED
  151. XMLPUBFUN void XMLCALL
  152. xmlSchemaDump (FILE *output,
  153. xmlSchemaPtr schema);
  154. #endif /* LIBXML_OUTPUT_ENABLED */
  155. /*
  156. * Interfaces for validating
  157. */
  158. XMLPUBFUN void XMLCALL
  159. xmlSchemaSetValidErrors (xmlSchemaValidCtxtPtr ctxt,
  160. xmlSchemaValidityErrorFunc err,
  161. xmlSchemaValidityWarningFunc warn,
  162. void *ctx);
  163. XMLPUBFUN void XMLCALL
  164. xmlSchemaSetValidStructuredErrors(xmlSchemaValidCtxtPtr ctxt,
  165. xmlStructuredErrorFunc serror,
  166. void *ctx);
  167. XMLPUBFUN int XMLCALL
  168. xmlSchemaGetValidErrors (xmlSchemaValidCtxtPtr ctxt,
  169. xmlSchemaValidityErrorFunc *err,
  170. xmlSchemaValidityWarningFunc *warn,
  171. void **ctx);
  172. XMLPUBFUN int XMLCALL
  173. xmlSchemaSetValidOptions (xmlSchemaValidCtxtPtr ctxt,
  174. int options);
  175. XMLPUBFUN void XMLCALL
  176. xmlSchemaValidateSetFilename(xmlSchemaValidCtxtPtr vctxt,
  177. const char *filename);
  178. XMLPUBFUN int XMLCALL
  179. xmlSchemaValidCtxtGetOptions(xmlSchemaValidCtxtPtr ctxt);
  180. XMLPUBFUN xmlSchemaValidCtxtPtr XMLCALL
  181. xmlSchemaNewValidCtxt (xmlSchemaPtr schema);
  182. XMLPUBFUN void XMLCALL
  183. xmlSchemaFreeValidCtxt (xmlSchemaValidCtxtPtr ctxt);
  184. XMLPUBFUN int XMLCALL
  185. xmlSchemaValidateDoc (xmlSchemaValidCtxtPtr ctxt,
  186. xmlDocPtr instance);
  187. XMLPUBFUN int XMLCALL
  188. xmlSchemaValidateOneElement (xmlSchemaValidCtxtPtr ctxt,
  189. xmlNodePtr elem);
  190. XMLPUBFUN int XMLCALL
  191. xmlSchemaValidateStream (xmlSchemaValidCtxtPtr ctxt,
  192. xmlParserInputBufferPtr input,
  193. xmlCharEncoding enc,
  194. xmlSAXHandlerPtr sax,
  195. void *user_data);
  196. XMLPUBFUN int XMLCALL
  197. xmlSchemaValidateFile (xmlSchemaValidCtxtPtr ctxt,
  198. const char * filename,
  199. int options);
  200. XMLPUBFUN xmlParserCtxtPtr XMLCALL
  201. xmlSchemaValidCtxtGetParserCtxt(xmlSchemaValidCtxtPtr ctxt);
  202. /*
  203. * Interface to insert Schemas SAX validation in a SAX stream
  204. */
  205. typedef struct _xmlSchemaSAXPlug xmlSchemaSAXPlugStruct;
  206. typedef xmlSchemaSAXPlugStruct *xmlSchemaSAXPlugPtr;
  207. XMLPUBFUN xmlSchemaSAXPlugPtr XMLCALL
  208. xmlSchemaSAXPlug (xmlSchemaValidCtxtPtr ctxt,
  209. xmlSAXHandlerPtr *sax,
  210. void **user_data);
  211. XMLPUBFUN int XMLCALL
  212. xmlSchemaSAXUnplug (xmlSchemaSAXPlugPtr plug);
  213. XMLPUBFUN void XMLCALL
  214. xmlSchemaValidateSetLocator (xmlSchemaValidCtxtPtr vctxt,
  215. xmlSchemaValidityLocatorFunc f,
  216. void *ctxt);
  217. #ifdef __cplusplus
  218. }
  219. #endif
  220. #endif /* LIBXML_SCHEMAS_ENABLED */
  221. #endif /* __XML_SCHEMA_H__ */