ReactOS  0.4.15-dev-1184-g23e04ae
valid.c File Reference
#include "libxml.h"
#include <string.h>
#include <stdlib.h>
#include <libxml/xmlmemory.h>
#include <libxml/hash.h>
#include <libxml/uri.h>
#include <libxml/valid.h>
#include <libxml/parser.h>
#include <libxml/parserInternals.h>
#include <libxml/xmlerror.h>
#include <libxml/list.h>
#include <libxml/globals.h>
#include "elfgcchack.h"
Include dependency graph for valid.c:

Go to the source code of this file.

Classes

struct  xmlRemoveMemo_t
 
struct  xmlValidateMemo_t
 

Macros

#define IN_LIBXML
 
#define TODO
 

Functions

static void xmlVErrMemory (xmlValidCtxtPtr ctxt, const char *extra)
 
static void LIBXML_ATTR_FORMAT (3, 0)
 
: the subelement name or NULL

xmlNewElementContent:

@type: the type of element content decl

Allocate an element content structure. Deprecated in favor of xmlNewDocElementContent

Returns NULL if not, otherwise the new element content structure

xmlElementContentPtr xmlNewDocElementContent (xmlDocPtr doc, const xmlChar *name, xmlElementContentType type)
 
xmlElementContentPtr xmlNewElementContent (const xmlChar *name, xmlElementContentType type)
 
xmlElementContentPtr xmlCopyDocElementContent (xmlDocPtr doc, xmlElementContentPtr cur)
 
xmlElementContentPtr xmlCopyElementContent (xmlElementContentPtr cur)
 
void xmlFreeDocElementContent (xmlDocPtr doc, xmlElementContentPtr cur)
 
void xmlFreeElementContent (xmlElementContentPtr cur)
 
void xmlSnprintfElementContent (char *buf, int size, xmlElementContentPtr content, int englob)
 
static void xmlFreeElement (xmlElementPtr elem)
 
: the enumeration name or NULL

xmlCreateEnumeration:

create and initialize an enumeration attribute node.

Returns the xmlEnumerationPtr just created or NULL in case of error.

xmlEnumerationPtr xmlCreateEnumeration (const xmlChar *name)
 
void xmlFreeEnumeration (xmlEnumerationPtr cur)
 
static void xmlFreeAttribute (xmlAttributePtr attr)
 
: the attribute name

xmlGetDtdQAttrDesc: @dtd: a pointer to the DtD to search @elem: the element name

@prefix: the attribute namespace prefix

Search the DTD for the description of this qualified attribute on this element.

returns the xmlAttributePtr if found or NULL

xmlAttributePtr xmlAddAttributeDecl (xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *elem, const xmlChar *name, const xmlChar *ns, xmlAttributeType type, xmlAttributeDefault def, const xmlChar *defaultValue, xmlEnumerationPtr tree)
 
static void xmlFreeAttributeTableEntry (void *attr, const xmlChar *name ATTRIBUTE_UNUSED)
 
void xmlFreeAttributeTable (xmlAttributeTablePtr table)
 
static void xmlFreeNotation (xmlNotationPtr nota)
 
xmlAttributePtr xmlGetDtdAttrDesc (xmlDtdPtr dtd, const xmlChar *elem, const xmlChar *name)
 
xmlAttributePtr xmlGetDtdQAttrDesc (xmlDtdPtr dtd, const xmlChar *elem, const xmlChar *name, const xmlChar *prefix)
 
: the notation name

xmlGetDtdNotationDesc: @dtd: a pointer to the DtD to search

Search the DTD for the description of this notation

returns the xmlNotationPtr if found or NULL

xmlNotationPtr xmlGetDtdNotationDesc (xmlDtdPtr dtd, const xmlChar *name)
 

: the entity name

xmlAddNotationDecl: @dtd: pointer to the DTD @ctxt: the validation context

@PublicID: the public identifier or NULL @SystemID: the system identifier or NULL

Register a new notation declaration

Returns NULL if not, otherwise the entity

#define DICT_FREE(str)
 
typedef struct xmlRemoveMemo_t xmlRemoveMemo
 
typedef xmlRemoveMemoxmlRemoveMemoPtr
 
typedef struct xmlValidateMemo_t xmlValidateMemo
 
typedef xmlValidateMemoxmlValidateMemoPtr
 
xmlElementPtr xmlAddElementDecl (xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *name, xmlElementTypeVal type, xmlElementContentPtr content)
 
static void xmlFreeElementTableEntry (void *elem, const xmlChar *name ATTRIBUTE_UNUSED)
 
void xmlFreeElementTable (xmlElementTablePtr table)
 
xmlNotationPtr xmlAddNotationDecl (xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *name, const xmlChar *PublicID, const xmlChar *SystemID)
 
static void xmlFreeNotationTableEntry (void *nota, const xmlChar *name ATTRIBUTE_UNUSED)
 
void xmlFreeNotationTable (xmlNotationTablePtr table)
 
static void xmlFreeID (xmlIDPtr id)
 
xmlIDPtr xmlAddID (xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value, xmlAttrPtr attr)
 
static void xmlFreeIDTableEntry (void *id, const xmlChar *name ATTRIBUTE_UNUSED)
 
void xmlFreeIDTable (xmlIDTablePtr table)
 
int xmlIsID (xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr)
 
int xmlRemoveID (xmlDocPtr doc, xmlAttrPtr attr)
 
xmlAttrPtr xmlGetID (xmlDocPtr doc, const xmlChar *ID)
 
static void xmlFreeRef (xmlLinkPtr lk)
 
static void xmlFreeRefTableEntry (void *payload, const xmlChar *name ATTRIBUTE_UNUSED)
 
static int xmlWalkRemoveRef (const void *data, void *user)
 
static int xmlDummyCompare (const void *data0 ATTRIBUTE_UNUSED, const void *data1 ATTRIBUTE_UNUSED)
 
xmlRefPtr xmlAddRef (xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value, xmlAttrPtr attr)
 
void xmlFreeRefTable (xmlRefTablePtr table)
 
int xmlIsRef (xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr)
 
int xmlRemoveRef (xmlDocPtr doc, xmlAttrPtr attr)
 
xmlListPtr xmlGetRefs (xmlDocPtr doc, const xmlChar *ID)
 

: the element name

xmlIsMixedElement: @doc: the document

Search in the DtDs whether an element accept Mixed content (or ANY) basically if it is supposed to accept text childs

returns 0 if no, 1 if yes, and -1 if no element description is available

#define bottom_valid
 
static xmlElementPtr xmlGetDtdElementDesc2 (xmlDtdPtr dtd, const xmlChar *name, int create)
 
xmlElementPtr xmlGetDtdElementDesc (xmlDtdPtr dtd, const xmlChar *name)
 
xmlElementPtr xmlGetDtdQElementDesc (xmlDtdPtr dtd, const xmlChar *name, const xmlChar *prefix)
 
int xmlIsMixedElement (xmlDocPtr doc, const xmlChar *name)
 

Macro Definition Documentation

◆ bottom_valid

#define bottom_valid

Definition at line 7138 of file valid.c.

◆ DICT_FREE

#define DICT_FREE (   str)
Value:
if ((str) && ((!dict) || \
(xmlDictOwns(dict, (const xmlChar *)(str)) == 0))) \
xmlFree((char *)(str));
const WCHAR * str
unsigned char xmlChar
Definition: xmlstring.h:28
XMLPUBFUN int XMLCALL xmlDictOwns(xmlDictPtr dict, const xmlChar *str)
Definition: dict.c:1218

DICT_FREE: @str: a string

Free a string if it is not owned by the "dict" dictionary in the current scope

Definition at line 2605 of file valid.c.

◆ IN_LIBXML

#define IN_LIBXML

Definition at line 10 of file valid.c.

◆ TODO

#define TODO
Value:
"Unimplemented block at %s:%d\n", \
__FILE__, __LINE__);
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:346
XMLPUBVAR void * xmlGenericErrorContext
Definition: globals.h:362

Definition at line 34 of file valid.c.

Typedef Documentation

◆ xmlRemoveMemo

◆ xmlRemoveMemoPtr

Definition at line 2886 of file valid.c.

◆ xmlValidateMemo

◆ xmlValidateMemoPtr

Definition at line 2894 of file valid.c.

Function Documentation

◆ LIBXML_ATTR_FORMAT()

static void LIBXML_ATTR_FORMAT ( ,
 
)
static

xmlErrValid: @ctxt: an XML validation parser context @error: the error number @extra: extra informations

Handle a validation error

Definition at line 96 of file valid.c.

