ReactOS 0.4.16-dev-2207-geb15453
valid.h File Reference
#include <libxml/xmlversion.h>
#include <libxml/xmlerror.h>
#include <libxml/tree.h>
#include <libxml/list.h>
#include <libxml/xmlautomata.h>
#include <libxml/xmlregexp.h>
Include dependency graph for valid.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _xmlValidCtxt
 

Macros

#define XML_TREE_INTERNALS
 

Typedefs

typedef struct _xmlValidState xmlValidState
 
typedef xmlValidStatexmlValidStatePtr
 
typedef void(* xmlValidityErrorFunc) (void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2
 
typedef void(*) typedef void(* xmlValidityWarningFunc) (void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2
 
typedef typedeftypedef void(*) typedef void(*) struct _xmlValidCtx xmlValidCtxt)
 
typedef xmlValidCtxtxmlValidCtxtPtr
 
typedef struct _xmlHashTable xmlNotationTable
 
typedef xmlNotationTablexmlNotationTablePtr
 
typedef struct _xmlHashTable xmlElementTable
 
typedef xmlElementTablexmlElementTablePtr
 
typedef struct _xmlHashTable xmlAttributeTable
 
typedef xmlAttributeTablexmlAttributeTablePtr
 
typedef struct _xmlHashTable xmlIDTable
 
typedef xmlIDTablexmlIDTablePtr
 
typedef struct _xmlHashTable xmlRefTable
 
typedef xmlRefTablexmlRefTablePtr
 

Functions

XMLPUBFUN xmlNotationPtr xmlAddNotationDecl (xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *name, const xmlChar *PublicID, const xmlChar *SystemID)
 
XMLPUBFUN void xmlFreeNotationTable (xmlNotationTablePtr table)
 
XMLPUBFUN xmlElementContentPtr xmlNewElementContent (const xmlChar *name, xmlElementContentType type)
 
XMLPUBFUN xmlElementContentPtr xmlCopyElementContent (xmlElementContentPtr content)
 
XMLPUBFUN void xmlFreeElementContent (xmlElementContentPtr cur)
 
XMLPUBFUN xmlElementContentPtr xmlNewDocElementContent (xmlDocPtr doc, const xmlChar *name, xmlElementContentType type)
 
XMLPUBFUN xmlElementContentPtr xmlCopyDocElementContent (xmlDocPtr doc, xmlElementContentPtr content)
 
XMLPUBFUN void xmlFreeDocElementContent (xmlDocPtr doc, xmlElementContentPtr cur)
 
XMLPUBFUN void xmlSnprintfElementContent (char *buf, int size, xmlElementContentPtr content, int englob)
 
XMLPUBFUN xmlElementPtr xmlAddElementDecl (xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *name, xmlElementTypeVal type, xmlElementContentPtr content)
 
XMLPUBFUN void xmlFreeElementTable (xmlElementTablePtr table)
 
XMLPUBFUN xmlEnumerationPtr xmlCreateEnumeration (const xmlChar *name)
 
XMLPUBFUN void xmlFreeEnumeration (xmlEnumerationPtr cur)
 
XMLPUBFUN xmlAttributePtr xmlAddAttributeDecl (xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *elem, const xmlChar *name, const xmlChar *ns, xmlAttributeType type, xmlAttributeDefault def, const xmlChar *defaultValue, xmlEnumerationPtr tree)
 
XMLPUBFUN void xmlFreeAttributeTable (xmlAttributeTablePtr table)
 
XMLPUBFUN xmlIDPtr xmlAddID (xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value, xmlAttrPtr attr)
 
XMLPUBFUN void xmlFreeIDTable (xmlIDTablePtr table)
 
XMLPUBFUN xmlAttrPtr xmlGetID (xmlDocPtr doc, const xmlChar *ID)
 
XMLPUBFUN int xmlIsID (xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr)
 
XMLPUBFUN int xmlRemoveID (xmlDocPtr doc, xmlAttrPtr attr)
 
XML_DEPRECATED XMLPUBFUN xmlRefPtr xmlAddRef (xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value, xmlAttrPtr attr)
 
XML_DEPRECATED XMLPUBFUN void xmlFreeRefTable (xmlRefTablePtr table)
 
XML_DEPRECATED XMLPUBFUN int xmlIsRef (xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr)
 
XML_DEPRECATED XMLPUBFUN int xmlRemoveRef (xmlDocPtr doc, xmlAttrPtr attr)
 
XML_DEPRECATED XMLPUBFUN xmlListPtr xmlGetRefs (xmlDocPtr doc, const xmlChar *ID)
 
XMLPUBFUN int xmlIsMixedElement (xmlDocPtr doc, const xmlChar *name)
 
XMLPUBFUN xmlAttributePtr xmlGetDtdAttrDesc (xmlDtdPtr dtd, const xmlChar *elem, const xmlChar *name)
 
XMLPUBFUN xmlAttributePtr xmlGetDtdQAttrDesc (xmlDtdPtr dtd, const xmlChar *elem, const xmlChar *name, const xmlChar *prefix)
 
XMLPUBFUN xmlNotationPtr xmlGetDtdNotationDesc (xmlDtdPtr dtd, const xmlChar *name)
 
XMLPUBFUN xmlElementPtr xmlGetDtdQElementDesc (xmlDtdPtr dtd, const xmlChar *name, const xmlChar *prefix)
 
XMLPUBFUN xmlElementPtr xmlGetDtdElementDesc (xmlDtdPtr dtd, const xmlChar *name)
 

Macro Definition Documentation

◆ XML_TREE_INTERNALS

#define XML_TREE_INTERNALS

Definition at line 16 of file valid.h.

Typedef Documentation

◆ xmlAttributeTable

Definition at line 120 of file valid.h.

◆ xmlAttributeTablePtr

Definition at line 121 of file valid.h.

◆ xmlElementTable

Definition at line 112 of file valid.h.

◆ xmlElementTablePtr

Definition at line 113 of file valid.h.

◆ xmlIDTable

Definition at line 128 of file valid.h.

◆ xmlIDTablePtr

Definition at line 129 of file valid.h.

◆ xmlNotationTable

Definition at line 104 of file valid.h.

◆ xmlNotationTablePtr

Definition at line 105 of file valid.h.

◆ xmlRefTable

Definition at line 136 of file valid.h.

◆ xmlRefTablePtr

Definition at line 137 of file valid.h.

◆ xmlValidCtxt

typedef typedeftypedef void(*) typedef void(*) struct _xmlValidCtx xmlValidCtxt)

Definition at line 67 of file valid.h.

◆ xmlValidCtxtPtr

Definition at line 68 of file valid.h.

◆ xmlValidityErrorFunc

