Path: blob/master/libs/xml2/include/libxml/xmlschemas.h
4394 views
/*1* Summary: incomplete XML Schemas structure implementation2* Description: interface to the XML Schemas handling and schema validity3* checking, it is incomplete right now.4*5* Copy: See Copyright for the status of this software.6*7* Author: Daniel Veillard8*/91011#ifndef __XML_SCHEMA_H__12#define __XML_SCHEMA_H__1314#include <libxml/xmlversion.h>1516#ifdef LIBXML_SCHEMAS_ENABLED1718#include <stdio.h>19#include <libxml/encoding.h>20#include <libxml/tree.h>21#include <libxml/xmlerror.h>2223#ifdef __cplusplus24extern "C" {25#endif2627/**28* This error codes are obsolete; not used any more.29*/30typedef enum {31XML_SCHEMAS_ERR_OK = 0,32XML_SCHEMAS_ERR_NOROOT = 1,33XML_SCHEMAS_ERR_UNDECLAREDELEM,34XML_SCHEMAS_ERR_NOTTOPLEVEL,35XML_SCHEMAS_ERR_MISSING,36XML_SCHEMAS_ERR_WRONGELEM,37XML_SCHEMAS_ERR_NOTYPE,38XML_SCHEMAS_ERR_NOROLLBACK,39XML_SCHEMAS_ERR_ISABSTRACT,40XML_SCHEMAS_ERR_NOTEMPTY,41XML_SCHEMAS_ERR_ELEMCONT,42XML_SCHEMAS_ERR_HAVEDEFAULT,43XML_SCHEMAS_ERR_NOTNILLABLE,44XML_SCHEMAS_ERR_EXTRACONTENT,45XML_SCHEMAS_ERR_INVALIDATTR,46XML_SCHEMAS_ERR_INVALIDELEM,47XML_SCHEMAS_ERR_NOTDETERMINIST,48XML_SCHEMAS_ERR_CONSTRUCT,49XML_SCHEMAS_ERR_INTERNAL,50XML_SCHEMAS_ERR_NOTSIMPLE,51XML_SCHEMAS_ERR_ATTRUNKNOWN,52XML_SCHEMAS_ERR_ATTRINVALID,53XML_SCHEMAS_ERR_VALUE,54XML_SCHEMAS_ERR_FACET,55XML_SCHEMAS_ERR_,56XML_SCHEMAS_ERR_XXX57} xmlSchemaValidError;5859/*60* ATTENTION: Change xmlSchemaSetValidOptions's check61* for invalid values, if adding to the validation62* options below.63*/64/**65* xmlSchemaValidOption:66*67* This is the set of XML Schema validation options.68*/69typedef enum {70XML_SCHEMA_VAL_VC_I_CREATE = 1<<071/* Default/fixed: create an attribute node72* or an element's text node on the instance.73*/74} xmlSchemaValidOption;7576/*77XML_SCHEMA_VAL_XSI_ASSEMBLE = 1<<1,78* assemble schemata using79* xsi:schemaLocation and80* xsi:noNamespaceSchemaLocation81*/8283/**84* The schemas related types are kept internal85*/86typedef struct _xmlSchema xmlSchema;87typedef xmlSchema *xmlSchemaPtr;8889/**90* xmlSchemaValidityErrorFunc:91* @ctx: the validation context92* @msg: the message93* @...: extra arguments94*95* Signature of an error callback from an XSD validation96*/97typedef void (*xmlSchemaValidityErrorFunc)98(void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);99100/**101* xmlSchemaValidityWarningFunc:102* @ctx: the validation context103* @msg: the message104* @...: extra arguments105*106* Signature of a warning callback from an XSD validation107*/108typedef void (*xmlSchemaValidityWarningFunc)109(void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);110111/**112* A schemas validation context113*/114typedef struct _xmlSchemaParserCtxt xmlSchemaParserCtxt;115typedef xmlSchemaParserCtxt *xmlSchemaParserCtxtPtr;116117typedef struct _xmlSchemaValidCtxt xmlSchemaValidCtxt;118typedef xmlSchemaValidCtxt *xmlSchemaValidCtxtPtr;119120/**121* xmlSchemaValidityLocatorFunc:122* @ctx: user provided context123* @file: returned file information124* @line: returned line information125*126* A schemas validation locator, a callback called by the validator.127* This is used when file or node information are not available128* to find out what file and line number are affected129*130* Returns: 0 in case of success and -1 in case of error131*/132133typedef int (*xmlSchemaValidityLocatorFunc) (void *ctx,134const char **file, unsigned long *line);135136/*137* Interfaces for parsing.138*/139XMLPUBFUN xmlSchemaParserCtxtPtr140xmlSchemaNewParserCtxt (const char *URL);141XMLPUBFUN xmlSchemaParserCtxtPtr142xmlSchemaNewMemParserCtxt (const char *buffer,143int size);144XMLPUBFUN xmlSchemaParserCtxtPtr145xmlSchemaNewDocParserCtxt (xmlDocPtr doc);146XMLPUBFUN void147xmlSchemaFreeParserCtxt (xmlSchemaParserCtxtPtr ctxt);148XMLPUBFUN void149xmlSchemaSetParserErrors (xmlSchemaParserCtxtPtr ctxt,150xmlSchemaValidityErrorFunc err,151xmlSchemaValidityWarningFunc warn,152void *ctx);153XMLPUBFUN void154xmlSchemaSetParserStructuredErrors(xmlSchemaParserCtxtPtr ctxt,155xmlStructuredErrorFunc serror,156void *ctx);157XMLPUBFUN int158xmlSchemaGetParserErrors(xmlSchemaParserCtxtPtr ctxt,159xmlSchemaValidityErrorFunc * err,160xmlSchemaValidityWarningFunc * warn,161void **ctx);162XMLPUBFUN int163xmlSchemaIsValid (xmlSchemaValidCtxtPtr ctxt);164165XMLPUBFUN xmlSchemaPtr166xmlSchemaParse (xmlSchemaParserCtxtPtr ctxt);167XMLPUBFUN void168xmlSchemaFree (xmlSchemaPtr schema);169#ifdef LIBXML_OUTPUT_ENABLED170XMLPUBFUN void171xmlSchemaDump (FILE *output,172xmlSchemaPtr schema);173#endif /* LIBXML_OUTPUT_ENABLED */174/*175* Interfaces for validating176*/177XMLPUBFUN void178xmlSchemaSetValidErrors (xmlSchemaValidCtxtPtr ctxt,179xmlSchemaValidityErrorFunc err,180xmlSchemaValidityWarningFunc warn,181void *ctx);182XMLPUBFUN void183xmlSchemaSetValidStructuredErrors(xmlSchemaValidCtxtPtr ctxt,184xmlStructuredErrorFunc serror,185void *ctx);186XMLPUBFUN int187xmlSchemaGetValidErrors (xmlSchemaValidCtxtPtr ctxt,188xmlSchemaValidityErrorFunc *err,189xmlSchemaValidityWarningFunc *warn,190void **ctx);191XMLPUBFUN int192xmlSchemaSetValidOptions (xmlSchemaValidCtxtPtr ctxt,193int options);194XMLPUBFUN void195xmlSchemaValidateSetFilename(xmlSchemaValidCtxtPtr vctxt,196const char *filename);197XMLPUBFUN int198xmlSchemaValidCtxtGetOptions(xmlSchemaValidCtxtPtr ctxt);199200XMLPUBFUN xmlSchemaValidCtxtPtr201xmlSchemaNewValidCtxt (xmlSchemaPtr schema);202XMLPUBFUN void203xmlSchemaFreeValidCtxt (xmlSchemaValidCtxtPtr ctxt);204XMLPUBFUN int205xmlSchemaValidateDoc (xmlSchemaValidCtxtPtr ctxt,206xmlDocPtr instance);207XMLPUBFUN int208xmlSchemaValidateOneElement (xmlSchemaValidCtxtPtr ctxt,209xmlNodePtr elem);210XMLPUBFUN int211xmlSchemaValidateStream (xmlSchemaValidCtxtPtr ctxt,212xmlParserInputBufferPtr input,213xmlCharEncoding enc,214xmlSAXHandlerPtr sax,215void *user_data);216XMLPUBFUN int217xmlSchemaValidateFile (xmlSchemaValidCtxtPtr ctxt,218const char * filename,219int options);220221XMLPUBFUN xmlParserCtxtPtr222xmlSchemaValidCtxtGetParserCtxt(xmlSchemaValidCtxtPtr ctxt);223224/*225* Interface to insert Schemas SAX validation in a SAX stream226*/227typedef struct _xmlSchemaSAXPlug xmlSchemaSAXPlugStruct;228typedef xmlSchemaSAXPlugStruct *xmlSchemaSAXPlugPtr;229230XMLPUBFUN xmlSchemaSAXPlugPtr231xmlSchemaSAXPlug (xmlSchemaValidCtxtPtr ctxt,232xmlSAXHandlerPtr *sax,233void **user_data);234XMLPUBFUN int235xmlSchemaSAXUnplug (xmlSchemaSAXPlugPtr plug);236237238XMLPUBFUN void239xmlSchemaValidateSetLocator (xmlSchemaValidCtxtPtr vctxt,240xmlSchemaValidityLocatorFunc f,241void *ctxt);242243#ifdef __cplusplus244}245#endif246247#endif /* LIBXML_SCHEMAS_ENABLED */248#endif /* __XML_SCHEMA_H__ */249250251