99 {
100  xmlGenericErrorFunc channel = NULL;
101  xmlParserCtxtPtr pctxt = NULL;
102  void *data = NULL;
103 
104  if (ctxt != NULL) {
105  channel = ctxt->error;
106  data = ctxt->userData;
107  /* Use the special values to detect if it is part of a parsing
108  context */
109  if ((ctxt->finishDtd == XML_CTXT_FINISH_DTD_0) ||
110  (ctxt->finishDtd == XML_CTXT_FINISH_DTD_1)) {
111  long delta = (char *) ctxt - (char *) ctxt->userData;
112  if ((delta > 0) && (delta < 250))
113  pctxt = ctxt->userData;
114  }
115  }
116  if (extra)
117  __xmlRaiseError(NULL, channel, data,
118  pctxt, NULL, XML_FROM_VALID, error,
119  XML_ERR_ERROR, NULL, 0, extra, NULL, NULL, 0, 0,
120  msg, extra);
121  else
122  __xmlRaiseError(NULL, channel, data,
123  pctxt, NULL, XML_FROM_VALID, error,
124  XML_ERR_ERROR, NULL, 0, NULL, NULL, NULL, 0, 0,
125  "%s", msg);
126 }
#define error(str)
Definition: mkdosfs.c:1605
smooth NULL
Definition: ftsmooth.c:416
Definition: id3.c:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
#define msg(x)
Definition: auth_time.c:54
void(XMLCDECL * xmlGenericErrorFunc)(void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2
Definition: xmlerror.h:845
void * userData
Definition: parser.h:186

◆ xmlAddAttributeDecl()

xmlAttributePtr xmlAddAttributeDecl ( xmlValidCtxtPtr  ctxt,
xmlDtdPtr  dtd,
const xmlChar elem,
const xmlChar name,
const xmlChar ns,
xmlAttributeType  type,
xmlAttributeDefault  def,
const xmlChar defaultValue,
xmlEnumerationPtr  tree 
)

Definition at line 1981 of file valid.c.

1985  {
1988  xmlElementPtr elemDef;
1989  xmlDictPtr dict = NULL;
1990 
1991  if (dtd == NULL) {
1993  return(NULL);
1994  }
1995  if (name == NULL) {
1997  return(NULL);
1998  }
1999  if (elem == NULL) {
2001  return(NULL);
2002  }
2003  if (dtd->doc != NULL)
2004  dict = dtd->doc->dict;
2005 
2006 #ifdef LIBXML_VALID_ENABLED
2007  /*
2008  * Check the type and possibly the default value.
2009  */
2010  switch (type) {
2011  case XML_ATTRIBUTE_CDATA:
2012  break;
2013  case XML_ATTRIBUTE_ID:
2014  break;
2015  case XML_ATTRIBUTE_IDREF:
2016  break;
2017  case XML_ATTRIBUTE_IDREFS:
2018  break;
2019  case XML_ATTRIBUTE_ENTITY:
2020  break;
2022  break;
2023  case XML_ATTRIBUTE_NMTOKEN:
2024  break;
2026  break;
2028  break;
2030  break;
2031  default:
2032  xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR,
2033  "Internal: ATTRIBUTE struct corrupted invalid type\n",
2034  NULL);
2036  return(NULL);
2037  }
2038  if ((defaultValue != NULL) &&
2039  (!xmlValidateAttributeValueInternal(dtd->doc, type, defaultValue))) {
2040  xmlErrValidNode(ctxt, (xmlNodePtr) dtd, XML_DTD_ATTRIBUTE_DEFAULT,
2041  "Attribute %s of %s: invalid default value\n",
2042  elem, name, defaultValue);
2043  defaultValue = NULL;
2044  if (ctxt != NULL)
2045  ctxt->valid = 0;
2046  }
2047 #endif /* LIBXML_VALID_ENABLED */
2048 
2049  /*
2050  * Check first that an attribute defined in the external subset wasn't
2051  * already defined in the internal subset
2052  */
2053  if ((dtd->doc != NULL) && (dtd->doc->extSubset == dtd) &&
2054  (dtd->doc->intSubset != NULL) &&
2055  (dtd->doc->intSubset->attributes != NULL)) {
2056  ret = xmlHashLookup3(dtd->doc->intSubset->attributes, name, ns, elem);
2057  if (ret != NULL) {
2059  return(NULL);
2060  }
2061  }
2062 
2063  /*
2064  * Create the Attribute table if needed.
2065  */
2067  if (table == NULL) {
2068  table = xmlHashCreateDict(0, dict);
2069  dtd->attributes = (void *) table;
2070  }
2071  if (table == NULL) {
2072  xmlVErrMemory(ctxt,
2073  "xmlAddAttributeDecl: Table creation failed!\n");
2075  return(NULL);
2076  }
2077 
2078 
2080  if (ret == NULL) {
2081  xmlVErrMemory(ctxt, "malloc failed");
2083  return(NULL);
2084  }
2085  memset(ret, 0, sizeof(xmlAttribute));
2086  ret->type = XML_ATTRIBUTE_DECL;
2087 
2088  /*
2089  * fill the structure.
2090  */
2091  ret->atype = type;
2092  /*
2093  * doc must be set before possible error causes call
2094  * to xmlFreeAttribute (because it's used to check on
2095  * dict use)
2096  */
2097  ret->doc = dtd->doc;
2098  if (dict) {
2099  ret->name = xmlDictLookup(dict, name, -1);
2100  ret->prefix = xmlDictLookup(dict, ns, -1);
2101  ret->elem = xmlDictLookup(dict, elem, -1);
2102  } else {
2103  ret->name = xmlStrdup(name);
2104  ret->prefix = xmlStrdup(ns);
2105  ret->elem = xmlStrdup(elem);
2106  }
2107  ret->def = def;
2108  ret->tree = tree;
2109  if (defaultValue != NULL) {
2110  if (dict)
2111  ret->defaultValue = xmlDictLookup(dict, defaultValue, -1);
2112  else
2113  ret->defaultValue = xmlStrdup(defaultValue);
2114  }
2115 
2116  /*
2117  * Validity Check:
2118  * Search the DTD for previous declarations of the ATTLIST
2119  */
2120  if (xmlHashAddEntry3(table, ret->name, ret->prefix, ret->elem, ret) < 0) {
2121 #ifdef LIBXML_VALID_ENABLED
2122  /*
2123  * The attribute is already defined in this DTD.
2124  */
2125  xmlErrValidWarning(ctxt, (xmlNodePtr) dtd, XML_DTD_ATTRIBUTE_REDEFINED,
2126  "Attribute %s of element %s: already defined\n",
2127  name, elem, NULL);
2128 #endif /* LIBXML_VALID_ENABLED */
2130  return(NULL);
2131  }
2132 
2133  /*
2134  * Validity Check:
2135  * Multiple ID per element
2136  */
2137  elemDef = xmlGetDtdElementDesc2(dtd, elem, 1);
2138  if (elemDef != NULL) {
2139 
2140 #ifdef LIBXML_VALID_ENABLED
2141  if ((type == XML_ATTRIBUTE_ID) &&
2142  (xmlScanIDAttributeDecl(NULL, elemDef, 1) != 0)) {
2143  xmlErrValidNode(ctxt, (xmlNodePtr) dtd, XML_DTD_MULTIPLE_ID,
2144  "Element %s has too may ID attributes defined : %s\n",
2145  elem, name, NULL);
2146  if (ctxt != NULL)
2147  ctxt->valid = 0;
2148  }
2149 #endif /* LIBXML_VALID_ENABLED */
2150 
2151  /*
2152  * Insert namespace default def first they need to be
2153  * processed first.
2154  */
2155  if ((xmlStrEqual(ret->name, BAD_CAST "xmlns")) ||
2156  ((ret->prefix != NULL &&
2157  (xmlStrEqual(ret->prefix, BAD_CAST "xmlns"))))) {
2158  ret->nexth = elemDef->attributes;
2159  elemDef->attributes = ret;
2160  } else {
2161  xmlAttributePtr tmp = elemDef->attributes;
2162 
2163  while ((tmp != NULL) &&
2164  ((xmlStrEqual(tmp->name, BAD_CAST "xmlns")) ||
2165  ((ret->prefix != NULL &&
2166  (xmlStrEqual(ret->prefix, BAD_CAST "xmlns")))))) {
2167  if (tmp->nexth == NULL)
2168  break;
2169  tmp = tmp->nexth;
2170  }
2171  if (tmp != NULL) {
2172  ret->nexth = tmp->nexth;
2173  tmp->nexth = ret;
2174  } else {
2175  ret->nexth = elemDef->attributes;
2176  elemDef->attributes = ret;
2177  }
2178  }
2179  }
2180 
2181  /*
2182  * Link it to the DTD
2183  */
2184  ret->parent = dtd;
2185  if (dtd->last == NULL) {
2186  dtd->children = dtd->last = (xmlNodePtr) ret;
2187  } else {
2188  dtd->last->next = (xmlNodePtr) ret;
2189  ret->prev = dtd->last;
2190  dtd->last = (xmlNodePtr) ret;
2191  }
2192  return(ret);
2193 }
XMLPUBFUN int XMLCALL xmlHashAddEntry3(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, const xmlChar *name3, void *userdata)
Definition: hash.c:536
struct _xmlDoc * doc
Definition: tree.h:415
struct _tree tree
void xmlFreeEnumeration(xmlEnumerationPtr cur)
Definition: valid.c:1831
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
static void xmlVErrMemory(xmlValidCtxtPtr ctxt, const char *extra)
Definition: valid.c:58
const xmlChar * name
Definition: tree.h:256
void * attributes
Definition: tree.h:420
static size_t elem
Definition: string.c:68
smooth NULL
Definition: ftsmooth.c:416
xmlAttributeTable * xmlAttributeTablePtr
Definition: valid.h:134
xmlNode * xmlNodePtr
Definition: tree.h:488
#define BAD_CAST
Definition: xmlstring.h:35
Definition: dict.c:116
XMLPUBFUN void *XMLCALL xmlHashLookup3(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, const xmlChar *name3)
Definition: hash.c:774
xmlAttributePtr attributes
Definition: tree.h:359
if(!(yy_init))
Definition: macro.lex.yy.c:714
struct _xmlNode * last
Definition: tree.h:411
XMLPUBFUN const xmlChar *XMLCALL xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:865
Definition: tree.h:489
int ret
Definition: mxnamespace.c:44
static void xmlFreeAttribute(xmlAttributePtr attr)
Definition: valid.c:1928
xmlAttribute * xmlAttributePtr
Definition: tree.h:252
struct _xmlNode * children
Definition: tree.h:410
static xmlElementPtr xmlGetDtdElementDesc2(xmlDtdPtr dtd, const xmlChar *name, int create)
Definition: valid.c:3249
struct _xmlAttribute * nexth
Definition: tree.h:264
XMLPUBFUN xmlHashTablePtr XMLCALL xmlHashCreateDict(int size, xmlDictPtr dict)
Definition: hash.c:215
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
Definition: name.c:38
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:157
int valid
Definition: valid.h:95
#define memset(x, y, z)
Definition: compat.h:39
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:66

Referenced by xmlSAX2AttributeDecl().

◆ xmlAddElementDecl()

xmlElementPtr xmlAddElementDecl ( xmlValidCtxtPtr  ctxt,
xmlDtdPtr  dtd,
const xmlChar name,
xmlElementTypeVal  type,
xmlElementContentPtr  content 
)

Definition at line 1430 of file valid.c.

1433  {
1436  xmlAttributePtr oldAttributes = NULL;
1437  xmlChar *ns, *uqname;
1438 
1439  if (dtd == NULL) {
1440  return(NULL);
1441  }
1442  if (name == NULL) {
1443  return(NULL);
1444  }
1445 
1446  switch (type) {
1448  if (content != NULL) {
1449  xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR,
1450  "xmlAddElementDecl: content != NULL for EMPTY\n",
1451  NULL);
1452  return(NULL);
1453  }
1454  break;
1455  case XML_ELEMENT_TYPE_ANY:
1456  if (content != NULL) {
1457  xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR,
1458  "xmlAddElementDecl: content != NULL for ANY\n",
1459  NULL);
1460  return(NULL);
1461  }
1462  break;
1464  if (content == NULL) {
1465  xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR,
1466  "xmlAddElementDecl: content == NULL for MIXED\n",
1467  NULL);
1468  return(NULL);
1469  }
1470  break;
1472  if (content == NULL) {
1473  xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR,
1474  "xmlAddElementDecl: content == NULL for ELEMENT\n",
1475  NULL);
1476  return(NULL);
1477  }
1478  break;
1479  default:
1480  xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR,
1481  "Internal: ELEMENT decl corrupted invalid type\n",
1482  NULL);
1483  return(NULL);
1484  }
1485 
1486  /*
1487  * check if name is a QName
1488  */
1489  uqname = xmlSplitQName2(name, &ns);
1490  if (uqname != NULL)
1491  name = uqname;
1492 
1493  /*
1494  * Create the Element table if needed.
1495  */
1497  if (table == NULL) {
1498  xmlDictPtr dict = NULL;
1499 
1500  if (dtd->doc != NULL)
1501  dict = dtd->doc->dict;
1502  table = xmlHashCreateDict(0, dict);
1503  dtd->elements = (void *) table;
1504  }
1505  if (table == NULL) {
1506  xmlVErrMemory(ctxt,
1507  "xmlAddElementDecl: Table creation failed!\n");
1508  if (uqname != NULL)
1509  xmlFree(uqname);
1510  if (ns != NULL)
1511  xmlFree(ns);
1512  return(NULL);
1513  }
1514 
1515  /*
1516  * lookup old attributes inserted on an undefined element in the
1517  * internal subset.
1518  */
1519  if ((dtd->doc != NULL) && (dtd->doc->intSubset != NULL)) {
1520  ret = xmlHashLookup2(dtd->doc->intSubset->elements, name, ns);
1521  if ((ret != NULL) && (ret->etype == XML_ELEMENT_TYPE_UNDEFINED)) {
1522  oldAttributes = ret->attributes;
1523  ret->attributes = NULL;
1524  xmlHashRemoveEntry2(dtd->doc->intSubset->elements, name, ns, NULL);
1526  }
1527  }
1528 
1529  /*
1530  * The element may already be present if one of its attribute
1531  * was registered first
1532  */
1534  if (ret != NULL) {
1535  if (ret->etype != XML_ELEMENT_TYPE_UNDEFINED) {
1536 #ifdef LIBXML_VALID_ENABLED
1537  /*
1538  * The element is already defined in this DTD.
1539  */
1540  xmlErrValidNode(ctxt, (xmlNodePtr) dtd, XML_DTD_ELEM_REDEFINED,
1541  "Redefinition of element %s\n",
1542  name, NULL, NULL);
1543 #endif /* LIBXML_VALID_ENABLED */
1544  if (uqname != NULL)
1545  xmlFree(uqname);
1546  if (ns != NULL)
1547  xmlFree(ns);
1548  return(NULL);
1549  }
1550  if (ns != NULL) {
1551  xmlFree(ns);
1552  ns = NULL;
1553  }
1554  } else {
1555  ret = (xmlElementPtr) xmlMalloc(sizeof(xmlElement));
1556  if (ret == NULL) {
1557  xmlVErrMemory(ctxt, "malloc failed");
1558  if (uqname != NULL)
1559  xmlFree(uqname);
1560  if (ns != NULL)
1561  xmlFree(ns);
1562  return(NULL);
1563  }
1564  memset(ret, 0, sizeof(xmlElement));
1565  ret->type = XML_ELEMENT_DECL;
1566 
1567  /*
1568  * fill the structure.
1569  */
1570  ret->name = xmlStrdup(name);
1571  if (ret->name == NULL) {
1572  xmlVErrMemory(ctxt, "malloc failed");
1573  if (uqname != NULL)
1574  xmlFree(uqname);
1575  if (ns != NULL)
1576  xmlFree(ns);
1577  xmlFree(ret);
1578  return(NULL);
1579  }
1580  ret->prefix = ns;
1581 
1582  /*
1583  * Validity Check:
1584  * Insertion must not fail
1585  */
1586  if (xmlHashAddEntry2(table, name, ns, ret)) {
1587 #ifdef LIBXML_VALID_ENABLED
1588  /*
1589  * The element is already defined in this DTD.
1590  */
1591  xmlErrValidNode(ctxt, (xmlNodePtr) dtd, XML_DTD_ELEM_REDEFINED,
1592  "Redefinition of element %s\n",
1593  name, NULL, NULL);
1594 #endif /* LIBXML_VALID_ENABLED */
1596  if (uqname != NULL)
1597  xmlFree(uqname);
1598  return(NULL);
1599  }
1600  /*
1601  * For new element, may have attributes from earlier
1602  * definition in internal subset
1603  */
1604  ret->attributes = oldAttributes;
1605  }
1606 
1607  /*
1608  * Finish to fill the structure.
1609  */
1610  ret->etype = type;
1611  /*
1612  * Avoid a stupid copy when called by the parser
1613  * and flag it by setting a special parent value
1614  * so the parser doesn't unallocate it.
1615  */
1616  if ((ctxt != NULL) &&
1617  ((ctxt->finishDtd == XML_CTXT_FINISH_DTD_0) ||
1618  (ctxt->finishDtd == XML_CTXT_FINISH_DTD_1))) {
1619  ret->content = content;
1620  if (content != NULL)
1621  content->parent = (xmlElementContentPtr) 1;
1622  } else {
1623  ret->content = xmlCopyDocElementContent(dtd->doc, content);
1624  }
1625 
1626  /*
1627  * Link it to the DTD
1628  */
1629  ret->parent = dtd;
1630  ret->doc = dtd->doc;
1631  if (dtd->last == NULL) {
1632  dtd->children = dtd->last = (xmlNodePtr) ret;
1633  } else {
1634  dtd->last->next = (xmlNodePtr) ret;
1635  ret->prev = dtd->last;
1636  dtd->last = (xmlNodePtr) ret;
1637  }
1638  if (uqname != NULL)
1639  xmlFree(uqname);
1640  return(ret);
1641 }
static void xmlFreeElement(xmlElementPtr elem)
Definition: valid.c:1401
unsigned int finishDtd
Definition: valid.h:93
struct _xmlDoc * doc
Definition: tree.h:415
XMLPUBFUN int XMLCALL xmlHashAddEntry2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, void *userdata)
Definition: hash.c:411
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
static void xmlVErrMemory(xmlValidCtxtPtr ctxt, const char *extra)
Definition: valid.c:58
xmlElementTable * xmlElementTablePtr
Definition: valid.h:126
XMLPUBFUN void *XMLCALL xmlHashLookup2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2)
Definition: hash.c:481
content
Definition: atl_ax.c:993
smooth NULL
Definition: ftsmooth.c:416
xmlNode * xmlNodePtr
Definition: tree.h:488
Definition: dict.c:116
if(!(yy_init))
Definition: macro.lex.yy.c:714
xmlElement * xmlElementPtr
Definition: tree.h:345
void * elements
Definition: tree.h:419
XMLPUBFUN int XMLCALL xmlHashRemoveEntry2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, xmlHashDeallocator f)
Definition: hash.c:1076
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
struct _xmlNode * last
Definition: tree.h:411
Definition: tree.h:489
int ret
Definition: mxnamespace.c:44
unsigned char xmlChar
Definition: xmlstring.h:28
struct _xmlNode * children
Definition: tree.h:410
XMLPUBFUN xmlHashTablePtr XMLCALL xmlHashCreateDict(int size, xmlDictPtr dict)
Definition: hash.c:215
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
Definition: name.c:38
xmlElementContentPtr xmlCopyDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur)
Definition: valid.c:1008
#define memset(x, y, z)
Definition: compat.h:39
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:66
xmlElementContent * xmlElementContentPtr
Definition: tree.h:305
XMLPUBFUN xmlChar *XMLCALL xmlSplitQName2(const xmlChar *name, xmlChar **prefix)