typedef void(* xmlValidityErrorFunc) (void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2

xmlValidityErrorFunc: @ctx: usually an xmlValidCtxtPtr to a validity error context, but comes from ctxt->userData (which normally contains such a pointer); ctxt->userData can be changed by the user. @msg: the string to format *printf like vararg ...: remaining arguments to the format

Callback called when a validity error is found. This is a message oriented function similar to an *printf function.

Definition at line 44 of file valid.h.

◆ xmlValidityWarningFunc

typedef void(*) typedef void(* xmlValidityWarningFunc) (void *ctx, const char *msg,...) LIBXML_ATTR_FORMAT(2

xmlValidityWarningFunc: @ctx: usually an xmlValidCtxtPtr to a validity error context, but comes from ctxt->userData (which normally contains such a pointer); ctxt->userData can be changed by the user. @msg: the string to format *printf like vararg ...: remaining arguments to the format

Callback called when a validity warning is found. This is a message oriented function similar to an *printf function.

Definition at line 59 of file valid.h.

◆ xmlValidState

typedef struct _xmlValidState xmlValidState

Definition at line 30 of file valid.h.

◆ xmlValidStatePtr

Definition at line 31 of file valid.h.

Function Documentation

◆ xmlAddAttributeDecl()

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

1816 {
1817 xmlAttributePtr ret;
1819 xmlElementPtr elemDef;
1820 xmlDictPtr dict = NULL;
1821
1822 if (dtd == NULL) {
1824 return(NULL);
1825 }
1826 if (name == NULL) {
1828 return(NULL);
1829 }
1830 if (elem == NULL) {
1832 return(NULL);
1833 }
1834 if (dtd->doc != NULL)
1835 dict = dtd->doc->dict;
1836
1837#ifdef LIBXML_VALID_ENABLED
1838 /*
1839 * Check the type and possibly the default value.
1840 */
1841 switch (type) {
1842 case XML_ATTRIBUTE_CDATA:
1843 break;
1844 case XML_ATTRIBUTE_ID:
1845 break;
1846 case XML_ATTRIBUTE_IDREF:
1847 break;
1848 case XML_ATTRIBUTE_IDREFS:
1849 break;
1850 case XML_ATTRIBUTE_ENTITY:
1851 break;
1852 case XML_ATTRIBUTE_ENTITIES:
1853 break;
1854 case XML_ATTRIBUTE_NMTOKEN:
1855 break;
1856 case XML_ATTRIBUTE_NMTOKENS:
1857 break;
1858 case XML_ATTRIBUTE_ENUMERATION:
1859 break;
1860 case XML_ATTRIBUTE_NOTATION:
1861 break;
1862 default:
1863 xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR,
1864 "Internal: ATTRIBUTE struct corrupted invalid type\n",
1865 NULL);
1867 return(NULL);
1868 }
1869 if ((defaultValue != NULL) &&
1870 (!xmlValidateAttributeValueInternal(dtd->doc, type, defaultValue))) {
1871 xmlErrValidNode(ctxt, (xmlNodePtr) dtd, XML_DTD_ATTRIBUTE_DEFAULT,
1872 "Attribute %s of %s: invalid default value\n",
1873 elem, name, defaultValue);
1874 defaultValue = NULL;
1875 if (ctxt != NULL)
1876 ctxt->valid = 0;
1877 }
1878#endif /* LIBXML_VALID_ENABLED */
1879
1880 /*
1881 * Check first that an attribute defined in the external subset wasn't
1882 * already defined in the internal subset
1883 */
1884 if ((dtd->doc != NULL) && (dtd->doc->extSubset == dtd) &&
1885 (dtd->doc->intSubset != NULL) &&
1886 (dtd->doc->intSubset->attributes != NULL)) {
1887 ret = xmlHashLookup3(dtd->doc->intSubset->attributes, name, ns, elem);
1888 if (ret != NULL) {
1890 return(NULL);
1891 }
1892 }
1893
1894 /*
1895 * Create the Attribute table if needed.
1896 */
1897 table = (xmlAttributeTablePtr) dtd->attributes;
1898 if (table == NULL) {
1899 table = xmlHashCreateDict(0, dict);
1900 dtd->attributes = (void *) table;
1901 }
1902 if (table == NULL) {
1903 xmlVErrMemory(ctxt,
1904 "xmlAddAttributeDecl: Table creation failed!\n");
1906 return(NULL);
1907 }
1908
1909
1910 ret = (xmlAttributePtr) xmlMalloc(sizeof(xmlAttribute));
1911 if (ret == NULL) {
1912 xmlVErrMemory(ctxt, "malloc failed");
1914 return(NULL);
1915 }
1916 memset(ret, 0, sizeof(xmlAttribute));
1917 ret->type = XML_ATTRIBUTE_DECL;
1918
1919 /*
1920 * fill the structure.
1921 */
1922 ret->atype = type;
1923 /*
1924 * doc must be set before possible error causes call
1925 * to xmlFreeAttribute (because it's used to check on
1926 * dict use)
1927 */
1928 ret->doc = dtd->doc;
1929 if (dict) {
1930 ret->name = xmlDictLookup(dict, name, -1);
1931 ret->prefix = xmlDictLookup(dict, ns, -1);
1932 ret->elem = xmlDictLookup(dict, elem, -1);
1933 } else {
1934 ret->name = xmlStrdup(name);
1935 ret->prefix = xmlStrdup(ns);
1936 ret->elem = xmlStrdup(elem);
1937 }
1938 ret->def = def;
1939 ret->tree = tree;
1940 if (defaultValue != NULL) {
1941 if (dict)
1942 ret->defaultValue = xmlDictLookup(dict, defaultValue, -1);
1943 else
1944 ret->defaultValue = xmlStrdup(defaultValue);
1945 }
1946
1947 /*
1948 * Validity Check:
1949 * Search the DTD for previous declarations of the ATTLIST
1950 */
1951 if (xmlHashAddEntry3(table, ret->name, ret->prefix, ret->elem, ret) < 0) {
1952#ifdef LIBXML_VALID_ENABLED
1953 /*
1954 * The attribute is already defined in this DTD.
1955 */
1956 xmlErrValidWarning(ctxt, (xmlNodePtr) dtd, XML_DTD_ATTRIBUTE_REDEFINED,
1957 "Attribute %s of element %s: already defined\n",
1958 name, elem, NULL);
1959#endif /* LIBXML_VALID_ENABLED */
1961 return(NULL);
1962 }
1963
1964 /*
1965 * Validity Check:
1966 * Multiple ID per element
1967 */
1968 elemDef = xmlGetDtdElementDesc2(ctxt, dtd, elem, 1);
1969 if (elemDef != NULL) {
1970
1971#ifdef LIBXML_VALID_ENABLED
1972 if ((type == XML_ATTRIBUTE_ID) &&
1973 (xmlScanIDAttributeDecl(NULL, elemDef, 1) != 0)) {
1974 xmlErrValidNode(ctxt, (xmlNodePtr) dtd, XML_DTD_MULTIPLE_ID,
1975 "Element %s has too may ID attributes defined : %s\n",
1976 elem, name, NULL);
1977 if (ctxt != NULL)
1978 ctxt->valid = 0;
1979 }
1980#endif /* LIBXML_VALID_ENABLED */
1981
1982 /*
1983 * Insert namespace default def first they need to be
1984 * processed first.
1985 */
1986 if ((xmlStrEqual(ret->name, BAD_CAST "xmlns")) ||
1987 ((ret->prefix != NULL &&
1988 (xmlStrEqual(ret->prefix, BAD_CAST "xmlns"))))) {
1989 ret->nexth = elemDef->attributes;
1990 elemDef->attributes = ret;
1991 } else {
1992 xmlAttributePtr tmp = elemDef->attributes;
1993
1994 while ((tmp != NULL) &&
1995 ((xmlStrEqual(tmp->name, BAD_CAST "xmlns")) ||
1996 ((ret->prefix != NULL &&
1997 (xmlStrEqual(ret->prefix, BAD_CAST "xmlns")))))) {
1998 if (tmp->nexth == NULL)
1999 break;
2000 tmp = tmp->nexth;
2001 }
2002 if (tmp != NULL) {
2003 ret->nexth = tmp->nexth;
2004 tmp->nexth = ret;
2005 } else {
2006 ret->nexth = elemDef->attributes;
2007 elemDef->attributes = ret;
2008 }
2009 }
2010 }
2011
2012 /*
2013 * Link it to the DTD
2014 */
2015 ret->parent = dtd;
2016 if (dtd->last == NULL) {
2017 dtd->children = dtd->last = (xmlNodePtr) ret;
2018 } else {
2019 dtd->last->next = (xmlNodePtr) ret;
2020 ret->prev = dtd->last;
2021 dtd->last = (xmlNodePtr) ret;
2022 }
2023 return(ret);
2024}
struct _tree tree
#define NULL
Definition: types.h:112
return ret
Definition: mutex.c:146
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
if(dx< 0)
Definition: linetemp.h:194
static size_t elem
Definition: string.c:71
const xmlChar * xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len)
Definition: dict.c:824
xmlMallocFunc xmlMalloc
Definition: globals.c:193
int xmlHashAddEntry3(xmlHashTablePtr hash, const xmlChar *key, const xmlChar *key2, const xmlChar *key3, void *payload)
Definition: hash.c:659
xmlHashTablePtr xmlHashCreateDict(int size, xmlDictPtr dict)
Definition: hash.c:209
void * xmlHashLookup3(xmlHashTablePtr hash, const xmlChar *key, const xmlChar *key2, const xmlChar *key3)
Definition: hash.c:806
#define memset(x, y, z)
Definition: compat.h:39
Definition: dict.c:59
Definition: name.c:39
Definition: mxnamespace.c:38
static void xmlVErrMemory(xmlValidCtxtPtr ctxt, const char *extra)
Definition: valid.c:56
static xmlElementPtr xmlGetDtdElementDesc2(xmlValidCtxtPtr ctxt, xmlDtdPtr dtd, const xmlChar *name, int create)
Definition: valid.c:3132
void xmlFreeEnumeration(xmlEnumerationPtr cur)
Definition: valid.c:1662
static void xmlFreeAttribute(xmlAttributePtr attr)
Definition: valid.c:1759
xmlAttributeTable * xmlAttributeTablePtr
Definition: valid.h:121
@ XML_DTD_ATTRIBUTE_REDEFINED
Definition: xmlerror.h:221
@ XML_DTD_MULTIPLE_ID
Definition: xmlerror.h:240
@ XML_DTD_ATTRIBUTE_DEFAULT
Definition: xmlerror.h:220
@ XML_ERR_INTERNAL_ERROR
Definition: xmlerror.h:101
#define BAD_CAST
Definition: xmlstring.h:35
XMLPUBFUN int xmlStrEqual(const xmlChar *str1, const xmlChar *str2)
Definition: xmlstring.c:162
XMLPUBFUN xmlChar * xmlStrdup(const xmlChar *cur)
Definition: xmlstring.c:69

