1 /* 2 * Summary: XML Schematron implementation 3 * Description: interface to the XML Schematron validity checking. 4 * 5 * Copy: See Copyright for the status of this software. 6 * 7 * Author: Daniel Veillard 8 */ 9 10 11 #ifndef __XML_SCHEMATRON_H__ 12 #define __XML_SCHEMATRON_H__ 13 14 #include <libxml/xmlversion.h> 15 16 #ifdef LIBXML_SCHEMATRON_ENABLED 17 18 #include <libxml/xmlerror.h> 19 #include <libxml/tree.h> 20 21 #ifdef __cplusplus 22 extern "C" { 23 #endif 24 25 typedef enum { 26 XML_SCHEMATRON_OUT_QUIET = 1 << 0, /* quiet no report */ 27 XML_SCHEMATRON_OUT_TEXT = 1 << 1, /* build a textual report */ 28 XML_SCHEMATRON_OUT_XML = 1 << 2, /* output SVRL */ 29 XML_SCHEMATRON_OUT_ERROR = 1 << 3, /* output via xmlStructuredErrorFunc */ 30 XML_SCHEMATRON_OUT_FILE = 1 << 8, /* output to a file descriptor */ 31 XML_SCHEMATRON_OUT_BUFFER = 1 << 9, /* output to a buffer */ 32 XML_SCHEMATRON_OUT_IO = 1 << 10 /* output to I/O mechanism */ 33 } xmlSchematronValidOptions; 34 35 /** 36 * The schemas related types are kept internal 37 */ 38 typedef struct _xmlSchematron xmlSchematron; 39 typedef xmlSchematron *xmlSchematronPtr; 40 41 /** 42 * xmlSchematronValidityErrorFunc: 43 * @ctx: the validation context 44 * @msg: the message 45 * @...: extra arguments 46 * 47 * Signature of an error callback from a Schematron validation 48 */ 49 typedef void (*xmlSchematronValidityErrorFunc) (void *ctx, const char *msg, ...); 50 51 /** 52 * xmlSchematronValidityWarningFunc: 53 * @ctx: the validation context 54 * @msg: the message 55 * @...: extra arguments 56 * 57 * Signature of a warning callback from a Schematron validation 58 */ 59 typedef void (*xmlSchematronValidityWarningFunc) (void *ctx, const char *msg, ...); 60 61 /** 62 * A schemas validation context 63 */ 64 typedef struct _xmlSchematronParserCtxt xmlSchematronParserCtxt; 65 typedef xmlSchematronParserCtxt *xmlSchematronParserCtxtPtr; 66 67 typedef struct _xmlSchematronValidCtxt xmlSchematronValidCtxt; 68 typedef xmlSchematronValidCtxt *xmlSchematronValidCtxtPtr; 69 70 /* 71 * Interfaces for parsing. 72 */ 73 XMLPUBFUN xmlSchematronParserCtxtPtr 74 xmlSchematronNewParserCtxt (const char *URL); 75 XMLPUBFUN xmlSchematronParserCtxtPtr 76 xmlSchematronNewMemParserCtxt(const char *buffer, 77 int size); 78 XMLPUBFUN xmlSchematronParserCtxtPtr 79 xmlSchematronNewDocParserCtxt(xmlDocPtr doc); 80 XMLPUBFUN void 81 xmlSchematronFreeParserCtxt (xmlSchematronParserCtxtPtr ctxt); 82 /***** 83 XMLPUBFUN void 84 xmlSchematronSetParserErrors(xmlSchematronParserCtxtPtr ctxt, 85 xmlSchematronValidityErrorFunc err, 86 xmlSchematronValidityWarningFunc warn, 87 void *ctx); 88 XMLPUBFUN int 89 xmlSchematronGetParserErrors(xmlSchematronParserCtxtPtr ctxt, 90 xmlSchematronValidityErrorFunc * err, 91 xmlSchematronValidityWarningFunc * warn, 92 void **ctx); 93 XMLPUBFUN int 94 xmlSchematronIsValid (xmlSchematronValidCtxtPtr ctxt); 95 *****/ 96 XMLPUBFUN xmlSchematronPtr 97 xmlSchematronParse (xmlSchematronParserCtxtPtr ctxt); 98 XMLPUBFUN void 99 xmlSchematronFree (xmlSchematronPtr schema); 100 /* 101 * Interfaces for validating 102 */ 103 XMLPUBFUN void 104 xmlSchematronSetValidStructuredErrors( 105 xmlSchematronValidCtxtPtr ctxt, 106 xmlStructuredErrorFunc serror, 107 void *ctx); 108 /****** 109 XMLPUBFUN void 110 xmlSchematronSetValidErrors (xmlSchematronValidCtxtPtr ctxt, 111 xmlSchematronValidityErrorFunc err, 112 xmlSchematronValidityWarningFunc warn, 113 void *ctx); 114 XMLPUBFUN int 115 xmlSchematronGetValidErrors (xmlSchematronValidCtxtPtr ctxt, 116 xmlSchematronValidityErrorFunc *err, 117 xmlSchematronValidityWarningFunc *warn, 118 void **ctx); 119 XMLPUBFUN int 120 xmlSchematronSetValidOptions(xmlSchematronValidCtxtPtr ctxt, 121 int options); 122 XMLPUBFUN int 123 xmlSchematronValidCtxtGetOptions(xmlSchematronValidCtxtPtr ctxt); 124 XMLPUBFUN int 125 xmlSchematronValidateOneElement (xmlSchematronValidCtxtPtr ctxt, 126 xmlNodePtr elem); 127 *******/ 128 129 XMLPUBFUN xmlSchematronValidCtxtPtr 130 xmlSchematronNewValidCtxt (xmlSchematronPtr schema, 131 int options); 132 XMLPUBFUN void 133 xmlSchematronFreeValidCtxt (xmlSchematronValidCtxtPtr ctxt); 134 XMLPUBFUN int 135 xmlSchematronValidateDoc (xmlSchematronValidCtxtPtr ctxt, 136 xmlDocPtr instance); 137 138 #ifdef __cplusplus 139 } 140 #endif 141 142 #endif /* LIBXML_SCHEMATRON_ENABLED */ 143 #endif /* __XML_SCHEMATRON_H__ */ 144