Referenced by xmlSAX2ElementDecl().

◆ xmlAddID()

xmlIDPtr xmlAddID ( xmlValidCtxtPtr  ctxt,
xmlDocPtr  doc,
const xmlChar value,
xmlAttrPtr  attr 
)

xmlAddID: @ctxt: the validation context @doc: pointer to the document @value: the value name @attr: the attribute holding the ID

Register a new id declaration

Returns NULL if not, otherwise the new xmlIDPtr

Definition at line 2645 of file valid.c.

2646  {
2647  xmlIDPtr ret;
2649 
2650  if (doc == NULL) {
2651  return(NULL);
2652  }
2653  if (value == NULL) {
2654  return(NULL);
2655  }
2656  if (attr == NULL) {
2657  return(NULL);
2658  }
2659 
2660  /*
2661  * Create the ID table if needed.
2662  */
2663  table = (xmlIDTablePtr) doc->ids;
2664  if (table == NULL) {
2665  doc->ids = table = xmlHashCreateDict(0, doc->dict);
2666  }
2667  if (table == NULL) {
2668  xmlVErrMemory(ctxt,
2669  "xmlAddID: Table creation failed!\n");
2670  return(NULL);
2671  }
2672 
2673  ret = (xmlIDPtr) xmlMalloc(sizeof(xmlID));
2674  if (ret == NULL) {
2675  xmlVErrMemory(ctxt, "malloc failed");
2676  return(NULL);
2677  }
2678 
2679  /*
2680  * fill the structure.
2681  */
2682  ret->value = xmlStrdup(value);
2683  ret->doc = doc;
2684  if ((ctxt != NULL) && (ctxt->vstateNr != 0)) {
2685  /*
2686  * Operating in streaming mode, attr is gonna disappear
2687  */
2688  if (doc->dict != NULL)
2689  ret->name = xmlDictLookup(doc->dict, attr->name, -1);
2690  else
2691  ret->name = xmlStrdup(attr->name);
2692  ret->attr = NULL;
2693  } else {
2694  ret->attr = attr;
2695  ret->name = NULL;
2696  }
2697  ret->lineno = xmlGetLineNo(attr->parent);
2698 
2699  if (xmlHashAddEntry(table, value, ret) < 0) {
2700 #ifdef LIBXML_VALID_ENABLED
2701  /*
2702  * The id is already defined in this DTD.
2703  */
2704  if (ctxt != NULL) {
2705  xmlErrValidNode(ctxt, attr->parent, XML_DTD_ID_REDEFINED,
2706  "ID %s already defined\n", value, NULL, NULL);
2707  }
2708 #endif /* LIBXML_VALID_ENABLED */
2709  xmlFreeID(ret);
2710  return(NULL);
2711  }
2712  if (attr != NULL)
2713  attr->atype = XML_ATTRIBUTE_ID;
2714  return(ret);
2715 }
static void xmlFreeID(xmlIDPtr id)
Definition: valid.c:2617
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
XMLPUBFUN int XMLCALL xmlHashAddEntry(xmlHashTablePtr table, const xmlChar *name, void *userdata)
Definition: hash.c:394
static void xmlVErrMemory(xmlValidCtxtPtr ctxt, const char *extra)
Definition: valid.c:58
smooth NULL
Definition: ftsmooth.c:416
void * ids
Definition: tree.h:575
XMLPUBFUN long XMLCALL xmlGetLineNo(const xmlNode *node)
if(!(yy_init))
Definition: macro.lex.yy.c:714
xmlID * xmlIDPtr
Definition: tree.h:456
XMLPUBFUN const xmlChar *XMLCALL xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:865
Definition: cookie.c:201
int ret
__u8 attr
Definition: mkdosfs.c:359
xmlIDTable * xmlIDTablePtr
Definition: valid.h:142
XMLPUBFUN xmlHashTablePtr XMLCALL xmlHashCreateDict(int size, xmlDictPtr dict)
Definition: hash.c:215
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
WCHAR * name
Definition: cookie.c:203
struct _xmlDict * dict
Definition: tree.h:580
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:66
Definition: tree.h:457
int vstateNr
Definition: valid.h:99

Referenced by xmlSAX2AttributeNs(), xsltAttribute(), and xsltAttrListTemplateProcess().

◆ xmlAddNotationDecl()

xmlNotationPtr xmlAddNotationDecl ( xmlValidCtxtPtr  ctxt,
xmlDtdPtr  dtd,
const xmlChar name,
const xmlChar PublicID,
const xmlChar SystemID 
)

Definition at line 2408 of file valid.c.

2410  {
2413 
2414  if (dtd == NULL) {
2415  return(NULL);
2416  }
2417  if (name == NULL) {
2418  return(NULL);
2419  }
2420  if ((PublicID == NULL) && (SystemID == NULL)) {
2421  return(NULL);
2422  }
2423 
2424  /*
2425  * Create the Notation table if needed.
2426  */
2428  if (table == NULL) {
2429  xmlDictPtr dict = NULL;
2430  if (dtd->doc != NULL)
2431  dict = dtd->doc->dict;
2432 
2433  dtd->notations = table = xmlHashCreateDict(0, dict);
2434  }
2435  if (table == NULL) {
2436  xmlVErrMemory(ctxt,
2437  "xmlAddNotationDecl: Table creation failed!\n");
2438  return(NULL);
2439  }
2440 
2441  ret = (xmlNotationPtr) xmlMalloc(sizeof(xmlNotation));
2442  if (ret == NULL) {
2443  xmlVErrMemory(ctxt, "malloc failed");
2444  return(NULL);
2445  }
2446  memset(ret, 0, sizeof(xmlNotation));
2447 
2448  /*
2449  * fill the structure.
2450  */
2451  ret->name = xmlStrdup(name);
2452  if (SystemID != NULL)
2453  ret->SystemID = xmlStrdup(SystemID);
2454  if (PublicID != NULL)
2455  ret->PublicID = xmlStrdup(PublicID);
2456 
2457  /*
2458  * Validity Check:
2459  * Check the DTD for previous declarations of the ATTLIST
2460  */
2461  if (xmlHashAddEntry(table, name, ret)) {
2462 #ifdef LIBXML_VALID_ENABLED
2463  xmlErrValid(NULL, XML_DTD_NOTATION_REDEFINED,
2464  "xmlAddNotationDecl: %s already defined\n",
2465  (const char *) name);
2466 #endif /* LIBXML_VALID_ENABLED */
2468  return(NULL);
2469  }
2470  return(ret);
2471 }
struct _xmlDoc * doc
Definition: tree.h:415
void * notations
Definition: tree.h:418
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
XMLPUBFUN int XMLCALL xmlHashAddEntry(xmlHashTablePtr table, const xmlChar *name, void *userdata)
Definition: hash.c:394
static void xmlVErrMemory(xmlValidCtxtPtr ctxt, const char *extra)
Definition: valid.c:58
static void xmlFreeNotation(xmlNotationPtr nota)
Definition: valid.c:2383
smooth NULL
Definition: ftsmooth.c:416
Definition: dict.c:116
if(!(yy_init))
Definition: macro.lex.yy.c:714
int ret
xmlNotationTable * xmlNotationTablePtr
Definition: valid.h:118
XMLPUBFUN xmlHashTablePtr XMLCALL xmlHashCreateDict(int size, xmlDictPtr dict)
Definition: hash.c:215
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
Definition: name.c:38
xmlNotation * xmlNotationPtr
Definition: tree.h:193
#define memset(x, y, z)
Definition: compat.h:39
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:66

Referenced by xmlSAX2NotationDecl().

◆ xmlAddRef()

xmlRefPtr xmlAddRef ( xmlValidCtxtPtr  ctxt,
xmlDocPtr  doc,
const xmlChar value,
xmlAttrPtr  attr 
)

xmlAddRef: @ctxt: the validation context @doc: pointer to the document @value: the value name @attr: the attribute holding the Ref

Register a new ref declaration

Returns NULL if not, otherwise the new xmlRefPtr

Definition at line 2973 of file valid.c.