Referenced by xmlSAX2AttributeDecl().

◆ xmlAddElementDecl()

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

Definition at line 1263 of file valid.c.

1266 {
1267 xmlElementPtr ret;
1269 xmlAttributePtr oldAttributes = NULL;
1270 xmlChar *ns, *uqname;
1271
1272 if (dtd == NULL) {
1273 return(NULL);
1274 }
1275 if (name == NULL) {
1276 return(NULL);
1277 }
1278
1279 switch (type) {
1280 case XML_ELEMENT_TYPE_EMPTY:
1281 if (content != NULL) {
1282 xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR,
1283 "xmlAddElementDecl: content != NULL for EMPTY\n",
1284 NULL);
1285 return(NULL);
1286 }
1287 break;
1288 case XML_ELEMENT_TYPE_ANY:
1289 if (content != NULL) {
1290 xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR,
1291 "xmlAddElementDecl: content != NULL for ANY\n",
1292 NULL);
1293 return(NULL);
1294 }
1295 break;
1296 case XML_ELEMENT_TYPE_MIXED:
1297 if (content == NULL) {
1298 xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR,
1299 "xmlAddElementDecl: content == NULL for MIXED\n",
1300 NULL);
1301 return(NULL);
1302 }
1303 break;
1304 case XML_ELEMENT_TYPE_ELEMENT:
1305 if (content == NULL) {
1306 xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR,
1307 "xmlAddElementDecl: content == NULL for ELEMENT\n",
1308 NULL);
1309 return(NULL);
1310 }
1311 break;
1312 default:
1313 xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR,
1314 "Internal: ELEMENT decl corrupted invalid type\n",
1315 NULL);
1316 return(NULL);
1317 }
1318
1319 /*
1320 * check if name is a QName
1321 */
1322 uqname = xmlSplitQName2(name, &ns);
1323 if (uqname != NULL)
1324 name = uqname;
1325
1326 /*
1327 * Create the Element table if needed.
1328 */
1329 table = (xmlElementTablePtr) dtd->elements;
1330 if (table == NULL) {
1331 xmlDictPtr dict = NULL;
1332
1333 if (dtd->doc != NULL)
1334 dict = dtd->doc->dict;
1335 table = xmlHashCreateDict(0, dict);
1336 dtd->elements = (void *) table;
1337 }
1338 if (table == NULL) {
1339 xmlVErrMemory(ctxt,
1340 "xmlAddElementDecl: Table creation failed!\n");
1341 if (uqname != NULL)
1342 xmlFree(uqname);
1343 if (ns != NULL)
1344 xmlFree(ns);
1345 return(NULL);
1346 }
1347
1348 /*
1349 * lookup old attributes inserted on an undefined element in the
1350 * internal subset.
1351 */
1352 if ((dtd->doc != NULL) && (dtd->doc->intSubset != NULL)) {
1353 ret = xmlHashLookup2(dtd->doc->intSubset->elements, name, ns);
1354 if ((ret != NULL) && (ret->etype == XML_ELEMENT_TYPE_UNDEFINED)) {
1355 oldAttributes = ret->attributes;
1356 ret->attributes = NULL;
1357 xmlHashRemoveEntry2(dtd->doc->intSubset->elements, name, ns, NULL);
1359 }
1360 }
1361
1362 /*
1363 * The element may already be present if one of its attribute
1364 * was registered first
1365 */
1367 if (ret != NULL) {
1368 if (ret->etype != XML_ELEMENT_TYPE_UNDEFINED) {
1369#ifdef LIBXML_VALID_ENABLED
1370 /*
1371 * The element is already defined in this DTD.
1372 */
1373 xmlErrValidNode(ctxt, (xmlNodePtr) dtd, XML_DTD_ELEM_REDEFINED,
1374 "Redefinition of element %s\n",
1375 name, NULL, NULL);
1376#endif /* LIBXML_VALID_ENABLED */
1377 if (uqname != NULL)
1378 xmlFree(uqname);
1379 if (ns != NULL)
1380 xmlFree(ns);
1381 return(NULL);
1382 }
1383 if (ns != NULL) {
1384 xmlFree(ns);
1385 ns = NULL;
1386 }
1387 } else {
1388 ret = (xmlElementPtr) xmlMalloc(sizeof(xmlElement));
1389 if (ret == NULL) {
1390 xmlVErrMemory(ctxt, "malloc failed");
1391 if (uqname != NULL)
1392 xmlFree(uqname);
1393 if (ns != NULL)
1394 xmlFree(ns);
1395 return(NULL);
1396 }
1397 memset(ret, 0, sizeof(xmlElement));
1398 ret->type = XML_ELEMENT_DECL;
1399
1400 /*
1401 * fill the structure.
1402 */
1403 ret->name = xmlStrdup(name);
1404 if (ret->name == NULL) {
1405 xmlVErrMemory(ctxt, "malloc failed");
1406 if (uqname != NULL)
1407 xmlFree(uqname);
1408 if (ns != NULL)
1409 xmlFree(ns);
1410 xmlFree(ret);
1411 return(NULL);
1412 }
1413 ret->prefix = ns;
1414
1415 /*
1416 * Validity Check:
1417 * Insertion must not fail
1418 */
1419 if (xmlHashAddEntry2(table, name, ns, ret)) {
1420#ifdef LIBXML_VALID_ENABLED
1421 /*
1422 * The element is already defined in this DTD.
1423 */
1424 xmlErrValidNode(ctxt, (xmlNodePtr) dtd, XML_DTD_ELEM_REDEFINED,
1425 "Redefinition of element %s\n",
1426 name, NULL, NULL);
1427#endif /* LIBXML_VALID_ENABLED */
1429 if (uqname != NULL)
1430 xmlFree(uqname);
1431 return(NULL);
1432 }
1433 /*
1434 * For new element, may have attributes from earlier
1435 * definition in internal subset
1436 */
1437 ret->attributes = oldAttributes;
1438 }
1439
1440 /*
1441 * Finish to fill the structure.
1442 */
1443 ret->etype = type;
1444 /*
1445 * Avoid a stupid copy when called by the parser
1446 * and flag it by setting a special parent value
1447 * so the parser doesn't unallocate it.
1448 */
1449 if ((ctxt != NULL) && (ctxt->flags & XML_VCTXT_USE_PCTXT)) {
1450 ret->content = content;
1451 if (content != NULL)
1452 content->parent = (xmlElementContentPtr) 1;
1453 } else {
1454 ret->content = xmlCopyDocElementContent(dtd->doc, content);
1455 }
1456
1457 /*
1458 * Link it to the DTD
1459 */
1460 ret->parent = dtd;
1461 ret->doc = dtd->doc;
1462 if (dtd->last == NULL) {
1463 dtd->children = dtd->last = (xmlNodePtr) ret;
1464 } else {
1465 dtd->last->next = (xmlNodePtr) ret;
1466 ret->prev = dtd->last;
1467 dtd->last = (xmlNodePtr) ret;
1468 }
1469 if (uqname != NULL)
1470 xmlFree(uqname);
1471 return(ret);
1472}
content
Definition: atl_ax.c:994
xmlFreeFunc xmlFree
Definition: globals.c:184
void * xmlHashLookup2(xmlHashTablePtr hash, const xmlChar *key, const xmlChar *key2)
Definition: hash.c:754
int xmlHashRemoveEntry2(xmlHashTablePtr hash, const xmlChar *key, const xmlChar *key2, xmlHashDeallocator dealloc)
Definition: hash.c:1121
int xmlHashAddEntry2(xmlHashTablePtr hash, const xmlChar *key, const xmlChar *key2, void *payload)
Definition: hash.c:639
#define XML_VCTXT_USE_PCTXT
Definition: parser.h:18
xmlElementContentPtr xmlCopyDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur)
Definition: valid.c:840
static void xmlFreeElement(xmlElementPtr elem)
Definition: valid.c:1234
xmlElementTable * xmlElementTablePtr
Definition: valid.h:113
@ XML_DTD_ELEM_REDEFINED
Definition: xmlerror.h:229
unsigned char xmlChar
Definition: xmlstring.h:28

