ReactOS 0.4.15-dev-7842-g558ab78
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 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 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

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)
 
: 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 xmlValidNormalizeString (xmlChar *str)
 
static int xmlIsStreaming (xmlValidCtxtPtr ctxt)
 
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)
 

Macro Definition Documentation

◆ DICT_FREE

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

DICT_FREE: @str: a string

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

Definition at line 2591 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 void * xmlGenericErrorContext
Definition: globals.h:353
XMLPUBVAR xmlGenericErrorFunc xmlGenericError
Definition: globals.h:337

Definition at line 31 of file valid.c.

Typedef Documentation

◆ xmlRemoveMemo

◆ xmlRemoveMemoPtr

Definition at line 2914 of file valid.c.

◆ xmlValidateMemo

◆ xmlValidateMemoPtr

Definition at line 2922 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 information

Handle a validation error

Definition at line 92 of file valid.c.

95{
96 xmlGenericErrorFunc channel = NULL;
97 xmlParserCtxtPtr pctxt = NULL;
98 void *data = NULL;
99
100 if (ctxt != NULL) {
101 channel = ctxt->error;
102 data = ctxt->userData;
103 /* Look up flag to detect if it is part of a parsing
104 context */
105 if (ctxt->flags & XML_VCTXT_USE_PCTXT) {
106 long delta = (char *) ctxt - (char *) ctxt->userData;
107 if ((delta > 0) && (delta < 250))
108 pctxt = ctxt->userData;
109 }
110 }
111 if (extra)
112 __xmlRaiseError(NULL, channel, data,
113 pctxt, NULL, XML_FROM_VALID, error,
114 XML_ERR_ERROR, NULL, 0, extra, NULL, NULL, 0, 0,
115 msg, extra);
116 else
117 __xmlRaiseError(NULL, channel, data,
118 pctxt, NULL, XML_FROM_VALID, error,
119 XML_ERR_ERROR, NULL, 0, NULL, NULL, NULL, 0, 0,
120 "%s", msg);
121}
#define msg(x)
Definition: auth_time.c:54
#define NULL
Definition: types.h:112
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
@ extra
Definition: id3.c:95
#define error(str)
Definition: mkdosfs.c:1605
void * userData
Definition: parser.h:186
void(XMLCDECL * xmlGenericErrorFunc)(void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2
Definition: xmlerror.h:847
@ XML_ERR_ERROR
Definition: xmlerror.h:27
@ XML_FROM_VALID
Definition: xmlerror.h:60

◆ 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 1967 of file valid.c.

1971 {
1974 xmlElementPtr elemDef;
1975 xmlDictPtr dict = NULL;
1976
1977 if (dtd == NULL) {
1979 return(NULL);
1980 }
1981 if (name == NULL) {
1983 return(NULL);
1984 }
1985 if (elem == NULL) {
1987 return(NULL);
1988 }
1989 if (dtd->doc != NULL)
1990 dict = dtd->doc->dict;
1991
1992#ifdef LIBXML_VALID_ENABLED
1993 /*
1994 * Check the type and possibly the default value.
1995 */
1996 switch (type) {
1998 break;
1999 case XML_ATTRIBUTE_ID:
2000 break;
2002 break;
2004 break;
2006 break;
2008 break;
2010 break;
2012 break;
2014 break;
2016 break;
2017 default:
2018 xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR,
2019 "Internal: ATTRIBUTE struct corrupted invalid type\n",
2020 NULL);
2022 return(NULL);
2023 }
2024 if ((defaultValue != NULL) &&
2025 (!xmlValidateAttributeValueInternal(dtd->doc, type, defaultValue))) {
2026 xmlErrValidNode(ctxt, (xmlNodePtr) dtd, XML_DTD_ATTRIBUTE_DEFAULT,
2027 "Attribute %s of %s: invalid default value\n",
2028 elem, name, defaultValue);
2029 defaultValue = NULL;
2030 if (ctxt != NULL)
2031 ctxt->valid = 0;
2032 }
2033#endif /* LIBXML_VALID_ENABLED */
2034
2035 /*
2036 * Check first that an attribute defined in the external subset wasn't
2037 * already defined in the internal subset
2038 */
2039 if ((dtd->doc != NULL) && (dtd->doc->extSubset == dtd) &&
2040 (dtd->doc->intSubset != NULL) &&
2041 (dtd->doc->intSubset->attributes != NULL)) {
2042 ret = xmlHashLookup3(dtd->doc->intSubset->attributes, name, ns, elem);
2043 if (ret != NULL) {
2045 return(NULL);
2046 }
2047 }
2048
2049 /*
2050 * Create the Attribute table if needed.
2051 */
2053 if (table == NULL) {
2054 table = xmlHashCreateDict(0, dict);
2055 dtd->attributes = (void *) table;
2056 }
2057 if (table == NULL) {
2058 xmlVErrMemory(ctxt,
2059 "xmlAddAttributeDecl: Table creation failed!\n");
2061 return(NULL);
2062 }
2063
2064
2066 if (ret == NULL) {
2067 xmlVErrMemory(ctxt, "malloc failed");
2069 return(NULL);
2070 }
2071 memset(ret, 0, sizeof(xmlAttribute));
2072 ret->type = XML_ATTRIBUTE_DECL;
2073
2074 /*
2075 * fill the structure.
2076 */
2077 ret->atype = type;
2078 /*
2079 * doc must be set before possible error causes call
2080 * to xmlFreeAttribute (because it's used to check on
2081 * dict use)
2082 */
2083 ret->doc = dtd->doc;
2084 if (dict) {
2085 ret->name = xmlDictLookup(dict, name, -1);
2086 ret->prefix = xmlDictLookup(dict, ns, -1);
2087 ret->elem = xmlDictLookup(dict, elem, -1);
2088 } else {
2089 ret->name = xmlStrdup(name);
2090 ret->prefix = xmlStrdup(ns);
2091 ret->elem = xmlStrdup(elem);
2092 }
2093 ret->def = def;
2094 ret->tree = tree;
2095 if (defaultValue != NULL) {
2096 if (dict)
2097 ret->defaultValue = xmlDictLookup(dict, defaultValue, -1);
2098 else
2099 ret->defaultValue = xmlStrdup(defaultValue);
2100 }
2101
2102 /*
2103 * Validity Check:
2104 * Search the DTD for previous declarations of the ATTLIST
2105 */
2106 if (xmlHashAddEntry3(table, ret->name, ret->prefix, ret->elem, ret) < 0) {
2107#ifdef LIBXML_VALID_ENABLED
2108 /*
2109 * The attribute is already defined in this DTD.
2110 */
2111 xmlErrValidWarning(ctxt, (xmlNodePtr) dtd, XML_DTD_ATTRIBUTE_REDEFINED,
2112 "Attribute %s of element %s: already defined\n",
2113 name, elem, NULL);
2114#endif /* LIBXML_VALID_ENABLED */
2116 return(NULL);
2117 }
2118
2119 /*
2120 * Validity Check:
2121 * Multiple ID per element
2122 */
2123 elemDef = xmlGetDtdElementDesc2(dtd, elem, 1);
2124 if (elemDef != NULL) {
2125
2126#ifdef LIBXML_VALID_ENABLED
2127 if ((type == XML_ATTRIBUTE_ID) &&
2128 (xmlScanIDAttributeDecl(NULL, elemDef, 1) != 0)) {
2129 xmlErrValidNode(ctxt, (xmlNodePtr) dtd, XML_DTD_MULTIPLE_ID,
2130 "Element %s has too may ID attributes defined : %s\n",
2131 elem, name, NULL);
2132 if (ctxt != NULL)
2133 ctxt->valid = 0;
2134 }
2135#endif /* LIBXML_VALID_ENABLED */
2136
2137 /*
2138 * Insert namespace default def first they need to be
2139 * processed first.
2140 */
2141 if ((xmlStrEqual(ret->name, BAD_CAST "xmlns")) ||
2142 ((ret->prefix != NULL &&
2143 (xmlStrEqual(ret->prefix, BAD_CAST "xmlns"))))) {
2144 ret->nexth = elemDef->attributes;
2145 elemDef->attributes = ret;
2146 } else {
2147 xmlAttributePtr tmp = elemDef->attributes;
2148
2149 while ((tmp != NULL) &&
2150 ((xmlStrEqual(tmp->name, BAD_CAST "xmlns")) ||
2151 ((ret->prefix != NULL &&
2152 (xmlStrEqual(ret->prefix, BAD_CAST "xmlns")))))) {
2153 if (tmp->nexth == NULL)
2154 break;
2155 tmp = tmp->nexth;
2156 }
2157 if (tmp != NULL) {
2158 ret->nexth = tmp->nexth;
2159 tmp->nexth = ret;
2160 } else {
2161 ret->nexth = elemDef->attributes;
2162 elemDef->attributes = ret;
2163 }
2164 }
2165 }
2166
2167 /*
2168 * Link it to the DTD
2169 */
2170 ret->parent = dtd;
2171 if (dtd->last == NULL) {
2172 dtd->children = dtd->last = (xmlNodePtr) ret;
2173 } else {
2174 dtd->last->next = (xmlNodePtr) ret;
2175 ret->prev = dtd->last;
2176 dtd->last = (xmlNodePtr) ret;
2177 }
2178 return(ret);
2179}
struct _tree tree
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
if(dx< 0)
Definition: linetemp.h:194
static size_t elem
Definition: string.c:68
XMLPUBFUN const xmlChar *XMLCALL xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:867
XMLPUBVAR xmlMallocFunc xmlMalloc
Definition: globals.h:248
XMLPUBFUN void *XMLCALL xmlHashLookup3(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, const xmlChar *name3)
Definition: hash.c:769
XMLPUBFUN xmlHashTablePtr XMLCALL xmlHashCreateDict(int size, xmlDictPtr dict)
Definition: hash.c:210
XMLPUBFUN int XMLCALL xmlHashAddEntry3(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, const xmlChar *name3, void *userdata)
Definition: hash.c:531
@ XML_ATTRIBUTE_NMTOKENS
Definition: tree.h:214
@ XML_ATTRIBUTE_IDREF
Definition: tree.h:209
@ XML_ATTRIBUTE_ENTITIES
Definition: tree.h:212
@ XML_ATTRIBUTE_IDREFS
Definition: tree.h:210
@ XML_ATTRIBUTE_ID
Definition: tree.h:208
@ XML_ATTRIBUTE_NOTATION
Definition: tree.h:216
@ XML_ATTRIBUTE_ENUMERATION
Definition: tree.h:215
@ XML_ATTRIBUTE_CDATA
Definition: tree.h:207
@ XML_ATTRIBUTE_NMTOKEN
Definition: tree.h:213
@ XML_ATTRIBUTE_ENTITY
Definition: tree.h:211
xmlNode * xmlNodePtr
Definition: tree.h:488
@ XML_ATTRIBUTE_DECL
Definition: tree.h:175
xmlAttribute * xmlAttributePtr
Definition: tree.h:252
#define memset(x, y, z)
Definition: compat.h:39
const xmlChar * name
Definition: tree.h:256
struct _xmlAttribute * nexth
Definition: tree.h:264
Definition: dict.c:111
struct _xmlDoc * doc
Definition: tree.h:415
struct _xmlNode * last
Definition: tree.h:411
struct _xmlNode * children
Definition: tree.h:410
void * attributes
Definition: tree.h:420
xmlAttributePtr attributes
Definition: tree.h:359
Definition: tree.h:489
Definition: name.c:39
Definition: mxnamespace.c:45
static void xmlVErrMemory(xmlValidCtxtPtr ctxt, const char *extra)
Definition: valid.c:55
static xmlElementPtr xmlGetDtdElementDesc2(xmlDtdPtr dtd, const xmlChar *name, int create)
Definition: valid.c:3287
void xmlFreeEnumeration(xmlEnumerationPtr cur)
Definition: valid.c:1817
static void xmlFreeAttribute(xmlAttributePtr attr)
Definition: valid.c:1914
xmlAttributeTable * xmlAttributeTablePtr
Definition: valid.h:134
int ret
@ XML_DTD_ATTRIBUTE_REDEFINED
Definition: xmlerror.h:220
@ XML_DTD_MULTIPLE_ID
Definition: xmlerror.h:239
@ XML_DTD_ATTRIBUTE_DEFAULT
Definition: xmlerror.h:219
@ XML_ERR_INTERNAL_ERROR
Definition: xmlerror.h:101
XMLPUBFUN xmlChar *XMLCALL xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:67
#define BAD_CAST
Definition: xmlstring.h:35
XMLPUBFUN int XMLCALL xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:160