2974  {
2975  xmlRefPtr ret;
2977  xmlListPtr ref_list;
2978 
2979  if (doc == NULL) {
2980  return(NULL);
2981  }
2982  if (value == NULL) {
2983  return(NULL);
2984  }
2985  if (attr == NULL) {
2986  return(NULL);
2987  }
2988 
2989  /*
2990  * Create the Ref table if needed.
2991  */
2992  table = (xmlRefTablePtr) doc->refs;
2993  if (table == NULL) {
2994  doc->refs = table = xmlHashCreateDict(0, doc->dict);
2995  }
2996  if (table == NULL) {
2997  xmlVErrMemory(ctxt,
2998  "xmlAddRef: Table creation failed!\n");
2999  return(NULL);
3000  }
3001 
3002  ret = (xmlRefPtr) xmlMalloc(sizeof(xmlRef));
3003  if (ret == NULL) {
3004  xmlVErrMemory(ctxt, "malloc failed");
3005  return(NULL);
3006  }
3007 
3008  /*
3009  * fill the structure.
3010  */
3011  ret->value = xmlStrdup(value);
3012  if ((ctxt != NULL) && (ctxt->vstateNr != 0)) {
3013  /*
3014  * Operating in streaming mode, attr is gonna disappear
3015  */
3016  ret->name = xmlStrdup(attr->name);
3017  ret->attr = NULL;
3018  } else {
3019  ret->name = NULL;
3020  ret->attr = attr;
3021  }
3022  ret->lineno = xmlGetLineNo(attr->parent);
3023 
3024  /* To add a reference :-
3025  * References are maintained as a list of references,
3026  * Lookup the entry, if no entry create new nodelist
3027  * Add the owning node to the NodeList
3028  * Return the ref
3029  */
3030 
3031  if (NULL == (ref_list = xmlHashLookup(table, value))) {
3032  if (NULL == (ref_list = xmlListCreate(xmlFreeRef, xmlDummyCompare))) {
3033  xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
3034  "xmlAddRef: Reference list creation failed!\n",
3035  NULL);
3036  goto failed;
3037  }
3038  if (xmlHashAddEntry(table, value, ref_list) < 0) {
3039  xmlListDelete(ref_list);
3040  xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
3041  "xmlAddRef: Reference list insertion failed!\n",
3042  NULL);
3043  goto failed;
3044  }
3045  }
3046  if (xmlListAppend(ref_list, ret) != 0) {
3047  xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
3048  "xmlAddRef: Reference list insertion failed!\n",
3049  NULL);
3050  goto failed;
3051  }
3052  return(ret);
3053 failed:
3054  if (ret != NULL) {
3055  if (ret->value != NULL)
3056  xmlFree((char *)ret->value);
3057  if (ret->name != NULL)
3058  xmlFree((char *)ret->name);
3059  xmlFree(ret);
3060  }
3061  return(NULL);
3062 }
XMLPUBFUN xmlListPtr XMLCALL xmlListCreate(xmlListDeallocator deallocator, xmlListDataCompare compare)
Definition: list.c:188
xmlRef * xmlRefPtr
Definition: tree.h:473
XMLPUBFUN int XMLCALL xmlListAppend(xmlListPtr l, void *data)
Definition: list.c:305
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
XMLPUBFUN int XMLCALL xmlHashAddEntry(xmlHashTablePtr table, const xmlChar *name, void *userdata)
Definition: hash.c:394
static void xmlVErrMemory(xmlValidCtxtPtr ctxt, const char *extra)
Definition: valid.c:58
void * refs
Definition: tree.h:576
Definition: tree.h:474
smooth NULL
Definition: ftsmooth.c:416
XMLPUBFUN long XMLCALL xmlGetLineNo(const xmlNode *node)
if(!(yy_init))
Definition: macro.lex.yy.c:714
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
Definition: cookie.c:201
int ret
__u8 attr
Definition: mkdosfs.c:359
static int xmlDummyCompare(const void *data0 ATTRIBUTE_UNUSED, const void *data1 ATTRIBUTE_UNUSED)
Definition: valid.c:2955
Definition: list.c:38
XMLPUBFUN xmlHashTablePtr XMLCALL xmlHashCreateDict(int size, xmlDictPtr dict)
Definition: hash.c:215
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
xmlRefTable * xmlRefTablePtr
Definition: valid.h:150
WCHAR * name
Definition: cookie.c:203
XMLPUBFUN void *XMLCALL xmlHashLookup(xmlHashTablePtr table, const xmlChar *name)
Definition: hash.c:466
XMLPUBFUN void XMLCALL xmlListDelete(xmlListPtr l)
Definition: list.c:333
static void xmlFreeRef(xmlLinkPtr lk)
Definition: valid.c:2903
struct _xmlDict * dict
Definition: tree.h:580
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:66
int vstateNr
Definition: valid.h:99

Referenced by xmlSAX2AttributeNs().

◆ xmlCopyDocElementContent()

xmlElementContentPtr xmlCopyDocElementContent ( xmlDocPtr  doc,
xmlElementContentPtr  cur 
)

xmlCopyDocElementContent: @doc: the document owning the element declaration @cur: An element content pointer.

Build a copy of an element content description.

Returns the new xmlElementContentPtr or NULL in case of error.

Definition at line 1008 of file valid.c.

1008  {
1009  xmlElementContentPtr ret = NULL, prev = NULL, tmp;
1010  xmlDictPtr dict = NULL;
1011 
1012  if (cur == NULL) return(NULL);
1013 
1014  if (doc != NULL)
1015  dict = doc->dict;
1016 
1018  if (ret == NULL) {
1019  xmlVErrMemory(NULL, "malloc failed");
1020  return(NULL);
1021  }
1022  memset(ret, 0, sizeof(xmlElementContent));
1023  ret->type = cur->type;
1024  ret->ocur = cur->ocur;
1025  if (cur->name != NULL) {
1026  if (dict)
1027  ret->name = xmlDictLookup(dict, cur->name, -1);
1028  else
1029  ret->name = xmlStrdup(cur->name);
1030  }
1031 
1032  if (cur->prefix != NULL) {
1033  if (dict)
1034  ret->prefix = xmlDictLookup(dict, cur->prefix, -1);
1035  else
1036  ret->prefix = xmlStrdup(cur->prefix);
1037  }
1038  if (cur->c1 != NULL)
1039  ret->c1 = xmlCopyDocElementContent(doc, cur->c1);
1040  if (ret->c1 != NULL)
1041  ret->c1->parent = ret;
1042  if (cur->c2 != NULL) {
1043  prev = ret;
1044  cur = cur->c2;
1045  while (cur != NULL) {
1047  if (tmp == NULL) {
1048  xmlVErrMemory(NULL, "malloc failed");
1049  return(ret);
1050  }
1051  memset(tmp, 0, sizeof(xmlElementContent));
1052  tmp->type = cur->type;
1053  tmp->ocur = cur->ocur;
1054  prev->c2 = tmp;
1055  if (cur->name != NULL) {
1056  if (dict)
1057  tmp->name = xmlDictLookup(dict, cur->name, -1);
1058  else
1059  tmp->name = xmlStrdup(cur->name);
1060  }
1061 
1062  if (cur->prefix != NULL) {
1063  if (dict)
1064  tmp->prefix = xmlDictLookup(dict, cur->prefix, -1);
1065  else
1066  tmp->prefix = xmlStrdup(cur->prefix);
1067  }
1068  if (cur->c1 != NULL)
1069  tmp->c1 = xmlCopyDocElementContent(doc,cur->c1);
1070  if (tmp->c1 != NULL)
1071  tmp->c1->parent = ret;
1072  prev = tmp;
1073  cur = cur->c2;
1074  }
1075  }
1076  return(ret);
1077 }
struct _xmlElementContent * c2
Definition: tree.h:311
struct _xmlElementContent * c1
Definition: tree.h:310
xmlElementContentOccur ocur
Definition: tree.h:308
static void xmlVErrMemory(xmlValidCtxtPtr ctxt, const char *extra)
Definition: valid.c:58
smooth NULL
Definition: ftsmooth.c:416
Definition: dict.c:116
const xmlChar * prefix
Definition: tree.h:313
XMLPUBFUN const xmlChar *XMLCALL xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:865
const xmlChar * name
Definition: tree.h:309
int ret
xmlElementContentType type
Definition: tree.h:307
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
xmlElementContentPtr xmlCopyDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur)
Definition: valid.c:1008
#define memset(x, y, z)
Definition: compat.h:39
struct _xmlDict * dict
Definition: tree.h:580
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:66
xmlElementContent * xmlElementContentPtr
Definition: tree.h:305

Referenced by xmlAddElementDecl(), and xmlCopyElementContent().

◆ xmlCopyElementContent()

xmlElementContentPtr xmlCopyElementContent ( xmlElementContentPtr  cur)

xmlCopyElementContent: @cur: An element content pointer.

Build a copy of an element content description. Deprecated, use xmlCopyDocElementContent instead

Returns the new xmlElementContentPtr or NULL in case of error.

Definition at line 1089 of file valid.c.

1089  {
1090  return(xmlCopyDocElementContent(NULL, cur));
1091 }
smooth NULL
Definition: ftsmooth.c:416
xmlElementContentPtr xmlCopyDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur)
Definition: valid.c:1008

◆ xmlCreateEnumeration()

xmlEnumerationPtr xmlCreateEnumeration ( const xmlChar name)

Definition at line 1809 of file valid.c.

1809  {
1811 
1813  if (ret == NULL) {
1814  xmlVErrMemory(NULL, "malloc failed");
1815  return(NULL);
1816  }
1817  memset(ret, 0, sizeof(xmlEnumeration));
1818 
1819  if (name != NULL)
1820  ret->name = xmlStrdup(name);
1821  return(ret);
1822 }
static void xmlVErrMemory(xmlValidCtxtPtr ctxt, const char *extra)
Definition: valid.c:58
xmlEnumeration * xmlEnumerationPtr
Definition: tree.h:239
smooth NULL
Definition: ftsmooth.c:416
int ret
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
Definition: name.c:38
#define memset(x, y, z)
Definition: compat.h:39
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:66

Referenced by xmlParseEnumerationType(), and xmlParseNotationType().

◆ xmlDummyCompare()

static int xmlDummyCompare ( const void *data0  ATTRIBUTE_UNUSED,
const void *data1  ATTRIBUTE_UNUSED 
)
static

xmlDummyCompare @data0: Value supplied by the user @data1: Value supplied by the user

Do nothing, return 0. Used to create unordered lists.

Definition at line 2955 of file valid.c.

2957 {
2958  return (0);
2959 }

Referenced by xmlAddRef().

◆ xmlFreeAttribute()

static void xmlFreeAttribute ( xmlAttributePtr  attr)
static

xmlFreeAttribute: @elem: An attribute

Deallocate the memory used by an attribute definition

Definition at line 1928 of file valid.c.

1928  {
1929  xmlDictPtr dict;
1930 
1931  if (attr == NULL) return;
1932  if (attr->doc != NULL)
1933  dict = attr->doc->dict;
1934  else
1935  dict = NULL;
1937  if (attr->tree != NULL)
1938  xmlFreeEnumeration(attr->tree);
1939  if (dict) {
1940  if ((attr->elem != NULL) && (!xmlDictOwns(dict, attr->elem)))
1941  xmlFree((xmlChar *) attr->elem);
1942  if ((attr->name != NULL) && (!xmlDictOwns(dict, attr->name)))
1943  xmlFree((xmlChar *) attr->name);
1944  if ((attr->prefix != NULL) && (!xmlDictOwns(dict, attr->prefix)))
1945  xmlFree((xmlChar *) attr->prefix);
1946  if ((attr->defaultValue != NULL) &&
1947  (!xmlDictOwns(dict, attr->defaultValue)))
1948  xmlFree((xmlChar *) attr->defaultValue);
1949  } else {
1950  if (attr->elem != NULL)
1951  xmlFree((xmlChar *) attr->elem);
1952  if (attr->name != NULL)
1953  xmlFree((xmlChar *) attr->name);
1954  if (attr->defaultValue != NULL)
1955  xmlFree((xmlChar *) attr->defaultValue);
1956  if (attr->prefix != NULL)
1957  xmlFree((xmlChar *) attr->prefix);
1958  }
1959  xmlFree(attr);
1960 }
void xmlFreeEnumeration(xmlEnumerationPtr cur)
Definition: valid.c:1831
smooth NULL
Definition: ftsmooth.c:416
Definition: dict.c:116
XMLPUBFUN void XMLCALL xmlUnlinkNode(xmlNodePtr cur)
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
Definition: cookie.c:201
Definition: tree.h:489
unsigned char xmlChar
Definition: xmlstring.h:28
XMLPUBFUN int XMLCALL xmlDictOwns(xmlDictPtr dict, const xmlChar *str)
Definition: dict.c:1218
WCHAR * name
Definition: cookie.c:203