Referenced by xmlSAX2ElementDecl().

◆ xmlAddID()

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

2518 {
2519 xmlIDPtr ret;
2521
2522 if (doc == NULL) {
2523 return(NULL);
2524 }
2525 if ((value == NULL) || (value[0] == 0)) {
2526 return(NULL);
2527 }
2528 if (attr == NULL) {
2529 return(NULL);
2530 }
2531
2532 /*
2533 * Create the ID table if needed.
2534 */
2535 table = (xmlIDTablePtr) doc->ids;
2536 if (table == NULL) {
2537 doc->ids = table = xmlHashCreateDict(0, doc->dict);
2538 }
2539 if (table == NULL) {
2540 xmlVErrMemory(ctxt,
2541 "xmlAddID: Table creation failed!\n");
2542 return(NULL);
2543 }
2544
2545 ret = (xmlIDPtr) xmlMalloc(sizeof(xmlID));
2546 if (ret == NULL) {
2547 xmlVErrMemory(ctxt, "malloc failed");
2548 return(NULL);
2549 }
2550
2551 /*
2552 * fill the structure.
2553 */
2554 ret->value = xmlStrdup(value);
2555 ret->doc = doc;
2556 if (xmlIsStreaming(ctxt)) {
2557 /*
2558 * Operating in streaming mode, attr is gonna disappear
2559 */
2560 if (doc->dict != NULL)
2561 ret->name = xmlDictLookup(doc->dict, attr->name, -1);
2562 else
2563 ret->name = xmlStrdup(attr->name);
2564 ret->attr = NULL;
2565 } else {
2566 ret->attr = attr;
2567 ret->name = NULL;
2568 }
2569 ret->lineno = xmlGetLineNo(attr->parent);
2570
2571 if (xmlHashAddEntry(table, value, ret) < 0) {
2572#ifdef LIBXML_VALID_ENABLED
2573 /*
2574 * The id is already defined in this DTD.
2575 */
2576 if (ctxt != NULL) {
2577 xmlErrValidNode(ctxt, attr->parent, XML_DTD_ID_REDEFINED,
2578 "ID %s already defined\n", value, NULL, NULL);
2579 }
2580#endif /* LIBXML_VALID_ENABLED */
2581 xmlFreeID(ret);
2582 return(NULL);
2583 }
2584 if (attr != NULL)
2585 attr->atype = XML_ATTRIBUTE_ID;
2586 return(ret);
2587}
int xmlHashAddEntry(xmlHashTablePtr hash, const xmlChar *key, void *payload)
Definition: hash.c:621
Definition: cookie.c:202
WCHAR * name
Definition: cookie.c:203
Definition: pdh_main.c:96
static int xmlIsStreaming(xmlValidCtxtPtr ctxt)
Definition: valid.c:2471
static void xmlFreeID(xmlIDPtr id)
Definition: valid.c:2489
xmlIDTable * xmlIDTablePtr
Definition: valid.h:129
@ XML_DTD_ID_REDEFINED
Definition: xmlerror.h:233

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

◆ xmlAddNotationDecl()

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

Definition at line 2239 of file valid.c.

2241 {
2242 xmlNotationPtr ret;
2244
2245 if (dtd == NULL) {
2246 return(NULL);
2247 }
2248 if (name == NULL) {
2249 return(NULL);
2250 }
2251 if ((PublicID == NULL) && (SystemID == NULL)) {
2252 return(NULL);
2253 }
2254
2255 /*
2256 * Create the Notation table if needed.
2257 */
2258 table = (xmlNotationTablePtr) dtd->notations;
2259 if (table == NULL) {
2260 xmlDictPtr dict = NULL;
2261 if (dtd->doc != NULL)
2262 dict = dtd->doc->dict;
2263
2264 dtd->notations = table = xmlHashCreateDict(0, dict);
2265 }
2266 if (table == NULL) {
2267 xmlVErrMemory(ctxt,
2268 "xmlAddNotationDecl: Table creation failed!\n");
2269 return(NULL);
2270 }
2271
2272 ret = (xmlNotationPtr) xmlMalloc(sizeof(xmlNotation));
2273 if (ret == NULL) {
2274 xmlVErrMemory(ctxt, "malloc failed");
2275 return(NULL);
2276 }
2277 memset(ret, 0, sizeof(xmlNotation));
2278
2279 /*
2280 * fill the structure.
2281 */
2282 ret->name = xmlStrdup(name);
2283 if (SystemID != NULL)
2284 ret->SystemID = xmlStrdup(SystemID);
2285 if (PublicID != NULL)
2286 ret->PublicID = xmlStrdup(PublicID);
2287
2288 /*
2289 * Validity Check:
2290 * Check the DTD for previous declarations of the ATTLIST
2291 */
2292 if (xmlHashAddEntry(table, name, ret)) {
2293#ifdef LIBXML_VALID_ENABLED
2294 xmlErrValid(NULL, XML_DTD_NOTATION_REDEFINED,
2295 "xmlAddNotationDecl: %s already defined\n",
2296 (const char *) name);
2297#endif /* LIBXML_VALID_ENABLED */
2299 return(NULL);
2300 }
2301 return(ret);
2302}
static void xmlFreeNotation(xmlNotationPtr nota)
Definition: valid.c:2214
xmlNotationTable * xmlNotationTablePtr
Definition: valid.h:105
@ XML_DTD_NOTATION_REDEFINED
Definition: xmlerror.h:246

