(root)/
gettext-0.22.4/
libtextstyle/
lib/
libxml/
valid.in.h
       1  /* libxml2 - Library for parsing XML documents
       2   * Copyright (C) 2006-2019 Free Software Foundation, Inc.
       3   *
       4   * This file is not part of the GNU gettext program, but is used with
       5   * GNU gettext.
       6   *
       7   * The original copyright notice is as follows:
       8   */
       9  
      10  /*
      11   * Copyright (C) 1998-2012 Daniel Veillard.  All Rights Reserved.
      12   *
      13   * Permission is hereby granted, free of charge, to any person obtaining a copy
      14   * of this software and associated documentation files (the "Software"), to deal
      15   * in the Software without restriction, including without limitation the rights
      16   * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
      17   * copies of the Software, and to permit persons to whom the Software is fur-
      18   * nished to do so, subject to the following conditions:
      19   *
      20   * The above copyright notice and this permission notice shall be included in
      21   * all copies or substantial portions of the Software.
      22   *
      23   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      24   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT-
      25   * NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
      26   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      27   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
      28   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
      29   * THE SOFTWARE.
      30   *
      31   * Author: Daniel Veillard
      32   */
      33  
      34  /*
      35   * Summary: The DTD validation
      36   * Description: API for the DTD handling and the validity checking
      37   */
      38  
      39  #ifndef __XML_VALID_H__
      40  #define __XML_VALID_H__
      41  
      42  #include <libxml/xmlversion.h>
      43  #include <libxml/xmlerror.h>
      44  #include <libxml/tree.h>
      45  #include <libxml/list.h>
      46  #include <libxml/xmlautomata.h>
      47  #include <libxml/xmlregexp.h>
      48  
      49  #ifdef __cplusplus
      50  extern "C" {
      51  #endif
      52  
      53  /*
      54   * Validation state added for non-determinist content model.
      55   */
      56  typedef struct _xmlValidState xmlValidState;
      57  typedef xmlValidState *xmlValidStatePtr;
      58  
      59  /**
      60   * xmlValidityErrorFunc:
      61   * @ctx:  usually an xmlValidCtxtPtr to a validity error context,
      62   *        but comes from ctxt->userData (which normally contains such
      63   *        a pointer); ctxt->userData can be changed by the user.
      64   * @msg:  the string to format *printf like vararg
      65   * @...:  remaining arguments to the format
      66   *
      67   * Callback called when a validity error is found. This is a message
      68   * oriented function similar to an *printf function.
      69   */
      70  typedef void (XMLCDECL *xmlValidityErrorFunc) (void *ctx,
      71  			     const char *msg,
      72  			     ...) LIBXML_ATTR_FORMAT(2,3);
      73  
      74  /**
      75   * xmlValidityWarningFunc:
      76   * @ctx:  usually an xmlValidCtxtPtr to a validity error context,
      77   *        but comes from ctxt->userData (which normally contains such
      78   *        a pointer); ctxt->userData can be changed by the user.
      79   * @msg:  the string to format *printf like vararg
      80   * @...:  remaining arguments to the format
      81   *
      82   * Callback called when a validity warning is found. This is a message
      83   * oriented function similar to an *printf function.
      84   */
      85  typedef void (XMLCDECL *xmlValidityWarningFunc) (void *ctx,
      86  			       const char *msg,
      87  			       ...) LIBXML_ATTR_FORMAT(2,3);
      88  
      89  #ifdef IN_LIBXML
      90  /**
      91   * XML_CTXT_FINISH_DTD_0:
      92   *
      93   * Special value for finishDtd field when embedded in an xmlParserCtxt
      94   */
      95  #define XML_CTXT_FINISH_DTD_0 0xabcd1234
      96  /**
      97   * XML_CTXT_FINISH_DTD_1:
      98   *
      99   * Special value for finishDtd field when embedded in an xmlParserCtxt
     100   */
     101  #define XML_CTXT_FINISH_DTD_1 0xabcd1235
     102  #endif
     103  
     104  /*
     105   * xmlValidCtxt:
     106   * An xmlValidCtxt is used for error reporting when validating.
     107   */
     108  typedef struct _xmlValidCtxt xmlValidCtxt;
     109  typedef xmlValidCtxt *xmlValidCtxtPtr;
     110  struct _xmlValidCtxt {
     111      void *userData;			/* user specific data block */
     112      xmlValidityErrorFunc error;		/* the callback in case of errors */
     113      xmlValidityWarningFunc warning;	/* the callback in case of warning */
     114  
     115      /* Node analysis stack used when validating within entities */
     116      xmlNodePtr         node;          /* Current parsed Node */
     117      int                nodeNr;        /* Depth of the parsing stack */
     118      int                nodeMax;       /* Max depth of the parsing stack */
     119      xmlNodePtr        *nodeTab;       /* array of nodes */
     120  
     121      unsigned int     finishDtd;       /* finished validating the Dtd ? */
     122      xmlDocPtr              doc;       /* the document */
     123      int                  valid;       /* temporary validity check result */
     124  
     125      /* state state used for non-determinist content validation */
     126      xmlValidState     *vstate;        /* current state */
     127      int                vstateNr;      /* Depth of the validation stack */
     128      int                vstateMax;     /* Max depth of the validation stack */
     129      xmlValidState     *vstateTab;     /* array of validation states */
     130  
     131  #ifdef LIBXML_REGEXP_ENABLED
     132      xmlAutomataPtr            am;     /* the automata */
     133      xmlAutomataStatePtr    state;     /* used to build the automata */
     134  #else
     135      void                     *am;
     136      void                  *state;
     137  #endif
     138  };
     139  
     140  /*
     141   * ALL notation declarations are stored in a table.
     142   * There is one table per DTD.
     143   */
     144  
     145  typedef struct _xmlHashTable xmlNotationTable;
     146  typedef xmlNotationTable *xmlNotationTablePtr;
     147  
     148  /*
     149   * ALL element declarations are stored in a table.
     150   * There is one table per DTD.
     151   */
     152  
     153  typedef struct _xmlHashTable xmlElementTable;
     154  typedef xmlElementTable *xmlElementTablePtr;
     155  
     156  /*
     157   * ALL attribute declarations are stored in a table.
     158   * There is one table per DTD.
     159   */
     160  
     161  typedef struct _xmlHashTable xmlAttributeTable;
     162  typedef xmlAttributeTable *xmlAttributeTablePtr;
     163  
     164  /*
     165   * ALL IDs attributes are stored in a table.
     166   * There is one table per document.
     167   */
     168  
     169  typedef struct _xmlHashTable xmlIDTable;
     170  typedef xmlIDTable *xmlIDTablePtr;
     171  
     172  /*
     173   * ALL Refs attributes are stored in a table.
     174   * There is one table per document.
     175   */
     176  
     177  typedef struct _xmlHashTable xmlRefTable;
     178  typedef xmlRefTable *xmlRefTablePtr;
     179  
     180  /* Notation */
     181  XMLPUBFUN xmlNotationPtr XMLCALL
     182  		xmlAddNotationDecl	(xmlValidCtxtPtr ctxt,
     183  					 xmlDtdPtr dtd,
     184  					 const xmlChar *name,
     185  					 const xmlChar *PublicID,
     186  					 const xmlChar *SystemID);
     187  #ifdef LIBXML_TREE_ENABLED
     188  XMLPUBFUN xmlNotationTablePtr XMLCALL
     189  		xmlCopyNotationTable	(xmlNotationTablePtr table);
     190  #endif /* LIBXML_TREE_ENABLED */
     191  XMLPUBFUN void XMLCALL
     192  		xmlFreeNotationTable	(xmlNotationTablePtr table);
     193  #ifdef LIBXML_OUTPUT_ENABLED
     194  XMLPUBFUN void XMLCALL
     195  		xmlDumpNotationDecl	(xmlBufferPtr buf,
     196  					 xmlNotationPtr nota);
     197  XMLPUBFUN void XMLCALL
     198  		xmlDumpNotationTable	(xmlBufferPtr buf,
     199  					 xmlNotationTablePtr table);
     200  #endif /* LIBXML_OUTPUT_ENABLED */
     201  
     202  /* Element Content */
     203  /* the non Doc version are being deprecated */
     204  XMLPUBFUN xmlElementContentPtr XMLCALL
     205  		xmlNewElementContent	(const xmlChar *name,
     206  					 xmlElementContentType type);
     207  XMLPUBFUN xmlElementContentPtr XMLCALL
     208  		xmlCopyElementContent	(xmlElementContentPtr content);
     209  XMLPUBFUN void XMLCALL
     210  		xmlFreeElementContent	(xmlElementContentPtr cur);
     211  /* the new versions with doc argument */
     212  XMLPUBFUN xmlElementContentPtr XMLCALL
     213  		xmlNewDocElementContent	(xmlDocPtr doc,
     214  					 const xmlChar *name,
     215  					 xmlElementContentType type);
     216  XMLPUBFUN xmlElementContentPtr XMLCALL
     217  		xmlCopyDocElementContent(xmlDocPtr doc,
     218  					 xmlElementContentPtr content);
     219  XMLPUBFUN void XMLCALL
     220  		xmlFreeDocElementContent(xmlDocPtr doc,
     221  					 xmlElementContentPtr cur);
     222  XMLPUBFUN void XMLCALL
     223  		xmlSnprintfElementContent(char *buf,
     224  					 int size,
     225  	                                 xmlElementContentPtr content,
     226  					 int englob);
     227  #ifdef LIBXML_OUTPUT_ENABLED
     228  /* DEPRECATED */
     229  XMLPUBFUN void XMLCALL
     230  		xmlSprintfElementContent(char *buf,
     231  	                                 xmlElementContentPtr content,
     232  					 int englob);
     233  #endif /* LIBXML_OUTPUT_ENABLED */
     234  /* DEPRECATED */
     235  
     236  /* Element */
     237  XMLPUBFUN xmlElementPtr XMLCALL
     238  		xmlAddElementDecl	(xmlValidCtxtPtr ctxt,
     239  					 xmlDtdPtr dtd,
     240  					 const xmlChar *name,
     241  					 xmlElementTypeVal type,
     242  					 xmlElementContentPtr content);
     243  #ifdef LIBXML_TREE_ENABLED
     244  XMLPUBFUN xmlElementTablePtr XMLCALL
     245  		xmlCopyElementTable	(xmlElementTablePtr table);
     246  #endif /* LIBXML_TREE_ENABLED */
     247  XMLPUBFUN void XMLCALL
     248  		xmlFreeElementTable	(xmlElementTablePtr table);
     249  #ifdef LIBXML_OUTPUT_ENABLED
     250  XMLPUBFUN void XMLCALL
     251  		xmlDumpElementTable	(xmlBufferPtr buf,
     252  					 xmlElementTablePtr table);
     253  XMLPUBFUN void XMLCALL
     254  		xmlDumpElementDecl	(xmlBufferPtr buf,
     255  					 xmlElementPtr elem);
     256  #endif /* LIBXML_OUTPUT_ENABLED */
     257  
     258  /* Enumeration */
     259  XMLPUBFUN xmlEnumerationPtr XMLCALL
     260  		xmlCreateEnumeration	(const xmlChar *name);
     261  XMLPUBFUN void XMLCALL
     262  		xmlFreeEnumeration	(xmlEnumerationPtr cur);
     263  #ifdef LIBXML_TREE_ENABLED
     264  XMLPUBFUN xmlEnumerationPtr XMLCALL
     265  		xmlCopyEnumeration	(xmlEnumerationPtr cur);
     266  #endif /* LIBXML_TREE_ENABLED */
     267  
     268  /* Attribute */
     269  XMLPUBFUN xmlAttributePtr XMLCALL
     270  		xmlAddAttributeDecl	(xmlValidCtxtPtr ctxt,
     271  					 xmlDtdPtr dtd,
     272  					 const xmlChar *elem,
     273  					 const xmlChar *name,
     274  					 const xmlChar *ns,
     275  					 xmlAttributeType type,
     276  					 xmlAttributeDefault def,
     277  					 const xmlChar *defaultValue,
     278  					 xmlEnumerationPtr tree);
     279  #ifdef LIBXML_TREE_ENABLED
     280  XMLPUBFUN xmlAttributeTablePtr XMLCALL
     281  		xmlCopyAttributeTable  (xmlAttributeTablePtr table);
     282  #endif /* LIBXML_TREE_ENABLED */
     283  XMLPUBFUN void XMLCALL
     284  		xmlFreeAttributeTable  (xmlAttributeTablePtr table);
     285  #ifdef LIBXML_OUTPUT_ENABLED
     286  XMLPUBFUN void XMLCALL
     287  		xmlDumpAttributeTable  (xmlBufferPtr buf,
     288  					xmlAttributeTablePtr table);
     289  XMLPUBFUN void XMLCALL
     290  		xmlDumpAttributeDecl   (xmlBufferPtr buf,
     291  					xmlAttributePtr attr);
     292  #endif /* LIBXML_OUTPUT_ENABLED */
     293  
     294  /* IDs */
     295  XMLPUBFUN xmlIDPtr XMLCALL
     296  		xmlAddID	       (xmlValidCtxtPtr ctxt,
     297  					xmlDocPtr doc,
     298  					const xmlChar *value,
     299  					xmlAttrPtr attr);
     300  XMLPUBFUN void XMLCALL
     301  		xmlFreeIDTable	       (xmlIDTablePtr table);
     302  XMLPUBFUN xmlAttrPtr XMLCALL
     303  		xmlGetID	       (xmlDocPtr doc,
     304  					const xmlChar *ID);
     305  XMLPUBFUN int XMLCALL
     306  		xmlIsID		       (xmlDocPtr doc,
     307  					xmlNodePtr elem,
     308  					xmlAttrPtr attr);
     309  XMLPUBFUN int XMLCALL
     310  		xmlRemoveID	       (xmlDocPtr doc,
     311  					xmlAttrPtr attr);
     312  
     313  /* IDREFs */
     314  XMLPUBFUN xmlRefPtr XMLCALL
     315  		xmlAddRef	       (xmlValidCtxtPtr ctxt,
     316  					xmlDocPtr doc,
     317  					const xmlChar *value,
     318  					xmlAttrPtr attr);
     319  XMLPUBFUN void XMLCALL
     320  		xmlFreeRefTable	       (xmlRefTablePtr table);
     321  XMLPUBFUN int XMLCALL
     322  		xmlIsRef	       (xmlDocPtr doc,
     323  					xmlNodePtr elem,
     324  					xmlAttrPtr attr);
     325  XMLPUBFUN int XMLCALL
     326  		xmlRemoveRef	       (xmlDocPtr doc,
     327  					xmlAttrPtr attr);
     328  XMLPUBFUN xmlListPtr XMLCALL
     329  		xmlGetRefs	       (xmlDocPtr doc,
     330  					const xmlChar *ID);
     331  
     332  /**
     333   * The public function calls related to validity checking.
     334   */
     335  #ifdef LIBXML_VALID_ENABLED
     336  /* Allocate/Release Validation Contexts */
     337  XMLPUBFUN xmlValidCtxtPtr XMLCALL
     338  		xmlNewValidCtxt(void);
     339  XMLPUBFUN void XMLCALL
     340  		xmlFreeValidCtxt(xmlValidCtxtPtr);
     341  
     342  XMLPUBFUN int XMLCALL
     343  		xmlValidateRoot		(xmlValidCtxtPtr ctxt,
     344  					 xmlDocPtr doc);
     345  XMLPUBFUN int XMLCALL
     346  		xmlValidateElementDecl	(xmlValidCtxtPtr ctxt,
     347  					 xmlDocPtr doc,
     348  		                         xmlElementPtr elem);
     349  XMLPUBFUN xmlChar * XMLCALL
     350  		xmlValidNormalizeAttributeValue(xmlDocPtr doc,
     351  					 xmlNodePtr elem,
     352  					 const xmlChar *name,
     353  					 const xmlChar *value);
     354  XMLPUBFUN xmlChar * XMLCALL
     355  		xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt,
     356  					 xmlDocPtr doc,
     357  					 xmlNodePtr elem,
     358  					 const xmlChar *name,
     359  					 const xmlChar *value);
     360  XMLPUBFUN int XMLCALL
     361  		xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt,
     362  					 xmlDocPtr doc,
     363  		                         xmlAttributePtr attr);
     364  XMLPUBFUN int XMLCALL
     365  		xmlValidateAttributeValue(xmlAttributeType type,
     366  					 const xmlChar *value);
     367  XMLPUBFUN int XMLCALL
     368  		xmlValidateNotationDecl	(xmlValidCtxtPtr ctxt,
     369  					 xmlDocPtr doc,
     370  		                         xmlNotationPtr nota);
     371  XMLPUBFUN int XMLCALL
     372  		xmlValidateDtd		(xmlValidCtxtPtr ctxt,
     373  					 xmlDocPtr doc,
     374  					 xmlDtdPtr dtd);
     375  XMLPUBFUN int XMLCALL
     376  		xmlValidateDtdFinal	(xmlValidCtxtPtr ctxt,
     377  					 xmlDocPtr doc);
     378  XMLPUBFUN int XMLCALL
     379  		xmlValidateDocument	(xmlValidCtxtPtr ctxt,
     380  					 xmlDocPtr doc);
     381  XMLPUBFUN int XMLCALL
     382  		xmlValidateElement	(xmlValidCtxtPtr ctxt,
     383  					 xmlDocPtr doc,
     384  					 xmlNodePtr elem);
     385  XMLPUBFUN int XMLCALL
     386  		xmlValidateOneElement	(xmlValidCtxtPtr ctxt,
     387  					 xmlDocPtr doc,
     388  		                         xmlNodePtr elem);
     389  XMLPUBFUN int XMLCALL
     390  		xmlValidateOneAttribute	(xmlValidCtxtPtr ctxt,
     391  					 xmlDocPtr doc,
     392  					 xmlNodePtr	elem,
     393  					 xmlAttrPtr attr,
     394  					 const xmlChar *value);
     395  XMLPUBFUN int XMLCALL
     396  		xmlValidateOneNamespace	(xmlValidCtxtPtr ctxt,
     397  					 xmlDocPtr doc,
     398  					 xmlNodePtr elem,
     399  					 const xmlChar *prefix,
     400  					 xmlNsPtr ns,
     401  					 const xmlChar *value);
     402  XMLPUBFUN int XMLCALL
     403  		xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt,
     404  					 xmlDocPtr doc);
     405  #endif /* LIBXML_VALID_ENABLED */
     406  
     407  #if defined(LIBXML_VALID_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
     408  XMLPUBFUN int XMLCALL
     409  		xmlValidateNotationUse	(xmlValidCtxtPtr ctxt,
     410  					 xmlDocPtr doc,
     411  					 const xmlChar *notationName);
     412  #endif /* LIBXML_VALID_ENABLED or LIBXML_SCHEMAS_ENABLED */
     413  
     414  XMLPUBFUN int XMLCALL
     415  		xmlIsMixedElement	(xmlDocPtr doc,
     416  					 const xmlChar *name);
     417  XMLPUBFUN xmlAttributePtr XMLCALL
     418  		xmlGetDtdAttrDesc	(xmlDtdPtr dtd,
     419  					 const xmlChar *elem,
     420  					 const xmlChar *name);
     421  XMLPUBFUN xmlAttributePtr XMLCALL
     422  		xmlGetDtdQAttrDesc	(xmlDtdPtr dtd,
     423  					 const xmlChar *elem,
     424  					 const xmlChar *name,
     425  					 const xmlChar *prefix);
     426  XMLPUBFUN xmlNotationPtr XMLCALL
     427  		xmlGetDtdNotationDesc	(xmlDtdPtr dtd,
     428  					 const xmlChar *name);
     429  XMLPUBFUN xmlElementPtr XMLCALL
     430  		xmlGetDtdQElementDesc	(xmlDtdPtr dtd,
     431  					 const xmlChar *name,
     432  					 const xmlChar *prefix);
     433  XMLPUBFUN xmlElementPtr XMLCALL
     434  		xmlGetDtdElementDesc	(xmlDtdPtr dtd,
     435  					 const xmlChar *name);
     436  
     437  #ifdef LIBXML_VALID_ENABLED
     438  
     439  XMLPUBFUN int XMLCALL
     440  		xmlValidGetPotentialChildren(xmlElementContent *ctree,
     441  					 const xmlChar **names,
     442  					 int *len,
     443  					 int max);
     444  
     445  XMLPUBFUN int XMLCALL
     446  		xmlValidGetValidElements(xmlNode *prev,
     447  					 xmlNode *next,
     448  					 const xmlChar **names,
     449  					 int max);
     450  XMLPUBFUN int XMLCALL
     451  		xmlValidateNameValue	(const xmlChar *value);
     452  XMLPUBFUN int XMLCALL
     453  		xmlValidateNamesValue	(const xmlChar *value);
     454  XMLPUBFUN int XMLCALL
     455  		xmlValidateNmtokenValue	(const xmlChar *value);
     456  XMLPUBFUN int XMLCALL
     457  		xmlValidateNmtokensValue(const xmlChar *value);
     458  
     459  #ifdef LIBXML_REGEXP_ENABLED
     460  /*
     461   * Validation based on the regexp support
     462   */
     463  XMLPUBFUN int XMLCALL
     464  		xmlValidBuildContentModel(xmlValidCtxtPtr ctxt,
     465  					 xmlElementPtr elem);
     466  
     467  XMLPUBFUN int XMLCALL
     468  		xmlValidatePushElement	(xmlValidCtxtPtr ctxt,
     469  					 xmlDocPtr doc,
     470  					 xmlNodePtr elem,
     471  					 const xmlChar *qname);
     472  XMLPUBFUN int XMLCALL
     473  		xmlValidatePushCData	(xmlValidCtxtPtr ctxt,
     474  					 const xmlChar *data,
     475  					 int len);
     476  XMLPUBFUN int XMLCALL
     477  		xmlValidatePopElement	(xmlValidCtxtPtr ctxt,
     478  					 xmlDocPtr doc,
     479  					 xmlNodePtr elem,
     480  					 const xmlChar *qname);
     481  #endif /* LIBXML_REGEXP_ENABLED */
     482  #endif /* LIBXML_VALID_ENABLED */
     483  #ifdef __cplusplus
     484  }
     485  #endif
     486  #endif /* __XML_VALID_H__ */