Referenced by xmlAddAttributeDecl(), and xmlFreeAttributeTableEntry().

◆ xmlFreeAttributeTable()

void xmlFreeAttributeTable ( xmlAttributeTablePtr  table)

xmlFreeAttributeTable: @table: An attribute table

Deallocate the memory used by an entities hash table.

Definition at line 2207 of file valid.c.

2207  {
2209 }
XMLPUBFUN void XMLCALL xmlHashFree(xmlHashTablePtr table, xmlHashDeallocator f)
Definition: hash.c:327
static void xmlFreeAttributeTableEntry(void *attr, const xmlChar *name ATTRIBUTE_UNUSED)
Definition: valid.c:2196

◆ xmlFreeAttributeTableEntry()

static void xmlFreeAttributeTableEntry ( void attr,
const xmlChar *name  ATTRIBUTE_UNUSED 
)
static

Definition at line 2196 of file valid.c.

2196  {
2198 }
Definition: cookie.c:201
static void xmlFreeAttribute(xmlAttributePtr attr)
Definition: valid.c:1928

Referenced by xmlFreeAttributeTable().

◆ xmlFreeDocElementContent()

void xmlFreeDocElementContent ( xmlDocPtr  doc,
xmlElementContentPtr  cur 
)

xmlFreeDocElementContent: @doc: the document owning the element declaration @cur: the element content tree to free

Free an element content structure. The whole subtree is removed.

Definition at line 1101 of file valid.c.

1101  {
1102  xmlDictPtr dict = NULL;
1103  size_t depth = 0;
1104 
1105  if (cur == NULL)
1106  return;
1107  if (doc != NULL)
1108  dict = doc->dict;
1109 
1110  while (1) {
1112 
1113  while ((cur->c1 != NULL) || (cur->c2 != NULL)) {
1114  cur = (cur->c1 != NULL) ? cur->c1 : cur->c2;
1115  depth += 1;
1116  }
1117 
1118  switch (cur->type) {
1123  break;
1124  default:
1125  xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
1126  "Internal: ELEMENT content corrupted invalid type\n",
1127  NULL);
1128  return;
1129  }
1130  if (dict) {
1131  if ((cur->name != NULL) && (!xmlDictOwns(dict, cur->name)))
1132  xmlFree((xmlChar *) cur->name);
1133  if ((cur->prefix != NULL) && (!xmlDictOwns(dict, cur->prefix)))
1134  xmlFree((xmlChar *) cur->prefix);
1135  } else {
1136  if (cur->name != NULL) xmlFree((xmlChar *) cur->name);
1137  if (cur->prefix != NULL) xmlFree((xmlChar *) cur->prefix);
1138  }
1139  parent = cur->parent;
1140  if ((depth == 0) || (parent == NULL)) {
1141  xmlFree(cur);
1142  break;
1143  }
1144  if (cur == parent->c1)
1145  parent->c1 = NULL;
1146  else
1147  parent->c2 = NULL;
1148  xmlFree(cur);
1149 
1150  if (parent->c2 != NULL) {
1151  cur = parent->c2;
1152  } else {
1153  depth -= 1;
1154  cur = parent;
1155  }
1156  }
1157 }
struct _xmlElementContent * c2
Definition: tree.h:311
struct _xmlElementContent * c1
Definition: tree.h:310
struct _xmlElementContent * parent
Definition: tree.h:312
smooth NULL
Definition: ftsmooth.c:416
Definition: dict.c:116
const xmlChar * prefix
Definition: tree.h:313
r parent
Definition: btrfs.c:2944
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
const xmlChar * name
Definition: tree.h:309
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
unsigned char xmlChar
Definition: xmlstring.h:28
xmlElementContentType type
Definition: tree.h:307
XMLPUBFUN int XMLCALL xmlDictOwns(xmlDictPtr dict, const xmlChar *str)
Definition: dict.c:1218
struct _xmlDict * dict
Definition: tree.h:580

Referenced by xmlFreeElement(), xmlFreeElementContent(), xmlParseElementChildrenContentDeclPriv(), xmlParseElementDecl(), and xmlParseElementMixedContentDecl().

◆ xmlFreeElement()

static void xmlFreeElement ( xmlElementPtr  elem)
static

xmlFreeElement: @elem: An element

Deallocate the memory used by an element definition

Definition at line 1401 of file valid.c.

1401  {
1402  if (elem == NULL) return;
1404  xmlFreeDocElementContent(elem->doc, elem->content);
1405  if (elem->name != NULL)
1406  xmlFree((xmlChar *) elem->name);
1407  if (elem->prefix != NULL)
1408  xmlFree((xmlChar *) elem->prefix);
1409 #ifdef LIBXML_REGEXP_ENABLED
1410  if (elem->contModel != NULL)
1411  xmlRegFreeRegexp(elem->contModel);
1412 #endif
1413  xmlFree(elem);
1414 }
void xmlFreeDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur)
Definition: valid.c:1101
static size_t elem
Definition: string.c:68
smooth NULL
Definition: ftsmooth.c:416
XMLPUBFUN void XMLCALL xmlUnlinkNode(xmlNodePtr cur)
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
Definition: tree.h:489
unsigned char xmlChar
Definition: xmlstring.h:28

Referenced by xmlAddElementDecl(), and xmlFreeElementTableEntry().

◆ xmlFreeElementContent()

void xmlFreeElementContent ( xmlElementContentPtr  cur)

xmlFreeElementContent: @cur: the element content tree to free

Free an element content structure. The whole subtree is removed. Deprecated, use xmlFreeDocElementContent instead

Definition at line 1167 of file valid.c.

1167  {
1169 }
void xmlFreeDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur)
Definition: valid.c:1101
smooth NULL
Definition: ftsmooth.c:416

◆ xmlFreeElementTable()

void xmlFreeElementTable ( xmlElementTablePtr  table)

xmlFreeElementTable: @table: An element table

Deallocate the memory used by an element hash table.

Definition at line 1655 of file valid.c.

1655  {
1657 }
XMLPUBFUN void XMLCALL xmlHashFree(xmlHashTablePtr table, xmlHashDeallocator f)
Definition: hash.c:327
static void xmlFreeElementTableEntry(void *elem, const xmlChar *name ATTRIBUTE_UNUSED)
Definition: valid.c:1644

◆ xmlFreeElementTableEntry()

static void xmlFreeElementTableEntry ( void elem,
const xmlChar *name  ATTRIBUTE_UNUSED 
)
static

Definition at line 1644 of file valid.c.

1644  {
1646 }
static void xmlFreeElement(xmlElementPtr elem)
Definition: valid.c:1401
static size_t elem
Definition: string.c:68

Referenced by xmlFreeElementTable().

◆ xmlFreeEnumeration()

void xmlFreeEnumeration ( xmlEnumerationPtr  cur)

xmlFreeEnumeration: @cur: the tree to free.

free an enumeration attribute node (recursive).

Definition at line 1831 of file valid.c.

1831  {
1832  if (cur == NULL) return;
1833 
1834  if (cur->next != NULL) xmlFreeEnumeration(cur->next);
1835 
1836  if (cur->name != NULL) xmlFree((xmlChar *) cur->name);
1837  xmlFree(cur);
1838 }
void xmlFreeEnumeration(xmlEnumerationPtr cur)
Definition: valid.c:1831
const xmlChar * name
Definition: tree.h:242
smooth NULL
Definition: ftsmooth.c:416
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
unsigned char xmlChar
Definition: xmlstring.h:28
struct _xmlEnumeration * next
Definition: tree.h:241

Referenced by attributeDeclDebug(), xmlAddAttributeDecl(), xmlFreeAttribute(), xmlParseAttributeListDecl(), xmlParseEnumerationType(), xmlParseNotationType(), and xmlSAX2AttributeDecl().

◆ xmlFreeID()

static void xmlFreeID ( xmlIDPtr  id)
static

xmlFreeID: @not: A id

Deallocate the memory used by an id definition

Definition at line 2617 of file valid.c.

2617  {
2618  xmlDictPtr dict = NULL;
2619 
2620  if (id == NULL) return;
2621 
2622  if (id->doc != NULL)
2623  dict = id->doc->dict;
2624 
2625  if (id->value != NULL)
2626  DICT_FREE(id->value)
2627  if (id->name != NULL)
2628  DICT_FREE(id->name)
2629  xmlFree(id);
2630 }
struct _xmlDictEntry * dict
Definition: dict.c:119
smooth NULL
Definition: ftsmooth.c:416
Definition: dict.c:116
if(!(yy_init))
Definition: macro.lex.yy.c:714
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
#define DICT_FREE(str)
Definition: valid.c:2605
Definition: name.c:38
GLenum GLuint id
Definition: glext.h:5579

Referenced by xmlAddID(), and xmlFreeIDTableEntry().

◆ xmlFreeIDTable()

void xmlFreeIDTable ( xmlIDTablePtr  table)

xmlFreeIDTable: @table: An id table

Deallocate the memory used by an ID hash table.

Definition at line 2729 of file valid.c.

2729  {
2731 }
XMLPUBFUN void XMLCALL xmlHashFree(xmlHashTablePtr table, xmlHashDeallocator f)
Definition: hash.c:327
static void xmlFreeIDTableEntry(void *id, const xmlChar *name ATTRIBUTE_UNUSED)
Definition: valid.c:2718

Referenced by xsltReleaseRVT().

◆ xmlFreeIDTableEntry()

static void xmlFreeIDTableEntry ( void id,
const xmlChar *name  ATTRIBUTE_UNUSED 
)
static

Definition at line 2718 of file valid.c.

2718  {
2719  xmlFreeID((xmlIDPtr) id);
2720 }
static void xmlFreeID(xmlIDPtr id)
Definition: valid.c:2617
Definition: tree.h:457

Referenced by xmlFreeIDTable(), and xmlRemoveID().

◆ xmlFreeNotation()

static void xmlFreeNotation ( xmlNotationPtr  nota)
static

xmlFreeNotation: @not: A notation

Deallocate the memory used by an notation definition

Definition at line 2383 of file valid.c.

2383  {
2384  if (nota == NULL) return;
2385  if (nota->name != NULL)
2386  xmlFree((xmlChar *) nota->name);
2387  if (nota->PublicID != NULL)
2388  xmlFree((xmlChar *) nota->PublicID);
2389  if (nota->SystemID != NULL)
2390  xmlFree((xmlChar *) nota->SystemID);
2391  xmlFree(nota);
2392 }
const xmlChar * PublicID
Definition: tree.h:196
smooth NULL
Definition: ftsmooth.c:416
const xmlChar * SystemID
Definition: tree.h:197
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
unsigned char xmlChar
Definition: xmlstring.h:28
const xmlChar * name
Definition: tree.h:195

Referenced by xmlAddNotationDecl(), and xmlFreeNotationTableEntry().

◆ xmlFreeNotationTable()

void xmlFreeNotationTable ( xmlNotationTablePtr  table)

xmlFreeNotationTable: @table: An notation table

Deallocate the memory used by an entities hash table.

Definition at line 2485 of file valid.c.

2485  {
2487 }
XMLPUBFUN void XMLCALL xmlHashFree(xmlHashTablePtr table, xmlHashDeallocator f)
Definition: hash.c:327
static void xmlFreeNotationTableEntry(void *nota, const xmlChar *name ATTRIBUTE_UNUSED)
Definition: valid.c:2474

◆ xmlFreeNotationTableEntry()

static void xmlFreeNotationTableEntry ( void nota,
const xmlChar *name  ATTRIBUTE_UNUSED 
)
static

Definition at line 2474 of file valid.c.

2474  {
2476 }
static void xmlFreeNotation(xmlNotationPtr nota)
Definition: valid.c:2383

Referenced by xmlFreeNotationTable().

◆ xmlFreeRef()

static void xmlFreeRef ( xmlLinkPtr  lk)
static