Referenced by xmlSAX2NotationDecl().

◆ xmlAddRef()

XML_DEPRECATED XMLPUBFUN 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 2848 of file valid.c.

2849 {
2850 xmlRefPtr ret;
2852 xmlListPtr ref_list;
2853
2854 if (doc == NULL) {
2855 return(NULL);
2856 }
2857 if (value == NULL) {
2858 return(NULL);
2859 }
2860 if (attr == NULL) {
2861 return(NULL);
2862 }
2863
2864 /*
2865 * Create the Ref table if needed.
2866 */
2867 table = (xmlRefTablePtr) doc->refs;
2868 if (table == NULL) {
2869 doc->refs = table = xmlHashCreateDict(0, doc->dict);
2870 }
2871 if (table == NULL) {
2872 xmlVErrMemory(ctxt,
2873 "xmlAddRef: Table creation failed!\n");
2874 return(NULL);
2875 }
2876
2877 ret = (xmlRefPtr) xmlMalloc(sizeof(xmlRef));
2878 if (ret == NULL) {
2879 xmlVErrMemory(ctxt, "malloc failed");
2880 return(NULL);
2881 }
2882
2883 /*
2884 * fill the structure.
2885 */
2886 ret->value = xmlStrdup(value);
2887 if (xmlIsStreaming(ctxt)) {
2888 /*
2889 * Operating in streaming mode, attr is gonna disappear
2890 */
2891 ret->name = xmlStrdup(attr->name);
2892 ret->attr = NULL;
2893 } else {
2894 ret->name = NULL;
2895 ret->attr = attr;
2896 }
2897 ret->lineno = xmlGetLineNo(attr->parent);
2898
2899 /* To add a reference :-
2900 * References are maintained as a list of references,
2901 * Lookup the entry, if no entry create new nodelist
2902 * Add the owning node to the NodeList
2903 * Return the ref
2904 */
2905
2906 if (NULL == (ref_list = xmlHashLookup(table, value))) {
2907 if (NULL == (ref_list = xmlListCreate(xmlFreeRef, xmlDummyCompare))) {
2908 xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
2909 "xmlAddRef: Reference list creation failed!\n",
2910 NULL);
2911 goto failed;
2912 }
2913 if (xmlHashAddEntry(table, value, ref_list) < 0) {
2914 xmlListDelete(ref_list);
2915 xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
2916 "xmlAddRef: Reference list insertion failed!\n",
2917 NULL);
2918 goto failed;
2919 }
2920 }
2921 if (xmlListAppend(ref_list, ret) != 0) {
2922 xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
2923 "xmlAddRef: Reference list insertion failed!\n",
2924 NULL);
2925 goto failed;
2926 }
2927 return(ret);
2928failed:
2929 if (ret != NULL) {
2930 if (ret->value != NULL)
2931 xmlFree((char *)ret->value);
2932 if (ret->name != NULL)
2933 xmlFree((char *)ret->name);
2934 xmlFree(ret);
2935 }
2936 return(NULL);
2937}
void * xmlHashLookup(xmlHashTablePtr hash, const xmlChar *key)
Definition: hash.c:739
XMLPUBFUN int xmlListAppend(xmlListPtr l, void *data)
Definition: list.c:305
XMLPUBFUN void xmlListDelete(xmlListPtr l)
Definition: list.c:333
XMLPUBFUN xmlListPtr xmlListCreate(xmlListDeallocator deallocator, xmlListDataCompare compare)
Definition: list.c:188
Definition: list.c:39
static int xmlDummyCompare(const void *data0 ATTRIBUTE_UNUSED, const void *data1 ATTRIBUTE_UNUSED)
Definition: valid.c:2828
static void xmlFreeRef(xmlLinkPtr lk)
Definition: valid.c:2776
xmlRefTable * xmlRefTablePtr
Definition: valid.h:137

Referenced by xmlSAX2AttributeNs().

◆ xmlCopyDocElementContent()

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

840 {
841 xmlElementContentPtr ret = NULL, prev = NULL, tmp;
842 xmlDictPtr dict = NULL;
843
844 if (cur == NULL) return(NULL);
845
846 if (doc != NULL)
847 dict = doc->dict;
848
849 ret = (xmlElementContentPtr) xmlMalloc(sizeof(xmlElementContent));
850 if (ret == NULL) {
851 xmlVErrMemory(NULL, "malloc failed");
852 return(NULL);
853 }
854 memset(ret, 0, sizeof(xmlElementContent));
855 ret->type = cur->type;
856 ret->ocur = cur->ocur;
857 if (cur->name != NULL) {
858 if (dict)
859 ret->name = xmlDictLookup(dict, cur->name, -1);
860 else
861 ret->name = xmlStrdup(cur->name);
862 }
863
864 if (cur->prefix != NULL) {
865 if (dict)
866 ret->prefix = xmlDictLookup(dict, cur->prefix, -1);
867 else
868 ret->prefix = xmlStrdup(cur->prefix);
869 }
870 if (cur->c1 != NULL)
871 ret->c1 = xmlCopyDocElementContent(doc, cur->c1);
872 if (ret->c1 != NULL)
873 ret->c1->parent = ret;
874 if (cur->c2 != NULL) {
875 prev = ret;
876 cur = cur->c2;
877 while (cur != NULL) {
878 tmp = (xmlElementContentPtr) xmlMalloc(sizeof(xmlElementContent));
879 if (tmp == NULL) {
880 xmlVErrMemory(NULL, "malloc failed");
881 return(ret);
882 }
883 memset(tmp, 0, sizeof(xmlElementContent));
884 tmp->type = cur->type;
885 tmp->ocur = cur->ocur;
886 prev->c2 = tmp;
887 tmp->parent = prev;
888 if (cur->name != NULL) {
889 if (dict)
890 tmp->name = xmlDictLookup(dict, cur->name, -1);
891 else
892 tmp->name = xmlStrdup(cur->name);
893 }
894
895 if (cur->prefix != NULL) {
896 if (dict)
897 tmp->prefix = xmlDictLookup(dict, cur->prefix, -1);
898 else
899 tmp->prefix = xmlStrdup(cur->prefix);
900 }
901 if (cur->c1 != NULL)
902 tmp->c1 = xmlCopyDocElementContent(doc,cur->c1);
903 if (tmp->c1 != NULL)
904 tmp->c1->parent = tmp;
905 prev = tmp;
906 cur = cur->c2;
907 }
908 }
909 return(ret);
910}
FxCollectionEntry * cur

Referenced by xmlAddElementDecl(), xmlCopyDocElementContent(), and xmlCopyElementContent().

◆ xmlCopyElementContent()

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

922 {
924}

◆ xmlCreateEnumeration()

XMLPUBFUN xmlEnumerationPtr xmlCreateEnumeration ( const xmlChar name)

Definition at line 1640 of file valid.c.

1640 {
1641 xmlEnumerationPtr ret;
1642
1643 ret = (xmlEnumerationPtr) xmlMalloc(sizeof(xmlEnumeration));
1644 if (ret == NULL) {
1645 xmlVErrMemory(NULL, "malloc failed");
1646 return(NULL);
1647 }
1648 memset(ret, 0, sizeof(xmlEnumeration));
1649
1650 if (name != NULL)
1651 ret->name = xmlStrdup(name);
1652 return(ret);
1653}

Referenced by xmlParseEnumerationType(), and xmlParseNotationType().

◆ xmlFreeAttributeTable()

XMLPUBFUN void xmlFreeAttributeTable ( xmlAttributeTablePtr  table)

xmlFreeAttributeTable: @table: An attribute table

Deallocate the memory used by an entities hash table.

Definition at line 2038 of file valid.c.

2038 {
2040}
void xmlHashFree(xmlHashTablePtr hash, xmlHashDeallocator dealloc)
Definition: hash.c:229
static void xmlFreeAttributeTableEntry(void *attr, const xmlChar *name ATTRIBUTE_UNUSED)
Definition: valid.c:2027