Referenced by xmlSAX2AttributeDecl().

◆ xmlAddElementDecl()

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

Definition at line 1418 of file valid.c.

1421 {
1424 xmlAttributePtr oldAttributes = NULL;
1425 xmlChar *ns, *uqname;
1426
1427 if (dtd == NULL) {
1428 return(NULL);
1429 }
1430 if (name == NULL) {
1431 return(NULL);
1432 }
1433
1434 switch (type) {
1436 if (content != NULL) {
1437 xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR,
1438 "xmlAddElementDecl: content != NULL for EMPTY\n",
1439 NULL);
1440 return(NULL);
1441 }
1442 break;
1444 if (content != NULL) {
1445 xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR,
1446 "xmlAddElementDecl: content != NULL for ANY\n",
1447 NULL);
1448 return(NULL);
1449 }
1450 break;
1452 if (content == NULL) {
1453 xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR,
1454 "xmlAddElementDecl: content == NULL for MIXED\n",
1455 NULL);
1456 return(NULL);
1457 }
1458 break;
1460 if (content == NULL) {
1461 xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR,
1462 "xmlAddElementDecl: content == NULL for ELEMENT\n",
1463 NULL);
1464 return(NULL);
1465 }
1466 break;
1467 default:
1468 xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR,
1469 "Internal: ELEMENT decl corrupted invalid type\n",
1470 NULL);
1471 return(NULL);
1472 }
1473
1474 /*
1475 * check if name is a QName
1476 */
1477 uqname = xmlSplitQName2(name, &ns);
1478 if (uqname != NULL)
1479 name = uqname;
1480
1481 /*
1482 * Create the Element table if needed.
1483 */
1485 if (table == NULL) {
1486 xmlDictPtr dict = NULL;
1487
1488 if (dtd->doc != NULL)
1489 dict = dtd->doc->dict;
1490 table = xmlHashCreateDict(0, dict);
1491 dtd->elements = (void *) table;
1492 }
1493 if (table == NULL) {
1494 xmlVErrMemory(ctxt,
1495 "xmlAddElementDecl: Table creation failed!\n");
1496 if (uqname != NULL)
1497 xmlFree(uqname);
1498 if (ns != NULL)
1499 xmlFree(ns);
1500 return(NULL);
1501 }
1502
1503 /*
1504 * lookup old attributes inserted on an undefined element in the
1505 * internal subset.
1506 */
1507 if ((dtd->doc != NULL) && (dtd->doc->intSubset != NULL)) {
1508 ret = xmlHashLookup2(dtd->doc->intSubset->elements, name, ns);
1509 if ((ret != NULL) && (ret->etype == XML_ELEMENT_TYPE_UNDEFINED)) {
1510 oldAttributes = ret->attributes;
1511 ret->attributes = NULL;
1512 xmlHashRemoveEntry2(dtd->doc->intSubset->elements, name, ns, NULL);
1514 }
1515 }
1516
1517 /*
1518 * The element may already be present if one of its attribute
1519 * was registered first
1520 */
1522 if (ret != NULL) {
1523 if (ret->etype != XML_ELEMENT_TYPE_UNDEFINED) {
1524#ifdef LIBXML_VALID_ENABLED
1525 /*
1526 * The element is already defined in this DTD.
1527 */
1528 xmlErrValidNode(ctxt, (xmlNodePtr) dtd, XML_DTD_ELEM_REDEFINED,
1529 "Redefinition of element %s\n",
1530 name, NULL, NULL);
1531#endif /* LIBXML_VALID_ENABLED */
1532 if (uqname != NULL)
1533 xmlFree(uqname);
1534 if (ns != NULL)
1535 xmlFree(ns);
1536 return(NULL);
1537 }
1538 if (ns != NULL) {
1539 xmlFree(ns);
1540 ns = NULL;
1541 }
1542 } else {
1544 if (ret == NULL) {
1545 xmlVErrMemory(ctxt, "malloc failed");
1546 if (uqname != NULL)
1547 xmlFree(uqname);
1548 if (ns != NULL)
1549 xmlFree(ns);
1550 return(NULL);
1551 }
1552 memset(ret, 0, sizeof(xmlElement));
1553 ret->type = XML_ELEMENT_DECL;
1554
1555 /*
1556 * fill the structure.
1557 */
1558 ret->name = xmlStrdup(name);
1559 if (ret->name == NULL) {
1560 xmlVErrMemory(ctxt, "malloc failed");
1561 if (uqname != NULL)
1562 xmlFree(uqname);
1563 if (ns != NULL)
1564 xmlFree(ns);
1565 xmlFree(ret);
1566 return(NULL);
1567 }
1568 ret->prefix = ns;
1569
1570 /*
1571 * Validity Check:
1572 * Insertion must not fail
1573 */
1574 if (xmlHashAddEntry2(table, name, ns, ret)) {
1575#ifdef LIBXML_VALID_ENABLED
1576 /*
1577 * The element is already defined in this DTD.
1578 */
1579 xmlErrValidNode(ctxt, (xmlNodePtr) dtd, XML_DTD_ELEM_REDEFINED,
1580 "Redefinition of element %s\n",
1581 name, NULL, NULL);
1582#endif /* LIBXML_VALID_ENABLED */
1584 if (uqname != NULL)
1585 xmlFree(uqname);
1586 return(NULL);
1587 }
1588 /*
1589 * For new element, may have attributes from earlier
1590 * definition in internal subset
1591 */
1592 ret->attributes = oldAttributes;
1593 }
1594
1595 /*
1596 * Finish to fill the structure.
1597 */
1598 ret->etype = type;
1599 /*
1600 * Avoid a stupid copy when called by the parser
1601 * and flag it by setting a special parent value
1602 * so the parser doesn't unallocate it.
1603 */
1604 if ((ctxt != NULL) && (ctxt->flags & XML_VCTXT_USE_PCTXT)) {
1605 ret->content = content;
1606 if (content != NULL)
1607 content->parent = (xmlElementContentPtr) 1;
1608 } else {
1609 ret->content = xmlCopyDocElementContent(dtd->doc, content);
1610 }
1611
1612 /*
1613 * Link it to the DTD
1614 */
1615 ret->parent = dtd;
1616 ret->doc = dtd->doc;
1617 if (dtd->last == NULL) {
1618 dtd->children = dtd->last = (xmlNodePtr) ret;
1619 } else {
1620 dtd->last->next = (xmlNodePtr) ret;
1621 ret->prev = dtd->last;
1622 dtd->last = (xmlNodePtr) ret;
1623 }
1624 if (uqname != NULL)
1625 xmlFree(uqname);
1626 return(ret);
1627}
content
Definition: atl_ax.c:994
XMLPUBVAR xmlFreeFunc xmlFree
Definition: globals.h:251
XMLPUBFUN int XMLCALL xmlHashAddEntry2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, void *userdata)
Definition: hash.c:406
XMLPUBFUN int XMLCALL xmlHashRemoveEntry2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2, xmlHashDeallocator f)
Definition: hash.c:1071
XMLPUBFUN void *XMLCALL xmlHashLookup2(xmlHashTablePtr table, const xmlChar *name, const xmlChar *name2)
Definition: hash.c:476
xmlElementContent * xmlElementContentPtr
Definition: tree.h:305
xmlElement * xmlElementPtr
Definition: tree.h:345
@ XML_ELEMENT_DECL
Definition: tree.h:174
@ XML_ELEMENT_TYPE_MIXED
Definition: tree.h:326
@ XML_ELEMENT_TYPE_EMPTY
Definition: tree.h:324
@ XML_ELEMENT_TYPE_UNDEFINED
Definition: tree.h:323
@ XML_ELEMENT_TYPE_ELEMENT
Definition: tree.h:327
@ XML_ELEMENT_TYPE_ANY
Definition: tree.h:325
XMLPUBFUN xmlChar *XMLCALL xmlSplitQName2(const xmlChar *name, xmlChar **prefix)
void * elements
Definition: tree.h:419
xmlElementContentPtr xmlCopyDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur)
Definition: valid.c:995
static void xmlFreeElement(xmlElementPtr elem)
Definition: valid.c:1389
xmlElementTable * xmlElementTablePtr
Definition: valid.h:126
@ XML_DTD_ELEM_REDEFINED
Definition: xmlerror.h:228

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 2672 of file valid.c.