xmlFreeRef: @lk: A list link

Deallocate the memory used by a ref definition

Definition at line 2903 of file valid.c.

2903  {
2905  if (ref == NULL) return;
2906  if (ref->value != NULL)
2907  xmlFree((xmlChar *)ref->value);
2908  if (ref->name != NULL)
2909  xmlFree((xmlChar *)ref->name);
2910  xmlFree(ref);
2911 }
xmlRef * xmlRefPtr
Definition: tree.h:473
Definition: send.c:48
Definition: tree.h:474
char name[1]
Definition: send.c:52
smooth NULL
Definition: ftsmooth.c:416
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
unsigned char xmlChar
Definition: xmlstring.h:28
XMLPUBFUN void *XMLCALL xmlLinkGetData(xmlLinkPtr lk)
Definition: list.c:604

Referenced by xmlAddRef().

◆ xmlFreeRefTable()

void xmlFreeRefTable ( xmlRefTablePtr  table)

xmlFreeRefTable: @table: An ref table

Deallocate the memory used by an Ref hash table.

Definition at line 3071 of file valid.c.

3071  {
3073 }
XMLPUBFUN void XMLCALL xmlHashFree(xmlHashTablePtr table, xmlHashDeallocator f)
Definition: hash.c:327
static void xmlFreeRefTableEntry(void *payload, const xmlChar *name ATTRIBUTE_UNUSED)
Definition: valid.c:2920

Referenced by xsltReleaseRVT().

◆ xmlFreeRefTableEntry()

static void xmlFreeRefTableEntry ( void payload,
const xmlChar *name  ATTRIBUTE_UNUSED 
)
static

xmlFreeRefTableEntry: @list_ref: A list of references.

Deallocate the memory used by a list of references

Definition at line 2920 of file valid.c.

2920  {
2921  xmlListPtr list_ref = (xmlListPtr) payload;
2922  if (list_ref == NULL) return;
2923  xmlListDelete(list_ref);
2924 }
smooth NULL
Definition: ftsmooth.c:416
xmlList * xmlListPtr
Definition: list.h:24
Definition: list.c:38
XMLPUBFUN void XMLCALL xmlListDelete(xmlListPtr l)
Definition: list.c:333

Referenced by xmlFreeRefTable(), and xmlRemoveRef().

◆ xmlGetDtdAttrDesc()

xmlAttributePtr xmlGetDtdAttrDesc ( xmlDtdPtr  dtd,
const xmlChar elem,
const xmlChar name 
)

Definition at line 3341 of file valid.c.

3341  {
3343  xmlAttributePtr cur;
3344  xmlChar *uqname = NULL, *prefix = NULL;
3345 
3346  if (dtd == NULL) return(NULL);
3347  if (dtd->attributes == NULL) return(NULL);
3348 
3350  if (table == NULL)
3351  return(NULL);
3352 
3353  uqname = xmlSplitQName2(name, &prefix);
3354 
3355  if (uqname != NULL) {
3356  cur = xmlHashLookup3(table, uqname, prefix, elem);
3357  if (prefix != NULL) xmlFree(prefix);
3358  if (uqname != NULL) xmlFree(uqname);
3359  } else
3360  cur = xmlHashLookup3(table, name, NULL, elem);
3361  return(cur);
3362 }
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
void * attributes
Definition: tree.h:420
static size_t elem
Definition: string.c:68
smooth NULL
Definition: ftsmooth.c:416
xmlAttributeTable * xmlAttributeTablePtr
Definition: valid.h:134
XMLPUBFUN void *XMLCALL xmlHashLookup3(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, const xmlChar *name3)
Definition: hash.c:774
if(!(yy_init))
Definition: macro.lex.yy.c:714
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
unsigned char xmlChar
Definition: xmlstring.h:28
Definition: name.c:38
XMLPUBFUN xmlChar *XMLCALL xmlSplitQName2(const xmlChar *name, xmlChar **prefix)

Referenced by xmlIsID(), xmlIsRef(), xsltGetCNsProp(), and xsltGetNsProp().

◆ xmlGetDtdElementDesc()

xmlElementPtr xmlGetDtdElementDesc ( xmlDtdPtr  dtd,
const xmlChar name 
)

Definition at line 3219 of file valid.c.

3219  {
3221  xmlElementPtr cur;
3222  xmlChar *uqname = NULL, *prefix = NULL;
3223 
3224  if ((dtd == NULL) || (name == NULL)) return(NULL);
3225  if (dtd->elements == NULL)
3226  return(NULL);
3228 
3229  uqname = xmlSplitQName2(name, &prefix);
3230  if (uqname != NULL)
3231  name = uqname;
3232  cur = xmlHashLookup2(table, name, prefix);
3233  if (prefix != NULL) xmlFree(prefix);
3234  if (uqname != NULL) xmlFree(uqname);
3235  return(cur);
3236 }
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
xmlElementTable * xmlElementTablePtr
Definition: valid.h:126
XMLPUBFUN void *XMLCALL xmlHashLookup2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2)
Definition: hash.c:481
smooth NULL
Definition: ftsmooth.c:416
void * elements
Definition: tree.h:419
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
unsigned char xmlChar
Definition: xmlstring.h:28
Definition: name.c:38
XMLPUBFUN xmlChar *XMLCALL xmlSplitQName2(const xmlChar *name, xmlChar **prefix)

Referenced by xmlIsMixedElement().

◆ xmlGetDtdElementDesc2()

static xmlElementPtr xmlGetDtdElementDesc2 ( xmlDtdPtr  dtd,
const xmlChar name,
int  create 
)
static

Definition at line 3249 of file valid.c.

3249  {
3251  xmlElementPtr cur;
3252  xmlChar *uqname = NULL, *prefix = NULL;
3253 
3254  if (dtd == NULL) return(NULL);
3255  if (dtd->elements == NULL) {
3256  xmlDictPtr dict = NULL;
3257 
3258  if (dtd->doc != NULL)
3259  dict = dtd->doc->dict;
3260 
3261  if (!create)
3262  return(NULL);
3263  /*
3264  * Create the Element table if needed.
3265  */
3267  if (table == NULL) {
3268  table = xmlHashCreateDict(0, dict);
3269  dtd->elements = (void *) table;
3270  }
3271  if (table == NULL) {
3272  xmlVErrMemory(NULL, "element table allocation failed");
3273  return(NULL);
3274  }
3275  }
3277 
3278  uqname = xmlSplitQName2(name, &prefix);
3279  if (uqname != NULL)
3280  name = uqname;
3281  cur = xmlHashLookup2(table, name, prefix);
3282  if ((cur == NULL) && (create)) {
3283  cur = (xmlElementPtr) xmlMalloc(sizeof(xmlElement));
3284  if (cur == NULL) {
3285  xmlVErrMemory(NULL, "malloc failed");
3286  return(NULL);
3287  }
3288  memset(cur, 0, sizeof(xmlElement));
3289  cur->type = XML_ELEMENT_DECL;
3290 
3291  /*
3292  * fill the structure.
3293  */
3294  cur->name = xmlStrdup(name);
3295  cur->prefix = xmlStrdup(prefix);
3297 
3298  xmlHashAddEntry2(table, name, prefix, cur);
3299  }
3300  if (prefix != NULL) xmlFree(prefix);
3301  if (uqname != NULL) xmlFree(uqname);
3302  return(cur);
3303 }
struct _xmlDoc * doc
Definition: tree.h:415
XMLPUBFUN int XMLCALL xmlHashAddEntry2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, void *userdata)
Definition: hash.c:411
xmlElementTypeVal etype
Definition: tree.h:357
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
static void xmlVErrMemory(xmlValidCtxtPtr ctxt, const char *extra)
Definition: valid.c:58
const xmlChar * prefix
Definition: tree.h:360
xmlElementTable * xmlElementTablePtr
Definition: valid.h:126
XMLPUBFUN void *XMLCALL xmlHashLookup2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2)
Definition: hash.c:481
xmlElementType type
Definition: tree.h:348
smooth NULL
Definition: ftsmooth.c:416
Definition: dict.c:116
const xmlChar * name
Definition: tree.h:349
if(!(yy_init))
Definition: macro.lex.yy.c:714
xmlElement * xmlElementPtr
Definition: tree.h:345
void * elements
Definition: tree.h:419
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
unsigned char xmlChar
Definition: xmlstring.h:28
XMLPUBFUN xmlHashTablePtr XMLCALL xmlHashCreateDict(int size, xmlDictPtr dict)
Definition: hash.c:215
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
Definition: name.c:38
#define memset(x, y, z)
Definition: compat.h:39
static const struct access_res create[16]
Definition: package.c:7720
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:66
XMLPUBFUN xmlChar *XMLCALL xmlSplitQName2(const xmlChar *name, xmlChar **prefix)

Referenced by xmlAddAttributeDecl().

◆ xmlGetDtdNotationDesc()

xmlNotationPtr xmlGetDtdNotationDesc ( xmlDtdPtr  dtd,
const xmlChar name 
)

Definition at line 3400 of file valid.c.

3400  {
3402 
3403  if (dtd == NULL) return(NULL);
3404  if (dtd->notations == NULL) return(NULL);
3406 
3407  return(xmlHashLookup(table, name));
3408 }
void * notations
Definition: tree.h:418
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
smooth NULL
Definition: ftsmooth.c:416
xmlNotationTable * xmlNotationTablePtr
Definition: valid.h:118
Definition: name.c:38
XMLPUBFUN void *XMLCALL xmlHashLookup(xmlHashTablePtr table, const xmlChar *name)
Definition: hash.c:466

◆ xmlGetDtdQAttrDesc()

xmlAttributePtr xmlGetDtdQAttrDesc ( xmlDtdPtr  dtd,
const xmlChar elem,
const xmlChar name,
const xmlChar prefix 
)

Definition at line 3378 of file valid.c.

3379  {
3381 
3382  if (dtd == NULL) return(NULL);
3383  if (dtd->attributes == NULL) return(NULL);
3385 
3386  return(xmlHashLookup3(table, name, prefix, elem));
3387 }
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
void * attributes
Definition: tree.h:420
static size_t elem
Definition: string.c:68
smooth NULL
Definition: ftsmooth.c:416
xmlAttributeTable * xmlAttributeTablePtr
Definition: valid.h:134
XMLPUBFUN void *XMLCALL xmlHashLookup3(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, const xmlChar *name3)
Definition: hash.c:774
Definition: name.c:38

◆ xmlGetDtdQElementDesc()

xmlElementPtr xmlGetDtdQElementDesc ( xmlDtdPtr  dtd,
const xmlChar name,
const xmlChar prefix 
)

Definition at line 3317 of file valid.c.

3318  {
3320 
3321  if (dtd == NULL) return(NULL);
3322  if (dtd->elements == NULL) return(NULL);
3324 
3325  return(xmlHashLookup2(table, name, prefix));
3326 }
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
xmlElementTable * xmlElementTablePtr
Definition: valid.h:126
XMLPUBFUN void *XMLCALL xmlHashLookup2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2)
Definition: hash.c:481
smooth NULL
Definition: ftsmooth.c:416
void * elements
Definition: tree.h:419
Definition: name.c:38

◆ xmlGetID()

xmlAttrPtr xmlGetID ( xmlDocPtr  doc,
const xmlChar ID 
)

xmlGetID: @doc: pointer to the document @ID: the ID value

Search the attribute declaring the given ID

Returns NULL if not found, otherwise the xmlAttrPtr defining the ID

Definition at line 2846 of file valid.c.

2846  {
2848  xmlIDPtr id;
2849 
2850  if (doc == NULL) {
2851  return(NULL);
2852  }
2853 
2854  if (ID == NULL) {
2855  return(NULL);
2856  }
2857 
2858  table = (xmlIDTablePtr) doc->ids;
2859  if (table == NULL)
2860  return(NULL);
2861 
2862  id = xmlHashLookup(table, ID);
2863  if (id == NULL)
2864  return(NULL);
2865  if (id->attr == NULL) {
2866  /*
2867  * We are operating on a stream, return a well known reference
2868  * since the attribute node doesn't exist anymore
2869  */
2870  return((xmlAttrPtr) doc);
2871  }
2872  return(id->attr);
2873 }
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
smooth NULL
Definition: ftsmooth.c:416
void * ids
Definition: tree.h:575
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define ID
Definition: ruserpass.c:36
xmlIDTable * xmlIDTablePtr
Definition: valid.h:142
Definition: tree.h:434
GLenum GLuint id
Definition: glext.h:5579
XMLPUBFUN void *XMLCALL xmlHashLookup(xmlHashTablePtr table, const xmlChar *name)
Definition: hash.c:466
Definition: tree.h:457