◆ xmlFreeDocElementContent()

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

934 {
935 xmlDictPtr dict = NULL;
936 size_t depth = 0;
937
938 if (cur == NULL)
939 return;
940 if (doc != NULL)
941 dict = doc->dict;
942
943 while (1) {
944 xmlElementContentPtr parent;
945
946 while ((cur->c1 != NULL) || (cur->c2 != NULL)) {
947 cur = (cur->c1 != NULL) ? cur->c1 : cur->c2;
948 depth += 1;
949 }
950
951 switch (cur->type) {
952 case XML_ELEMENT_CONTENT_PCDATA:
953 case XML_ELEMENT_CONTENT_ELEMENT:
954 case XML_ELEMENT_CONTENT_SEQ:
955 case XML_ELEMENT_CONTENT_OR:
956 break;
957 default:
958 xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
959 "Internal: ELEMENT content corrupted invalid type\n",
960 NULL);
961 return;
962 }
963 if (dict) {
964 if ((cur->name != NULL) && (!xmlDictOwns(dict, cur->name)))
965 xmlFree((xmlChar *) cur->name);
966 if ((cur->prefix != NULL) && (!xmlDictOwns(dict, cur->prefix)))
967 xmlFree((xmlChar *) cur->prefix);
968 } else {
969 if (cur->name != NULL) xmlFree((xmlChar *) cur->name);
970 if (cur->prefix != NULL) xmlFree((xmlChar *) cur->prefix);
971 }
972 parent = cur->parent;
973 if ((depth == 0) || (parent == NULL)) {
974 xmlFree(cur);
975 break;
976 }
977 if (cur == parent->c1)
978 parent->c1 = NULL;
979 else
980 parent->c2 = NULL;
981 xmlFree(cur);
982
983 if (parent->c2 != NULL) {
984 cur = parent->c2;
985 } else {
986 depth -= 1;
987 cur = parent;
988 }
989 }
990}
r parent
Definition: btrfs.c:3010
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
int xmlDictOwns(xmlDictPtr dict, const xmlChar *str)
Definition: dict.c:376

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

◆ xmlFreeElementContent()

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

1000 {
1002}
void xmlFreeDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur)
Definition: valid.c:934

◆ xmlFreeElementTable()

XMLPUBFUN void xmlFreeElementTable ( xmlElementTablePtr  table)

xmlFreeElementTable: @table: An element table

Deallocate the memory used by an element hash table.

Definition at line 1486 of file valid.c.

1486 {
1488}
static void xmlFreeElementTableEntry(void *elem, const xmlChar *name ATTRIBUTE_UNUSED)
Definition: valid.c:1475

◆ xmlFreeEnumeration()

XMLPUBFUN void xmlFreeEnumeration ( xmlEnumerationPtr  cur)

xmlFreeEnumeration: @cur: the tree to free.

free an enumeration attribute node (recursive).

Definition at line 1662 of file valid.c.

1662 {
1663 if (cur == NULL) return;
1664
1665 if (cur->next != NULL) xmlFreeEnumeration(cur->next);
1666
1667 if (cur->name != NULL) xmlFree((xmlChar *) cur->name);
1668 xmlFree(cur);
1669}

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

◆ xmlFreeIDTable()

XMLPUBFUN void xmlFreeIDTable ( xmlIDTablePtr  table)

xmlFreeIDTable: @table: An id table

Deallocate the memory used by an ID hash table.

Definition at line 2601 of file valid.c.

2601 {
2603}
static void xmlFreeIDTableEntry(void *id, const xmlChar *name ATTRIBUTE_UNUSED)
Definition: valid.c:2590

Referenced by xsltReleaseRVT().

◆ xmlFreeNotationTable()

XMLPUBFUN void xmlFreeNotationTable ( xmlNotationTablePtr  table)

xmlFreeNotationTable: @table: An notation table

Deallocate the memory used by an entities hash table.

Definition at line 2316 of file valid.c.

2316 {
2318}
static void xmlFreeNotationTableEntry(void *nota, const xmlChar *name ATTRIBUTE_UNUSED)
Definition: valid.c:2305

◆ xmlFreeRefTable()

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

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

◆ xmlGetDtdAttrDesc()

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

Definition at line 3230 of file valid.c.

3230 {
3232 xmlAttributePtr cur;
3233 xmlChar *uqname = NULL, *prefix = NULL;
3234
3235 if (dtd == NULL) return(NULL);
3236 if (dtd->attributes == NULL) return(NULL);
3237
3238 table = (xmlAttributeTablePtr) dtd->attributes;
3239 if (table == NULL)
3240 return(NULL);
3241
3242 uqname = xmlSplitQName2(name, &prefix);
3243
3244 if (uqname != NULL) {
3245 cur = xmlHashLookup3(table, uqname, prefix, elem);
3246 if (prefix != NULL) xmlFree(prefix);
3247 if (uqname != NULL) xmlFree(uqname);
3248 } else
3250 return(cur);
3251}
Character const *const prefix
Definition: tempnam.cpp:195

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

◆ xmlGetDtdElementDesc()

XMLPUBFUN xmlElementPtr xmlGetDtdElementDesc ( xmlDtdPtr  dtd,
const xmlChar name 
)

Definition at line 3102 of file valid.c.

3102 {
3104 xmlElementPtr cur;
3105 xmlChar *uqname = NULL, *prefix = NULL;
3106
3107 if ((dtd == NULL) || (name == NULL)) return(NULL);
3108 if (dtd->elements == NULL)
3109 return(NULL);
3110 table = (xmlElementTablePtr) dtd->elements;
3111
3112 uqname = xmlSplitQName2(name, &prefix);
3113 if (uqname != NULL)
3114 name = uqname;
3116 if (prefix != NULL) xmlFree(prefix);
3117 if (uqname != NULL) xmlFree(uqname);
3118 return(cur);
3119}

Referenced by xmlIsMixedElement().

◆ xmlGetDtdNotationDesc()

XMLPUBFUN xmlNotationPtr xmlGetDtdNotationDesc ( xmlDtdPtr  dtd,
const xmlChar name 
)

Definition at line 3289 of file valid.c.

3289 {
3291
3292 if (dtd == NULL) return(NULL);
3293 if (dtd->notations == NULL) return(NULL);
3294 table = (xmlNotationTablePtr) dtd->notations;
3295
3296 return(xmlHashLookup(table, name));
3297}

◆ xmlGetDtdQAttrDesc()

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

Definition at line 3267 of file valid.c.

3268 {
3270
3271 if (dtd == NULL) return(NULL);
3272 if (dtd->attributes == NULL) return(NULL);
3273 table = (xmlAttributeTablePtr) dtd->attributes;
3274
3275 return(xmlHashLookup3(table, name, prefix, elem));
3276}

◆ xmlGetDtdQElementDesc()

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

Definition at line 3206 of file valid.c.

3207 {
3209
3210 if (dtd == NULL) return(NULL);
3211 if (dtd->elements == NULL) return(NULL);
3212 table = (xmlElementTablePtr) dtd->elements;
3213
3214 return(xmlHashLookup2(table, name, prefix));
3215}

◆ xmlGetID()

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

2719 {
2721 xmlIDPtr id;
2722
2723 if (doc == NULL) {
2724 return(NULL);
2725 }
2726
2727 if (ID == NULL) {
2728 return(NULL);
2729 }
2730
2731 table = (xmlIDTablePtr) doc->ids;
2732 if (table == NULL)
2733 return(NULL);
2734
2735 id = xmlHashLookup(table, ID);
2736 if (id == NULL)
2737 return(NULL);
2738 if (id->attr == NULL) {
2739 /*
2740 * We are operating on a stream, return a well known reference
2741 * since the attribute node doesn't exist anymore
2742 */
2743 return((xmlAttrPtr) doc);
2744 }
2745 return(id->attr);
2746}
GLuint id
Definition: glext.h:5910
#define ID
Definition: ruserpass.c:36

