Daniel Veillard | ed6c549 | 2005-07-23 15:00:22 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * Summary: XML Schemastron 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/tree.h> |
| 19 | |
| 20 | #ifdef __cplusplus |
| 21 | extern "C" { |
| 22 | #endif |
| 23 | |
| 24 | #define XML_SCHEMATRON_NS BAD_CAST "http://purl.oclc.org/dsdl/schematron" |
| 25 | |
| 26 | typedef enum { |
| 27 | XML_SCHEMATRON_OUT_QUIET = 1 << 0, /* quiet no report */ |
| 28 | XML_SCHEMATRON_OUT_TEXT = 1 << 1, /* build a textual report */ |
| 29 | XML_SCHEMATRON_OUT_XML = 1 << 2, /* output SVRL */ |
| 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 | * A schemas validation context |
| 43 | */ |
| 44 | typedef void (*xmlSchematronValidityErrorFunc) (void *ctx, const char *msg, ...); |
| 45 | typedef void (*xmlSchematronValidityWarningFunc) (void *ctx, const char *msg, ...); |
| 46 | |
| 47 | typedef struct _xmlSchematronParserCtxt xmlSchematronParserCtxt; |
| 48 | typedef xmlSchematronParserCtxt *xmlSchematronParserCtxtPtr; |
| 49 | |
| 50 | typedef struct _xmlSchematronValidCtxt xmlSchematronValidCtxt; |
| 51 | typedef xmlSchematronValidCtxt *xmlSchematronValidCtxtPtr; |
| 52 | |
| 53 | /* |
| 54 | * Interfaces for parsing. |
| 55 | */ |
| 56 | XMLPUBFUN xmlSchematronParserCtxtPtr XMLCALL |
| 57 | xmlSchematronNewParserCtxt (const char *URL); |
| 58 | XMLPUBFUN xmlSchematronParserCtxtPtr XMLCALL |
| 59 | xmlSchematronNewMemParserCtxt(const char *buffer, |
| 60 | int size); |
| 61 | XMLPUBFUN xmlSchematronParserCtxtPtr XMLCALL |
| 62 | xmlSchematronNewDocParserCtxt(xmlDocPtr doc); |
| 63 | XMLPUBFUN void XMLCALL |
| 64 | xmlSchematronFreeParserCtxt (xmlSchematronParserCtxtPtr ctxt); |
| 65 | XMLPUBFUN void XMLCALL |
| 66 | xmlSchematronSetParserErrors(xmlSchematronParserCtxtPtr ctxt, |
| 67 | xmlSchematronValidityErrorFunc err, |
| 68 | xmlSchematronValidityWarningFunc warn, |
| 69 | void *ctx); |
| 70 | XMLPUBFUN int XMLCALL |
| 71 | xmlSchematronGetParserErrors(xmlSchematronParserCtxtPtr ctxt, |
| 72 | xmlSchematronValidityErrorFunc * err, |
| 73 | xmlSchematronValidityWarningFunc * warn, |
| 74 | void **ctx); |
| 75 | XMLPUBFUN int XMLCALL |
| 76 | xmlSchematronIsValid (xmlSchematronValidCtxtPtr ctxt); |
| 77 | |
| 78 | XMLPUBFUN xmlSchematronPtr XMLCALL |
| 79 | xmlSchematronParse (xmlSchematronParserCtxtPtr ctxt); |
| 80 | XMLPUBFUN void XMLCALL |
| 81 | xmlSchematronFree (xmlSchematronPtr schema); |
| 82 | #ifdef LIBXML_OUTPUT_ENABLED |
| 83 | XMLPUBFUN void XMLCALL |
| 84 | xmlSchematronDump (FILE *output, |
| 85 | xmlSchematronPtr schema); |
| 86 | #endif /* LIBXML_OUTPUT_ENABLED */ |
| 87 | /* |
| 88 | * Interfaces for validating |
| 89 | */ |
| 90 | XMLPUBFUN void XMLCALL |
| 91 | xmlSchematronSetValidErrors (xmlSchematronValidCtxtPtr ctxt, |
| 92 | xmlSchematronValidityErrorFunc err, |
| 93 | xmlSchematronValidityWarningFunc warn, |
| 94 | void *ctx); |
| 95 | XMLPUBFUN void XMLCALL |
| 96 | xmlSchematronSetValidStructuredErrors(xmlSchematronValidCtxtPtr ctxt, |
| 97 | xmlStructuredErrorFunc serror, void *ctx); |
| 98 | XMLPUBFUN int XMLCALL |
| 99 | xmlSchematronGetValidErrors (xmlSchematronValidCtxtPtr ctxt, |
| 100 | xmlSchematronValidityErrorFunc *err, |
| 101 | xmlSchematronValidityWarningFunc *warn, |
| 102 | void **ctx); |
| 103 | XMLPUBFUN int XMLCALL |
| 104 | xmlSchematronSetValidOptions(xmlSchematronValidCtxtPtr ctxt, |
| 105 | int options); |
| 106 | XMLPUBFUN int XMLCALL |
| 107 | xmlSchematronValidCtxtGetOptions(xmlSchematronValidCtxtPtr ctxt); |
| 108 | |
| 109 | XMLPUBFUN xmlSchematronValidCtxtPtr XMLCALL |
| 110 | xmlSchematronNewValidCtxt (xmlSchematronPtr schema, |
| 111 | int options); |
| 112 | XMLPUBFUN void XMLCALL |
| 113 | xmlSchematronFreeValidCtxt (xmlSchematronValidCtxtPtr ctxt); |
| 114 | XMLPUBFUN int XMLCALL |
| 115 | xmlSchematronValidateDoc (xmlSchematronValidCtxtPtr ctxt, |
| 116 | xmlDocPtr instance); |
| 117 | XMLPUBFUN int XMLCALL |
| 118 | xmlSchematronValidateOneElement (xmlSchematronValidCtxtPtr ctxt, |
| 119 | xmlNodePtr elem); |
| 120 | |
| 121 | #ifdef __cplusplus |
| 122 | } |
| 123 | #endif |
| 124 | |
| 125 | #endif /* LIBXML_SCHEMATRON_ENABLED */ |
| 126 | #endif /* __XML_SCHEMATRON_H__ */ |