2673 {
2674 xmlIDPtr ret;
2676
2677 if (doc == NULL) {
2678 return(NULL);
2679 }
2680 if ((value == NULL) || (value[0] == 0)) {
2681 return(NULL);
2682 }
2683 if (attr == NULL) {
2684 return(NULL);
2685 }
2686
2687 /*
2688 * Create the ID table if needed.
2689 */
2690 table = (xmlIDTablePtr) doc->ids;
2691 if (table == NULL) {
2692 doc->ids = table = xmlHashCreateDict(0, doc->dict);
2693 }
2694 if (table == NULL) {
2695 xmlVErrMemory(ctxt,
2696 "xmlAddID: Table creation failed!\n");
2697 return(NULL);
2698 }
2699
2700 ret = (xmlIDPtr) xmlMalloc(sizeof(xmlID));
2701 if (ret == NULL) {
2702 xmlVErrMemory(ctxt, "malloc failed");
2703 return(NULL);
2704 }
2705
2706 /*
2707 * fill the structure.
2708 */
2709 ret->value = xmlStrdup(value);
2710 ret->doc = doc;
2711 if (xmlIsStreaming(ctxt)) {
2712 /*
2713 * Operating in streaming mode, attr is gonna disappear
2714 */
2715 if (doc->dict != NULL)
2716 ret->name = xmlDictLookup(doc->dict, attr->name, -1);
2717 else
2718 ret->name = xmlStrdup(attr->name);
2719 ret->attr = NULL;
2720 } else {
2721 ret->attr = attr;
2722 ret->name = NULL;
2723 }
2724 ret->lineno = xmlGetLineNo(attr->parent);
2725
2726 if (xmlHashAddEntry(table, value, ret) < 0) {
2727#ifdef LIBXML_VALID_ENABLED
2728 /*
2729 * The id is already defined in this DTD.
2730 */
2731 if (ctxt != NULL) {
2732 xmlErrValidNode(ctxt, attr->parent, XML_DTD_ID_REDEFINED,
2733 "ID %s already defined\n", value, NULL, NULL);
2734 }
2735#endif /* LIBXML_VALID_ENABLED */
2736 xmlFreeID(ret);
2737 return(NULL);
2738 }
2739 if (attr != NULL)
2740 attr->atype = XML_ATTRIBUTE_ID;
2741 return(ret);
2742}
XMLPUBFUN int XMLCALL xmlHashAddEntry(xmlHashTablePtr table, const xmlChar *name, void *userdata)
Definition: hash.c:389
xmlID * xmlIDPtr
Definition: tree.h:456
XMLPUBFUN long XMLCALL xmlGetLineNo(const xmlNode *node)
void * ids
Definition: tree.h:575
struct _xmlDict * dict
Definition: tree.h:580
Definition: tree.h:457
Definition: cookie.c:202
WCHAR * name
Definition: cookie.c:203
Definition: pdh_main.c:94
static int xmlIsStreaming(xmlValidCtxtPtr ctxt)
Definition: valid.c:2626
static void xmlFreeID(xmlIDPtr id)
Definition: valid.c:2644
xmlIDTable * xmlIDTablePtr
Definition: valid.h:142
@ XML_DTD_ID_REDEFINED
Definition: xmlerror.h:232

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 2394 of file valid.c.