Referenced by xsltLoadStylesheetPI(), and xsltTestStepMatch().

◆ xmlGetRefs()

XML_DEPRECATED XMLPUBFUN 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 3067 of file valid.c.

3067 {
3069
3070 if (doc == NULL) {
3071 return(NULL);
3072 }
3073
3074 if (ID == NULL) {
3075 return(NULL);
3076 }
3077
3078 table = (xmlRefTablePtr) doc->refs;
3079 if (table == NULL)
3080 return(NULL);
3081
3082 return (xmlHashLookup(table, ID));
3083}

◆ xmlIsID()

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

2619 {
2620 if ((attr == NULL) || (attr->name == NULL)) return(0);
2621 if ((attr->ns != NULL) && (attr->ns->prefix != NULL) &&
2622 (!strcmp((char *) attr->name, "id")) &&
2623 (!strcmp((char *) attr->ns->prefix, "xml")))
2624 return(1);
2625 if (doc == NULL) return(0);
2626 if ((doc->intSubset == NULL) && (doc->extSubset == NULL) &&
2627 (doc->type != XML_HTML_DOCUMENT_NODE)) {
2628 return(0);
2629 } else if (doc->type == XML_HTML_DOCUMENT_NODE) {
2630 if ((xmlStrEqual(BAD_CAST "id", attr->name)) ||
2631 ((xmlStrEqual(BAD_CAST "name", attr->name)) &&
2632 ((elem == NULL) || (xmlStrEqual(elem->name, BAD_CAST "a")))))
2633 return(1);
2634 return(0);
2635 } else if (elem == NULL) {
2636 return(0);
2637 } else {
2638 xmlAttributePtr attrDecl = NULL;
2639
2640 xmlChar felem[50], fattr[50];
2641 xmlChar *fullelemname, *fullattrname;
2642
2643 fullelemname = (elem->ns != NULL && elem->ns->prefix != NULL) ?
2644 xmlBuildQName(elem->name, elem->ns->prefix, felem, 50) :
2645 (xmlChar *)elem->name;
2646
2647 fullattrname = (attr->ns != NULL && attr->ns->prefix != NULL) ?
2648 xmlBuildQName(attr->name, attr->ns->prefix, fattr, 50) :
2649 (xmlChar *)attr->name;
2650
2651 if (fullelemname != NULL && fullattrname != NULL) {
2652 attrDecl = xmlGetDtdAttrDesc(doc->intSubset, fullelemname,
2653 fullattrname);
2654 if ((attrDecl == NULL) && (doc->extSubset != NULL))
2655 attrDecl = xmlGetDtdAttrDesc(doc->extSubset, fullelemname,
2656 fullattrname);
2657 }
2658
2659 if ((fullattrname != fattr) && (fullattrname != attr->name))
2660 xmlFree(fullattrname);
2661 if ((fullelemname != felem) && (fullelemname != elem->name))
2662 xmlFree(fullelemname);
2663
2664 if ((attrDecl != NULL) && (attrDecl->atype == XML_ATTRIBUTE_ID))
2665 return(1);
2666 }
2667 return(0);
2668}
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3319
Definition: fatfs.h:133
xmlAttributePtr xmlGetDtdAttrDesc(xmlDtdPtr dtd, const xmlChar *elem, const xmlChar *name)
Definition: valid.c:3230

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

◆ xmlIsMixedElement()

XMLPUBFUN int xmlIsMixedElement ( xmlDocPtr  doc,
const xmlChar name 
)

The public function calls related to validity checking.

Definition at line 3345 of file valid.c.

3345 {
3346 xmlElementPtr elemDecl;
3347
3348 if ((doc == NULL) || (doc->intSubset == NULL)) return(-1);
3349
3350 elemDecl = xmlGetDtdElementDesc(doc->intSubset, name);
3351 if ((elemDecl == NULL) && (doc->extSubset != NULL))
3352 elemDecl = xmlGetDtdElementDesc(doc->extSubset, name);
3353 if (elemDecl == NULL) return(-1);
3354 switch (elemDecl->etype) {
3355 case XML_ELEMENT_TYPE_UNDEFINED:
3356 return(-1);
3357 case XML_ELEMENT_TYPE_ELEMENT:
3358 return(0);
3359 case XML_ELEMENT_TYPE_EMPTY:
3360 /*
3361 * return 1 for EMPTY since we want VC error to pop up
3362 * on <empty> </empty> for example
3363 */
3364 case XML_ELEMENT_TYPE_ANY:
3365 case XML_ELEMENT_TYPE_MIXED:
3366 return(1);
3367 }
3368 return(1);
3369}
xmlElementPtr xmlGetDtdElementDesc(xmlDtdPtr dtd, const xmlChar *name)
Definition: valid.c:3102

Referenced by areBlanks().

◆ xmlIsRef()

XML_DEPRECATED XMLPUBFUN 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 2967 of file valid.c.

2967 {
2968 if (attr == NULL)
2969 return(0);
2970 if (doc == NULL) {
2971 doc = attr->doc;
2972 if (doc == NULL) return(0);
2973 }
2974
2975 if ((doc->intSubset == NULL) && (doc->extSubset == NULL)) {
2976 return(0);
2977 } else if (doc->type == XML_HTML_DOCUMENT_NODE) {
2978 /* TODO @@@ */
2979 return(0);
2980 } else {
2981 xmlAttributePtr attrDecl;
2982
2983 if (elem == NULL) return(0);
2984 attrDecl = xmlGetDtdAttrDesc(doc->intSubset, elem->name, attr->name);
2985 if ((attrDecl == NULL) && (doc->extSubset != NULL))
2986 attrDecl = xmlGetDtdAttrDesc(doc->extSubset,
2987 elem->name, attr->name);
2988
2989 if ((attrDecl != NULL) &&
2990 (attrDecl->atype == XML_ATTRIBUTE_IDREF ||
2991 attrDecl->atype == XML_ATTRIBUTE_IDREFS))
2992 return(1);
2993 }
2994 return(0);
2995}

Referenced by xmlSAX2AttributeNs().

◆ xmlNewDocElementContent()

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

Definition at line 753 of file valid.c.

754 {
755 xmlElementContentPtr ret;
756 xmlDictPtr dict = NULL;
757
758 if (doc != NULL)
759 dict = doc->dict;
760
761 switch(type) {
762 case XML_ELEMENT_CONTENT_ELEMENT:
763 if (name == NULL) {
764 xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
765 "xmlNewElementContent : name == NULL !\n",
766 NULL);
767 }
768 break;
769 case XML_ELEMENT_CONTENT_PCDATA:
770 case XML_ELEMENT_CONTENT_SEQ:
771 case XML_ELEMENT_CONTENT_OR:
772 if (name != NULL) {
773 xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
774 "xmlNewElementContent : name != NULL !\n",
775 NULL);
776 }
777 break;
778 default:
779 xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
780 "Internal: ELEMENT content corrupted invalid type\n",
781 NULL);
782 return(NULL);
783 }
784 ret = (xmlElementContentPtr) xmlMalloc(sizeof(xmlElementContent));
785 if (ret == NULL) {
786 xmlVErrMemory(NULL, "malloc failed");
787 return(NULL);
788 }
789 memset(ret, 0, sizeof(xmlElementContent));
790 ret->type = type;
791 ret->ocur = XML_ELEMENT_CONTENT_ONCE;
792 if (name != NULL) {
793 int l;
794 const xmlChar *tmp;
795
796 tmp = xmlSplitQName3(name, &l);
797 if (tmp == NULL) {
798 if (dict == NULL)
799 ret->name = xmlStrdup(name);
800 else
801 ret->name = xmlDictLookup(dict, name, -1);
802 } else {
803 if (dict == NULL) {
804 ret->prefix = xmlStrndup(name, l);
805 ret->name = xmlStrdup(tmp);
806 } else {
807 ret->prefix = xmlDictLookup(dict, name, l);
808 ret->name = xmlDictLookup(dict, tmp, -1);
809 }
810 }
811 }
812 return(ret);
813}
r l[0]
Definition: byte_order.h:168
XMLPUBFUN xmlChar * xmlStrndup(const xmlChar *cur, int len)
Definition: xmlstring.c:45

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