Referenced by xsltLoadStylesheetPI(), and xsltTestCompMatch().

◆ xmlGetRefs()

xmlListPtr xmlGetRefs ( xmlDocPtr  doc,
const xmlChar ID 
)

xmlGetRefs: @doc: pointer to the document @ID: the ID value

Find the set of references for the supplied ID.

Returns NULL if not found, otherwise node set for the ID.

Definition at line 3184 of file valid.c.

3184  {
3186 
3187  if (doc == NULL) {
3188  return(NULL);
3189  }
3190 
3191  if (ID == NULL) {
3192  return(NULL);
3193  }
3194 
3195  table = (xmlRefTablePtr) doc->refs;
3196  if (table == NULL)
3197  return(NULL);
3198 
3199  return (xmlHashLookup(table, ID));
3200 }
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
void * refs
Definition: tree.h:576
smooth NULL
Definition: ftsmooth.c:416
if(!(yy_init))
Definition: macro.lex.yy.c:714
#define ID
Definition: ruserpass.c:36
xmlRefTable * xmlRefTablePtr
Definition: valid.h:150
XMLPUBFUN void *XMLCALL xmlHashLookup(xmlHashTablePtr table, const xmlChar *name)
Definition: hash.c:466

◆ xmlIsID()

int xmlIsID ( xmlDocPtr  doc,
xmlNodePtr  elem,
xmlAttrPtr  attr 
)

xmlIsID: @doc: the document @elem: the element carrying the attribute @attr: the attribute

Determine whether an attribute is of type ID. In case we have DTD(s) then this is done if DTD loading has been requested. In the case of HTML documents parsed with the HTML parser, then ID detection is done systematically.

Returns 0 or 1 depending on the lookup result

Definition at line 2747 of file valid.c.

2747  {
2748  if ((attr == NULL) || (attr->name == NULL)) return(0);
2749  if ((attr->ns != NULL) && (attr->ns->prefix != NULL) &&
2750  (!strcmp((char *) attr->name, "id")) &&
2751  (!strcmp((char *) attr->ns->prefix, "xml")))
2752  return(1);
2753  if (doc == NULL) return(0);
2754  if ((doc->intSubset == NULL) && (doc->extSubset == NULL) &&
2755  (doc->type != XML_HTML_DOCUMENT_NODE)) {
2756  return(0);
2757  } else if (doc->type == XML_HTML_DOCUMENT_NODE) {
2758  if ((xmlStrEqual(BAD_CAST "id", attr->name)) ||
2759  ((xmlStrEqual(BAD_CAST "name", attr->name)) &&
2760  ((elem == NULL) || (xmlStrEqual(elem->name, BAD_CAST "a")))))
2761  return(1);
2762  return(0);
2763  } else if (elem == NULL) {
2764  return(0);
2765  } else {
2766  xmlAttributePtr attrDecl = NULL;
2767 
2768  xmlChar felem[50], fattr[50];
2769  xmlChar *fullelemname, *fullattrname;
2770 
2771  fullelemname = (elem->ns != NULL && elem->ns->prefix != NULL) ?
2772  xmlBuildQName(elem->name, elem->ns->prefix, felem, 50) :
2773  (xmlChar *)elem->name;
2774 
2775  fullattrname = (attr->ns != NULL && attr->ns->prefix != NULL) ?
2776  xmlBuildQName(attr->name, attr->ns->prefix, fattr, 50) :
2777  (xmlChar *)attr->name;
2778 
2779  if (fullelemname != NULL && fullattrname != NULL) {
2780  attrDecl = xmlGetDtdAttrDesc(doc->intSubset, fullelemname,
2781  fullattrname);
2782  if ((attrDecl == NULL) && (doc->extSubset != NULL))
2783  attrDecl = xmlGetDtdAttrDesc(doc->extSubset, fullelemname,
2784  fullattrname);
2785  }
2786 
2787  if ((fullattrname != fattr) && (fullattrname != attr->name))
2788  xmlFree(fullattrname);
2789  if ((fullelemname != felem) && (fullelemname != elem->name))
2790  xmlFree(fullelemname);
2791 
2792  if ((attrDecl != NULL) && (attrDecl->atype == XML_ATTRIBUTE_ID))
2793  return(1);
2794  }
2795  return(0);
2796 }
xmlElementType type
Definition: tree.h:553
XMLPUBFUN xmlChar *XMLCALL xmlBuildQName(const xmlChar *ncname, const xmlChar *prefix, xmlChar *memory, int len)
struct _xmlDtd * intSubset
Definition: tree.h:570
Definition: fatfs.h:133
static size_t elem
Definition: string.c:68
smooth NULL
Definition: ftsmooth.c:416
xmlAttributeType atype
Definition: tree.h:265
#define BAD_CAST
Definition: xmlstring.h:35
xmlAttributePtr xmlGetDtdAttrDesc(xmlDtdPtr dtd, const xmlChar *elem, const xmlChar *name)
Definition: valid.c:3341
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
Definition: cookie.c:201
unsigned char xmlChar
Definition: xmlstring.h:28
struct _xmlDtd * extSubset
Definition: tree.h:571
Definition: name.c:38
WCHAR * name
Definition: cookie.c:203
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:157

Referenced by xmlSAX2AttributeNs(), xsltAttribute(), and xsltAttrListTemplateProcess().

◆ xmlIsMixedElement()

int xmlIsMixedElement ( xmlDocPtr  doc,
const xmlChar name 
)

The public function calls related to validity checking.

Definition at line 3456 of file valid.c.

3456  {
3457  xmlElementPtr elemDecl;
3458 
3459  if ((doc == NULL) || (doc->intSubset == NULL)) return(-1);
3460 
3461  elemDecl = xmlGetDtdElementDesc(doc->intSubset, name);
3462  if ((elemDecl == NULL) && (doc->extSubset != NULL))
3463  elemDecl = xmlGetDtdElementDesc(doc->extSubset, name);
3464  if (elemDecl == NULL) return(-1);
3465  switch (elemDecl->etype) {
3467  return(-1);
3469  return(0);
3471  /*
3472  * return 1 for EMPTY since we want VC error to pop up
3473  * on <empty> </empty> for example
3474  */
3475  case XML_ELEMENT_TYPE_ANY:
3477  return(1);
3478  }
3479  return(1);
3480 }
struct _xmlDtd * intSubset
Definition: tree.h:570
xmlElementTypeVal etype
Definition: tree.h:357
xmlElementPtr xmlGetDtdElementDesc(xmlDtdPtr dtd, const xmlChar *name)
Definition: valid.c:3219
smooth NULL
Definition: ftsmooth.c:416
struct _xmlDtd * extSubset
Definition: tree.h:571
Definition: name.c:38

Referenced by areBlanks().

◆ xmlIsRef()

int xmlIsRef ( xmlDocPtr  doc,
xmlNodePtr  elem,
xmlAttrPtr  attr 
)

xmlIsRef: @doc: the document @elem: the element carrying the attribute @attr: the attribute

Determine whether an attribute is of type Ref. In case we have DTD(s) then this is simple, otherwise we use an heuristic: name Ref (upper or lowercase).

Returns 0 or 1 depending on the lookup result

Definition at line 3088 of file valid.c.

3088  {
3089  if (attr == NULL)
3090  return(0);
3091  if (doc == NULL) {
3092  doc = attr->doc;
3093  if (doc == NULL) return(0);
3094  }
3095 
3096  if ((doc->intSubset == NULL) && (doc->extSubset == NULL)) {
3097  return(0);
3098  } else if (doc->type == XML_HTML_DOCUMENT_NODE) {
3099  /* TODO @@@ */
3100  return(0);
3101  } else {
3102  xmlAttributePtr attrDecl;
3103 
3104  if (elem == NULL) return(0);
3105  attrDecl = xmlGetDtdAttrDesc(doc->intSubset, elem->name, attr->name);
3106  if ((attrDecl == NULL) && (doc->extSubset != NULL))
3107  attrDecl = xmlGetDtdAttrDesc(doc->extSubset,
3108  elem->name, attr->name);
3109 
3110  if ((attrDecl != NULL) &&
3111  (attrDecl->atype == XML_ATTRIBUTE_IDREF ||
3112  attrDecl->atype == XML_ATTRIBUTE_IDREFS))
3113  return(1);
3114  }
3115  return(0);
3116 }
xmlElementType type
Definition: tree.h:553
struct _xmlDtd * intSubset
Definition: tree.h:570
static size_t elem
Definition: string.c:68
smooth NULL
Definition: ftsmooth.c:416
xmlAttributeType atype
Definition: tree.h:265
xmlAttributePtr xmlGetDtdAttrDesc(xmlDtdPtr dtd, const xmlChar *elem, const xmlChar *name)
Definition: valid.c:3341
Definition: cookie.c:201
struct _xmlDtd * extSubset
Definition: tree.h:571
WCHAR * name
Definition: cookie.c:203

Referenced by xmlSAX2AttributeNs().

◆ xmlNewDocElementContent()

xmlElementContentPtr xmlNewDocElementContent ( xmlDocPtr  doc,
const xmlChar name,
xmlElementContentType  type 
)

Definition at line 921 of file valid.c.

922  {
924  xmlDictPtr dict = NULL;
925 
926  if (doc != NULL)
927  dict = doc->dict;
928 
929  switch(type) {
931  if (name == NULL) {
932  xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
933  "xmlNewElementContent : name == NULL !\n",
934  NULL);
935  }
936  break;
940  if (name != NULL) {
941  xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
942  "xmlNewElementContent : name != NULL !\n",
943  NULL);
944  }
945  break;
946  default:
947  xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
948  "Internal: ELEMENT content corrupted invalid type\n",
949  NULL);
950  return(NULL);
951  }
953  if (ret == NULL) {
954  xmlVErrMemory(NULL, "malloc failed");
955  return(NULL);
956  }
957  memset(ret, 0, sizeof(xmlElementContent));
958  ret->type = type;
960  if (name != NULL) {
961  int l;
962  const xmlChar *tmp;
963 
964  tmp = xmlSplitQName3(name, &l);
965  if (tmp == NULL) {
966  if (dict == NULL)
967  ret->name = xmlStrdup(name);
968  else
969  ret->name = xmlDictLookup(dict, name, -1);
970  } else {
971  if (dict == NULL) {
972  ret->prefix = xmlStrndup(name, l);
973  ret->name = xmlStrdup(tmp);
974  } else {
975  ret->prefix = xmlDictLookup(dict, name, l);
976  ret->name = xmlDictLookup(dict, tmp, -1);
977  }
978  }
979  }
980  return(ret);
981 }
XMLPUBFUN const xmlChar *XMLCALL xmlSplitQName3(const xmlChar *name, int *len)
XMLPUBFUN xmlChar *XMLCALL xmlStrndup(const xmlChar *cur, int len)
Definition: xmlstring.c:41
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static void xmlVErrMemory(xmlValidCtxtPtr ctxt, const char *extra)
Definition: valid.c:58
smooth NULL
Definition: ftsmooth.c:416
Definition: dict.c:116
r l[0]
Definition: byte_order.h:167
XMLPUBFUN const xmlChar *XMLCALL xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:865
int ret
unsigned char xmlChar
Definition: xmlstring.h:28
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:247
Definition: name.c:38
#define memset(x, y, z)
Definition: compat.h:39
struct _xmlDict * dict
Definition: tree.h:580
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:66
xmlElementContent * xmlElementContentPtr
Definition: tree.h:305

Referenced by xmlNewElementContent(), xmlParseElementChildrenContentDeclPriv(), and xmlParseElementMixedContentDecl().

◆ xmlNewElementContent()

xmlElementContentPtr xmlNewElementContent ( const xmlChar name,
xmlElementContentType  type 
)

Definition at line 994 of file valid.c.

