Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:41:52

0001 /*
0002  * Summary: incomplete XML Schemas structure implementation
0003  * Description: interface to the XML Schemas handling and schema validity
0004  *              checking, it is incomplete right now.
0005  *
0006  * Copy: See Copyright for the status of this software.
0007  *
0008  * Author: Daniel Veillard
0009  */
0010 
0011 
0012 #ifndef __XML_SCHEMA_H__
0013 #define __XML_SCHEMA_H__
0014 
0015 #include <libxml/xmlversion.h>
0016 
0017 #ifdef LIBXML_SCHEMAS_ENABLED
0018 
0019 #include <stdio.h>
0020 #include <libxml/encoding.h>
0021 #include <libxml/tree.h>
0022 #include <libxml/xmlerror.h>
0023 
0024 #ifdef __cplusplus
0025 extern "C" {
0026 #endif
0027 
0028 /**
0029  * This error codes are obsolete; not used any more.
0030  */
0031 typedef enum {
0032     XML_SCHEMAS_ERR_OK      = 0,
0033     XML_SCHEMAS_ERR_NOROOT  = 1,
0034     XML_SCHEMAS_ERR_UNDECLAREDELEM,
0035     XML_SCHEMAS_ERR_NOTTOPLEVEL,
0036     XML_SCHEMAS_ERR_MISSING,
0037     XML_SCHEMAS_ERR_WRONGELEM,
0038     XML_SCHEMAS_ERR_NOTYPE,
0039     XML_SCHEMAS_ERR_NOROLLBACK,
0040     XML_SCHEMAS_ERR_ISABSTRACT,
0041     XML_SCHEMAS_ERR_NOTEMPTY,
0042     XML_SCHEMAS_ERR_ELEMCONT,
0043     XML_SCHEMAS_ERR_HAVEDEFAULT,
0044     XML_SCHEMAS_ERR_NOTNILLABLE,
0045     XML_SCHEMAS_ERR_EXTRACONTENT,
0046     XML_SCHEMAS_ERR_INVALIDATTR,
0047     XML_SCHEMAS_ERR_INVALIDELEM,
0048     XML_SCHEMAS_ERR_NOTDETERMINIST,
0049     XML_SCHEMAS_ERR_CONSTRUCT,
0050     XML_SCHEMAS_ERR_INTERNAL,
0051     XML_SCHEMAS_ERR_NOTSIMPLE,
0052     XML_SCHEMAS_ERR_ATTRUNKNOWN,
0053     XML_SCHEMAS_ERR_ATTRINVALID,
0054     XML_SCHEMAS_ERR_VALUE,
0055     XML_SCHEMAS_ERR_FACET,
0056     XML_SCHEMAS_ERR_,
0057     XML_SCHEMAS_ERR_XXX
0058 } xmlSchemaValidError;
0059 
0060 /*
0061 * ATTENTION: Change xmlSchemaSetValidOptions's check
0062 * for invalid values, if adding to the validation
0063 * options below.
0064 */
0065 /**
0066  * xmlSchemaValidOption:
0067  *
0068  * This is the set of XML Schema validation options.
0069  */
0070 typedef enum {
0071     XML_SCHEMA_VAL_VC_I_CREATE          = 1<<0
0072     /* Default/fixed: create an attribute node
0073     * or an element's text node on the instance.
0074     */
0075 } xmlSchemaValidOption;
0076 
0077 /*
0078     XML_SCHEMA_VAL_XSI_ASSEMBLE         = 1<<1,
0079     * assemble schemata using
0080     * xsi:schemaLocation and
0081     * xsi:noNamespaceSchemaLocation
0082 */
0083 
0084 /**
0085  * The schemas related types are kept internal
0086  */
0087 typedef struct _xmlSchema xmlSchema;
0088 typedef xmlSchema *xmlSchemaPtr;
0089 
0090 /**
0091  * xmlSchemaValidityErrorFunc:
0092  * @ctx: the validation context
0093  * @msg: the message
0094  * @...: extra arguments
0095  *
0096  * Signature of an error callback from an XSD validation
0097  */
0098 typedef void (*xmlSchemaValidityErrorFunc)
0099                  (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
0100 
0101 /**
0102  * xmlSchemaValidityWarningFunc:
0103  * @ctx: the validation context
0104  * @msg: the message
0105  * @...: extra arguments
0106  *
0107  * Signature of a warning callback from an XSD validation
0108  */
0109 typedef void (*xmlSchemaValidityWarningFunc)
0110                  (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);
0111 
0112 /**
0113  * A schemas validation context
0114  */
0115 typedef struct _xmlSchemaParserCtxt xmlSchemaParserCtxt;
0116 typedef xmlSchemaParserCtxt *xmlSchemaParserCtxtPtr;
0117 
0118 typedef struct _xmlSchemaValidCtxt xmlSchemaValidCtxt;
0119 typedef xmlSchemaValidCtxt *xmlSchemaValidCtxtPtr;
0120 
0121 /**
0122  * xmlSchemaValidityLocatorFunc:
0123  * @ctx: user provided context
0124  * @file: returned file information
0125  * @line: returned line information
0126  *
0127  * A schemas validation locator, a callback called by the validator.
0128  * This is used when file or node information are not available
0129  * to find out what file and line number are affected
0130  *
0131  * Returns: 0 in case of success and -1 in case of error
0132  */
0133 
0134 typedef int (*xmlSchemaValidityLocatorFunc) (void *ctx,
0135                            const char **file, unsigned long *line);
0136 
0137 /*
0138  * Interfaces for parsing.
0139  */
0140 XMLPUBFUN xmlSchemaParserCtxtPtr
0141         xmlSchemaNewParserCtxt  (const char *URL);
0142 XMLPUBFUN xmlSchemaParserCtxtPtr
0143         xmlSchemaNewMemParserCtxt   (const char *buffer,
0144                      int size);
0145 XMLPUBFUN xmlSchemaParserCtxtPtr
0146         xmlSchemaNewDocParserCtxt   (xmlDocPtr doc);
0147 XMLPUBFUN void
0148         xmlSchemaFreeParserCtxt (xmlSchemaParserCtxtPtr ctxt);
0149 XMLPUBFUN void
0150         xmlSchemaSetParserErrors    (xmlSchemaParserCtxtPtr ctxt,
0151                      xmlSchemaValidityErrorFunc err,
0152                      xmlSchemaValidityWarningFunc warn,
0153                      void *ctx);
0154 XMLPUBFUN void
0155         xmlSchemaSetParserStructuredErrors(xmlSchemaParserCtxtPtr ctxt,
0156                      xmlStructuredErrorFunc serror,
0157                      void *ctx);
0158 XMLPUBFUN int
0159         xmlSchemaGetParserErrors(xmlSchemaParserCtxtPtr ctxt,
0160                     xmlSchemaValidityErrorFunc * err,
0161                     xmlSchemaValidityWarningFunc * warn,
0162                     void **ctx);
0163 XMLPUBFUN int
0164         xmlSchemaIsValid    (xmlSchemaValidCtxtPtr ctxt);
0165 
0166 XMLPUBFUN xmlSchemaPtr
0167         xmlSchemaParse      (xmlSchemaParserCtxtPtr ctxt);
0168 XMLPUBFUN void
0169         xmlSchemaFree       (xmlSchemaPtr schema);
0170 #ifdef LIBXML_OUTPUT_ENABLED
0171 XMLPUBFUN void
0172         xmlSchemaDump       (FILE *output,
0173                      xmlSchemaPtr schema);
0174 #endif /* LIBXML_OUTPUT_ENABLED */
0175 /*
0176  * Interfaces for validating
0177  */
0178 XMLPUBFUN void
0179         xmlSchemaSetValidErrors (xmlSchemaValidCtxtPtr ctxt,
0180                      xmlSchemaValidityErrorFunc err,
0181                      xmlSchemaValidityWarningFunc warn,
0182                      void *ctx);
0183 XMLPUBFUN void
0184         xmlSchemaSetValidStructuredErrors(xmlSchemaValidCtxtPtr ctxt,
0185                      xmlStructuredErrorFunc serror,
0186                      void *ctx);
0187 XMLPUBFUN int
0188         xmlSchemaGetValidErrors (xmlSchemaValidCtxtPtr ctxt,
0189                      xmlSchemaValidityErrorFunc *err,
0190                      xmlSchemaValidityWarningFunc *warn,
0191                      void **ctx);
0192 XMLPUBFUN int
0193         xmlSchemaSetValidOptions    (xmlSchemaValidCtxtPtr ctxt,
0194                      int options);
0195 XMLPUBFUN void
0196             xmlSchemaValidateSetFilename(xmlSchemaValidCtxtPtr vctxt,
0197                                      const char *filename);
0198 XMLPUBFUN int
0199         xmlSchemaValidCtxtGetOptions(xmlSchemaValidCtxtPtr ctxt);
0200 
0201 XMLPUBFUN xmlSchemaValidCtxtPtr
0202         xmlSchemaNewValidCtxt   (xmlSchemaPtr schema);
0203 XMLPUBFUN void
0204         xmlSchemaFreeValidCtxt  (xmlSchemaValidCtxtPtr ctxt);
0205 XMLPUBFUN int
0206         xmlSchemaValidateDoc    (xmlSchemaValidCtxtPtr ctxt,
0207                      xmlDocPtr instance);
0208 XMLPUBFUN int
0209             xmlSchemaValidateOneElement (xmlSchemaValidCtxtPtr ctxt,
0210                              xmlNodePtr elem);
0211 XMLPUBFUN int
0212         xmlSchemaValidateStream (xmlSchemaValidCtxtPtr ctxt,
0213                      xmlParserInputBufferPtr input,
0214                      xmlCharEncoding enc,
0215                      xmlSAXHandlerPtr sax,
0216                      void *user_data);
0217 XMLPUBFUN int
0218         xmlSchemaValidateFile   (xmlSchemaValidCtxtPtr ctxt,
0219                      const char * filename,
0220                      int options);
0221 
0222 XMLPUBFUN xmlParserCtxtPtr
0223         xmlSchemaValidCtxtGetParserCtxt(xmlSchemaValidCtxtPtr ctxt);
0224 
0225 /*
0226  * Interface to insert Schemas SAX validation in a SAX stream
0227  */
0228 typedef struct _xmlSchemaSAXPlug xmlSchemaSAXPlugStruct;
0229 typedef xmlSchemaSAXPlugStruct *xmlSchemaSAXPlugPtr;
0230 
0231 XMLPUBFUN xmlSchemaSAXPlugPtr
0232             xmlSchemaSAXPlug        (xmlSchemaValidCtxtPtr ctxt,
0233                      xmlSAXHandlerPtr *sax,
0234                      void **user_data);
0235 XMLPUBFUN int
0236             xmlSchemaSAXUnplug      (xmlSchemaSAXPlugPtr plug);
0237 
0238 
0239 XMLPUBFUN void
0240             xmlSchemaValidateSetLocator (xmlSchemaValidCtxtPtr vctxt,
0241                      xmlSchemaValidityLocatorFunc f,
0242                      void *ctxt);
0243 
0244 #ifdef __cplusplus
0245 }
0246 #endif
0247 
0248 #endif /* LIBXML_SCHEMAS_ENABLED */
0249 #endif /* __XML_SCHEMA_H__ */