2396 {
2399
2400 if (dtd == NULL) {
2401 return(NULL);
2402 }
2403 if (name == NULL) {
2404 return(NULL);
2405 }
2406 if ((PublicID == NULL) && (SystemID == NULL)) {
2407 return(NULL);
2408 }
2409
2410 /*
2411 * Create the Notation table if needed.
2412 */
2414 if (table == NULL) {
2415 xmlDictPtr dict = NULL;
2416 if (dtd->doc != NULL)
2417 dict = dtd->doc->dict;
2418
2419 dtd->notations = table = xmlHashCreateDict(0, dict);
2420 }
2421 if (table == NULL) {
2422 xmlVErrMemory(ctxt,
2423 "xmlAddNotationDecl: Table creation failed!\n");
2424 return(NULL);
2425 }
2426
2428 if (ret == NULL) {
2429 xmlVErrMemory(ctxt, "malloc failed");
2430 return(NULL);
2431 }
2432 memset(ret, 0, sizeof(xmlNotation));
2433
2434 /*
2435 * fill the structure.
2436 */
2437 ret->name = xmlStrdup(name);
2438 if (SystemID != NULL)
2439 ret->SystemID = xmlStrdup(SystemID);
2440 if (PublicID != NULL)
2441 ret->PublicID = xmlStrdup(PublicID);
2442
2443 /*
2444 * Validity Check:
2445 * Check the DTD for previous declarations of the ATTLIST
2446 */
2447 if (xmlHashAddEntry(table, name, ret)) {
2448#ifdef LIBXML_VALID_ENABLED
2449 xmlErrValid(NULL, XML_DTD_NOTATION_REDEFINED,
2450 "xmlAddNotationDecl: %s already defined\n",
2451 (const char *) name);
2452#endif /* LIBXML_VALID_ENABLED */
2454 return(NULL);
2455 }
2456 return(ret);
2457}
xmlNotation * xmlNotationPtr
Definition: tree.h:193
void * notations
Definition: tree.h:418
static void xmlFreeNotation(xmlNotationPtr nota)
Definition: valid.c:2369
xmlNotationTable * xmlNotationTablePtr
Definition: valid.h:118
@ XML_DTD_NOTATION_REDEFINED
Definition: xmlerror.h:245

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

DEPRECATED, do not use. This function will be removed from the public API.

Register a new ref declaration

Returns NULL if not, otherwise the new xmlRefPtr

Definition at line 3003 of file valid.c.

3004 {
3005 xmlRefPtr ret;
3007 xmlListPtr ref_list;
3008
3009 if (doc == NULL) {
3010 return(NULL);
3011 }
3012 if (value == NULL) {
3013 return(NULL);
3014 }
3015 if (attr == NULL) {
3016 return(NULL);
3017 }
3018
3019 /*
3020 * Create the Ref table if needed.
3021 */
3022 table = (xmlRefTablePtr) doc->refs;
3023 if (table == NULL) {
3024 doc->refs = table = xmlHashCreateDict(0, doc->dict);
3025 }
3026 if (table == NULL) {
3027 xmlVErrMemory(ctxt,
3028 "xmlAddRef: Table creation failed!\n");
3029 return(NULL);
3030 }
3031
3032 ret = (xmlRefPtr) xmlMalloc(sizeof(xmlRef));
3033 if (ret == NULL) {
3034 xmlVErrMemory(ctxt, "malloc failed");
3035 return(NULL);
3036 }
3037
3038 /*
3039 * fill the structure.
3040 */
3041 ret->value = xmlStrdup(value);
3042 if (xmlIsStreaming(ctxt)) {
3043 /*
3044 * Operating in streaming mode, attr is gonna disappear
3045 */
3046 ret->name = xmlStrdup(attr->name);
3047 ret->attr = NULL;
3048 } else {
3049 ret->name = NULL;
3050 ret->attr = attr;
3051 }
3052 ret->lineno = xmlGetLineNo(attr->parent);
3053
3054 /* To add a reference :-
3055 * References are maintained as a list of references,
3056 * Lookup the entry, if no entry create new nodelist
3057 * Add the owning node to the NodeList
3058 * Return the ref
3059 */
3060
3061 if (NULL == (ref_list = xmlHashLookup(table, value))) {
3062 if (NULL == (ref_list = xmlListCreate(xmlFreeRef, xmlDummyCompare))) {
3063 xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
3064 "xmlAddRef: Reference list creation failed!\n",
3065 NULL);
3066 goto failed;
3067 }
3068 if (xmlHashAddEntry(table, value, ref_list) < 0) {
3069 xmlListDelete(ref_list);
3070 xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
3071 "xmlAddRef: Reference list insertion failed!\n",
3072 NULL);
3073 goto failed;
3074 }
3075 }
3076 if (xmlListAppend(ref_list, ret) != 0) {
3077 xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
3078 "xmlAddRef: Reference list insertion failed!\n",
3079 NULL);
3080 goto failed;
3081 }
3082 return(ret);
3083failed:
3084 if (ret != NULL) {
3085 if (ret->value != NULL)
3086 xmlFree((char *)ret->value);
3087 if (ret->name != NULL)
3088 xmlFree((char *)ret->name);
3089 xmlFree(ret);
3090 }
3091 return(NULL);
3092}
XMLPUBFUN void *XMLCALL xmlHashLookup(xmlHashTablePtr table, const xmlChar *name)
Definition: hash.c:461
XMLPUBFUN int XMLCALL xmlListAppend(xmlListPtr l, void *data)
Definition: list.c:305
XMLPUBFUN void XMLCALL xmlListDelete(xmlListPtr l)
Definition: list.c:333
XMLPUBFUN xmlListPtr XMLCALL xmlListCreate(xmlListDeallocator deallocator, xmlListDataCompare compare)
Definition: list.c:188
xmlRef * xmlRefPtr
Definition: tree.h:473
void * refs
Definition: tree.h:576
Definition: list.c:39
Definition: tree.h:474
static int xmlDummyCompare(const void *data0 ATTRIBUTE_UNUSED, const void *data1 ATTRIBUTE_UNUSED)
Definition: valid.c:2983
static void xmlFreeRef(xmlLinkPtr lk)
Definition: valid.c:2931
xmlRefTable * xmlRefTablePtr
Definition: valid.h:150

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 995 of file valid.c.

995 {
996 xmlElementContentPtr ret = NULL, prev = NULL, tmp;
997 xmlDictPtr dict = NULL;
998
999 if (cur == NULL) return(NULL);
1000
1001 if (doc != NULL)
1002 dict = doc->dict;
1003
1005 if (ret == NULL) {
1006 xmlVErrMemory(NULL, "malloc failed");
1007 return(NULL);
1008 }
1009 memset(ret, 0, sizeof(xmlElementContent));
1010 ret->type = cur->type;
1011 ret->ocur = cur->ocur;
1012 if (cur->name != NULL) {
1013 if (dict)
1014 ret->name = xmlDictLookup(dict, cur->name, -1);
1015 else
1016 ret->name = xmlStrdup(cur->name);
1017 }
1018
1019 if (cur->prefix != NULL) {
1020 if (dict)
1021 ret->prefix = xmlDictLookup(dict, cur->prefix, -1);
1022 else
1023 ret->prefix = xmlStrdup(cur->prefix);
1024 }
1025 if (cur->c1 != NULL)
1026 ret->c1 = xmlCopyDocElementContent(doc, cur->c1);
1027 if (ret->c1 != NULL)
1028 ret->c1->parent = ret;
1029 if (cur->c2 != NULL) {
1030 prev = ret;
1031 cur = cur->c2;
1032 while (cur != NULL) {
1034 if (tmp == NULL) {
1035 xmlVErrMemory(NULL, "malloc failed");
1036 return(ret);
1037 }
1038 memset(tmp, 0, sizeof(xmlElementContent));
1039 tmp->type = cur->type;
1040 tmp->ocur = cur->ocur;
1041 prev->c2 = tmp;
1042 tmp->parent = prev;
1043 if (cur->name != NULL) {
1044 if (dict)
1045 tmp->name = xmlDictLookup(dict, cur->name, -1);
1046 else
1047 tmp->name = xmlStrdup(cur->name);
1048 }
1049
1050 if (cur->prefix != NULL) {
1051 if (dict)
1052 tmp->prefix = xmlDictLookup(dict, cur->prefix, -1);
1053 else
1054 tmp->prefix = xmlStrdup(cur->prefix);
1055 }
1056 if (cur->c1 != NULL)
1057 tmp->c1 = xmlCopyDocElementContent(doc,cur->c1);
1058 if (tmp->c1 != NULL)
1059 tmp->c1->parent = ret;
1060 prev = tmp;
1061 cur = cur->c2;
1062 }
1063 }
1064 return(ret);
1065}
FxCollectionEntry * cur

Referenced by xmlAddElementDecl(), xmlCopyDocElementContent(), 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 1077 of file valid.c.

1077 {
1079}

◆ xmlCreateEnumeration()

xmlEnumerationPtr xmlCreateEnumeration ( const xmlChar name)

Definition at line 1795 of file valid.c.

1795 {
1797
1799 if (ret == NULL) {
1800 xmlVErrMemory(NULL, "malloc failed");
1801 return(NULL);
1802 }
1803 memset(ret, 0, sizeof(xmlEnumeration));
1804
1805 if (name != NULL)
1806 ret->name = xmlStrdup(name);
1807 return(ret);
1808}
xmlEnumeration * xmlEnumerationPtr
Definition: tree.h:239

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 2983 of file valid.c.

