1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-10-26 20:25:14 +03:00
libxml2/include/libxml/valid.h

408 lines
12 KiB
C
Raw Normal View History

2001-02-23 20:55:21 +03:00
/*
* valid.h : interface to the DTD handling and the validity checking
*
* See Copyright for the status of this software.
*
* daniel@veillard.com
2001-02-23 20:55:21 +03:00
*/
#ifndef __XML_VALID_H__
#define __XML_VALID_H__
2003-08-25 13:05:12 +04:00
#include <libxml/xmlversion.h>
#include <libxml/xmlerror.h>
2001-02-23 20:55:21 +03:00
#include <libxml/tree.h>
#include <libxml/list.h>
#include <libxml/xmlautomata.h>
#include <libxml/xmlregexp.h>
2001-02-23 20:55:21 +03:00
#ifdef __cplusplus
extern "C" {
#endif
/*
* Validation state added for non-determinist content model.
*/
typedef struct _xmlValidState xmlValidState;
typedef xmlValidState *xmlValidStatePtr;
2001-02-23 20:55:21 +03:00
/**
* xmlValidityErrorFunc:
* @ctx: an xmlValidCtxtPtr validity error context
* @msg: the string to format *printf like vararg
* @...: remaining arguments to the format
*
* Callback called when a validity error is found. This is a message
* oriented function similar to an *printf function.
2001-02-23 20:55:21 +03:00
*/
typedef void (*xmlValidityErrorFunc) (void *ctx,
const char *msg,
...);
2001-02-23 20:55:21 +03:00
/**
* xmlValidityWarningFunc:
* @ctx: an xmlValidCtxtPtr validity error context
* @msg: the string to format *printf like vararg
* @...: remaining arguments to the format
*
* Callback called when a validity warning is found. This is a message
* oriented function similar to an *printf function.
*/
typedef void (*xmlValidityWarningFunc) (void *ctx,
const char *msg,
...);
2001-02-23 20:55:21 +03:00
/*
* xmlValidCtxt:
* An xmlValidCtxt is used for error reporting when validating.
*/
2001-02-23 20:55:21 +03:00
typedef struct _xmlValidCtxt xmlValidCtxt;
typedef xmlValidCtxt *xmlValidCtxtPtr;
struct _xmlValidCtxt {
void *userData; /* user specific data block */
xmlValidityErrorFunc error; /* the callback in case of errors */
xmlValidityWarningFunc warning; /* the callback in case of warning */
/* Node analysis stack used when validating within entities */
xmlNodePtr node; /* Current parsed Node */
int nodeNr; /* Depth of the parsing stack */
int nodeMax; /* Max depth of the parsing stack */
xmlNodePtr *nodeTab; /* array of nodes */
int finishDtd; /* finished validating the Dtd ? */
xmlDocPtr doc; /* the document */
int valid; /* temporary validity check result */
/* state state used for non-determinist content validation */
xmlValidState *vstate; /* current state */
int vstateNr; /* Depth of the validation stack */
int vstateMax; /* Max depth of the validation stack */
xmlValidState *vstateTab; /* array of validation states */
#ifdef LIBXML_REGEXP_ENABLED
xmlAutomataPtr am; /* the automata */
xmlAutomataStatePtr state; /* used to build the automata */
#else
void *am;
void *state;
#endif
2001-02-23 20:55:21 +03:00
};
/*
* ALL notation declarations are stored in a table.
* There is one table per DTD.
2001-02-23 20:55:21 +03:00
*/
typedef struct _xmlHashTable xmlNotationTable;
typedef xmlNotationTable *xmlNotationTablePtr;
/*
* ALL element declarations are stored in a table.
* There is one table per DTD.
2001-02-23 20:55:21 +03:00
*/
typedef struct _xmlHashTable xmlElementTable;
typedef xmlElementTable *xmlElementTablePtr;
/*
* ALL attribute declarations are stored in a table.
* There is one table per DTD.
2001-02-23 20:55:21 +03:00
*/
typedef struct _xmlHashTable xmlAttributeTable;
typedef xmlAttributeTable *xmlAttributeTablePtr;
/*
* ALL IDs attributes are stored in a table.
* There is one table per document.
2001-02-23 20:55:21 +03:00
*/
typedef struct _xmlHashTable xmlIDTable;
typedef xmlIDTable *xmlIDTablePtr;
/*
* ALL Refs attributes are stored in a table.
* There is one table per document.
2001-02-23 20:55:21 +03:00
*/
typedef struct _xmlHashTable xmlRefTable;
typedef xmlRefTable *xmlRefTablePtr;
/* Allocate/Release Validation Contexts */
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlValidCtxtPtr XMLCALL
xmlNewValidCtxt(void);
XMLPUBFUN void XMLCALL
xmlFreeValidCtxt(xmlValidCtxtPtr);
2001-02-23 20:55:21 +03:00
/* Notation */
2003-08-25 13:05:12 +04:00
XMLPUBFUN xmlNotationPtr XMLCALL
xmlAddNotationDecl (xmlValidCtxtPtr ctxt,
2001-02-23 20:55:21 +03:00
xmlDtdPtr dtd,
const xmlChar *name,
const xmlChar *PublicID,
const xmlChar *SystemID);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNotationTablePtr XMLCALL
xmlCopyNotationTable (xmlNotationTablePtr table);
XMLPUBFUN void XMLCALL
xmlFreeNotationTable (xmlNotationTablePtr table);
#ifdef LIBXML_OUTPUT_ENABLED
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlDumpNotationDecl (xmlBufferPtr buf,
2001-02-23 20:55:21 +03:00
xmlNotationPtr nota);
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlDumpNotationTable (xmlBufferPtr buf,
2001-02-23 20:55:21 +03:00
xmlNotationTablePtr table);
#endif /* LIBXML_OUTPUT_ENABLED */
2001-02-23 20:55:21 +03:00
/* Element Content */
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlElementContentPtr XMLCALL
xmlNewElementContent (const xmlChar *name,
xmlElementContentType type);
XMLPUBFUN xmlElementContentPtr XMLCALL
xmlCopyElementContent (xmlElementContentPtr content);
XMLPUBFUN void XMLCALL
xmlFreeElementContent (xmlElementContentPtr cur);
XMLPUBFUN void XMLCALL
xmlSnprintfElementContent(char *buf,
int size,
xmlElementContentPtr content,
int glob);
/* DEPRECATED */
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlSprintfElementContent(char *buf,
xmlElementContentPtr content,
int glob);
/* DEPRECATED */
2001-02-23 20:55:21 +03:00
/* Element */
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlElementPtr XMLCALL
xmlAddElementDecl (xmlValidCtxtPtr ctxt,
2001-02-23 20:55:21 +03:00
xmlDtdPtr dtd,
const xmlChar *name,
xmlElementTypeVal type,
xmlElementContentPtr content);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlElementTablePtr XMLCALL
xmlCopyElementTable (xmlElementTablePtr table);
XMLPUBFUN void XMLCALL
xmlFreeElementTable (xmlElementTablePtr table);
#ifdef LIBXML_OUTPUT_ENABLED
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlDumpElementTable (xmlBufferPtr buf,
2001-02-23 20:55:21 +03:00
xmlElementTablePtr table);
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlDumpElementDecl (xmlBufferPtr buf,
2001-02-23 20:55:21 +03:00
xmlElementPtr elem);
#endif /* LIBXML_OUTPUT_ENABLED */
2001-02-23 20:55:21 +03:00
/* Enumeration */
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlEnumerationPtr XMLCALL
xmlCreateEnumeration (const xmlChar *name);
XMLPUBFUN void XMLCALL
xmlFreeEnumeration (xmlEnumerationPtr cur);
XMLPUBFUN xmlEnumerationPtr XMLCALL
xmlCopyEnumeration (xmlEnumerationPtr cur);
2001-02-23 20:55:21 +03:00
/* Attribute */
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlAttributePtr XMLCALL
xmlAddAttributeDecl (xmlValidCtxtPtr ctxt,
xmlDtdPtr dtd,
const xmlChar *elem,
const xmlChar *name,
const xmlChar *ns,
xmlAttributeType type,
xmlAttributeDefault def,
const xmlChar *defaultValue,
xmlEnumerationPtr tree);
XMLPUBFUN xmlAttributeTablePtr XMLCALL
xmlCopyAttributeTable (xmlAttributeTablePtr table);
XMLPUBFUN void XMLCALL
xmlFreeAttributeTable (xmlAttributeTablePtr table);
#ifdef LIBXML_OUTPUT_ENABLED
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlDumpAttributeTable (xmlBufferPtr buf,
xmlAttributeTablePtr table);
XMLPUBFUN void XMLCALL
xmlDumpAttributeDecl (xmlBufferPtr buf,
xmlAttributePtr attr);
#endif /* LIBXML_OUTPUT_ENABLED */
2001-02-23 20:55:21 +03:00
/* IDs */
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlIDPtr XMLCALL
xmlAddID (xmlValidCtxtPtr ctxt,
xmlDocPtr doc,
const xmlChar *value,
xmlAttrPtr attr);
XMLPUBFUN void XMLCALL
xmlFreeIDTable (xmlIDTablePtr table);
XMLPUBFUN xmlAttrPtr XMLCALL
xmlGetID (xmlDocPtr doc,
const xmlChar *ID);
XMLPUBFUN int XMLCALL
xmlIsID (xmlDocPtr doc,
xmlNodePtr elem,
xmlAttrPtr attr);
XMLPUBFUN int XMLCALL
xmlRemoveID (xmlDocPtr doc,
xmlAttrPtr attr);
2001-02-23 20:55:21 +03:00
/* IDREFs */
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlRefPtr XMLCALL
xmlAddRef (xmlValidCtxtPtr ctxt,
xmlDocPtr doc,
const xmlChar *value,
xmlAttrPtr attr);
XMLPUBFUN void XMLCALL
xmlFreeRefTable (xmlRefTablePtr table);
XMLPUBFUN int XMLCALL
xmlIsRef (xmlDocPtr doc,
xmlNodePtr elem,
xmlAttrPtr attr);
XMLPUBFUN int XMLCALL
xmlRemoveRef (xmlDocPtr doc,
xmlAttrPtr attr);
XMLPUBFUN xmlListPtr XMLCALL
xmlGetRefs (xmlDocPtr doc,
const xmlChar *ID);
2001-02-23 20:55:21 +03:00
/**
* The public function calls related to validity checking.
2001-02-23 20:55:21 +03:00
*/
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlValidateRoot (xmlValidCtxtPtr ctxt,
2001-02-23 20:55:21 +03:00
xmlDocPtr doc);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlValidateElementDecl (xmlValidCtxtPtr ctxt,
2001-02-23 20:55:21 +03:00
xmlDocPtr doc,
xmlElementPtr elem);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlChar * XMLCALL
xmlValidNormalizeAttributeValue(xmlDocPtr doc,
xmlNodePtr elem,
const xmlChar *name,
const xmlChar *value);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlChar * XMLCALL
xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt,
xmlDocPtr doc,
2001-02-23 20:55:21 +03:00
xmlNodePtr elem,
const xmlChar *name,
const xmlChar *value);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt,
2001-02-23 20:55:21 +03:00
xmlDocPtr doc,
xmlAttributePtr attr);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlValidateAttributeValue(xmlAttributeType type,
2001-02-23 20:55:21 +03:00
const xmlChar *value);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlValidateNotationDecl (xmlValidCtxtPtr ctxt,
2001-02-23 20:55:21 +03:00
xmlDocPtr doc,
xmlNotationPtr nota);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlValidateDtd (xmlValidCtxtPtr ctxt,
2001-02-23 20:55:21 +03:00
xmlDocPtr doc,
xmlDtdPtr dtd);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlValidateDtdFinal (xmlValidCtxtPtr ctxt,
2001-02-23 20:55:21 +03:00
xmlDocPtr doc);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlValidateDocument (xmlValidCtxtPtr ctxt,
2001-02-23 20:55:21 +03:00
xmlDocPtr doc);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlValidateElement (xmlValidCtxtPtr ctxt,
2001-02-23 20:55:21 +03:00
xmlDocPtr doc,
xmlNodePtr elem);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlValidateOneElement (xmlValidCtxtPtr ctxt,
2001-02-23 20:55:21 +03:00
xmlDocPtr doc,
xmlNodePtr elem);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlValidateOneAttribute (xmlValidCtxtPtr ctxt,
2001-02-23 20:55:21 +03:00
xmlDocPtr doc,
xmlNodePtr elem,
xmlAttrPtr attr,
const xmlChar *value);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlValidateOneNamespace (xmlValidCtxtPtr ctxt,
xmlDocPtr doc,
xmlNodePtr elem,
const xmlChar *prefix,
xmlNsPtr ns,
const xmlChar *value);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt,
2001-02-23 20:55:21 +03:00
xmlDocPtr doc);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlValidateNotationUse (xmlValidCtxtPtr ctxt,
2001-02-23 20:55:21 +03:00
xmlDocPtr doc,
const xmlChar *notationName);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlIsMixedElement (xmlDocPtr doc,
2001-02-23 20:55:21 +03:00
const xmlChar *name);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlAttributePtr XMLCALL
xmlGetDtdAttrDesc (xmlDtdPtr dtd,
2001-02-23 20:55:21 +03:00
const xmlChar *elem,
const xmlChar *name);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlAttributePtr XMLCALL
xmlGetDtdQAttrDesc (xmlDtdPtr dtd,
const xmlChar *elem,
const xmlChar *name,
const xmlChar *prefix);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlNotationPtr XMLCALL
xmlGetDtdNotationDesc (xmlDtdPtr dtd,
2001-02-23 20:55:21 +03:00
const xmlChar *name);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlElementPtr XMLCALL
xmlGetDtdQElementDesc (xmlDtdPtr dtd,
const xmlChar *name,
const xmlChar *prefix);
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlElementPtr XMLCALL
xmlGetDtdElementDesc (xmlDtdPtr dtd,
2001-02-23 20:55:21 +03:00
const xmlChar *name);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlValidGetValidElements(xmlNode *prev,
2001-02-23 20:55:21 +03:00
xmlNode *next,
const xmlChar **list,
int max);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlValidGetPotentialChildren(xmlElementContent *ctree,
2001-02-23 20:55:21 +03:00
const xmlChar **list,
int *len,
int max);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlValidateNameValue (const xmlChar *value);
XMLPUBFUN int XMLCALL
xmlValidateNamesValue (const xmlChar *value);
XMLPUBFUN int XMLCALL
xmlValidateNmtokenValue (const xmlChar *value);
XMLPUBFUN int XMLCALL
xmlValidateNmtokensValue(const xmlChar *value);
#ifdef LIBXML_REGEXP_ENABLED
/*
* Validation based on the regexp support
*/
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlValidBuildContentModel(xmlValidCtxtPtr ctxt,
xmlElementPtr elem);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlValidatePushElement (xmlValidCtxtPtr ctxt,
xmlDocPtr doc,
xmlNodePtr elem,
const xmlChar *qname);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlValidatePushCData (xmlValidCtxtPtr ctxt,
const xmlChar *data,
int len);
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlValidatePopElement (xmlValidCtxtPtr ctxt,
xmlDocPtr doc,
xmlNodePtr elem,
const xmlChar *qname);
#endif /* LIBXML_REGEXP_ENABLED */
2001-02-23 20:55:21 +03:00
#ifdef __cplusplus
}
#endif
#endif /* __XML_VALID_H__ */