994  {
996 }
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
xmlElementContentPtr xmlNewDocElementContent(xmlDocPtr doc, const xmlChar *name, xmlElementContentType type)
Definition: valid.c:921
smooth NULL
Definition: ftsmooth.c:416
Definition: name.c:38

◆ xmlRemoveID()

int xmlRemoveID ( xmlDocPtr  doc,
xmlAttrPtr  attr 
)

xmlRemoveID: @doc: the document @attr: the attribute

Remove the given attribute from the ID table maintained internally.

Returns -1 if the lookup failed and 0 otherwise

Definition at line 2808 of file valid.c.

2808  {
2810  xmlIDPtr id;
2811  xmlChar *ID;
2812 
2813  if (doc == NULL) return(-1);
2814  if (attr == NULL) return(-1);
2815 
2816  table = (xmlIDTablePtr) doc->ids;
2817  if (table == NULL)
2818  return(-1);
2819 
2820  ID = xmlNodeListGetString(doc, attr->children, 1);
2821  if (ID == NULL)
2822  return(-1);
2823 
2824  id = xmlHashLookup(table, ID);
2825  if (id == NULL || id->attr != attr) {
2826  xmlFree(ID);
2827  return(-1);
2828  }
2829 
2831  xmlFree(ID);
2832  attr->atype = 0;
2833  return(0);
2834 }
XMLPUBFUN int XMLCALL xmlHashRemoveEntry(xmlHashTablePtr table, const xmlChar *name, xmlHashDeallocator f)
Definition: hash.c:1057
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
smooth NULL
Definition: ftsmooth.c:416
void * ids
Definition: tree.h:575
static void xmlFreeIDTableEntry(void *id, const xmlChar *name ATTRIBUTE_UNUSED)
Definition: valid.c:2718
if(!(yy_init))
Definition: macro.lex.yy.c:714
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
Definition: cookie.c:201
XMLPUBFUN xmlChar *XMLCALL xmlNodeListGetString(xmlDocPtr doc, const xmlNode *list, int inLine)
unsigned char xmlChar
Definition: xmlstring.h:28
#define ID
Definition: ruserpass.c:36
xmlIDTable * xmlIDTablePtr
Definition: valid.h:142
GLenum GLuint id
Definition: glext.h:5579
XMLPUBFUN void *XMLCALL xmlHashLookup(xmlHashTablePtr table, const xmlChar *name)
Definition: hash.c:466
Definition: tree.h:457

◆ xmlRemoveRef()

int xmlRemoveRef ( xmlDocPtr  doc,
xmlAttrPtr  attr 
)

xmlRemoveRef: @doc: the document @attr: the attribute

Remove the given attribute from the Ref table maintained internally.

Returns -1 if the lookup failed and 0 otherwise

Definition at line 3128 of file valid.c.

3128  {
3129  xmlListPtr ref_list;
3131  xmlChar *ID;
3133 
3134  if (doc == NULL) return(-1);
3135  if (attr == NULL) return(-1);
3136 
3137  table = (xmlRefTablePtr) doc->refs;
3138  if (table == NULL)
3139  return(-1);
3140 
3141  ID = xmlNodeListGetString(doc, attr->children, 1);
3142  if (ID == NULL)
3143  return(-1);
3144 
3145  ref_list = xmlHashLookup(table, ID);
3146  if(ref_list == NULL) {
3147  xmlFree(ID);
3148  return (-1);
3149  }
3150 
3151  /* At this point, ref_list refers to a list of references which
3152  * have the same key as the supplied attr. Our list of references
3153  * is ordered by reference address and we don't have that information
3154  * here to use when removing. We'll have to walk the list and
3155  * check for a matching attribute, when we find one stop the walk
3156  * and remove the entry.
3157  * The list is ordered by reference, so that means we don't have the
3158  * key. Passing the list and the reference to the walker means we
3159  * will have enough data to be able to remove the entry.
3160  */
3161  target.l = ref_list;
3162  target.ap = attr;
3163 
3164  /* Remove the supplied attr from our list */
3165  xmlListWalk(ref_list, xmlWalkRemoveRef, &target);
3166 
3167  /*If the list is empty then remove the list entry in the hash */
3168  if (xmlListEmpty(ref_list))
3170  xmlFree(ID);
3171  return(0);
3172 }
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
XMLPUBFUN int XMLCALL xmlListEmpty(xmlListPtr l)
Definition: list.c:446
void * refs
Definition: tree.h:576
XMLPUBFUN void XMLCALL xmlListWalk(xmlListPtr l, xmlListWalker walker, void *user)
Definition: list.c:676
smooth NULL
Definition: ftsmooth.c:416
if(!(yy_init))
Definition: macro.lex.yy.c:714
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:250
Definition: cookie.c:201
XMLPUBFUN xmlChar *XMLCALL xmlNodeListGetString(xmlDocPtr doc, const xmlNode *list, int inLine)
__u8 attr
Definition: mkdosfs.c:359
unsigned char xmlChar
Definition: xmlstring.h:28
#define ID
Definition: ruserpass.c:36
XMLPUBFUN int XMLCALL xmlHashUpdateEntry(xmlHashTablePtr table, const xmlChar *name, void *userdata, xmlHashDeallocator f)
Definition: hash.c:430
Definition: list.c:38
xmlRefTable * xmlRefTablePtr
Definition: valid.h:150
GLenum target
Definition: glext.h:7315
XMLPUBFUN void *XMLCALL xmlHashLookup(xmlHashTablePtr table, const xmlChar *name)
Definition: hash.c:466
static void xmlFreeRefTableEntry(void *payload, const xmlChar *name ATTRIBUTE_UNUSED)
Definition: valid.c:2920
static int xmlWalkRemoveRef(const void *data, void *user)
Definition: valid.c:2934

◆ xmlSnprintfElementContent()

void xmlSnprintfElementContent ( char buf,
int  size,
xmlElementContentPtr  content,
int  englob 
)

xmlSnprintfElementContent: @buf: an output buffer @size: the buffer size @content: An element table @englob: 1 if one must print the englobing parenthesis, 0 otherwise

This will dump the content of the element content definition Intended just for the debug routine

Definition at line 1297 of file valid.c.

1297  {
1298  int len;
1299 
1300  if (content == NULL) return;
1301  len = strlen(buf);
1302  if (size - len < 50) {
1303  if ((size - len > 4) && (buf[len - 1] != '.'))
1304  strcat(buf, " ...");
1305  return;
1306  }
1307  if (englob) strcat(buf, "(");
1308  switch (content->type) {
1310  strcat(buf, "#PCDATA");
1311  break;
1313  int qnameLen = xmlStrlen(content->name);
1314 
1315  if (content->prefix != NULL)
1316  qnameLen += xmlStrlen(content->prefix) + 1;
1317  if (size - len < qnameLen + 10) {
1318  strcat(buf, " ...");
1319  return;
1320  }
1321  if (content->prefix != NULL) {
1322  strcat(buf, (char *) content->prefix);
1323  strcat(buf, ":");
1324  }
1325  if (content->name != NULL)
1326  strcat(buf, (char *) content->name);
1327  break;
1328  }
1330  if ((content->c1->type == XML_ELEMENT_CONTENT_OR) ||
1331  (content->c1->type == XML_ELEMENT_CONTENT_SEQ))
1333  else
1335  len = strlen(buf);
1336  if (size - len < 50) {
1337  if ((size - len > 4) && (buf[len - 1] != '.'))
1338  strcat(buf, " ...");
1339  return;
1340  }
1341  strcat(buf, " , ");
1342  if (((content->c2->type == XML_ELEMENT_CONTENT_OR) ||
1343  (content->c2->ocur != XML_ELEMENT_CONTENT_ONCE)) &&
1344  (content->c2->type != XML_ELEMENT_CONTENT_ELEMENT))
1346  else
1348  break;
1350  if ((content->c1->type == XML_ELEMENT_CONTENT_OR) ||
1351  (content->c1->type == XML_ELEMENT_CONTENT_SEQ))
1353  else
1355  len = strlen(buf);
1356  if (size - len < 50) {
1357  if ((size - len > 4) && (buf[len - 1] != '.'))
1358  strcat(buf, " ...");
1359  return;
1360  }
1361  strcat(buf, " | ");
1362  if (((content->c2->type == XML_ELEMENT_CONTENT_SEQ) ||
1363  (content->c2->ocur != XML_ELEMENT_CONTENT_ONCE)) &&
1364  (content->c2->type != XML_ELEMENT_CONTENT_ELEMENT))
1366  else
1368  break;
1369  }
1370  if (size - strlen(buf) <= 2) return;
1371  if (englob)
1372  strcat(buf, ")");
1373  switch (content->ocur) {
1375  break;
1377  strcat(buf, "?");
1378  break;
1380  strcat(buf, "*");
1381  break;
1383  strcat(buf, "+");
1384  break;
1385  }
1386 }
void xmlSnprintfElementContent(char *buf, int size, xmlElementContentPtr content, int englob)
Definition: valid.c:1297
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
XMLPUBFUN int XMLCALL xmlStrlen(const xmlChar *str)
Definition: xmlstring.c:422
content
Definition: atl_ax.c:993
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
GLenum GLsizei len
Definition: glext.h:6722

◆ xmlVErrMemory()

static void xmlVErrMemory ( xmlValidCtxtPtr  ctxt,
const char extra 
)
static

xmlVErrMemory: @ctxt: an XML validation parser context @extra: extra informations

Handle an out of memory error

Definition at line 58 of file valid.c.

59 {
60  xmlGenericErrorFunc channel = NULL;
61  xmlParserCtxtPtr pctxt = NULL;
62  void *data = NULL;
63 
64  if (ctxt != NULL) {
65  channel = ctxt->error;
66  data = ctxt->userData;
67  /* Use the special values to detect if it is part of a parsing
68  context */
69  if ((ctxt->finishDtd == XML_CTXT_FINISH_DTD_0) ||
70  (ctxt->finishDtd == XML_CTXT_FINISH_DTD_1)) {
71  long delta = (char *) ctxt - (char *) ctxt->userData;
72  if ((delta > 0) && (delta < 250))
73  pctxt = ctxt->userData;
74  }
75  }
76  if (extra)
77  __xmlRaiseError(NULL, channel, data,
79  XML_ERR_FATAL, NULL, 0, extra, NULL, NULL, 0, 0,
80  "Memory allocation failed : %s\n", extra);
81  else
82  __xmlRaiseError(NULL, channel, data,
84  XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, 0, 0,
85  "Memory allocation failed\n");
86 }
unsigned int finishDtd
Definition: valid.h:93
xmlValidityErrorFunc error
Definition: valid.h:84
smooth NULL
Definition: ftsmooth.c:416
Definition: id3.c:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
void(XMLCDECL * xmlGenericErrorFunc)(void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2
Definition: xmlerror.h:845
void * userData
Definition: valid.h:83

Referenced by xmlAddAttributeDecl(), xmlAddElementDecl(), xmlAddID(), xmlAddNotationDecl(), xmlAddRef(), xmlCopyDocElementContent(), xmlCreateEnumeration(), xmlGetDtdElementDesc2(), and xmlNewDocElementContent().

◆ xmlWalkRemoveRef()

static int xmlWalkRemoveRef ( const void data,
void user 
)
static

xmlWalkRemoveRef: @data: Contents of current link @user: Value supplied by the user

Returns 0 to abort the walk or 1 to continue

Definition at line 2934 of file valid.c.

2935 {
2936  xmlAttrPtr attr0 = ((xmlRefPtr)data)->attr;
2937  xmlAttrPtr attr1 = ((xmlRemoveMemoPtr)user)->ap;
2938  xmlListPtr ref_list = ((xmlRemoveMemoPtr)user)->l;
2939 
2940  if (attr0 == attr1) { /* Matched: remove and terminate walk */
2941  xmlListRemoveFirst(ref_list, (void *)data);
2942  return 0;
2943  }
2944  return 1;
2945 }
XMLPUBFUN int XMLCALL xmlListRemoveFirst(xmlListPtr l, void *data)
Definition: list.c:353
xmlRef * xmlRefPtr
Definition: tree.h:473
xmlRemoveMemo * xmlRemoveMemoPtr
Definition: valid.c:2886
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
Definition: list.c:38
Definition: tree.h:434
void user(int argc, const char *argv[])
Definition: cmds.c:1350

Referenced by xmlRemoveRef().