2985{
2986 return (0);
2987}

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 1914 of file valid.c.

1914 {
1915 xmlDictPtr dict;
1916
1917 if (attr == NULL) return;
1918 if (attr->doc != NULL)
1919 dict = attr->doc->dict;
1920 else
1921 dict = NULL;
1923 if (attr->tree != NULL)
1924 xmlFreeEnumeration(attr->tree);
1925 if (dict) {
1926 if ((attr->elem != NULL) && (!xmlDictOwns(dict, attr->elem)))
1927 xmlFree((xmlChar *) attr->elem);
1928 if ((attr->name != NULL) && (!xmlDictOwns(dict, attr->name)))
1929 xmlFree((xmlChar *) attr->name);
1930 if ((attr->prefix != NULL) && (!xmlDictOwns(dict, attr->prefix)))
1931 xmlFree((xmlChar *) attr->prefix);
1932 if ((attr->defaultValue != NULL) &&
1933 (!xmlDictOwns(dict, attr->defaultValue)))
1934 xmlFree((xmlChar *) attr->defaultValue);
1935 } else {
1936 if (attr->elem != NULL)
1937 xmlFree((xmlChar *) attr->elem);
1938 if (attr->name != NULL)
1939 xmlFree((xmlChar *) attr->name);
1940 if (attr->defaultValue != NULL)
1941 xmlFree((xmlChar *) attr->defaultValue);
1942 if (attr->prefix != NULL)
1943 xmlFree((xmlChar *) attr->prefix);
1944 }
1945 xmlFree(attr);
1946}
XMLPUBFUN void XMLCALL xmlUnlinkNode(xmlNodePtr cur)

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 2193 of file valid.c.

2193 {
2195}
XMLPUBFUN void XMLCALL xmlHashFree(xmlHashTablePtr table, xmlHashDeallocator f)
Definition: hash.c:322
static void xmlFreeAttributeTableEntry(void *attr, const xmlChar *name ATTRIBUTE_UNUSED)
Definition: valid.c:2182

◆ xmlFreeAttributeTableEntry()

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

Definition at line 2182 of file valid.c.

2182 {
2184}

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 1089 of file valid.c.

1089 {
1090 xmlDictPtr dict = NULL;
1091 size_t depth = 0;
1092
1093 if (cur == NULL)
1094 return;
1095 if (doc != NULL)
1096 dict = doc->dict;
1097
1098 while (1) {
1100
1101 while ((cur->c1 != NULL) || (cur->c2 != NULL)) {
1102 cur = (cur->c1 != NULL) ? cur->c1 : cur->c2;
1103 depth += 1;
1104 }
1105
1106 switch (cur->type) {
1111 break;
1112 default:
1113 xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
1114 "Internal: ELEMENT content corrupted invalid type\n",
1115 NULL);
1116 return;
1117 }
1118 if (dict) {
1119 if ((cur->name != NULL) && (!xmlDictOwns(dict, cur->name)))
1120 xmlFree((xmlChar *) cur->name);
1121 if ((cur->prefix != NULL) && (!xmlDictOwns(dict, cur->prefix)))
1122 xmlFree((xmlChar *) cur->prefix);
1123 } else {
1124 if (cur->name != NULL) xmlFree((xmlChar *) cur->name);
1125 if (cur->prefix != NULL) xmlFree((xmlChar *) cur->prefix);
1126 }
1127 parent = cur->parent;
1128 if ((depth == 0) || (parent == NULL)) {
1129 xmlFree(cur);
1130 break;
1131 }
1132 if (cur == parent->c1)
1133 parent->c1 = NULL;
1134 else
1135 parent->c2 = NULL;
1136 xmlFree(cur);
1137
1138 if (parent->c2 != NULL) {
1139 cur = parent->c2;
1140 } else {
1141 depth -= 1;
1142 cur = parent;
1143 }
1144 }
1145}
r parent
Definition: btrfs.c:3010
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
@ XML_ELEMENT_CONTENT_PCDATA
Definition: tree.h:279
@ XML_ELEMENT_CONTENT_ELEMENT
Definition: tree.h:280
@ XML_ELEMENT_CONTENT_OR
Definition: tree.h:282
@ XML_ELEMENT_CONTENT_SEQ
Definition: tree.h:281

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 1389 of file valid.c.

1389 {
1390 if (elem == NULL) return;
1392 xmlFreeDocElementContent(elem->doc, elem->content);
1393 if (elem->name != NULL)
1394 xmlFree((xmlChar *) elem->name);
1395 if (elem->prefix != NULL)
1396 xmlFree((xmlChar *) elem->prefix);
1397#ifdef LIBXML_REGEXP_ENABLED
1398 if (elem->contModel != NULL)
1399 xmlRegFreeRegexp(elem->contModel);
1400#endif
1401 xmlFree(elem);
1402}
void xmlFreeDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur)
Definition: valid.c:1089

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 1155 of file valid.c.

1155 {
1157}

◆ xmlFreeElementTable()

void xmlFreeElementTable ( xmlElementTablePtr  table)

xmlFreeElementTable: @table: An element table

Deallocate the memory used by an element hash table.

Definition at line 1641 of file valid.c.

1641 {
1643}
static void xmlFreeElementTableEntry(void *elem, const xmlChar *name ATTRIBUTE_UNUSED)
Definition: valid.c:1630

◆ xmlFreeElementTableEntry()

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

Definition at line 1630 of file valid.c.

1630 {
1632}

Referenced by xmlFreeElementTable().

◆ xmlFreeEnumeration()

void xmlFreeEnumeration ( xmlEnumerationPtr  cur)

xmlFreeEnumeration: @cur: the tree to free.

free an enumeration attribute node (recursive).

Definition at line 1817 of file valid.c.

1817 {
1818 if (cur == NULL) return;
1819
1820 if (cur->next != NULL) xmlFreeEnumeration(cur->next);
1821
1822 if (cur->name != NULL) xmlFree((xmlChar *) cur->name);
1823 xmlFree(cur);
1824}

Referenced by attributeDeclDebug(), xmlAddAttributeDecl(), xmlFreeAttribute(), xmlFreeEnumeration(), 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 2644 of file valid.c.

2644 {
2645 xmlDictPtr dict = NULL;
2646
2647 if (id == NULL) return;
2648
2649 if (id->doc != NULL)
2650 dict = id->doc->dict;
2651
2652 if (id->value != NULL)
2653 DICT_FREE(id->value)
2654 if (id->name != NULL)
2655 DICT_FREE(id->name)
2656 xmlFree(id);
2657}
GLuint id
Definition: glext.h:5910
struct _xmlDictEntry * dict
Definition: dict.c:114
#define DICT_FREE(str)
Definition: valid.c:2591

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 2756 of file valid.c.

2756 {
2758}
static void xmlFreeIDTableEntry(void *id, const xmlChar *name ATTRIBUTE_UNUSED)
Definition: valid.c:2745

Referenced by xsltReleaseRVT().

◆ xmlFreeIDTableEntry()

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

Definition at line 2745 of file valid.c.

2745 {
2746 xmlFreeID((xmlIDPtr) id);
2747}

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 2369 of file valid.c.

2369 {
2370 if (nota == NULL) return;
2371 if (nota->name != NULL)
2372 xmlFree((xmlChar *) nota->name);
2373 if (nota->PublicID != NULL)
2374 xmlFree((xmlChar *) nota->PublicID);
2375 if (nota->SystemID != NULL)
2376 xmlFree((xmlChar *) nota->SystemID);
2377 xmlFree(nota);
2378}
const xmlChar * name
Definition: tree.h:195
const xmlChar * SystemID
Definition: tree.h:197
const xmlChar * PublicID
Definition: tree.h:196

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 2471 of file valid.c.

2471 {
2473}
static void xmlFreeNotationTableEntry(void *nota, const xmlChar *name ATTRIBUTE_UNUSED)
Definition: valid.c:2460

◆ xmlFreeNotationTableEntry()

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

Definition at line 2460 of file valid.c.

2460 {
2462}

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 2931 of file valid.c.

