epoc32/include/stdapis/libxml2/libxml2_valid.h
branchSymbian3
changeset 4 837f303aceeb
equal deleted inserted replaced
3:e1b950c65cb4 4:837f303aceeb
       
     1 /*
       
     2  * Summary: The DTD validation
       
     3  * Description: API for the DTD handling and the validity checking
       
     4  *
       
     5  * Copy: See Copyright for the status of this software.
       
     6  *
       
     7  * Author: Daniel Veillard
       
     8  * Portion Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. 
       
     9  */
       
    10 
       
    11 /** @file
       
    12 @publishedAll
       
    13 @released
       
    14 */
       
    15 
       
    16 #ifndef XML_VALID_H
       
    17 #define XML_VALID_H
       
    18 
       
    19 #include <stdapis/libxml2/libxml2_xmlerror.h>
       
    20 #include <stdapis/libxml2/libxml2_tree.h>
       
    21 #include <stdapis/libxml2/libxml2_list.h>
       
    22 
       
    23 #ifdef LIBXML_AUTOMATA_ENABLED
       
    24 #include "libxml2_xmlautomata.h"
       
    25 #endif
       
    26 
       
    27 #ifdef LIBXML_REGEXP_ENABLED
       
    28 #include "libxml2_xmlregexp.h"
       
    29 #endif
       
    30 
       
    31 #ifdef __cplusplus
       
    32 extern "C" {
       
    33 #endif
       
    34 
       
    35 /*
       
    36  * Validation state added for non-determinist content model.
       
    37  */
       
    38 typedef struct _xmlValidState xmlValidState;
       
    39 typedef xmlValidState *xmlValidStatePtr;
       
    40 
       
    41 /**
       
    42  * xmlValidityErrorFunc:
       
    43  * @param ctx an xmlValidCtxtPtr validity error context
       
    44  * @param msg the string to format *printf like vararg
       
    45  * @param # remaining arguments to the format
       
    46  *
       
    47  * Callback called when a validity error is found. This is a message
       
    48  * oriented function similar to an *printf function.
       
    49  */
       
    50 typedef void (*xmlValidityErrorFunc) (void *ctx,
       
    51                              const char *msg,
       
    52                              ...);
       
    53 
       
    54 /**
       
    55  * xmlValidityWarningFunc:
       
    56  * @param ctx an xmlValidCtxtPtr validity error context
       
    57  * @param msg the string to format *printf like vararg
       
    58  * @param # remaining arguments to the format
       
    59  *
       
    60  * Callback called when a validity warning is found. This is a message
       
    61  * oriented function similar to an *printf function.
       
    62  */
       
    63 typedef void (*xmlValidityWarningFunc) (void *ctx,
       
    64                                const char *msg,
       
    65                                ...);
       
    66 
       
    67 /*
       
    68  * xmlValidCtxt:
       
    69  * An xmlValidCtxt is used for error reporting when validating.
       
    70  */
       
    71 typedef struct _xmlValidCtxt xmlValidCtxt;
       
    72 typedef xmlValidCtxt *xmlValidCtxtPtr;
       
    73 struct _xmlValidCtxt {
       
    74     void *userData;         /* user specific data block */
       
    75     xmlValidityErrorFunc error;     /* the callback in case of errors */
       
    76     xmlValidityWarningFunc warning; /* the callback in case of warning */
       
    77 
       
    78     /* Node analysis stack used when validating within entities */
       
    79     xmlNodePtr         node;          /* Current parsed Node */
       
    80     int                nodeNr;        /* Depth of the parsing stack */
       
    81     int                nodeMax;       /* Max depth of the parsing stack */
       
    82     xmlNodePtr*        nodeTab;       /* array of nodes */
       
    83 
       
    84     int              finishDtd;       /* finished validating the Dtd ? */
       
    85     xmlDocPtr              doc;       /* the document */
       
    86     int                  valid;       /* temporary validity check result */
       
    87 
       
    88     /* state state used for non-determinist content validation */
       
    89     xmlValidState*     vstate;        /* current state */
       
    90     int                vstateNr;      /* Depth of the validation stack */
       
    91     int                vstateMax;     /* Max depth of the validation stack */
       
    92     xmlValidState*     vstateTab;     /* array of validation states */
       
    93 
       
    94 #ifdef LIBXML_REGEXP_ENABLED
       
    95     xmlAutomataPtr            am;     /* the automata */
       
    96     xmlAutomataStatePtr    state;     /* used to build the automata */
       
    97 #else
       
    98     void                     *am;
       
    99     void                  *state;
       
   100 #endif
       
   101 };
       
   102 
       
   103 /*
       
   104  * ALL notation declarations are stored in a table.
       
   105  * There is one table per DTD.
       
   106  */
       
   107 
       
   108 typedef struct _xmlHashTable xmlNotationTable;
       
   109 typedef xmlNotationTable *xmlNotationTablePtr;
       
   110 
       
   111 /*
       
   112  * ALL element declarations are stored in a table.
       
   113  * There is one table per DTD.
       
   114  */
       
   115 
       
   116 typedef struct _xmlHashTable xmlElementTable;
       
   117 typedef xmlElementTable *xmlElementTablePtr;
       
   118 
       
   119 /*
       
   120  * ALL attribute declarations are stored in a table.
       
   121  * There is one table per DTD.
       
   122  */
       
   123 
       
   124 typedef struct _xmlHashTable xmlAttributeTable;
       
   125 typedef xmlAttributeTable *xmlAttributeTablePtr;
       
   126 
       
   127 /*
       
   128  * ALL IDs attributes are stored in a table.
       
   129  * There is one table per document.
       
   130  */
       
   131 
       
   132 typedef struct _xmlHashTable xmlIDTable;
       
   133 typedef xmlIDTable *xmlIDTablePtr;
       
   134 
       
   135 /*
       
   136  * ALL Refs attributes are stored in a table.
       
   137  * There is one table per document.
       
   138  */
       
   139 
       
   140 typedef struct _xmlHashTable xmlRefTable;
       
   141 typedef xmlRefTable *xmlRefTablePtr;
       
   142 
       
   143 /* Allocate/Release Validation Contexts */
       
   144 XMLPUBFUN xmlValidCtxtPtr XMLCALL
       
   145                 xmlNewValidCtxt(void);
       
   146 XMLPUBFUN void XMLCALL
       
   147                 xmlFreeValidCtxt(xmlValidCtxtPtr);
       
   148 
       
   149 /* Notation */
       
   150 XMLPUBFUN xmlNotationPtr XMLCALL
       
   151                 xmlAddNotationDecl      (xmlValidCtxtPtr ctxt,
       
   152                                          xmlDtdPtr dtd,
       
   153                                          const xmlChar *name,
       
   154                                          const xmlChar *PublicID,
       
   155                                          const xmlChar *SystemID);
       
   156 XMLPUBFUN xmlNotationTablePtr XMLCALL
       
   157                 xmlCopyNotationTable    (xmlNotationTablePtr table);
       
   158 XMLPUBFUN void XMLCALL
       
   159                 xmlFreeNotationTable    (xmlNotationTablePtr table);
       
   160 #ifdef LIBXML_OUTPUT_ENABLED
       
   161 XMLPUBFUN void XMLCALL
       
   162                 xmlDumpNotationDecl     (xmlBufferPtr buf,
       
   163                                          xmlNotationPtr nota);
       
   164 XMLPUBFUN void XMLCALL
       
   165                 xmlDumpNotationTable    (xmlBufferPtr buf,
       
   166                                          xmlNotationTablePtr table);
       
   167 #endif /* LIBXML_OUTPUT_ENABLED */
       
   168 
       
   169 /* Element Content */
       
   170 XMLPUBFUN xmlElementContentPtr XMLCALL
       
   171                 xmlNewElementContent    (const xmlChar *name,
       
   172                                          xmlElementContentType type);
       
   173 XMLPUBFUN xmlElementContentPtr XMLCALL
       
   174                 xmlCopyElementContent   (xmlElementContentPtr content);
       
   175 XMLPUBFUN void XMLCALL
       
   176                 xmlFreeElementContent   (xmlElementContentPtr cur);
       
   177 XMLPUBFUN void XMLCALL
       
   178                 xmlSnprintfElementContent(char *buf,
       
   179                                          int size,
       
   180                                          xmlElementContentPtr content,
       
   181                                          int glob);
       
   182 /* DEPRECATED */
       
   183 XMLPUBFUN void XMLCALL
       
   184                 xmlSprintfElementContent(char *buf,
       
   185                                          xmlElementContentPtr content,
       
   186                                          int glob);
       
   187 /* DEPRECATED */
       
   188 
       
   189 /* Element */
       
   190 XMLPUBFUN xmlElementPtr XMLCALL
       
   191                 xmlAddElementDecl       (xmlValidCtxtPtr ctxt,
       
   192                                          xmlDtdPtr dtd,
       
   193                                          const xmlChar *name,
       
   194                                          xmlElementTypeVal type,
       
   195                                          xmlElementContentPtr content);
       
   196 XMLPUBFUN xmlElementTablePtr XMLCALL
       
   197                 xmlCopyElementTable     (xmlElementTablePtr table);
       
   198 XMLPUBFUN void XMLCALL
       
   199                 xmlFreeElementTable     (xmlElementTablePtr table);
       
   200 #ifdef LIBXML_OUTPUT_ENABLED
       
   201 XMLPUBFUN void XMLCALL
       
   202                 xmlDumpElementTable     (xmlBufferPtr buf,
       
   203                                          xmlElementTablePtr table);
       
   204 XMLPUBFUN void XMLCALL
       
   205                 xmlDumpElementDecl      (xmlBufferPtr buf,
       
   206                                          xmlElementPtr elem);
       
   207 #endif /* LIBXML_OUTPUT_ENABLED */
       
   208 
       
   209 /* Enumeration */
       
   210 XMLPUBFUN xmlEnumerationPtr XMLCALL
       
   211                 xmlCreateEnumeration    (const xmlChar *name);
       
   212 XMLPUBFUN void XMLCALL
       
   213                 xmlFreeEnumeration      (xmlEnumerationPtr cur);
       
   214 XMLPUBFUN xmlEnumerationPtr XMLCALL
       
   215                 xmlCopyEnumeration      (xmlEnumerationPtr cur);
       
   216 
       
   217 /* Attribute */
       
   218 XMLPUBFUN xmlAttributePtr XMLCALL
       
   219                 xmlAddAttributeDecl     (xmlValidCtxtPtr ctxt,
       
   220                                          xmlDtdPtr dtd,
       
   221                                          const xmlChar *elem,
       
   222                                          const xmlChar *name,
       
   223                                          const xmlChar *ns,
       
   224                                          xmlAttributeType type,
       
   225                                          xmlAttributeDefault def,
       
   226                                          const xmlChar *defaultValue,
       
   227                                          xmlEnumerationPtr tree);
       
   228 XMLPUBFUN xmlAttributeTablePtr XMLCALL
       
   229                 xmlCopyAttributeTable  (xmlAttributeTablePtr table);
       
   230 XMLPUBFUN void XMLCALL
       
   231                 xmlFreeAttributeTable  (xmlAttributeTablePtr table);
       
   232 #ifdef LIBXML_OUTPUT_ENABLED
       
   233 XMLPUBFUN void XMLCALL
       
   234                 xmlDumpAttributeTable  (xmlBufferPtr buf,
       
   235                                         xmlAttributeTablePtr table);
       
   236 XMLPUBFUN void XMLCALL
       
   237                 xmlDumpAttributeDecl   (xmlBufferPtr buf,
       
   238                                         xmlAttributePtr attr);
       
   239 #endif /* LIBXML_OUTPUT_ENABLED */
       
   240 
       
   241 XMLPUBFUN xmlIDPtr XMLCALL
       
   242                 xmlAddID               (xmlValidCtxtPtr ctxt,
       
   243                                         xmlDocPtr doc,
       
   244                                         const xmlChar *value,
       
   245                                         xmlAttrPtr attr);
       
   246 XMLPUBFUN void XMLCALL
       
   247                 xmlFreeIDTable         (xmlIDTablePtr table);
       
   248 XMLPUBFUN xmlAttrPtr XMLCALL
       
   249                 xmlGetID               (xmlDocPtr doc,
       
   250                                         const xmlChar *ID);
       
   251 XMLPUBFUN int XMLCALL
       
   252                 xmlIsID                (xmlDocPtr doc,
       
   253                                         xmlNodePtr elem,
       
   254                                         xmlAttrPtr attr);
       
   255 XMLPUBFUN int XMLCALL
       
   256                 xmlRemoveID            (xmlDocPtr doc,
       
   257                                         xmlAttrPtr attr);
       
   258 
       
   259                     
       
   260 /* IDREFs */
       
   261 XMLPUBFUN xmlRefPtr XMLCALL
       
   262                 xmlAddRef              (xmlValidCtxtPtr ctxt,
       
   263                                         xmlDocPtr doc,
       
   264                                         const xmlChar *value,
       
   265                                         xmlAttrPtr attr);
       
   266 XMLPUBFUN void XMLCALL
       
   267                 xmlFreeRefTable        (xmlRefTablePtr table);
       
   268 XMLPUBFUN int XMLCALL
       
   269                 xmlIsRef               (xmlDocPtr doc,
       
   270                                         xmlNodePtr elem,
       
   271                                         xmlAttrPtr attr);
       
   272 XMLPUBFUN int XMLCALL
       
   273                 xmlRemoveRef           (xmlDocPtr doc,
       
   274                                         xmlAttrPtr attr);
       
   275 
       
   276 #ifndef XMLENGINE_EXCLUDE_UNUSED
       
   277 XMLPUBFUN xmlListPtr XMLCALL
       
   278                 xmlGetRefs      (xmlDocPtr doc, const xmlChar *ID);
       
   279 #endif /* ifndef XMLENGINE_EXCLUDE_UNUSED */
       
   280 
       
   281 /**
       
   282  * The public function calls related to validity checking.
       
   283  */
       
   284 
       
   285 XMLPUBFUN int XMLCALL
       
   286                 xmlValidateRoot         (xmlValidCtxtPtr ctxt,
       
   287                                          xmlDocPtr doc);
       
   288 XMLPUBFUN int XMLCALL
       
   289                 xmlValidateElementDecl  (xmlValidCtxtPtr ctxt,
       
   290                                          xmlDocPtr doc,
       
   291                                          xmlElementPtr elem);
       
   292 XMLPUBFUN xmlChar * XMLCALL
       
   293                 xmlValidNormalizeAttributeValue(xmlDocPtr doc,
       
   294                                          xmlNodePtr elem,
       
   295                                          const xmlChar *name,
       
   296                                          const xmlChar *value);
       
   297 XMLPUBFUN xmlChar * XMLCALL
       
   298                 xmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt,
       
   299                                          xmlDocPtr doc,
       
   300                                          xmlNodePtr elem,
       
   301                                          const xmlChar *name,
       
   302                                          const xmlChar *value);
       
   303 XMLPUBFUN int XMLCALL
       
   304                 xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt,
       
   305                                          xmlDocPtr doc,
       
   306                                          xmlAttributePtr attr);
       
   307 XMLPUBFUN int XMLCALL
       
   308                 xmlValidateAttributeValue(xmlAttributeType type,
       
   309                                          const xmlChar *value);
       
   310 XMLPUBFUN int XMLCALL
       
   311                 xmlValidateNotationDecl (xmlValidCtxtPtr ctxt,
       
   312                                          xmlDocPtr doc,
       
   313                                          xmlNotationPtr nota);
       
   314 XMLPUBFUN int XMLCALL
       
   315                 xmlValidateDtd          (xmlValidCtxtPtr ctxt,
       
   316                                          xmlDocPtr doc,
       
   317                                          xmlDtdPtr dtd);
       
   318 XMLPUBFUN int XMLCALL
       
   319                 xmlValidateDtdFinal     (xmlValidCtxtPtr ctxt,
       
   320                                          xmlDocPtr doc);
       
   321 XMLPUBFUN int XMLCALL
       
   322                 xmlValidateDocument     (xmlValidCtxtPtr ctxt,
       
   323                                          xmlDocPtr doc);
       
   324 XMLPUBFUN int XMLCALL
       
   325                 xmlValidateElement      (xmlValidCtxtPtr ctxt,
       
   326                                          xmlDocPtr doc,
       
   327                                          xmlNodePtr elem);
       
   328 XMLPUBFUN int XMLCALL
       
   329                 xmlValidateOneElement   (xmlValidCtxtPtr ctxt,
       
   330                                          xmlDocPtr doc,
       
   331                                          xmlNodePtr elem);
       
   332 XMLPUBFUN int XMLCALL
       
   333                 xmlValidateOneAttribute (xmlValidCtxtPtr ctxt,
       
   334                                          xmlDocPtr doc,
       
   335                                          xmlNodePtr     elem,
       
   336                                          xmlAttrPtr attr,
       
   337                                          const xmlChar *value);
       
   338 XMLPUBFUN int XMLCALL
       
   339                 xmlValidateOneNamespace (xmlValidCtxtPtr ctxt,
       
   340                                          xmlDocPtr doc,
       
   341                                          xmlNodePtr elem,
       
   342                                          const xmlChar *prefix,
       
   343                                          xmlNsPtr ns,
       
   344                                          const xmlChar *value);
       
   345 XMLPUBFUN int XMLCALL
       
   346                 xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt,
       
   347                                          xmlDocPtr doc);
       
   348 XMLPUBFUN int XMLCALL
       
   349                 xmlValidateNotationUse  (xmlValidCtxtPtr ctxt,
       
   350                                          xmlDocPtr doc,
       
   351                                          const xmlChar *notationName);
       
   352 XMLPUBFUN int XMLCALL
       
   353                 xmlIsMixedElement       (xmlDocPtr doc,
       
   354                                          const xmlChar *name);
       
   355 XMLPUBFUN xmlAttributePtr XMLCALL
       
   356                 xmlGetDtdAttrDesc       (xmlDtdPtr dtd,
       
   357                                          const xmlChar *elem,
       
   358                                          const xmlChar *name);
       
   359 XMLPUBFUN xmlAttributePtr XMLCALL
       
   360                 xmlGetDtdQAttrDesc      (xmlDtdPtr dtd,
       
   361                                          const xmlChar *elem,
       
   362                                          const xmlChar *name,
       
   363                                          const xmlChar *prefix);
       
   364 XMLPUBFUN xmlNotationPtr XMLCALL
       
   365                 xmlGetDtdNotationDesc   (xmlDtdPtr dtd,
       
   366                                          const xmlChar *name);
       
   367 XMLPUBFUN xmlElementPtr XMLCALL
       
   368                 xmlGetDtdQElementDesc   (xmlDtdPtr dtd,
       
   369                                          const xmlChar *name,
       
   370                                          const xmlChar *prefix);
       
   371 XMLPUBFUN xmlElementPtr XMLCALL
       
   372                 xmlGetDtdElementDesc    (xmlDtdPtr dtd,
       
   373                                          const xmlChar *name);
       
   374 
       
   375 XMLPUBFUN int XMLCALL
       
   376                 xmlValidGetValidElements(xmlNode *prev,
       
   377                                          xmlNode *next,
       
   378                                          const xmlChar **names,
       
   379                                          int max);
       
   380 XMLPUBFUN int XMLCALL
       
   381                 xmlValidGetPotentialChildren(xmlElementContent *ctree,
       
   382                                          const xmlChar **list,
       
   383                                          int *len,
       
   384                                          int max);
       
   385 XMLPUBFUN int XMLCALL
       
   386                 xmlValidateNameValue    (const xmlChar *value);
       
   387 XMLPUBFUN int XMLCALL
       
   388                 xmlValidateNamesValue   (const xmlChar *value);
       
   389 XMLPUBFUN int XMLCALL
       
   390                 xmlValidateNmtokenValue (const xmlChar *value);
       
   391 XMLPUBFUN int XMLCALL
       
   392                 xmlValidateNmtokensValue(const xmlChar *value);
       
   393 
       
   394 #ifdef LIBXML_REGEXP_ENABLED
       
   395 /*
       
   396  * Validation based on the regexp support
       
   397  */
       
   398 XMLPUBFUN int XMLCALL
       
   399                 xmlValidBuildContentModel(xmlValidCtxtPtr ctxt,
       
   400                                          xmlElementPtr elem);
       
   401 
       
   402 XMLPUBFUN int XMLCALL
       
   403                 xmlValidatePushElement  (xmlValidCtxtPtr ctxt,
       
   404                                          xmlDocPtr doc,
       
   405                                          xmlNodePtr elem,
       
   406                                          const xmlChar *qname);
       
   407 XMLPUBFUN int XMLCALL
       
   408                 xmlValidatePushCData    (xmlValidCtxtPtr ctxt,
       
   409                                          const xmlChar *data,
       
   410                                          int len);
       
   411 XMLPUBFUN int XMLCALL
       
   412                 xmlValidatePopElement   (xmlValidCtxtPtr ctxt,
       
   413                                          xmlDocPtr doc,
       
   414                                          xmlNodePtr elem,
       
   415                                          const xmlChar *qname);
       
   416 #endif /* LIBXML_REGEXP_ENABLED */
       
   417 #ifdef __cplusplus
       
   418 }
       
   419 #endif
       
   420 #endif /* XML_VALID_H */
       
   421