15#pragma convert("ISO8859-1")
27#ifdef LIBXML_ZLIB_ENABLED
40#ifdef LIBXML_HTML_ENABLED
43#ifdef LIBXML_DEBUG_ENABLED
94 msg =
"invalid hexadecimal character value\n";
97 msg =
"invalid decimal character value\n";
100 msg =
"unterminated entity reference %15s\n";
103 msg =
"string is not in UTF-8\n";
106 msg =
"unexpected error number\n";
120 {
't',
'e',
'x',
't',
'n',
'o',
'e',
'n',
'c', 0 };
124static int xmlCompressMode = 0;
125static int xmlCheckDTD = 1;
127#define UPDATE_LAST_CHILD_AND_PARENT(n) if ((n) != NULL) { \
128 xmlNodePtr ulccur = (n)->children; \
129 if (ulccur == NULL) { \
132 while (ulccur->next != NULL) { \
133 ulccur->parent = (n); \
134 ulccur = ulccur->next; \
136 ulccur->parent = (n); \
137 (n)->last = ulccur; \
140#define IS_STR_XML(str) ((str != NULL) && (str[0] == 'x') && \
141 (str[1] == 'm') && (str[2] == 'l') && (str[3] == 0))
154#ifdef LIBXML_TREE_ENABLED
228 lenn =
strlen((
char *) ncname);
229 lenp =
strlen((
char *) prefix);
243 ret[lenn + lenp + 1] = 0;
273#ifndef XML_XML_NAMESPACE
275 if ((
name[0] ==
'x') && (
name[1] ==
'm') &&
276 (
name[2] ==
'l') && (
name[3] ==
':'))
295 if (*prefix ==
NULL) {
302 if (*prefix !=
NULL) {
356#define CUR_SCHAR(s, l) xmlStringCurrentChar(NULL, s, &l)
358#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
382 if (((*
cur >=
'a') && (*
cur <=
'z')) || ((*
cur >=
'A') && (*
cur <=
'Z')) ||
387 while (((*
cur >=
'a') && (*
cur <=
'z')) ||
388 ((*
cur >=
'A') && (*
cur <=
'Z')) ||
389 ((*
cur >=
'0') && (*
cur <=
'9')) ||
390 (*
cur ==
'_') || (*
cur ==
'-') || (*
cur ==
'.'))
432#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
455 if (((*
cur >=
'a') && (*
cur <=
'z')) || ((*
cur >=
'A') && (*
cur <=
'Z')) ||
460 while (((*
cur >=
'a') && (*
cur <=
'z')) ||
461 ((*
cur >=
'A') && (*
cur <=
'Z')) ||
462 ((*
cur >=
'0') && (*
cur <=
'9')) ||
463 (*
cur ==
'_') || (*
cur ==
'-') || (*
cur ==
'.'))
467 if (((*
cur >=
'a') && (*
cur <=
'z')) ||
468 ((*
cur >=
'A') && (*
cur <=
'Z')) ||
473 while (((*
cur >=
'a') && (*
cur <=
'z')) ||
474 ((*
cur >=
'A') && (*
cur <=
'Z')) ||
475 ((*
cur >=
'0') && (*
cur <=
'9')) ||
476 (*
cur ==
'_') || (*
cur ==
'-') || (*
cur ==
'.'))
553 if (((*
cur >=
'a') && (*
cur <=
'z')) || ((*
cur >=
'A') && (*
cur <=
'Z')) ||
554 (*
cur ==
'_') || (*
cur ==
':'))
558 while (((*
cur >=
'a') && (*
cur <=
'z')) ||
559 ((*
cur >=
'A') && (*
cur <=
'Z')) ||
560 ((*
cur >=
'0') && (*
cur <=
'9')) ||
561 (*
cur ==
'_') || (*
cur ==
'-') || (*
cur ==
'.') || (*
cur ==
':'))
622 if (((*
cur >=
'a') && (*
cur <=
'z')) ||
623 ((*
cur >=
'A') && (*
cur <=
'Z')) ||
624 ((*
cur >=
'0') && (*
cur <=
'9')) ||
625 (*
cur ==
'_') || (*
cur ==
'-') || (*
cur ==
'.') || (*
cur ==
':'))
629 while (((*
cur >=
'a') && (*
cur <=
'z')) ||
630 ((*
cur >=
'A') && (*
cur <=
'Z')) ||
631 ((*
cur >=
'0') && (*
cur <=
'9')) ||
632 (*
cur ==
'_') || (*
cur ==
'-') || (*
cur ==
'.') || (*
cur ==
':'))
808 "xmlSetNs: node == NULL\n");
828 "xmlFreeNs : ns == NULL\n");
849 "xmlFreeNsList : ns == NULL\n");
880 "xmlNewDtd(%s): document %s already have a DTD %s\n",
900 if (ExternalID !=
NULL)
902 if (SystemID !=
NULL)
955 "xmlCreateIntSubset(): document %s already have an internal subset\n",
980 if (ExternalID !=
NULL) {
990 if (SystemID !=
NULL) {
1053#define DICT_FREE(str) \
1054 if ((str) && ((!dict) || \
1055 (xmlDictOwns(dict, (const xmlChar *)(str)) == 0))) \
1056 xmlFree((char *)(str));
1066#define DICT_COPY(str, cpy) \
1069 if (xmlDictOwns(dict, (const xmlChar *)(str))) \
1070 cpy = (xmlChar *) (str); \
1072 cpy = (xmlChar *) xmlDictLookup((dict), (const xmlChar *)(str), -1); \
1074 cpy = xmlStrdup((const xmlChar *)(str)); }
1083#define DICT_CONST_COPY(str, cpy) \
1086 if (xmlDictOwns(dict, (const xmlChar *)(str))) \
1087 cpy = (const xmlChar *) (str); \
1089 cpy = xmlDictLookup((dict), (const xmlChar *)(str), -1); \
1091 cpy = (const xmlChar *) xmlStrdup((const xmlChar *)(str)); }
1182 cur->standalone = -1;
1183 cur->compression = -1;
1185 cur->parseFlags = 0;
1213 "xmlFreeDoc : document == NULL\n");
1217#ifdef LIBXML_DEBUG_RUNTIME
1218#ifdef LIBXML_DEBUG_ENABLED
1235 extSubset =
cur->extSubset;
1236 intSubset =
cur->intSubset;
1237 if (intSubset == extSubset)
1239 if (extSubset !=
NULL) {
1244 if (intSubset !=
NULL) {
1291 if (
cur[0] ==
'&') {
1303 if ((
cur + 2 <
end) && (
cur[1] ==
'#') && (
cur[2] ==
'x')) {
1309 while (tmp !=
';') {
1320 if ((tmp >=
'0') && (tmp <=
'9'))
1321 charval = charval * 16 + (tmp -
'0');
1322 else if ((tmp >=
'a') && (tmp <=
'f'))
1323 charval = charval * 16 + (tmp -
'a') + 10;
1324 else if ((tmp >=
'A') && (tmp <=
'F'))
1325 charval = charval * 16 + (tmp -
'A') + 10;
1341 }
else if ((
cur + 1 <
end) && (
cur[1] ==
'#')) {
1347 while (tmp !=
';') {
1349 if ((tmp >=
'0') && (tmp <=
'9'))
1350 charval = charval * 10 + (tmp -
'0');
1384 if ((ent !=
NULL) &&
1512 if (
cur[0] ==
'&') {
1524 if ((
cur[1] ==
'#') && (
cur[2] ==
'x')) {
1527 while (tmp !=
';') {
1529 if ((tmp >=
'0') && (tmp <=
'9'))
1530 charval = charval * 16 + (tmp -
'0');
1531 else if ((tmp >=
'a') && (tmp <=
'f'))
1532 charval = charval * 16 + (tmp -
'a') + 10;
1533 else if ((tmp >=
'A') && (tmp <=
'F'))
1534 charval = charval * 16 + (tmp -
'A') + 10;
1547 }
else if (
cur[1] ==
'#') {
1550 while (tmp !=
';') {
1552 if ((tmp >=
'0') && (tmp <=
'9'))
1553 charval = charval * 10 + (tmp -
'0');
1572 while ((*
cur != 0) && (*
cur !=
';'))
cur++;
1584 if ((ent !=
NULL) &&
1763 "xmlGetNodeListString : invalid node type %d\n",
1772#ifdef LIBXML_TREE_ENABLED
1823 xmlNodeListGetRawString(doc, ent->
children, 1);
1846 "xmlGetNodeListString : invalid node type %d\n",
1865 if ((eatname == 1) &&
1877 if ((eatname == 1) &&
1907 tmp =
cur->children;
1908 while (tmp !=
NULL) {
1941#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || \
1942 defined(LIBXML_SCHEMAS_ENABLED)
1958 "xmlNewProp : name == NULL\n");
1984 "xmlNewNsProp : name == NULL\n");
2009 "xmlNewNsPropEatName : name == NULL\n");
2038 "xmlNewDocProp : name == NULL\n");
2065 tmp =
cur->children;
2066 while (tmp !=
NULL) {
2136 "xmlRemoveProp : cur == NULL\n");
2143 "xmlRemoveProp : cur->parent == NULL\n");
2147 tmp =
cur->parent->properties;
2149 cur->parent->properties =
cur->next;
2155 while (tmp !=
NULL) {
2159 tmp->
next->prev = tmp;
2167 "xmlRemoveProp : attribute not owned by its node\n");
2188 "xmlNewPI : name == NULL\n");
2253 "xmlNewNode : name == NULL\n");
2297 "xmlNewNode : name == NULL\n");
2396#ifdef LIBXML_TREE_ENABLED
2490#ifdef LIBXML_TREE_ENABLED
2518 "xmlNewTextChild : parent == NULL\n");
2526 "xmlNewTextChild : name == NULL\n");
2599 if (
name[0] ==
'&') {
2643 if (
name[0] ==
'&') {
2828 const xmlChar *newValue = oldValue;
2830 int oldDictOwnsOldValue = oldDict && (
xmlDictOwns(oldDict, oldValue) == 1);
2831 if (oldDictOwnsOldValue) {
2854 if (
tree->doc != doc) {
2859 prop =
tree->properties;
2860 while (prop !=
NULL) {
2865 if (prop->
doc != doc) {
2867 prop->
name = _copyStringForNewDictIfNeeded(oldPropDict, newDict, prop->
name);
2895 }
else if (
tree->children !=
NULL) {
2899 tree->name = _copyStringForNewDictIfNeeded(oldTreeDict, newDict,
tree->name);
2900 tree->content = (
xmlChar *)_copyStringForNewDictIfNeeded(oldTreeDict,
NULL,
tree->content);
2921 if (
cur->doc != doc)
2927#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
2953 "xmlNewChild : parent == NULL\n");
2961 "xmlNewChild : name == NULL\n");
3037 if (prop->
doc !=
cur->doc) {
3046 prop->
next->prev = prop;
3081 "xmlAddNextSibling : cur == NULL\n");
3088 "xmlAddNextSibling : elem == NULL\n");
3096 "xmlAddNextSibling : cur == elem\n");
3110 (
cur->name ==
cur->next->name)) {
3138#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || \
3139 defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED)
3161 "xmlAddPrevSibling : cur == NULL\n");
3168 "xmlAddPrevSibling : elem == NULL\n");
3176 "xmlAddPrevSibling : cur == elem\n");
3195 (
cur->name ==
cur->prev->name)) {
3201 return xmlAddPropSibling(
cur->prev,
cur,
elem);
3241 "xmlAddSibling : cur == NULL\n");
3249 "xmlAddSibling : elem == NULL\n");
3257 "xmlAddSibling : cur == elem\n");
3267 (
cur->parent->children !=
NULL) &&
3268 (
cur->parent->last !=
NULL) &&
3269 (
cur->parent->last->next ==
NULL)) {
3319 "xmlAddChildList : parent == NULL\n");
3327 "xmlAddChildList : child == NULL\n");
3336 "Elements moved to a different document\n");
3411 "xmlAddChild : parent == NULL\n");
3419 "xmlAddChild : child == NULL\n");
3427 "xmlAddChild : parent == cur\n");
3502 lastattr = lastattr->
next;
3533 "xmlGetLastChild : parent == NULL\n");
3540#ifdef LIBXML_TREE_ENABLED
3559 unsigned long ret = 0;
3671 switch (
node->type) {
3710 switch (
node->type) {
3757 while ((
cur->children !=
NULL) &&
3856 if ((
cur->children !=
NULL) &&
3867 }
else if ((
cur->content !=
NULL) &&
3901 "xmlUnlinkNode : node == NULL\n");
3954 cur->next->prev =
cur->prev;
3956 cur->prev->next =
cur->next;
3960#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED)
3981 "xmlReplaceNode : old == NULL or without parent\n");
3995 "xmlReplaceNode : Trying to replace attribute node with other node type\n");
4002 "xmlReplaceNode : Trying to replace a non-attribute node with attribute node\n");
4020 if (
cur->parent->children == old)
4021 cur->parent->children =
cur;
4022 if (
cur->parent->last == old)
4051 switch (
cur->type) {
4058 "xmlCopyNamespace: invalid type %d\n",
cur->type);
4103 else if (doc !=
NULL)
4107 else if (
cur->children !=
NULL)
4165 tmp =
ret->children;
4166 while (tmp !=
NULL) {
4263 switch (
node->type) {
4282#ifdef LIBXML_TREE_ENABLED
4390 if ((doc ==
NULL) || (
node->doc != doc)) {
4399 ret->children =
node->children;
4401 ret->last =
ret->children;
4402 }
else if ((
node->children !=
NULL) && (extended != 2)) {
4462#ifdef LIBXML_TREE_ENABLED
4486 }
else if (
p !=
q) {
4532 ret = xmlStaticCopyNode(
node, doc,
NULL, extended);
4564#if defined(LIBXML_TREE_ENABLED)
4582 ret->entities = (
void *) xmlCopyEntitiesTable(
4585 ret->notations = (
void *) xmlCopyNotationTable(
4588 ret->elements = (
void *) xmlCopyElementTable(
4591 ret->attributes = (
void *) xmlCopyAttributeTable(
4594 ret->pentities = (
void *) xmlCopyEntitiesTable(
4603 switch (tmp->
etype) {
4612 xmlGetParameterEntityFromDtd(
ret, tmp->
name);
4651#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
4663xmlCopyDoc(
xmlDocPtr doc,
int recursive) {