2931 {
2933 if (ref == NULL) return;
2934 if (ref->value != NULL)
2935 xmlFree((xmlChar *)ref->value);
2936 if (ref->name != NULL)
2937 xmlFree((xmlChar *)ref->name);
2938 xmlFree(ref);
2939}
XMLPUBFUN void *XMLCALL xmlLinkGetData(xmlLinkPtr lk)
Definition: list.c:604
Definition: send.c:48
char name[1]
Definition: send.c:52

Referenced by xmlAddRef().

◆ xmlFreeRefTable()

void xmlFreeRefTable ( xmlRefTablePtr  table)

xmlFreeRefTable: @table: An ref table

DEPRECATED, do not use. This function will be removed from the public API.

Deallocate the memory used by an Ref hash table.

Definition at line 3103 of file valid.c.

3103 {
3105}
static void xmlFreeRefTableEntry(void *payload, const xmlChar *name ATTRIBUTE_UNUSED)
Definition: valid.c:2948

◆ 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 2948 of file valid.c.

2948 {
2949 xmlListPtr list_ref = (xmlListPtr) payload;
2950 if (list_ref == NULL) return;
2951 xmlListDelete(list_ref);
2952}
xmlList * xmlListPtr
Definition: list.h:24

Referenced by xmlFreeRefTable(), and xmlRemoveRef().

◆ xmlGetDtdAttrDesc()

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

Definition at line 3379 of file valid.c.

3379 {
3382 xmlChar *uqname = NULL, *prefix = NULL;
3383
3384 if (dtd == NULL) return(NULL);
3385 if (dtd->attributes == NULL) return(NULL);
3386
3388 if (table == NULL)
3389 return(NULL);
3390
3391 uqname = xmlSplitQName2(name, &prefix);
3392
3393 if (uqname != NULL) {
3394 cur = xmlHashLookup3(table, uqname, prefix, elem);
3395 if (prefix != NULL) xmlFree(prefix);
3396 if (uqname != NULL) xmlFree(uqname);
3397 } else
3399 return(cur);
3400}

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

◆ xmlGetDtdElementDesc()

xmlElementPtr xmlGetDtdElementDesc ( xmlDtdPtr  dtd,
const xmlChar name 
)

Definition at line 3257 of file valid.c.

3257 {
3260 xmlChar *uqname = NULL, *prefix = NULL;
3261
3262 if ((dtd == NULL) || (name == NULL)) return(NULL);
3263 if (dtd->elements == NULL)
3264 return(NULL);
3266
3267 uqname = xmlSplitQName2(name, &prefix);
3268 if (uqname != NULL)
3269 name = uqname;
3270 cur = xmlHashLookup2(table, name, prefix);
3271 if (prefix != NULL) xmlFree(prefix);
3272 if (uqname != NULL) xmlFree(uqname);
3273 return(cur);
3274}

Referenced by xmlIsMixedElement().

◆ xmlGetDtdElementDesc2()

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

Definition at line 3287 of file valid.c.

3287 {
3290 xmlChar *uqname = NULL, *prefix = NULL;
3291
3292 if (dtd == NULL) return(NULL);
3293 if (dtd->elements == NULL) {
3294 xmlDictPtr dict = NULL;
3295
3296 if (dtd->doc != NULL)
3297 dict = dtd->doc->dict;
3298
3299 if (!create)
3300 return(NULL);
3301 /*
3302 * Create the Element table if needed.
3303 */
3305 if (table == NULL) {
3306 table = xmlHashCreateDict(0, dict);
3307 dtd->elements = (void *) table;
3308 }
3309 if (table == NULL) {
3310 xmlVErrMemory(NULL, "element table allocation failed");
3311 return(NULL);
3312 }
3313 }
3315
3316 uqname = xmlSplitQName2(name, &prefix);
3317 if (uqname != NULL)
3318 name = uqname;
3319 cur = xmlHashLookup2(table, name, prefix);
3320 if ((cur == NULL) && (create)) {
3322 if (cur == NULL) {
3323 xmlVErrMemory(NULL, "malloc failed");
3324 return(NULL);
3325 }
3326 memset(cur, 0, sizeof(xmlElement));
3327 cur->type = XML_ELEMENT_DECL;
3328
3329 /*
3330 * fill the structure.
3331 */
3332 cur->name = xmlStrdup(name);
3333 cur->prefix = xmlStrdup(prefix);
3335
3336 xmlHashAddEntry2(table, name, prefix, cur);
3337 }
3338 if (prefix != NULL) xmlFree(prefix);
3339 if (uqname != NULL) xmlFree(uqname);
3340 return(cur);
3341}
static const struct access_res create[16]
Definition: package.c:7644

Referenced by xmlAddAttributeDecl().

◆ xmlGetDtdNotationDesc()

xmlNotationPtr xmlGetDtdNotationDesc ( xmlDtdPtr  dtd,
const xmlChar name 
)

Definition at line 3438 of file valid.c.

3438 {
3440
3441 if (dtd == NULL) return(NULL);
3442 if (dtd->notations == NULL) return(NULL);
3444
3445 return(xmlHashLookup(table, name));
3446}

◆ xmlGetDtdQAttrDesc()

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

Definition at line 3416 of file valid.c.

3417 {
3419
3420 if (dtd == NULL) return(NULL);
3421 if (dtd->attributes == NULL) return(NULL);
3423
3424 return(xmlHashLookup3(table, name, prefix, elem));
3425}

◆ xmlGetDtdQElementDesc()

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

Definition at line 3355 of file valid.c.

3356 {
3358
3359 if (dtd == NULL) return(NULL);
3360 if (dtd->elements == NULL) return(NULL);
3362
3363 return(xmlHashLookup2(table, name, prefix));
3364}

◆ 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 2874 of file valid.c.

2874 {
2876 xmlIDPtr id;
2877
2878 if (doc == NULL) {
2879 return(NULL);
2880 }
2881
2882 if (ID == NULL) {
2883 return(NULL);
2884 }
2885
2886 table = (xmlIDTablePtr) doc->ids;
2887 if (table == NULL)
2888 return(NULL);
2889
2890 id = xmlHashLookup(table, ID);
2891 if (id == NULL)
2892 return(NULL);
2893 if (id->attr == NULL) {
2894 /*
2895 * We are operating on a stream, return a well known reference
2896 * since the attribute node doesn't exist anymore
2897 */
2898 return((xmlAttrPtr) doc);
2899 }
2900 return(id->attr);
2901}
#define ID
Definition: ruserpass.c:36
Definition: tree.h:434

Referenced by xsltLoadStylesheetPI(), and xsltTestStepMatch().

◆ xmlGetRefs()

xmlListPtr xmlGetRefs ( xmlDocPtr  doc,
const xmlChar ID 
)

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

DEPRECATED, do not use. This function will be removed from the public API.

Find the set of references for the supplied ID.

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

Definition at line 3222 of file valid.c.

3222 {
3224
3225 if (doc == NULL) {
3226 return(NULL);
3227 }
3228
3229 if (ID == NULL) {
3230 return(NULL);
3231 }
3232
3233 table = (xmlRefTablePtr) doc->refs;
3234 if (table == NULL)
3235 return(NULL);
3236
3237 return (xmlHashLookup(table, ID));
3238}

◆ 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 2774 of file valid.c.

