1 /* libxml2 - Library for parsing XML documents 2 * Copyright (C) 2006-2019 Free Software Foundation, Inc. 3 * 4 * This file is not part of the GNU gettext program, but is used with 5 * GNU gettext. 6 * 7 * The original copyright notice is as follows: 8 */ 9 10 /* 11 * Copyright (C) 1998-2012 Daniel Veillard. All Rights Reserved. 12 * 13 * Permission is hereby granted, free of charge, to any person obtaining a copy 14 * of this software and associated documentation files (the "Software"), to deal 15 * in the Software without restriction, including without limitation the rights 16 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 * copies of the Software, and to permit persons to whom the Software is fur- 18 * nished to do so, subject to the following conditions: 19 * 20 * The above copyright notice and this permission notice shall be included in 21 * all copies or substantial portions of the Software. 22 * 23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- 25 * NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29 * THE SOFTWARE. 30 * 31 * Author: Daniel Veillard 32 */ 33 34 /* 35 * Summary: XML Schemastron implementation 36 * Description: interface to the XML Schematron validity checking. 37 */ 38 39 #ifndef __XML_SCHEMATRON_H__ 40 #define __XML_SCHEMATRON_H__ 41 42 #include <libxml/xmlversion.h> 43 44 #ifdef LIBXML_SCHEMATRON_ENABLED 45 46 #include <libxml/tree.h> 47 48 #ifdef __cplusplus 49 extern "C" { 50 #endif 51 52 typedef enum { 53 XML_SCHEMATRON_OUT_QUIET = 1 << 0, /* quiet no report */ 54 XML_SCHEMATRON_OUT_TEXT = 1 << 1, /* build a textual report */ 55 XML_SCHEMATRON_OUT_XML = 1 << 2, /* output SVRL */ 56 XML_SCHEMATRON_OUT_ERROR = 1 << 3, /* output via xmlStructuredErrorFunc */ 57 XML_SCHEMATRON_OUT_FILE = 1 << 8, /* output to a file descriptor */ 58 XML_SCHEMATRON_OUT_BUFFER = 1 << 9, /* output to a buffer */ 59 XML_SCHEMATRON_OUT_IO = 1 << 10 /* output to I/O mechanism */ 60 } xmlSchematronValidOptions; 61 62 /** 63 * The schemas related types are kept internal 64 */ 65 typedef struct _xmlSchematron xmlSchematron; 66 typedef xmlSchematron *xmlSchematronPtr; 67 68 /** 69 * xmlSchematronValidityErrorFunc: 70 * @ctx: the validation context 71 * @msg: the message 72 * @...: extra arguments 73 * 74 * Signature of an error callback from a Schematron validation 75 */ 76 typedef void (*xmlSchematronValidityErrorFunc) (void *ctx, const char *msg, ...); 77 78 /** 79 * xmlSchematronValidityWarningFunc: 80 * @ctx: the validation context 81 * @msg: the message 82 * @...: extra arguments 83 * 84 * Signature of a warning callback from a Schematron validation 85 */ 86 typedef void (*xmlSchematronValidityWarningFunc) (void *ctx, const char *msg, ...); 87 88 /** 89 * A schemas validation context 90 */ 91 typedef struct _xmlSchematronParserCtxt xmlSchematronParserCtxt; 92 typedef xmlSchematronParserCtxt *xmlSchematronParserCtxtPtr; 93 94 typedef struct _xmlSchematronValidCtxt xmlSchematronValidCtxt; 95 typedef xmlSchematronValidCtxt *xmlSchematronValidCtxtPtr; 96 97 /* 98 * Interfaces for parsing. 99 */ 100 XMLPUBFUN xmlSchematronParserCtxtPtr XMLCALL 101 xmlSchematronNewParserCtxt (const char *URL); 102 XMLPUBFUN xmlSchematronParserCtxtPtr XMLCALL 103 xmlSchematronNewMemParserCtxt(const char *buffer, 104 int size); 105 XMLPUBFUN xmlSchematronParserCtxtPtr XMLCALL 106 xmlSchematronNewDocParserCtxt(xmlDocPtr doc); 107 XMLPUBFUN void XMLCALL 108 xmlSchematronFreeParserCtxt (xmlSchematronParserCtxtPtr ctxt); 109 /***** 110 XMLPUBFUN void XMLCALL 111 xmlSchematronSetParserErrors(xmlSchematronParserCtxtPtr ctxt, 112 xmlSchematronValidityErrorFunc err, 113 xmlSchematronValidityWarningFunc warn, 114 void *ctx); 115 XMLPUBFUN int XMLCALL 116 xmlSchematronGetParserErrors(xmlSchematronParserCtxtPtr ctxt, 117 xmlSchematronValidityErrorFunc * err, 118 xmlSchematronValidityWarningFunc * warn, 119 void **ctx); 120 XMLPUBFUN int XMLCALL 121 xmlSchematronIsValid (xmlSchematronValidCtxtPtr ctxt); 122 *****/ 123 XMLPUBFUN xmlSchematronPtr XMLCALL 124 xmlSchematronParse (xmlSchematronParserCtxtPtr ctxt); 125 XMLPUBFUN void XMLCALL 126 xmlSchematronFree (xmlSchematronPtr schema); 127 /* 128 * Interfaces for validating 129 */ 130 XMLPUBFUN void XMLCALL 131 xmlSchematronSetValidStructuredErrors( 132 xmlSchematronValidCtxtPtr ctxt, 133 xmlStructuredErrorFunc serror, 134 void *ctx); 135 /****** 136 XMLPUBFUN void XMLCALL 137 xmlSchematronSetValidErrors (xmlSchematronValidCtxtPtr ctxt, 138 xmlSchematronValidityErrorFunc err, 139 xmlSchematronValidityWarningFunc warn, 140 void *ctx); 141 XMLPUBFUN int XMLCALL 142 xmlSchematronGetValidErrors (xmlSchematronValidCtxtPtr ctxt, 143 xmlSchematronValidityErrorFunc *err, 144 xmlSchematronValidityWarningFunc *warn, 145 void **ctx); 146 XMLPUBFUN int XMLCALL 147 xmlSchematronSetValidOptions(xmlSchematronValidCtxtPtr ctxt, 148 int options); 149 XMLPUBFUN int XMLCALL 150 xmlSchematronValidCtxtGetOptions(xmlSchematronValidCtxtPtr ctxt); 151 XMLPUBFUN int XMLCALL 152 xmlSchematronValidateOneElement (xmlSchematronValidCtxtPtr ctxt, 153 xmlNodePtr elem); 154 *******/ 155 156 XMLPUBFUN xmlSchematronValidCtxtPtr XMLCALL 157 xmlSchematronNewValidCtxt (xmlSchematronPtr schema, 158 int options); 159 XMLPUBFUN void XMLCALL 160 xmlSchematronFreeValidCtxt (xmlSchematronValidCtxtPtr ctxt); 161 XMLPUBFUN int XMLCALL 162 xmlSchematronValidateDoc (xmlSchematronValidCtxtPtr ctxt, 163 xmlDocPtr instance); 164 165 #ifdef __cplusplus 166 } 167 #endif 168 169 #endif /* LIBXML_SCHEMATRON_ENABLED */ 170 #endif /* __XML_SCHEMATRON_H__ */ 171