xmlschemas.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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) (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
  85. /**
  86. * xmlSchemaValidityWarningFunc:
  87. * @ctx: the validation context
  88. * @msg: the message
  89. * @...: extra arguments
  90. *
  91. * Signature of a warning callback from an XSD validation
  92. */
  93. typedef void (XMLCDECL *xmlSchemaValidityWarningFunc) (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
  94. /**
  95. * A schemas validation context
  96. */
  97. typedef struct _xmlSchemaParserCtxt xmlSchemaParserCtxt;
  98. typedef xmlSchemaParserCtxt *xmlSchemaParserCtxtPtr;
  99. typedef struct _xmlSchemaValidCtxt xmlSchemaValidCtxt;
  100. typedef xmlSchemaValidCtxt *xmlSchemaValidCtxtPtr;
  101. /*
  102. * Interfaces for parsing.
  103. */
  104. XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL
  105. xmlSchemaNewParserCtxt (const char *URL);
  106. XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL
  107. xmlSchemaNewMemParserCtxt (const char *buffer,
  108. int size);
  109. XMLPUBFUN xmlSchemaParserCtxtPtr XMLCALL
  110. xmlSchemaNewDocParserCtxt (xmlDocPtr doc);
  111. XMLPUBFUN void XMLCALL
  112. xmlSchemaFreeParserCtxt (xmlSchemaParserCtxtPtr ctxt);
  113. XMLPUBFUN void XMLCALL
  114. xmlSchemaSetParserErrors (xmlSchemaParserCtxtPtr ctxt,
  115. xmlSchemaValidityErrorFunc err,
  116. xmlSchemaValidityWarningFunc warn,
  117. void *ctx);
  118. XMLPUBFUN void XMLCALL
  119. xmlSchemaSetParserStructuredErrors(xmlSchemaParserCtxtPtr ctxt,
  120. xmlStructuredErrorFunc serror,
  121. void *ctx);
  122. XMLPUBFUN int XMLCALL
  123. xmlSchemaGetParserErrors(xmlSchemaParserCtxtPtr ctxt,
  124. xmlSchemaValidityErrorFunc * err,
  125. xmlSchemaValidityWarningFunc * warn,
  126. void **ctx);
  127. XMLPUBFUN int XMLCALL
  128. xmlSchemaIsValid (xmlSchemaValidCtxtPtr ctxt);
  129. XMLPUBFUN xmlSchemaPtr XMLCALL
  130. xmlSchemaParse (xmlSchemaParserCtxtPtr ctxt);
  131. XMLPUBFUN void XMLCALL
  132. xmlSchemaFree (xmlSchemaPtr schema);
  133. #ifdef LIBXML_OUTPUT_ENABLED
  134. XMLPUBFUN void XMLCALL
  135. xmlSchemaDump (FILE *output,
  136. xmlSchemaPtr schema);
  137. #endif /* LIBXML_OUTPUT_ENABLED */
  138. /*
  139. * Interfaces for validating
  140. */
  141. XMLPUBFUN void XMLCALL
  142. xmlSchemaSetValidErrors (xmlSchemaValidCtxtPtr ctxt,
  143. xmlSchemaValidityErrorFunc err,
  144. xmlSchemaValidityWarningFunc warn,
  145. void *ctx);
  146. XMLPUBFUN void XMLCALL
  147. xmlSchemaSetValidStructuredErrors(xmlSchemaValidCtxtPtr ctxt,
  148. xmlStructuredErrorFunc serror,
  149. void *ctx);
  150. XMLPUBFUN int XMLCALL
  151. xmlSchemaGetValidErrors (xmlSchemaValidCtxtPtr ctxt,
  152. xmlSchemaValidityErrorFunc *err,
  153. xmlSchemaValidityWarningFunc *warn,
  154. void **ctx);
  155. XMLPUBFUN int XMLCALL
  156. xmlSchemaSetValidOptions (xmlSchemaValidCtxtPtr ctxt,
  157. int options);
  158. XMLPUBFUN int XMLCALL
  159. xmlSchemaValidCtxtGetOptions(xmlSchemaValidCtxtPtr ctxt);
  160. XMLPUBFUN xmlSchemaValidCtxtPtr XMLCALL
  161. xmlSchemaNewValidCtxt (xmlSchemaPtr schema);
  162. XMLPUBFUN void XMLCALL
  163. xmlSchemaFreeValidCtxt (xmlSchemaValidCtxtPtr ctxt);
  164. XMLPUBFUN int XMLCALL
  165. xmlSchemaValidateDoc (xmlSchemaValidCtxtPtr ctxt,
  166. xmlDocPtr instance);
  167. XMLPUBFUN int XMLCALL
  168. xmlSchemaValidateOneElement (xmlSchemaValidCtxtPtr ctxt,
  169. xmlNodePtr elem);
  170. XMLPUBFUN int XMLCALL
  171. xmlSchemaValidateStream (xmlSchemaValidCtxtPtr ctxt,
  172. xmlParserInputBufferPtr input,
  173. xmlCharEncoding enc,
  174. xmlSAXHandlerPtr sax,
  175. void *user_data);
  176. XMLPUBFUN int XMLCALL
  177. xmlSchemaValidateFile (xmlSchemaValidCtxtPtr ctxt,
  178. const char * filename,
  179. int options);
  180. XMLPUBFUN xmlParserCtxtPtr XMLCALL
  181. xmlSchemaValidCtxtGetParserCtxt(xmlSchemaValidCtxtPtr ctxt);
  182. /*
  183. * Interface to insert Schemas SAX validation in a SAX stream
  184. */
  185. typedef struct _xmlSchemaSAXPlug xmlSchemaSAXPlugStruct;
  186. typedef xmlSchemaSAXPlugStruct *xmlSchemaSAXPlugPtr;
  187. XMLPUBFUN xmlSchemaSAXPlugPtr XMLCALL
  188. xmlSchemaSAXPlug (xmlSchemaValidCtxtPtr ctxt,
  189. xmlSAXHandlerPtr *sax,
  190. void **user_data);
  191. XMLPUBFUN int XMLCALL
  192. xmlSchemaSAXUnplug (xmlSchemaSAXPlugPtr plug);
  193. #ifdef __cplusplus
  194. }
  195. #endif
  196. #endif /* LIBXML_SCHEMAS_ENABLED */
  197. #endif /* __XML_SCHEMA_H__ */