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 .
*
2001-06-24 16:13:24 +04:00
* 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>
2003-10-10 18:10:40 +04:00
# include <libxml/xmlerror.h>
2001-02-23 20:55:21 +03:00
# include <libxml/tree.h>
2001-03-24 20:00:36 +03:00
# include <libxml/list.h>
2002-09-13 18:48:12 +04:00
# include <libxml/xmlautomata.h>
# include <libxml/xmlregexp.h>
2001-02-23 20:55:21 +03:00
# ifdef __cplusplus
extern " C " {
# endif
2001-04-20 17:03:48 +04:00
/*
2002-03-12 21:46:39 +03:00
* Validation state added for non - determinist content model .
2001-04-20 17:03:48 +04:00
*/
typedef struct _xmlValidState xmlValidState ;
typedef xmlValidState * xmlValidStatePtr ;
2001-02-23 20:55:21 +03:00
/**
2002-01-22 21:15:52 +03:00
* xmlValidityErrorFunc :
* @ ctx : an xmlValidCtxtPtr validity error context
* @ msg : the string to format * printf like vararg
* @ . . . : remaining arguments to the format
*
2002-03-12 21:46:39 +03:00
* Callback called when a validity error is found . This is a message
2002-01-22 21:15:52 +03:00
* oriented function similar to an * printf function .
2001-02-23 20:55:21 +03:00
*/
2002-01-22 21:15:52 +03:00
typedef void ( * xmlValidityErrorFunc ) ( void * ctx ,
const char * msg ,
. . . ) ;
2001-02-23 20:55:21 +03:00
2002-01-22 21:15:52 +03:00
/**
* xmlValidityWarningFunc :
* @ ctx : an xmlValidCtxtPtr validity error context
* @ msg : the string to format * printf like vararg
* @ . . . : remaining arguments to the format
*
2002-03-12 21:46:39 +03:00
* Callback called when a validity warning is found . This is a message
2002-01-22 21:15:52 +03:00
* oriented function similar to an * printf function .
*/
typedef void ( * xmlValidityWarningFunc ) ( void * ctx ,
const char * msg ,
. . . ) ;
2001-02-23 20:55:21 +03:00
2003-11-16 09:25:42 +03:00
/*
2002-01-22 21:15:52 +03:00
* xmlValidCtxt :
2002-03-12 21:46:39 +03:00
* An xmlValidCtxt is used for error reporting when validating .
2002-01-22 21:15:52 +03:00
*/
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 */
2001-04-20 17:03:48 +04:00
/* 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 */
2002-09-13 18:48:12 +04:00
# 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
} ;
/*
2002-03-12 21:46:39 +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 ;
/*
2002-03-12 21:46:39 +03:00
* 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 ;
/*
2002-03-12 21:46:39 +03:00
* 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 ;
/*
2002-03-12 21:46:39 +03:00
* 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 ;
/*
2002-03-12 21:46:39 +03:00
* 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 ;
2003-06-09 13:10:36 +04:00
/* Allocate/Release Validation Contexts */
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlValidCtxtPtr XMLCALL
xmlNewValidCtxt ( void ) ;
XMLPUBFUN void XMLCALL
xmlFreeValidCtxt ( xmlValidCtxtPtr ) ;
2003-06-09 13:10:36 +04:00
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 ) ;
2003-09-29 17:20:24 +04:00
# 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 ) ;
2003-09-29 17:20:24 +04:00
# 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 ) ;
2001-08-15 16:06:36 +04:00
/* DEPRECATED */
2003-08-27 12:59:58 +04:00
XMLPUBFUN void XMLCALL
xmlSprintfElementContent ( char * buf ,
xmlElementContentPtr content ,
int glob ) ;
2001-08-15 16:06:36 +04:00
/* 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 ) ;
2003-09-29 17:20:24 +04:00
# 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 ) ;
2003-09-29 17:20:24 +04:00
# 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 ) ;
2003-09-29 17:20:24 +04:00
# 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 ) ;
2003-09-29 17:20:24 +04:00
# 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
/**
2002-03-12 21:46:39 +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 ,
2002-02-20 00:08:48 +03:00
xmlNodePtr elem ,
const xmlChar * name ,
const xmlChar * value ) ;
2003-08-27 12:59:58 +04:00
XMLPUBFUN xmlChar * XMLCALL
xmlValidCtxtNormalizeAttributeValue ( xmlValidCtxtPtr ctxt ,
2002-02-20 00:08:48 +03:00
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 ,
2002-09-26 20:10:21 +04:00
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 ,
2001-08-07 05:10:10 +04:00
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 ,
2001-08-07 05:10:10 +04:00
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 ) ;
2002-09-16 14:51:38 +04:00
# ifdef LIBXML_REGEXP_ENABLED
/*
* Validation based on the regexp support
*/
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlValidBuildContentModel ( xmlValidCtxtPtr ctxt ,
2002-09-16 14:51:38 +04:00
xmlElementPtr elem ) ;
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlValidatePushElement ( xmlValidCtxtPtr ctxt ,
2002-12-20 03:16:24 +03:00
xmlDocPtr doc ,
xmlNodePtr elem ,
const xmlChar * qname ) ;
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlValidatePushCData ( xmlValidCtxtPtr ctxt ,
2002-12-20 03:16:24 +03:00
const xmlChar * data ,
int len ) ;
2003-08-27 12:59:58 +04:00
XMLPUBFUN int XMLCALL
xmlValidatePopElement ( xmlValidCtxtPtr ctxt ,
2002-12-20 03:16:24 +03:00
xmlDocPtr doc ,
xmlNodePtr elem ,
const xmlChar * qname ) ;
2002-09-16 14:51:38 +04:00
# endif /* LIBXML_REGEXP_ENABLED */
2001-02-23 20:55:21 +03:00
# ifdef __cplusplus
}
# endif
# endif /* __XML_VALID_H__ */