2774 {
2775 if ((attr == NULL) || (attr->name == NULL)) return(0);
2776 if ((attr->ns != NULL) && (attr->ns->prefix != NULL) &&
2777 (!strcmp((char *) attr->name, "id")) &&
2778 (!strcmp((char *) attr->ns->prefix, "xml")))
2779 return(1);
2780 if (doc == NULL) return(0);
2781 if ((doc->intSubset == NULL) && (doc->extSubset == NULL) &&
2782 (doc->type != XML_HTML_DOCUMENT_NODE)) {
2783 return(0);
2784 } else if (doc->type == XML_HTML_DOCUMENT_NODE) {
2785 if ((xmlStrEqual(BAD_CAST "id", attr->name)) ||
2786 ((xmlStrEqual(BAD_CAST "name", attr->name)) &&
2787 ((elem == NULL) || (xmlStrEqual(elem->name, BAD_CAST "a")))))
2788 return(1);
2789 return(0);
2790 } else if (elem == NULL) {
2791 return(0);
2792 } else {
2793 xmlAttributePtr attrDecl = NULL;
2794
2795 xmlChar felem[50], fattr[50];
2796 xmlChar *fullelemname, *fullattrname;
2797
2798 fullelemname = (elem->ns != NULL && elem->ns->prefix != NULL) ?
2799 xmlBuildQName(elem->name, elem->ns->prefix, felem, 50) :
2800 (xmlChar *)elem->name;
2801
2802 fullattrname = (attr->ns != NULL && attr->ns->prefix != NULL) ?
2803 xmlBuildQName(attr->name, attr->ns->prefix, fattr, 50) :
2804 (xmlChar *)attr->name;
2805
2806 if (fullelemname != NULL && fullattrname != NULL) {
2807 attrDecl = xmlGetDtdAttrDesc(doc->intSubset, fullelemname,
2808 fullattrname);
2809 if ((attrDecl == NULL) && (doc->extSubset != NULL))
2810 attrDecl = xmlGetDtdAttrDesc(doc->extSubset, fullelemname,
2811 fullattrname);
2812 }
2813
2814 if ((fullattrname != fattr) && (fullattrname != attr->name))
2815 xmlFree(fullattrname);
2816 if ((fullelemname != felem) && (fullelemname != elem->name))
2817 xmlFree(fullelemname);
2818
2819 if ((attrDecl != NULL) && (attrDecl->atype == XML_ATTRIBUTE_ID))
2820 return(1);
2821 }
2822 return(0);
2823}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
XMLPUBFUN xmlChar *XMLCALL xmlBuildQName(const xmlChar *ncname, const xmlChar *prefix, xmlChar *memory, int len)
@ XML_HTML_DOCUMENT_NODE
Definition: tree.h:172
xmlAttributeType atype
Definition: tree.h:265
struct _xmlDtd * intSubset
Definition: tree.h:570
xmlElementType type
Definition: tree.h:553
struct _xmlDtd * extSubset
Definition: tree.h:571
Definition: fatfs.h:133
xmlAttributePtr xmlGetDtdAttrDesc(xmlDtdPtr dtd, const xmlChar *elem, const xmlChar *name)
Definition: valid.c:3379

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 3494 of file valid.c.

3494 {
3495 xmlElementPtr elemDecl;
3496
3497 if ((doc == NULL) || (doc->intSubset == NULL)) return(-1);
3498
3499 elemDecl = xmlGetDtdElementDesc(doc->intSubset, name);
3500 if ((elemDecl == NULL) && (doc->extSubset != NULL))
3501 elemDecl = xmlGetDtdElementDesc(doc->extSubset, name);
3502 if (elemDecl == NULL) return(-1);
3503 switch (elemDecl->etype) {
3505 return(-1);
3507 return(0);
3509 /*
3510 * return 1 for EMPTY since we want VC error to pop up
3511 * on <empty> </empty> for example
3512 */
3515 return(1);
3516 }
3517 return(1);
3518}
xmlElementTypeVal etype
Definition: tree.h:357
xmlElementPtr xmlGetDtdElementDesc(xmlDtdPtr dtd, const xmlChar *name)
Definition: valid.c:3257

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

DEPRECATED, do not use. This function will be removed from the public API.

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 3122 of file valid.c.

3122 {
3123 if (attr == NULL)
3124 return(0);
3125 if (doc == NULL) {
3126 doc = attr->doc;
3127 if (doc == NULL) return(0);
3128 }
3129
3130 if ((doc->intSubset == NULL) && (doc->extSubset == NULL)) {
3131 return(0);
3132 } else if (doc->type == XML_HTML_DOCUMENT_NODE) {
3133 /* TODO @@@ */
3134 return(0);
3135 } else {
3136 xmlAttributePtr attrDecl;
3137
3138 if (elem == NULL) return(0);
3139 attrDecl = xmlGetDtdAttrDesc(doc->intSubset, elem->name, attr->name);
3140 if ((attrDecl == NULL) && (doc->extSubset != NULL))
3141 attrDecl = xmlGetDtdAttrDesc(doc->extSubset,
3142 elem->name, attr->name);
3143
3144 if ((attrDecl != NULL) &&
3145 (attrDecl->atype == XML_ATTRIBUTE_IDREF ||
3146 attrDecl->atype == XML_ATTRIBUTE_IDREFS))
3147 return(1);
3148 }
3149 return(0);
3150}

Referenced by xmlSAX2AttributeNs().

◆ xmlIsStreaming()

static int xmlIsStreaming ( xmlValidCtxtPtr  ctxt)
static

Definition at line 2626 of file valid.c.

2626 {
2627 xmlParserCtxtPtr pctxt;
2628
2629 if (ctxt == NULL)
2630 return(0);
2631 if ((ctxt->flags & XML_VCTXT_USE_PCTXT) == 0)
2632 return(0);
2633 pctxt = ctxt->userData;
2634 return(pctxt->parseMode == XML_PARSE_READER);
2635}
@ XML_PARSE_READER
Definition: parser.h:167
xmlParserMode parseMode
Definition: parser.h:302

Referenced by xmlAddID(), and xmlAddRef().

◆ xmlNewDocElementContent()

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

Definition at line 908 of file valid.c.

909 {
911 xmlDictPtr dict = NULL;
912
913 if (doc != NULL)
914 dict = doc->dict;
915
916 switch(type) {
918 if (name == NULL) {
919 xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
920 "xmlNewElementContent : name == NULL !\n",
921 NULL);
922 }
923 break;
927 if (name != NULL) {
928 xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
929 "xmlNewElementContent : name != NULL !\n",
930 NULL);
931 }
932 break;
933 default:
934 xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
935 "Internal: ELEMENT content corrupted invalid type\n",
936 NULL);
937 return(NULL);
938 }
940 if (ret == NULL) {
941 xmlVErrMemory(NULL, "malloc failed");
942 return(NULL);
943 }
944 memset(ret, 0, sizeof(xmlElementContent));
945 ret->type = type;
947 if (name != NULL) {
948 int l;
949 const xmlChar *tmp;
950
951 tmp = xmlSplitQName3(name, &l);
952 if (tmp == NULL) {
953 if (dict == NULL)
954 ret->name = xmlStrdup(name);
955 else
956 ret->name = xmlDictLookup(dict, name, -1);
957 } else {
958 if (dict == NULL) {
959 ret->prefix = xmlStrndup(name, l);
960 ret->name = xmlStrdup(tmp);
961 } else {
962 ret->prefix = xmlDictLookup(dict, name, l);
963 ret->name = xmlDictLookup(dict, tmp, -1);
964 }
965 }
966 }
967 return(ret);
968}
r l[0]
Definition: byte_order.h:168
@ XML_ELEMENT_CONTENT_ONCE
Definition: tree.h:291
XMLPUBFUN const xmlChar *XMLCALL xmlSplitQName3(const xmlChar *name, int *len)
XMLPUBFUN xmlChar *XMLCALL xmlStrndup(const xmlChar *cur, int len)
Definition: xmlstring.c:42

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

◆ xmlNewElementContent()

xmlElementContentPtr xmlNewElementContent ( const xmlChar name,
xmlElementContentType  type 
)

Definition at line 981 of file valid.c.

981 {
983}
xmlElementContentPtr xmlNewDocElementContent(xmlDocPtr doc, const xmlChar *name, xmlElementContentType type)
Definition: valid.c:908

◆ 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 2835 of file valid.c.

2835 {
2837 xmlIDPtr id;
2838 xmlChar *ID;
2839
2840 if (doc == NULL) return(-1);
2841 if (attr == NULL) return(-1);
2842
2843 table = (xmlIDTablePtr) doc->ids;
2844 if (table == NULL)
2845 return(-1);
2846
2847 ID = xmlNodeListGetString(doc, attr->children, 1);
2848 if (ID == NULL)
2849 return(-1);
2851
2852 id = xmlHashLookup(table, ID);
2853 if (id == NULL || id->attr != attr) {
2854 xmlFree(ID);
2855 return(-1);
2856 }
2857
2859 xmlFree(ID);
2860 attr->atype = 0;
2861 return(0);
2862}
XMLPUBFUN int XMLCALL xmlHashRemoveEntry(xmlHashTablePtr table, const xmlChar *name, xmlHashDeallocator f)
Definition: hash.c:1052
XMLPUBFUN xmlChar *XMLCALL xmlNodeListGetString(xmlDocPtr doc, const xmlNode *list, int inLine)
static void xmlValidNormalizeString(xmlChar *str)
Definition: valid.c:2603

◆ xmlRemoveRef()

int xmlRemoveRef ( xmlDocPtr  doc,
xmlAttrPtr  attr 
)

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

DEPRECATED, do not use. This function will be removed from the public API.