◆ xmlNewElementContent()

XMLPUBFUN xmlElementContentPtr xmlNewElementContent ( const xmlChar name,
xmlElementContentType  type 
)

Definition at line 826 of file valid.c.

826 {
828}
xmlElementContentPtr xmlNewDocElementContent(xmlDocPtr doc, const xmlChar *name, xmlElementContentType type)
Definition: valid.c:753

◆ xmlRemoveID()

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

2680 {
2682 xmlIDPtr id;
2683 xmlChar *ID;
2684
2685 if (doc == NULL) return(-1);
2686 if (attr == NULL) return(-1);
2687
2688 table = (xmlIDTablePtr) doc->ids;
2689 if (table == NULL)
2690 return(-1);
2691
2692 ID = xmlNodeListGetString(doc, attr->children, 1);
2693 if (ID == NULL)
2694 return(-1);
2696
2697 id = xmlHashLookup(table, ID);
2698 if (id == NULL || id->attr != attr) {
2699 xmlFree(ID);
2700 return(-1);
2701 }
2702
2704 xmlFree(ID);
2705 attr->atype = 0;
2706 return(0);
2707}
int xmlHashRemoveEntry(xmlHashTablePtr hash, const xmlChar *key, xmlHashDeallocator dealloc)
Definition: hash.c:1102
static void xmlValidNormalizeString(xmlChar *str)
Definition: valid.c:2448

◆ xmlRemoveRef()

XML_DEPRECATED XMLPUBFUN 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 3009 of file valid.c.

3009 {
3010 xmlListPtr ref_list;
3012 xmlChar *ID;
3014
3015 if (doc == NULL) return(-1);
3016 if (attr == NULL) return(-1);
3017
3018 table = (xmlRefTablePtr) doc->refs;
3019 if (table == NULL)
3020 return(-1);
3021
3022 ID = xmlNodeListGetString(doc, attr->children, 1);
3023 if (ID == NULL)
3024 return(-1);
3025
3026 ref_list = xmlHashLookup(table, ID);
3027 if(ref_list == NULL) {
3028 xmlFree(ID);
3029 return (-1);
3030 }
3031
3032 /* At this point, ref_list refers to a list of references which
3033 * have the same key as the supplied attr. Our list of references
3034 * is ordered by reference address and we don't have that information
3035 * here to use when removing. We'll have to walk the list and
3036 * check for a matching attribute, when we find one stop the walk
3037 * and remove the entry.
3038 * The list is ordered by reference, so that means we don't have the
3039 * key. Passing the list and the reference to the walker means we
3040 * will have enough data to be able to remove the entry.
3041 */
3042 target.l = ref_list;
3043 target.ap = attr;
3044
3045 /* Remove the supplied attr from our list */
3046 xmlListWalk(ref_list, xmlWalkRemoveRef, &target);
3047
3048 /*If the list is empty then remove the list entry in the hash */
3049 if (xmlListEmpty(ref_list))
3051 xmlFree(ID);
3052 return(0);
3053}
int xmlHashUpdateEntry(xmlHashTablePtr hash, const xmlChar *key, void *payload, xmlHashDeallocator dealloc)
Definition: hash.c:678
XMLPUBFUN void xmlListWalk(xmlListPtr l, xmlListWalker walker, void *user)
Definition: list.c:676
XMLPUBFUN int xmlListEmpty(xmlListPtr l)
Definition: list.c:446
Definition: tools.h:99
static int xmlWalkRemoveRef(const void *data, void *user)
Definition: valid.c:2807

◆ xmlSnprintfElementContent()

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

1130 {
1131 int len;
1132
1133 if (content == NULL) return;
1134 len = strlen(buf);
1135 if (size - len < 50) {
1136 if ((size - len > 4) && (buf[len - 1] != '.'))
1137 strcat(buf, " ...");
1138 return;
1139 }
1140 if (englob) strcat(buf, "(");
1141 switch (content->type) {
1142 case XML_ELEMENT_CONTENT_PCDATA:
1143 strcat(buf, "#PCDATA");
1144 break;
1145 case XML_ELEMENT_CONTENT_ELEMENT: {
1146 int qnameLen = xmlStrlen(content->name);
1147
1148 if (content->prefix != NULL)
1149 qnameLen += xmlStrlen(content->prefix) + 1;
1150 if (size - len < qnameLen + 10) {
1151 strcat(buf, " ...");
1152 return;
1153 }
1154 if (content->prefix != NULL) {
1155 strcat(buf, (char *) content->prefix);
1156 strcat(buf, ":");
1157 }
1158 if (content->name != NULL)
1159 strcat(buf, (char *) content->name);
1160 break;
1161 }
1162 case XML_ELEMENT_CONTENT_SEQ:
1163 if ((content->c1->type == XML_ELEMENT_CONTENT_OR) ||
1164 (content->c1->type == XML_ELEMENT_CONTENT_SEQ))
1166 else
1168 len = strlen(buf);
1169 if (size - len < 50) {
1170 if ((size - len > 4) && (buf[len - 1] != '.'))
1171 strcat(buf, " ...");
1172 return;
1173 }
1174 strcat(buf, " , ");
1175 if (((content->c2->type == XML_ELEMENT_CONTENT_OR) ||
1176 (content->c2->ocur != XML_ELEMENT_CONTENT_ONCE)) &&
1177 (content->c2->type != XML_ELEMENT_CONTENT_ELEMENT))
1179 else
1181 break;
1182 case XML_ELEMENT_CONTENT_OR:
1183 if ((content->c1->type == XML_ELEMENT_CONTENT_OR) ||
1184 (content->c1->type == XML_ELEMENT_CONTENT_SEQ))
1186 else
1188 len = strlen(buf);
1189 if (size - len < 50) {
1190 if ((size - len > 4) && (buf[len - 1] != '.'))
1191 strcat(buf, " ...");
1192 return;
1193 }
1194 strcat(buf, " | ");
1195 if (((content->c2->type == XML_ELEMENT_CONTENT_SEQ) ||
1196 (content->c2->ocur != XML_ELEMENT_CONTENT_ONCE)) &&
1197 (content->c2->type != XML_ELEMENT_CONTENT_ELEMENT))
1199 else
1201 break;
1202 }
1203 if (size - strlen(buf) <= 2) return;
1204 if (englob)
1205 strcat(buf, ")");
1206 switch (content->ocur) {
1207 case XML_ELEMENT_CONTENT_ONCE:
1208 break;
1209 case XML_ELEMENT_CONTENT_OPT:
1210 strcat(buf, "?");
1211 break;
1212 case XML_ELEMENT_CONTENT_MULT:
1213 strcat(buf, "*");
1214 break;
1215 case XML_ELEMENT_CONTENT_PLUS:
1216 strcat(buf, "+");
1217 break;
1218 }
1219}
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1592
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLsizei len
Definition: glext.h:6722
strcat
Definition: string.h:92
void xmlSnprintfElementContent(char *buf, int size, xmlElementContentPtr content, int englob)
Definition: valid.c:1130
XMLPUBFUN int xmlStrlen(const xmlChar *str)
Definition: xmlstring.c:428

Referenced by xmlSnprintfElementContent().