xmlschemas.h 5.6 KB

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