Remove the given attribute from the Ref table maintained internally.

Returns -1 if the lookup failed and 0 otherwise

Definition at line 3164 of file valid.c.

3164 {
3165 xmlListPtr ref_list;
3167 xmlChar *ID;
3169
3170 if (doc == NULL) return(-1);
3171 if (attr == NULL) return(-1);
3172
3173 table = (xmlRefTablePtr) doc->refs;
3174 if (table == NULL)
3175 return(-1);
3176
3177 ID = xmlNodeListGetString(doc, attr->children, 1);
3178 if (ID == NULL)
3179 return(-1);
3180
3181 ref_list = xmlHashLookup(table, ID);
3182 if(ref_list == NULL) {
3183 xmlFree(ID);
3184 return (-1);
3185 }
3186
3187 /* At this point, ref_list refers to a list of references which
3188 * have the same key as the supplied attr. Our list of references
3189 * is ordered by reference address and we don't have that information
3190 * here to use when removing. We'll have to walk the list and
3191 * check for a matching attribute, when we find one stop the walk
3192 * and remove the entry.
3193 * The list is ordered by reference, so that means we don't have the
3194 * key. Passing the list and the reference to the walker means we
3195 * will have enough data to be able to remove the entry.
3196 */
3197 target.l = ref_list;
3198 target.ap = attr;
3199
3200 /* Remove the supplied attr from our list */
3201 xmlListWalk(ref_list, xmlWalkRemoveRef, &target);
3202
3203 /*If the list is empty then remove the list entry in the hash */
3204 if (xmlListEmpty(ref_list))
3206 xmlFree(ID);
3207 return(0);
3208}
GLenum target
Definition: glext.h:7315
XMLPUBFUN int XMLCALL xmlHashUpdateEntry(xmlHashTablePtr table, const xmlChar *name, void *userdata, xmlHashDeallocator f)
Definition: hash.c:425
XMLPUBFUN void XMLCALL xmlListWalk(xmlListPtr l, xmlListWalker walker, void *user)
Definition: list.c:676
XMLPUBFUN int XMLCALL xmlListEmpty(xmlListPtr l)
Definition: list.c:446
static int xmlWalkRemoveRef(const void *data, void *user)
Definition: valid.c:2962

◆ 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 1285 of file valid.c.

1285 {
1286 int len;
1287
1288 if (content == NULL) return;
1289 len = strlen(buf);
1290 if (size - len < 50) {
1291 if ((size - len > 4) && (buf[len - 1] != '.'))
1292 strcat(buf, " ...");
1293 return;
1294 }
1295 if (englob) strcat(buf, "(");
1296 switch (content->type) {
1298 strcat(buf, "#PCDATA");
1299 break;
1301 int qnameLen = xmlStrlen(content->name);
1302
1303 if (content->prefix != NULL)
1304 qnameLen += xmlStrlen(content->prefix) + 1;
1305 if (size - len < qnameLen + 10) {
1306 strcat(buf, " ...");
1307 return;
1308 }
1309 if (content->prefix != NULL) {
1310 strcat(buf, (char *) content->prefix);
1311 strcat(buf, ":");
1312 }
1313 if (content->name != NULL)
1314 strcat(buf, (char *) content->name);
1315 break;
1316 }
1318 if ((content->c1->type == XML_ELEMENT_CONTENT_OR) ||
1319 (content->c1->type == XML_ELEMENT_CONTENT_SEQ))
1321 else
1323 len = strlen(buf);
1324 if (size - len < 50) {
1325 if ((size - len > 4) && (buf[len - 1] != '.'))
1326 strcat(buf, " ...");
1327 return;
1328 }
1329 strcat(buf, " , ");
1330 if (((content->c2->type == XML_ELEMENT_CONTENT_OR) ||
1331 (content->c2->ocur != XML_ELEMENT_CONTENT_ONCE)) &&
1332 (content->c2->type != XML_ELEMENT_CONTENT_ELEMENT))
1334 else
1336 break;
1338 if ((content->c1->type == XML_ELEMENT_CONTENT_OR) ||
1339 (content->c1->type == XML_ELEMENT_CONTENT_SEQ))
1341 else
1343 len = strlen(buf);
1344 if (size - len < 50) {
1345 if ((size - len > 4) && (buf[len - 1] != '.'))
1346 strcat(buf, " ...");
1347 return;
1348 }
1349 strcat(buf, " | ");
1350 if (((content->c2->type == XML_ELEMENT_CONTENT_SEQ) ||
1351 (content->c2->ocur != XML_ELEMENT_CONTENT_ONCE)) &&
1352 (content->c2->type != XML_ELEMENT_CONTENT_ELEMENT))
1354 else
1356 break;
1357 }
1358 if (size - strlen(buf) <= 2) return;
1359 if (englob)
1360 strcat(buf, ")");
1361 switch (content->ocur) {
1363 break;
1365 strcat(buf, "?");
1366 break;
1368 strcat(buf, "*");
1369 break;
1371 strcat(buf, "+");
1372 break;
1373 }
1374}
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLsizei len
Definition: glext.h:6722
@ XML_ELEMENT_CONTENT_OPT
Definition: tree.h:292
@ XML_ELEMENT_CONTENT_PLUS
Definition: tree.h:294
@ XML_ELEMENT_CONTENT_MULT
Definition: tree.h:293
void xmlSnprintfElementContent(char *buf, int size, xmlElementContentPtr content, int englob)
Definition: valid.c:1285
XMLPUBFUN int XMLCALL xmlStrlen(const xmlChar *str)
Definition: xmlstring.c:426

Referenced by xmlSnprintfElementContent().

◆ xmlValidNormalizeString()

static void xmlValidNormalizeString ( xmlChar str)
static

xmlValidNormalizeString: @str: a string

Normalize a string in-place.

Definition at line 2603 of file valid.c.

2603 {
2604 xmlChar *dst;
2605 const xmlChar *src;
2606
2607 if (str == NULL)
2608 return;
2609 src = str;
2610 dst = str;
2611
2612 while (*src == 0x20) src++;
2613 while (*src != 0) {
2614 if (*src == 0x20) {
2615 while (*src == 0x20) src++;
2616 if (*src != 0)
2617 *dst++ = 0x20;
2618 } else {
2619 *dst++ = *src++;
2620 }
2621 }
2622 *dst = 0;
2623}
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

Referenced by xmlRemoveID().

◆ xmlVErrMemory()

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

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

Handle an out of memory error

Definition at line 55 of file valid.c.

56{
57 xmlGenericErrorFunc channel = NULL;
58 xmlParserCtxtPtr pctxt = NULL;
59 void *data = NULL;
60
61 if (ctxt != NULL) {
62 channel = ctxt->error;
63 data = ctxt->userData;
64 /* Look up flag to detect if it is part of a parsing
65 context */
66 if (ctxt->flags & XML_VCTXT_USE_PCTXT) {
67 long delta = (char *) ctxt - (char *) ctxt->userData;
68 if ((delta > 0) && (delta < 250))
69 pctxt = ctxt->userData;
70 }
71 }
72 if (extra)
73 __xmlRaiseError(NULL, channel, data,
75 XML_ERR_FATAL, NULL, 0, extra, NULL, NULL, 0, 0,
76 "Memory allocation failed : %s\n", extra);
77 else
78 __xmlRaiseError(NULL, channel, data,
80 XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, 0, 0,
81 "Memory allocation failed\n");
82}
@ XML_ERR_FATAL
Definition: xmlerror.h:28
@ XML_ERR_NO_MEMORY
Definition: xmlerror.h:102

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 2962 of file valid.c.

2963{
2964 xmlAttrPtr attr0 = ((xmlRefPtr)data)->attr;
2965 xmlAttrPtr attr1 = ((xmlRemoveMemoPtr)user)->ap;
2966 xmlListPtr ref_list = ((xmlRemoveMemoPtr)user)->l;
2967
2968 if (attr0 == attr1) { /* Matched: remove and terminate walk */
2969 xmlListRemoveFirst(ref_list, (void *)data);
2970 return 0;
2971 }
2972 return 1;
2973}
void user(int argc, const char *argv[])
Definition: cmds.c:1350
XMLPUBFUN int XMLCALL xmlListRemoveFirst(xmlListPtr l, void *data)
Definition: list.c:353
xmlRemoveMemo * xmlRemoveMemoPtr
Definition: valid.c:2914

Referenced by xmlRemoveRef().