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

467 lines
13 KiB
C
Raw Normal View History

2001-02-23 20:55:21 +03:00
/*
* Summary: The DTD validation
* Description: API for the DTD handling and the validity checking
2001-02-23 20:55:21 +03:00
*
* Copy: See Copyright for the status of this software.
2001-02-23 20:55:21 +03:00
*
* Author: Daniel Veillard
2001-02-23 20:55:21 +03:00
*/
#ifndef __XML_VALID_H__
#define __XML_VALID_H__
2024-06-16 20:56:08 +03:00
/** DOC_DISABLE */
2003-08-25 13:05:12 +04:00
#include <libxml/xmlversion.h>
#include <libxml/xmlerror.h>
#define XML_TREE_INTERNALS
2001-02-23 20:55:21 +03:00
#include <libxml/tree.h>
#undef XML_TREE_INTERNALS
#include <libxml/list.h>
#include <libxml/xmlautomata.h>
#include <libxml/xmlregexp.h>
2024-06-16 20:56:08 +03:00
/** DOC_ENABLE */
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: usually an xmlValidCtxtPtr to a validity error context,
* but comes from ctxt->userData (which normally contains such
* a pointer); ctxt->userData can be changed by the user.
* @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,
...) LIBXML_ATTR_FORMAT(2,3);
2001-02-23 20:55:21 +03:00
/**
* xmlValidityWarningFunc:
* @ctx: usually an xmlValidCtxtPtr to a validity error context,
* but comes from ctxt->userData (which normally contains such
* a pointer); ctxt->userData can be changed by the user.
* @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,
...) LIBXML_ATTR_FORMAT(2,3);
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 */
unsigned int flags; /* internal flags */
2001-02-23 20:55:21 +03:00
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;
/* Notation */
XMLPUBFUN xmlNotationPtr
2003-08-25 13:05:12 +04:00
xmlAddNotationDecl (xmlValidCtxtPtr ctxt,
2001-02-23 20:55:21 +03:00
xmlDtdPtr dtd,
const xmlChar *name,
const xmlChar *PublicID,
const xmlChar *SystemID);
XMLPUBFUN xmlNotationTablePtr
2003-08-27 12:59:58 +04:00
xmlCopyNotationTable (xmlNotationTablePtr table);
XMLPUBFUN void
2003-08-27 12:59:58 +04:00
xmlFreeNotationTable (xmlNotationTablePtr table);
#ifdef LIBXML_OUTPUT_ENABLED
XML_DEPRECATED
XMLPUBFUN void
2003-08-27 12:59:58 +04:00
xmlDumpNotationDecl (xmlBufferPtr buf,
2001-02-23 20:55:21 +03:00
xmlNotationPtr nota);
/* XML_DEPRECATED, still used in lxml */
XMLPUBFUN void
2003-08-27 12:59:58 +04:00
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 */
/* the non Doc version are being deprecated */
XMLPUBFUN xmlElementContentPtr
2003-08-27 12:59:58 +04:00
xmlNewElementContent (const xmlChar *name,
xmlElementContentType type);
XMLPUBFUN xmlElementContentPtr
2003-08-27 12:59:58 +04:00
xmlCopyElementContent (xmlElementContentPtr content);
XMLPUBFUN void
2003-08-27 12:59:58 +04:00
xmlFreeElementContent (xmlElementContentPtr cur);
/* the new versions with doc argument */
XMLPUBFUN xmlElementContentPtr
xmlNewDocElementContent (xmlDocPtr doc,
const xmlChar *name,
xmlElementContentType type);
XMLPUBFUN xmlElementContentPtr
xmlCopyDocElementContent(xmlDocPtr doc,
xmlElementContentPtr content);
XMLPUBFUN void
xmlFreeDocElementContent(xmlDocPtr doc,
xmlElementContentPtr cur);
XMLPUBFUN void
2003-08-27 12:59:58 +04:00
xmlSnprintfElementContent(char *buf,
int size,
xmlElementContentPtr content,
int englob);
2005-01-02 12:53:13 +03:00
#ifdef LIBXML_OUTPUT_ENABLED
XML_DEPRECATED
XMLPUBFUN void
2003-08-27 12:59:58 +04:00
xmlSprintfElementContent(char *buf,
xmlElementContentPtr content,
int englob);
2005-01-02 12:53:13 +03:00
#endif /* LIBXML_OUTPUT_ENABLED */
2001-02-23 20:55:21 +03:00
/* Element */
XMLPUBFUN xmlElementPtr
2003-08-27 12:59:58 +04:00
xmlAddElementDecl (xmlValidCtxtPtr ctxt,
2001-02-23 20:55:21 +03:00
xmlDtdPtr dtd,
const xmlChar *name,
xmlElementTypeVal type,
xmlElementContentPtr content);
XMLPUBFUN xmlElementTablePtr
2003-08-27 12:59:58 +04:00
xmlCopyElementTable (xmlElementTablePtr table);
XMLPUBFUN void
2003-08-27 12:59:58 +04:00
xmlFreeElementTable (xmlElementTablePtr table);
#ifdef LIBXML_OUTPUT_ENABLED
XML_DEPRECATED
XMLPUBFUN void
2003-08-27 12:59:58 +04:00
xmlDumpElementTable (xmlBufferPtr buf,
2001-02-23 20:55:21 +03:00
xmlElementTablePtr table);
XML_DEPRECATED
XMLPUBFUN void
2003-08-27 12:59:58 +04:00
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 */
XMLPUBFUN xmlEnumerationPtr
2003-08-27 12:59:58 +04:00
xmlCreateEnumeration (const xmlChar *name);
XMLPUBFUN void
2003-08-27 12:59:58 +04:00
xmlFreeEnumeration (xmlEnumerationPtr cur);
XMLPUBFUN xmlEnumerationPtr
2003-08-27 12:59:58 +04:00
xmlCopyEnumeration (xmlEnumerationPtr cur);
2001-02-23 20:55:21 +03:00
/* Attribute */
XMLPUBFUN xmlAttributePtr
2003-08-27 12:59:58 +04:00
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
2003-08-27 12:59:58 +04:00
xmlCopyAttributeTable (xmlAttributeTablePtr table);
XMLPUBFUN void
2003-08-27 12:59:58 +04:00
xmlFreeAttributeTable (xmlAttributeTablePtr table);
#ifdef LIBXML_OUTPUT_ENABLED
XML_DEPRECATED
XMLPUBFUN void
2003-08-27 12:59:58 +04:00
xmlDumpAttributeTable (xmlBufferPtr buf,
xmlAttributeTablePtr table);
XML_DEPRECATED
XMLPUBFUN void
2003-08-27 12:59:58 +04:00
xmlDumpAttributeDecl (xmlBufferPtr buf,
xmlAttributePtr attr);
#endif /* LIBXML_OUTPUT_ENABLED */
2001-02-23 20:55:21 +03:00
/* IDs */
XMLPUBFUN int
2024-02-29 21:38:29 +03:00
xmlAddIDSafe (xmlAttrPtr attr,
const xmlChar *value);
XMLPUBFUN xmlIDPtr
2003-08-27 12:59:58 +04:00
xmlAddID (xmlValidCtxtPtr ctxt,
xmlDocPtr doc,
const xmlChar *value,
xmlAttrPtr attr);
XMLPUBFUN void
2003-08-27 12:59:58 +04:00
xmlFreeIDTable (xmlIDTablePtr table);
XMLPUBFUN xmlAttrPtr
2003-08-27 12:59:58 +04:00
xmlGetID (xmlDocPtr doc,
const xmlChar *ID);
XMLPUBFUN int
2003-08-27 12:59:58 +04:00
xmlIsID (xmlDocPtr doc,
xmlNodePtr elem,
xmlAttrPtr attr);
XMLPUBFUN int
xmlRemoveID (xmlDocPtr doc,
2003-08-27 12:59:58 +04:00
xmlAttrPtr attr);
2001-02-23 20:55:21 +03:00
/* IDREFs */
XML_DEPRECATED
XMLPUBFUN xmlRefPtr
2003-08-27 12:59:58 +04:00
xmlAddRef (xmlValidCtxtPtr ctxt,
xmlDocPtr doc,
const xmlChar *value,
xmlAttrPtr attr);
XML_DEPRECATED
XMLPUBFUN void
2003-08-27 12:59:58 +04:00
xmlFreeRefTable (xmlRefTablePtr table);
XML_DEPRECATED
XMLPUBFUN int
2003-08-27 12:59:58 +04:00
xmlIsRef (xmlDocPtr doc,
xmlNodePtr elem,
xmlAttrPtr attr);
XML_DEPRECATED
XMLPUBFUN int
xmlRemoveRef (xmlDocPtr doc,
2003-08-27 12:59:58 +04:00
xmlAttrPtr attr);
XML_DEPRECATED
XMLPUBFUN xmlListPtr
2003-08-27 12:59:58 +04:00
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
*/
#ifdef LIBXML_VALID_ENABLED
2005-01-02 12:53:13 +03:00
/* Allocate/Release Validation Contexts */
XMLPUBFUN xmlValidCtxtPtr
2005-01-02 12:53:13 +03:00
xmlNewValidCtxt(void);
XMLPUBFUN void
2005-01-02 12:53:13 +03:00
xmlFreeValidCtxt(xmlValidCtxtPtr);
XML_DEPRECATED
XMLPUBFUN int
2003-08-27 12:59:58 +04:00
xmlValidateRoot (xmlValidCtxtPtr ctxt,
2001-02-23 20:55:21 +03:00
xmlDocPtr doc);
XML_DEPRECATED
XMLPUBFUN int
2003-08-27 12:59:58 +04:00
xmlValidateElementDecl (xmlValidCtxtPtr ctxt,
2001-02-23 20:55:21 +03:00
xmlDocPtr doc,
xmlElementPtr elem);
XML_DEPRECATED
XMLPUBFUN xmlChar *
2003-08-27 12:59:58 +04:00
xmlValidNormalizeAttributeValue(xmlDocPtr doc,
xmlNodePtr elem,
const xmlChar *name,
const xmlChar *value);
XML_DEPRECATED
XMLPUBFUN xmlChar *
2003-08-27 12:59:58 +04:00
xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt,
xmlDocPtr doc,
2001-02-23 20:55:21 +03:00
xmlNodePtr elem,
const xmlChar *name,
const xmlChar *value);
XML_DEPRECATED
XMLPUBFUN int
2003-08-27 12:59:58 +04:00
xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt,
2001-02-23 20:55:21 +03:00
xmlDocPtr doc,
xmlAttributePtr attr);
XML_DEPRECATED
XMLPUBFUN int
2003-08-27 12:59:58 +04:00
xmlValidateAttributeValue(xmlAttributeType type,
2001-02-23 20:55:21 +03:00
const xmlChar *value);
XML_DEPRECATED
XMLPUBFUN int
2003-08-27 12:59:58 +04:00
xmlValidateNotationDecl (xmlValidCtxtPtr ctxt,
2001-02-23 20:55:21 +03:00
xmlDocPtr doc,
xmlNotationPtr nota);
XMLPUBFUN int
2003-08-27 12:59:58 +04:00
xmlValidateDtd (xmlValidCtxtPtr ctxt,
2001-02-23 20:55:21 +03:00
xmlDocPtr doc,
xmlDtdPtr dtd);
XML_DEPRECATED
XMLPUBFUN int
2003-08-27 12:59:58 +04:00
xmlValidateDtdFinal (xmlValidCtxtPtr ctxt,
2001-02-23 20:55:21 +03:00
xmlDocPtr doc);
XMLPUBFUN int
2003-08-27 12:59:58 +04:00
xmlValidateDocument (xmlValidCtxtPtr ctxt,
2001-02-23 20:55:21 +03:00
xmlDocPtr doc);
XMLPUBFUN int
2003-08-27 12:59:58 +04:00
xmlValidateElement (xmlValidCtxtPtr ctxt,
2001-02-23 20:55:21 +03:00
xmlDocPtr doc,
xmlNodePtr elem);
XML_DEPRECATED
XMLPUBFUN int
2003-08-27 12:59:58 +04:00
xmlValidateOneElement (xmlValidCtxtPtr ctxt,
2001-02-23 20:55:21 +03:00
xmlDocPtr doc,
xmlNodePtr elem);
XML_DEPRECATED
XMLPUBFUN int
2003-08-27 12:59:58 +04:00
xmlValidateOneAttribute (xmlValidCtxtPtr ctxt,
2001-02-23 20:55:21 +03:00
xmlDocPtr doc,
xmlNodePtr elem,
xmlAttrPtr attr,
const xmlChar *value);
XML_DEPRECATED
XMLPUBFUN int
2003-08-27 12:59:58 +04:00
xmlValidateOneNamespace (xmlValidCtxtPtr ctxt,
xmlDocPtr doc,
xmlNodePtr elem,
const xmlChar *prefix,
xmlNsPtr ns,
const xmlChar *value);
XML_DEPRECATED
XMLPUBFUN int
2003-08-27 12:59:58 +04:00
xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt,
2001-02-23 20:55:21 +03:00
xmlDocPtr doc);
XML_DEPRECATED
XMLPUBFUN int
2003-08-27 12:59:58 +04:00
xmlValidateNotationUse (xmlValidCtxtPtr ctxt,
2001-02-23 20:55:21 +03:00
xmlDocPtr doc,
const xmlChar *notationName);
#endif /* LIBXML_VALID_ENABLED */
XMLPUBFUN int
2003-08-27 12:59:58 +04:00
xmlIsMixedElement (xmlDocPtr doc,
2001-02-23 20:55:21 +03:00
const xmlChar *name);
XMLPUBFUN xmlAttributePtr
2003-08-27 12:59:58 +04:00
xmlGetDtdAttrDesc (xmlDtdPtr dtd,
2001-02-23 20:55:21 +03:00
const xmlChar *elem,
const xmlChar *name);
XMLPUBFUN xmlAttributePtr
2003-08-27 12:59:58 +04:00
xmlGetDtdQAttrDesc (xmlDtdPtr dtd,
const xmlChar *elem,
const xmlChar *name,
const xmlChar *prefix);
XMLPUBFUN xmlNotationPtr
2003-08-27 12:59:58 +04:00
xmlGetDtdNotationDesc (xmlDtdPtr dtd,
2001-02-23 20:55:21 +03:00
const xmlChar *name);
XMLPUBFUN xmlElementPtr
2003-08-27 12:59:58 +04:00
xmlGetDtdQElementDesc (xmlDtdPtr dtd,
const xmlChar *name,
const xmlChar *prefix);
XMLPUBFUN xmlElementPtr
2003-08-27 12:59:58 +04:00
xmlGetDtdElementDesc (xmlDtdPtr dtd,
2001-02-23 20:55:21 +03:00
const xmlChar *name);
2005-01-02 12:53:13 +03:00
#ifdef LIBXML_VALID_ENABLED
XMLPUBFUN int
2003-08-27 12:59:58 +04:00
xmlValidGetPotentialChildren(xmlElementContent *ctree,
const xmlChar **names,
2001-02-23 20:55:21 +03:00
int *len,
int max);
XMLPUBFUN int
2005-01-02 12:53:13 +03:00
xmlValidGetValidElements(xmlNode *prev,
xmlNode *next,
const xmlChar **names,
int max);
XMLPUBFUN int
2003-08-27 12:59:58 +04:00
xmlValidateNameValue (const xmlChar *value);
XMLPUBFUN int
2003-08-27 12:59:58 +04:00
xmlValidateNamesValue (const xmlChar *value);
XMLPUBFUN int
2003-08-27 12:59:58 +04:00
xmlValidateNmtokenValue (const xmlChar *value);
XMLPUBFUN int
2003-08-27 12:59:58 +04:00
xmlValidateNmtokensValue(const xmlChar *value);
#ifdef LIBXML_REGEXP_ENABLED
/*
* Validation based on the regexp support
*/
XML_DEPRECATED
XMLPUBFUN int
2003-08-27 12:59:58 +04:00
xmlValidBuildContentModel(xmlValidCtxtPtr ctxt,
xmlElementPtr elem);
XML_DEPRECATED
XMLPUBFUN int
2003-08-27 12:59:58 +04:00
xmlValidatePushElement (xmlValidCtxtPtr ctxt,
xmlDocPtr doc,
xmlNodePtr elem,
const xmlChar *qname);
XML_DEPRECATED
XMLPUBFUN int
2003-08-27 12:59:58 +04:00
xmlValidatePushCData (xmlValidCtxtPtr ctxt,
const xmlChar *data,
int len);
XML_DEPRECATED
XMLPUBFUN int
2003-08-27 12:59:58 +04:00
xmlValidatePopElement (xmlValidCtxtPtr ctxt,
xmlDocPtr doc,
xmlNodePtr elem,
const xmlChar *qname);
#endif /* LIBXML_REGEXP_ENABLED */
2005-01-02 12:53:13 +03:00
#endif /* LIBXML_VALID_ENABLED */
2001-02-23 20:55:21 +03:00
#ifdef __cplusplus
}
#endif
#endif /* __XML_VALID_H__ */