| OLD | NEW |
| 1 /* | 1 /* |
| 2 * valid.c : part of the code use to do the DTD handling and the validity | 2 * valid.c : part of the code use to do the DTD handling and the validity |
| 3 * checking | 3 * checking |
| 4 * | 4 * |
| 5 * See Copyright for the status of this software. | 5 * See Copyright for the status of this software. |
| 6 * | 6 * |
| 7 * daniel@veillard.com | 7 * daniel@veillard.com |
| 8 */ | 8 */ |
| 9 | 9 |
| 10 #define IN_LIBXML | 10 #define IN_LIBXML |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include <libxml/parserInternals.h> | 24 #include <libxml/parserInternals.h> |
| 25 #include <libxml/xmlerror.h> | 25 #include <libxml/xmlerror.h> |
| 26 #include <libxml/list.h> | 26 #include <libxml/list.h> |
| 27 #include <libxml/globals.h> | 27 #include <libxml/globals.h> |
| 28 | 28 |
| 29 static xmlElementPtr xmlGetDtdElementDesc2(xmlDtdPtr dtd, const xmlChar *name, | 29 static xmlElementPtr xmlGetDtdElementDesc2(xmlDtdPtr dtd, const xmlChar *name, |
| 30 int create); | 30 int create); |
| 31 /* #define DEBUG_VALID_ALGO */ | 31 /* #define DEBUG_VALID_ALGO */ |
| 32 /* #define DEBUG_REGEXP_ALGO */ | 32 /* #define DEBUG_REGEXP_ALGO */ |
| 33 | 33 |
| 34 #define TODO » » » » » » » » \ | 34 #define TODO» » » » » » » » \ |
| 35 xmlGenericError(xmlGenericErrorContext, \ | 35 xmlGenericError(xmlGenericErrorContext, \ |
| 36 "Unimplemented block at %s:%d\n", \ | 36 "Unimplemented block at %s:%d\n", \ |
| 37 __FILE__, __LINE__); | 37 __FILE__, __LINE__); |
| 38 | 38 |
| 39 #ifdef LIBXML_VALID_ENABLED | 39 #ifdef LIBXML_VALID_ENABLED |
| 40 static int | 40 static int |
| 41 xmlValidateAttributeValueInternal(xmlDocPtr doc, xmlAttributeType type, | 41 xmlValidateAttributeValueInternal(xmlDocPtr doc, xmlAttributeType type, |
| 42 const xmlChar *value); | 42 const xmlChar *value); |
| 43 #endif | 43 #endif |
| 44 /************************************************************************ | 44 /************************************************************************ |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 ctxt->vstateMax *= 2; | 294 ctxt->vstateMax *= 2; |
| 295 ctxt->vstateTab = tmp; | 295 ctxt->vstateTab = tmp; |
| 296 } | 296 } |
| 297 ctxt->vstate = &ctxt->vstateTab[ctxt->vstateNr]; | 297 ctxt->vstate = &ctxt->vstateTab[ctxt->vstateNr]; |
| 298 ctxt->vstateTab[ctxt->vstateNr].elemDecl = elemDecl; | 298 ctxt->vstateTab[ctxt->vstateNr].elemDecl = elemDecl; |
| 299 ctxt->vstateTab[ctxt->vstateNr].node = node; | 299 ctxt->vstateTab[ctxt->vstateNr].node = node; |
| 300 if ((elemDecl != NULL) && (elemDecl->etype == XML_ELEMENT_TYPE_ELEMENT)) { | 300 if ((elemDecl != NULL) && (elemDecl->etype == XML_ELEMENT_TYPE_ELEMENT)) { |
| 301 if (elemDecl->contModel == NULL) | 301 if (elemDecl->contModel == NULL) |
| 302 xmlValidBuildContentModel(ctxt, elemDecl); | 302 xmlValidBuildContentModel(ctxt, elemDecl); |
| 303 if (elemDecl->contModel != NULL) { | 303 if (elemDecl->contModel != NULL) { |
| 304 » ctxt->vstateTab[ctxt->vstateNr].exec = | 304 » ctxt->vstateTab[ctxt->vstateNr].exec = |
| 305 xmlRegNewExecCtxt(elemDecl->contModel, NULL, NULL); | 305 xmlRegNewExecCtxt(elemDecl->contModel, NULL, NULL); |
| 306 } else { | 306 } else { |
| 307 ctxt->vstateTab[ctxt->vstateNr].exec = NULL; | 307 ctxt->vstateTab[ctxt->vstateNr].exec = NULL; |
| 308 xmlErrValidNode(ctxt, (xmlNodePtr) elemDecl, | 308 xmlErrValidNode(ctxt, (xmlNodePtr) elemDecl, |
| 309 XML_ERR_INTERNAL_ERROR, | 309 XML_ERR_INTERNAL_ERROR, |
| 310 "Failed to build content model regexp for %s\n", | 310 "Failed to build content model regexp for %s\n", |
| 311 node->name, NULL, NULL); | 311 node->name, NULL, NULL); |
| 312 } | 312 } |
| 313 } | 313 } |
| 314 return(ctxt->vstateNr++); | 314 return(ctxt->vstateNr++); |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 xmlGenericError(xmlGenericErrorContext, "\n"); | 616 xmlGenericError(xmlGenericErrorContext, "\n"); |
| 617 } | 617 } |
| 618 | 618 |
| 619 /***** | 619 /***** |
| 620 #define DEBUG_VALID_STATE(n,c) xmlValidDebug(n,c); | 620 #define DEBUG_VALID_STATE(n,c) xmlValidDebug(n,c); |
| 621 *****/ | 621 *****/ |
| 622 | 622 |
| 623 #define DEBUG_VALID_STATE(n,c) xmlValidStateDebug(ctxt); | 623 #define DEBUG_VALID_STATE(n,c) xmlValidStateDebug(ctxt); |
| 624 #define DEBUG_VALID_MSG(m) \ | 624 #define DEBUG_VALID_MSG(m) \ |
| 625 xmlGenericError(xmlGenericErrorContext, "%s\n", m); | 625 xmlGenericError(xmlGenericErrorContext, "%s\n", m); |
| 626 | 626 |
| 627 #else | 627 #else |
| 628 #define DEBUG_VALID_STATE(n,c) | 628 #define DEBUG_VALID_STATE(n,c) |
| 629 #define DEBUG_VALID_MSG(m) | 629 #define DEBUG_VALID_MSG(m) |
| 630 #endif | 630 #endif |
| 631 | 631 |
| 632 /* TODO: use hash table for accesses to elem and attribute definitions */ | 632 /* TODO: use hash table for accesses to elem and attribute definitions */ |
| 633 | 633 |
| 634 | 634 |
| 635 #define CHECK_DTD \ | 635 #define CHECK_DTD \ |
| 636 if (doc == NULL) return(0); \ | 636 if (doc == NULL) return(0); \ |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 case XML_ELEMENT_CONTENT_PCDATA: | 669 case XML_ELEMENT_CONTENT_PCDATA: |
| 670 xmlErrValidNode(ctxt, NULL, XML_ERR_INTERNAL_ERROR, | 670 xmlErrValidNode(ctxt, NULL, XML_ERR_INTERNAL_ERROR, |
| 671 "Found PCDATA in content model of %s\n", | 671 "Found PCDATA in content model of %s\n", |
| 672 name, NULL, NULL); | 672 name, NULL, NULL); |
| 673 return(0); | 673 return(0); |
| 674 break; | 674 break; |
| 675 case XML_ELEMENT_CONTENT_ELEMENT: { | 675 case XML_ELEMENT_CONTENT_ELEMENT: { |
| 676 xmlAutomataStatePtr oldstate = ctxt->state; | 676 xmlAutomataStatePtr oldstate = ctxt->state; |
| 677 xmlChar fn[50]; | 677 xmlChar fn[50]; |
| 678 xmlChar *fullname; | 678 xmlChar *fullname; |
| 679 » | 679 |
| 680 fullname = xmlBuildQName(content->name, content->prefix, fn, 50); | 680 fullname = xmlBuildQName(content->name, content->prefix, fn, 50); |
| 681 if (fullname == NULL) { | 681 if (fullname == NULL) { |
| 682 xmlVErrMemory(ctxt, "Building content model"); | 682 xmlVErrMemory(ctxt, "Building content model"); |
| 683 return(0); | 683 return(0); |
| 684 } | 684 } |
| 685 | 685 |
| 686 switch (content->ocur) { | 686 switch (content->ocur) { |
| 687 case XML_ELEMENT_CONTENT_ONCE: | 687 case XML_ELEMENT_CONTENT_ONCE: |
| 688 ctxt->state = xmlAutomataNewTransition(ctxt->am, | 688 ctxt->state = xmlAutomataNewTransition(ctxt->am, |
| 689 ctxt->state, NULL, fullname, NULL); | 689 ctxt->state, NULL, fullname, NULL); |
| 690 break; | 690 break; |
| 691 case XML_ELEMENT_CONTENT_OPT: | 691 case XML_ELEMENT_CONTENT_OPT: |
| 692 ctxt->state = xmlAutomataNewTransition(ctxt->am, | 692 ctxt->state = xmlAutomataNewTransition(ctxt->am, |
| 693 ctxt->state, NULL, fullname, NULL); | 693 ctxt->state, NULL, fullname, NULL); |
| 694 xmlAutomataNewEpsilon(ctxt->am, oldstate, ctxt->state); | 694 xmlAutomataNewEpsilon(ctxt->am, oldstate, ctxt->state); |
| 695 break; | 695 break; |
| 696 case XML_ELEMENT_CONTENT_PLUS: | 696 case XML_ELEMENT_CONTENT_PLUS: |
| 697 ctxt->state = xmlAutomataNewTransition(ctxt->am, | 697 ctxt->state = xmlAutomataNewTransition(ctxt->am, |
| 698 ctxt->state, NULL, fullname, NULL); | 698 ctxt->state, NULL, fullname, NULL); |
| 699 xmlAutomataNewTransition(ctxt->am, ctxt->state, | 699 xmlAutomataNewTransition(ctxt->am, ctxt->state, |
| 700 ctxt->state, fullname, NULL); | 700 ctxt->state, fullname, NULL); |
| 701 break; | 701 break; |
| 702 case XML_ELEMENT_CONTENT_MULT: | 702 case XML_ELEMENT_CONTENT_MULT: |
| 703 ctxt->state = xmlAutomataNewEpsilon(ctxt->am, | 703 ctxt->state = xmlAutomataNewEpsilon(ctxt->am, |
| 704 » » » » » ctxt->state, NULL); | 704 » » » » » ctxt->state, NULL); |
| 705 xmlAutomataNewTransition(ctxt->am, | 705 xmlAutomataNewTransition(ctxt->am, |
| 706 » » » ctxt->state, ctxt->state, fullname, NULL); | 706 » » » ctxt->state, ctxt->state, fullname, NULL); |
| 707 break; | 707 break; |
| 708 } | 708 } |
| 709 if ((fullname != fn) && (fullname != content->name)) | 709 if ((fullname != fn) && (fullname != content->name)) |
| 710 xmlFree(fullname); | 710 xmlFree(fullname); |
| 711 break; | 711 break; |
| 712 } | 712 } |
| 713 case XML_ELEMENT_CONTENT_SEQ: { | 713 case XML_ELEMENT_CONTENT_SEQ: { |
| 714 xmlAutomataStatePtr oldstate, oldend; | 714 xmlAutomataStatePtr oldstate, oldend; |
| 715 xmlElementContentOccur ocur; | 715 xmlElementContentOccur ocur; |
| 716 | 716 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 745 xmlAutomataNewEpsilon(ctxt->am, oldend, oldstate); | 745 xmlAutomataNewEpsilon(ctxt->am, oldend, oldstate); |
| 746 break; | 746 break; |
| 747 } | 747 } |
| 748 break; | 748 break; |
| 749 } | 749 } |
| 750 case XML_ELEMENT_CONTENT_OR: { | 750 case XML_ELEMENT_CONTENT_OR: { |
| 751 xmlAutomataStatePtr oldstate, oldend; | 751 xmlAutomataStatePtr oldstate, oldend; |
| 752 xmlElementContentOccur ocur; | 752 xmlElementContentOccur ocur; |
| 753 | 753 |
| 754 ocur = content->ocur; | 754 ocur = content->ocur; |
| 755 » if ((ocur == XML_ELEMENT_CONTENT_PLUS) || | 755 » if ((ocur == XML_ELEMENT_CONTENT_PLUS) || |
| 756 (ocur == XML_ELEMENT_CONTENT_MULT)) { | 756 (ocur == XML_ELEMENT_CONTENT_MULT)) { |
| 757 ctxt->state = xmlAutomataNewEpsilon(ctxt->am, | 757 ctxt->state = xmlAutomataNewEpsilon(ctxt->am, |
| 758 ctxt->state, NULL); | 758 ctxt->state, NULL); |
| 759 } | 759 } |
| 760 oldstate = ctxt->state; | 760 oldstate = ctxt->state; |
| 761 oldend = xmlAutomataNewState(ctxt->am); | 761 oldend = xmlAutomataNewState(ctxt->am); |
| 762 | 762 |
| 763 /* | 763 /* |
| 764 * iterate over the subtypes and remerge the end with an | 764 * iterate over the subtypes and remerge the end with an |
| 765 * epsilon transition | 765 * epsilon transition |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 937 case XML_ELEMENT_CONTENT_PCDATA: | 937 case XML_ELEMENT_CONTENT_PCDATA: |
| 938 case XML_ELEMENT_CONTENT_SEQ: | 938 case XML_ELEMENT_CONTENT_SEQ: |
| 939 case XML_ELEMENT_CONTENT_OR: | 939 case XML_ELEMENT_CONTENT_OR: |
| 940 if (name != NULL) { | 940 if (name != NULL) { |
| 941 xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR, | 941 xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR, |
| 942 "xmlNewElementContent : name != NULL !\n", | 942 "xmlNewElementContent : name != NULL !\n", |
| 943 NULL); | 943 NULL); |
| 944 } | 944 } |
| 945 break; | 945 break; |
| 946 default: | 946 default: |
| 947 » xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR, | 947 » xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR, |
| 948 "Internal: ELEMENT content corrupted invalid type\n", | 948 "Internal: ELEMENT content corrupted invalid type\n", |
| 949 NULL); | 949 NULL); |
| 950 return(NULL); | 950 return(NULL); |
| 951 } | 951 } |
| 952 ret = (xmlElementContentPtr) xmlMalloc(sizeof(xmlElementContent)); | 952 ret = (xmlElementContentPtr) xmlMalloc(sizeof(xmlElementContent)); |
| 953 if (ret == NULL) { | 953 if (ret == NULL) { |
| 954 xmlVErrMemory(NULL, "malloc failed"); | 954 xmlVErrMemory(NULL, "malloc failed"); |
| 955 return(NULL); | 955 return(NULL); |
| 956 } | 956 } |
| 957 memset(ret, 0, sizeof(xmlElementContent)); | 957 memset(ret, 0, sizeof(xmlElementContent)); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 xmlNewElementContent(const xmlChar *name, xmlElementContentType type) { | 994 xmlNewElementContent(const xmlChar *name, xmlElementContentType type) { |
| 995 return(xmlNewDocElementContent(NULL, name, type)); | 995 return(xmlNewDocElementContent(NULL, name, type)); |
| 996 } | 996 } |
| 997 | 997 |
| 998 /** | 998 /** |
| 999 * xmlCopyDocElementContent: | 999 * xmlCopyDocElementContent: |
| 1000 * @doc: the document owning the element declaration | 1000 * @doc: the document owning the element declaration |
| 1001 * @cur: An element content pointer. | 1001 * @cur: An element content pointer. |
| 1002 * | 1002 * |
| 1003 * Build a copy of an element content description. | 1003 * Build a copy of an element content description. |
| 1004 * | 1004 * |
| 1005 * Returns the new xmlElementContentPtr or NULL in case of error. | 1005 * Returns the new xmlElementContentPtr or NULL in case of error. |
| 1006 */ | 1006 */ |
| 1007 xmlElementContentPtr | 1007 xmlElementContentPtr |
| 1008 xmlCopyDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur) { | 1008 xmlCopyDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur) { |
| 1009 xmlElementContentPtr ret = NULL, prev = NULL, tmp; | 1009 xmlElementContentPtr ret = NULL, prev = NULL, tmp; |
| 1010 xmlDictPtr dict = NULL; | 1010 xmlDictPtr dict = NULL; |
| 1011 | 1011 |
| 1012 if (cur == NULL) return(NULL); | 1012 if (cur == NULL) return(NULL); |
| 1013 | 1013 |
| 1014 if (doc != NULL) | 1014 if (doc != NULL) |
| 1015 dict = doc->dict; | 1015 dict = doc->dict; |
| 1016 | 1016 |
| 1017 ret = (xmlElementContentPtr) xmlMalloc(sizeof(xmlElementContent)); | 1017 ret = (xmlElementContentPtr) xmlMalloc(sizeof(xmlElementContent)); |
| 1018 if (ret == NULL) { | 1018 if (ret == NULL) { |
| 1019 xmlVErrMemory(NULL, "malloc failed"); | 1019 xmlVErrMemory(NULL, "malloc failed"); |
| 1020 return(NULL); | 1020 return(NULL); |
| 1021 } | 1021 } |
| 1022 memset(ret, 0, sizeof(xmlElementContent)); | 1022 memset(ret, 0, sizeof(xmlElementContent)); |
| 1023 ret->type = cur->type; | 1023 ret->type = cur->type; |
| 1024 ret->ocur = cur->ocur; | 1024 ret->ocur = cur->ocur; |
| 1025 if (cur->name != NULL) { | 1025 if (cur->name != NULL) { |
| 1026 if (dict) | 1026 if (dict) |
| 1027 ret->name = xmlDictLookup(dict, cur->name, -1); | 1027 ret->name = xmlDictLookup(dict, cur->name, -1); |
| 1028 else | 1028 else |
| 1029 ret->name = xmlStrdup(cur->name); | 1029 ret->name = xmlStrdup(cur->name); |
| 1030 } | 1030 } |
| 1031 | 1031 |
| 1032 if (cur->prefix != NULL) { | 1032 if (cur->prefix != NULL) { |
| 1033 if (dict) | 1033 if (dict) |
| 1034 ret->prefix = xmlDictLookup(dict, cur->prefix, -1); | 1034 ret->prefix = xmlDictLookup(dict, cur->prefix, -1); |
| 1035 else | 1035 else |
| 1036 ret->prefix = xmlStrdup(cur->prefix); | 1036 ret->prefix = xmlStrdup(cur->prefix); |
| 1037 } | 1037 } |
| 1038 if (cur->c1 != NULL) | 1038 if (cur->c1 != NULL) |
| 1039 ret->c1 = xmlCopyDocElementContent(doc, cur->c1); | 1039 ret->c1 = xmlCopyDocElementContent(doc, cur->c1); |
| 1040 if (ret->c1 != NULL) | 1040 if (ret->c1 != NULL) |
| 1041 ret->c1->parent = ret; | 1041 ret->c1->parent = ret; |
| 1042 if (cur->c2 != NULL) { | 1042 if (cur->c2 != NULL) { |
| 1043 prev = ret; | 1043 prev = ret; |
| 1044 cur = cur->c2; | 1044 cur = cur->c2; |
| 1045 while (cur != NULL) { | 1045 while (cur != NULL) { |
| 1046 tmp = (xmlElementContentPtr) xmlMalloc(sizeof(xmlElementContent)); | 1046 tmp = (xmlElementContentPtr) xmlMalloc(sizeof(xmlElementContent)); |
| 1047 if (tmp == NULL) { | 1047 if (tmp == NULL) { |
| 1048 xmlVErrMemory(NULL, "malloc failed"); | 1048 xmlVErrMemory(NULL, "malloc failed"); |
| 1049 return(ret); | 1049 return(ret); |
| 1050 } | 1050 } |
| 1051 memset(tmp, 0, sizeof(xmlElementContent)); | 1051 memset(tmp, 0, sizeof(xmlElementContent)); |
| 1052 tmp->type = cur->type; | 1052 tmp->type = cur->type; |
| 1053 tmp->ocur = cur->ocur; | 1053 tmp->ocur = cur->ocur; |
| 1054 prev->c2 = tmp; | 1054 prev->c2 = tmp; |
| 1055 if (cur->name != NULL) { | 1055 if (cur->name != NULL) { |
| 1056 if (dict) | 1056 if (dict) |
| 1057 tmp->name = xmlDictLookup(dict, cur->name, -1); | 1057 tmp->name = xmlDictLookup(dict, cur->name, -1); |
| 1058 else | 1058 else |
| 1059 tmp->name = xmlStrdup(cur->name); | 1059 tmp->name = xmlStrdup(cur->name); |
| 1060 } | 1060 } |
| 1061 » | 1061 |
| 1062 if (cur->prefix != NULL) { | 1062 if (cur->prefix != NULL) { |
| 1063 if (dict) | 1063 if (dict) |
| 1064 tmp->prefix = xmlDictLookup(dict, cur->prefix, -1); | 1064 tmp->prefix = xmlDictLookup(dict, cur->prefix, -1); |
| 1065 else | 1065 else |
| 1066 tmp->prefix = xmlStrdup(cur->prefix); | 1066 tmp->prefix = xmlStrdup(cur->prefix); |
| 1067 } | 1067 } |
| 1068 if (cur->c1 != NULL) | 1068 if (cur->c1 != NULL) |
| 1069 tmp->c1 = xmlCopyDocElementContent(doc,cur->c1); | 1069 tmp->c1 = xmlCopyDocElementContent(doc,cur->c1); |
| 1070 if (tmp->c1 != NULL) | 1070 if (tmp->c1 != NULL) |
| 1071 tmp->c1->parent = ret; | 1071 tmp->c1->parent = ret; |
| 1072 prev = tmp; | 1072 prev = tmp; |
| 1073 cur = cur->c2; | 1073 cur = cur->c2; |
| 1074 } | 1074 } |
| 1075 } | 1075 } |
| 1076 return(ret); | 1076 return(ret); |
| 1077 } | 1077 } |
| 1078 | 1078 |
| 1079 /** | 1079 /** |
| 1080 * xmlCopyElementContent: | 1080 * xmlCopyElementContent: |
| 1081 * @cur: An element content pointer. | 1081 * @cur: An element content pointer. |
| 1082 * | 1082 * |
| 1083 * Build a copy of an element content description. | 1083 * Build a copy of an element content description. |
| 1084 * Deprecated, use xmlCopyDocElementContent instead | 1084 * Deprecated, use xmlCopyDocElementContent instead |
| 1085 * | 1085 * |
| 1086 * Returns the new xmlElementContentPtr or NULL in case of error. | 1086 * Returns the new xmlElementContentPtr or NULL in case of error. |
| 1087 */ | 1087 */ |
| 1088 xmlElementContentPtr | 1088 xmlElementContentPtr |
| 1089 xmlCopyElementContent(xmlElementContentPtr cur) { | 1089 xmlCopyElementContent(xmlElementContentPtr cur) { |
| 1090 return(xmlCopyDocElementContent(NULL, cur)); | 1090 return(xmlCopyDocElementContent(NULL, cur)); |
| 1091 } | 1091 } |
| 1092 | 1092 |
| 1093 /** | 1093 /** |
| 1094 * xmlFreeDocElementContent: | 1094 * xmlFreeDocElementContent: |
| 1095 * @doc: the document owning the element declaration | 1095 * @doc: the document owning the element declaration |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1107 | 1107 |
| 1108 while (cur != NULL) { | 1108 while (cur != NULL) { |
| 1109 next = cur->c2; | 1109 next = cur->c2; |
| 1110 switch (cur->type) { | 1110 switch (cur->type) { |
| 1111 case XML_ELEMENT_CONTENT_PCDATA: | 1111 case XML_ELEMENT_CONTENT_PCDATA: |
| 1112 case XML_ELEMENT_CONTENT_ELEMENT: | 1112 case XML_ELEMENT_CONTENT_ELEMENT: |
| 1113 case XML_ELEMENT_CONTENT_SEQ: | 1113 case XML_ELEMENT_CONTENT_SEQ: |
| 1114 case XML_ELEMENT_CONTENT_OR: | 1114 case XML_ELEMENT_CONTENT_OR: |
| 1115 break; | 1115 break; |
| 1116 default: | 1116 default: |
| 1117 » » xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR, | 1117 » » xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR, |
| 1118 "Internal: ELEMENT content corrupted invalid type\n", | 1118 "Internal: ELEMENT content corrupted invalid type\n", |
| 1119 NULL); | 1119 NULL); |
| 1120 return; | 1120 return; |
| 1121 } | 1121 } |
| 1122 if (cur->c1 != NULL) xmlFreeDocElementContent(doc, cur->c1); | 1122 if (cur->c1 != NULL) xmlFreeDocElementContent(doc, cur->c1); |
| 1123 if (dict) { | 1123 if (dict) { |
| 1124 if ((cur->name != NULL) && (!xmlDictOwns(dict, cur->name))) | 1124 if ((cur->name != NULL) && (!xmlDictOwns(dict, cur->name))) |
| 1125 xmlFree((xmlChar *) cur->name); | 1125 xmlFree((xmlChar *) cur->name); |
| 1126 if ((cur->prefix != NULL) && (!xmlDictOwns(dict, cur->prefix))) | 1126 if ((cur->prefix != NULL) && (!xmlDictOwns(dict, cur->prefix))) |
| 1127 xmlFree((xmlChar *) cur->prefix); | 1127 xmlFree((xmlChar *) cur->prefix); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1193 xmlDumpElementContent(buf, content->c1, 0); | 1193 xmlDumpElementContent(buf, content->c1, 0); |
| 1194 xmlBufferWriteChar(buf, " | "); | 1194 xmlBufferWriteChar(buf, " | "); |
| 1195 if ((content->c2->type == XML_ELEMENT_CONTENT_SEQ) || | 1195 if ((content->c2->type == XML_ELEMENT_CONTENT_SEQ) || |
| 1196 ((content->c2->type == XML_ELEMENT_CONTENT_OR) && | 1196 ((content->c2->type == XML_ELEMENT_CONTENT_OR) && |
| 1197 (content->c2->ocur != XML_ELEMENT_CONTENT_ONCE))) | 1197 (content->c2->ocur != XML_ELEMENT_CONTENT_ONCE))) |
| 1198 xmlDumpElementContent(buf, content->c2, 1); | 1198 xmlDumpElementContent(buf, content->c2, 1); |
| 1199 else | 1199 else |
| 1200 xmlDumpElementContent(buf, content->c2, 0); | 1200 xmlDumpElementContent(buf, content->c2, 0); |
| 1201 break; | 1201 break; |
| 1202 default: | 1202 default: |
| 1203 » xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR, | 1203 » xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR, |
| 1204 "Internal: ELEMENT content corrupted invalid type\n", | 1204 "Internal: ELEMENT content corrupted invalid type\n", |
| 1205 NULL); | 1205 NULL); |
| 1206 } | 1206 } |
| 1207 if (glob) | 1207 if (glob) |
| 1208 xmlBufferWriteChar(buf, ")"); | 1208 xmlBufferWriteChar(buf, ")"); |
| 1209 switch (content->ocur) { | 1209 switch (content->ocur) { |
| 1210 case XML_ELEMENT_CONTENT_ONCE: | 1210 case XML_ELEMENT_CONTENT_ONCE: |
| 1211 break; | 1211 break; |
| 1212 case XML_ELEMENT_CONTENT_OPT: | 1212 case XML_ELEMENT_CONTENT_OPT: |
| 1213 xmlBufferWriteChar(buf, "?"); | 1213 xmlBufferWriteChar(buf, "?"); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1390 if (dtd == NULL) { | 1390 if (dtd == NULL) { |
| 1391 return(NULL); | 1391 return(NULL); |
| 1392 } | 1392 } |
| 1393 if (name == NULL) { | 1393 if (name == NULL) { |
| 1394 return(NULL); | 1394 return(NULL); |
| 1395 } | 1395 } |
| 1396 | 1396 |
| 1397 switch (type) { | 1397 switch (type) { |
| 1398 case XML_ELEMENT_TYPE_EMPTY: | 1398 case XML_ELEMENT_TYPE_EMPTY: |
| 1399 if (content != NULL) { | 1399 if (content != NULL) { |
| 1400 » » xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR, | 1400 » » xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR, |
| 1401 "xmlAddElementDecl: content != NULL for EMPTY\n", | 1401 "xmlAddElementDecl: content != NULL for EMPTY\n", |
| 1402 NULL); | 1402 NULL); |
| 1403 return(NULL); | 1403 return(NULL); |
| 1404 } | 1404 } |
| 1405 break; | 1405 break; |
| 1406 case XML_ELEMENT_TYPE_ANY: | 1406 case XML_ELEMENT_TYPE_ANY: |
| 1407 if (content != NULL) { | 1407 if (content != NULL) { |
| 1408 » » xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR, | 1408 » » xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR, |
| 1409 "xmlAddElementDecl: content != NULL for ANY\n", | 1409 "xmlAddElementDecl: content != NULL for ANY\n", |
| 1410 NULL); | 1410 NULL); |
| 1411 return(NULL); | 1411 return(NULL); |
| 1412 } | 1412 } |
| 1413 break; | 1413 break; |
| 1414 case XML_ELEMENT_TYPE_MIXED: | 1414 case XML_ELEMENT_TYPE_MIXED: |
| 1415 if (content == NULL) { | 1415 if (content == NULL) { |
| 1416 » » xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR, | 1416 » » xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR, |
| 1417 "xmlAddElementDecl: content == NULL for MIXED\n", | 1417 "xmlAddElementDecl: content == NULL for MIXED\n", |
| 1418 NULL); | 1418 NULL); |
| 1419 return(NULL); | 1419 return(NULL); |
| 1420 } | 1420 } |
| 1421 break; | 1421 break; |
| 1422 case XML_ELEMENT_TYPE_ELEMENT: | 1422 case XML_ELEMENT_TYPE_ELEMENT: |
| 1423 if (content == NULL) { | 1423 if (content == NULL) { |
| 1424 » » xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR, | 1424 » » xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR, |
| 1425 "xmlAddElementDecl: content == NULL for ELEMENT\n", | 1425 "xmlAddElementDecl: content == NULL for ELEMENT\n", |
| 1426 NULL); | 1426 NULL); |
| 1427 return(NULL); | 1427 return(NULL); |
| 1428 } | 1428 } |
| 1429 break; | 1429 break; |
| 1430 default: | 1430 default: |
| 1431 » xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR, | 1431 » xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR, |
| 1432 "Internal: ELEMENT decl corrupted invalid type\n", | 1432 "Internal: ELEMENT decl corrupted invalid type\n", |
| 1433 NULL); | 1433 NULL); |
| 1434 return(NULL); | 1434 return(NULL); |
| 1435 } | 1435 } |
| 1436 | 1436 |
| 1437 /* | 1437 /* |
| 1438 * check if name is a QName | 1438 * check if name is a QName |
| 1439 */ | 1439 */ |
| 1440 uqname = xmlSplitQName2(name, &ns); | 1440 uqname = xmlSplitQName2(name, &ns); |
| 1441 if (uqname != NULL) | 1441 if (uqname != NULL) |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1601 xmlFreeElementTable(xmlElementTablePtr table) { | 1601 xmlFreeElementTable(xmlElementTablePtr table) { |
| 1602 xmlHashFree(table, (xmlHashDeallocator) xmlFreeElement); | 1602 xmlHashFree(table, (xmlHashDeallocator) xmlFreeElement); |
| 1603 } | 1603 } |
| 1604 | 1604 |
| 1605 #ifdef LIBXML_TREE_ENABLED | 1605 #ifdef LIBXML_TREE_ENABLED |
| 1606 /** | 1606 /** |
| 1607 * xmlCopyElement: | 1607 * xmlCopyElement: |
| 1608 * @elem: An element | 1608 * @elem: An element |
| 1609 * | 1609 * |
| 1610 * Build a copy of an element. | 1610 * Build a copy of an element. |
| 1611 * | 1611 * |
| 1612 * Returns the new xmlElementPtr or NULL in case of error. | 1612 * Returns the new xmlElementPtr or NULL in case of error. |
| 1613 */ | 1613 */ |
| 1614 static xmlElementPtr | 1614 static xmlElementPtr |
| 1615 xmlCopyElement(xmlElementPtr elem) { | 1615 xmlCopyElement(xmlElementPtr elem) { |
| 1616 xmlElementPtr cur; | 1616 xmlElementPtr cur; |
| 1617 | 1617 |
| 1618 cur = (xmlElementPtr) xmlMalloc(sizeof(xmlElement)); | 1618 cur = (xmlElementPtr) xmlMalloc(sizeof(xmlElement)); |
| 1619 if (cur == NULL) { | 1619 if (cur == NULL) { |
| 1620 xmlVErrMemory(NULL, "malloc failed"); | 1620 xmlVErrMemory(NULL, "malloc failed"); |
| 1621 return(NULL); | 1621 return(NULL); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1635 /* TODO : rebuild the attribute list on the copy */ | 1635 /* TODO : rebuild the attribute list on the copy */ |
| 1636 cur->attributes = NULL; | 1636 cur->attributes = NULL; |
| 1637 return(cur); | 1637 return(cur); |
| 1638 } | 1638 } |
| 1639 | 1639 |
| 1640 /** | 1640 /** |
| 1641 * xmlCopyElementTable: | 1641 * xmlCopyElementTable: |
| 1642 * @table: An element table | 1642 * @table: An element table |
| 1643 * | 1643 * |
| 1644 * Build a copy of an element table. | 1644 * Build a copy of an element table. |
| 1645 * | 1645 * |
| 1646 * Returns the new xmlElementTablePtr or NULL in case of error. | 1646 * Returns the new xmlElementTablePtr or NULL in case of error. |
| 1647 */ | 1647 */ |
| 1648 xmlElementTablePtr | 1648 xmlElementTablePtr |
| 1649 xmlCopyElementTable(xmlElementTablePtr table) { | 1649 xmlCopyElementTable(xmlElementTablePtr table) { |
| 1650 return((xmlElementTablePtr) xmlHashCopy(table, | 1650 return((xmlElementTablePtr) xmlHashCopy(table, |
| 1651 (xmlHashCopier) xmlCopyElement)); | 1651 (xmlHashCopier) xmlCopyElement)); |
| 1652 } | 1652 } |
| 1653 #endif /* LIBXML_TREE_ENABLED */ | 1653 #endif /* LIBXML_TREE_ENABLED */ |
| 1654 | 1654 |
| 1655 #ifdef LIBXML_OUTPUT_ENABLED | 1655 #ifdef LIBXML_OUTPUT_ENABLED |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1700 if (elem->prefix != NULL) { | 1700 if (elem->prefix != NULL) { |
| 1701 xmlBufferWriteCHAR(buf, elem->prefix); | 1701 xmlBufferWriteCHAR(buf, elem->prefix); |
| 1702 xmlBufferWriteChar(buf, ":"); | 1702 xmlBufferWriteChar(buf, ":"); |
| 1703 } | 1703 } |
| 1704 xmlBufferWriteCHAR(buf, elem->name); | 1704 xmlBufferWriteCHAR(buf, elem->name); |
| 1705 xmlBufferWriteChar(buf, " "); | 1705 xmlBufferWriteChar(buf, " "); |
| 1706 xmlDumpElementContent(buf, elem->content, 1); | 1706 xmlDumpElementContent(buf, elem->content, 1); |
| 1707 xmlBufferWriteChar(buf, ">\n"); | 1707 xmlBufferWriteChar(buf, ">\n"); |
| 1708 break; | 1708 break; |
| 1709 default: | 1709 default: |
| 1710 » xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR, | 1710 » xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR, |
| 1711 "Internal: ELEMENT struct corrupted invalid type\n", | 1711 "Internal: ELEMENT struct corrupted invalid type\n", |
| 1712 NULL); | 1712 NULL); |
| 1713 } | 1713 } |
| 1714 } | 1714 } |
| 1715 | 1715 |
| 1716 /** | 1716 /** |
| 1717 * xmlDumpElementDeclScan: | 1717 * xmlDumpElementDeclScan: |
| 1718 * @elem: An element table | 1718 * @elem: An element table |
| 1719 * @buf: the XML buffer output | 1719 * @buf: the XML buffer output |
| 1720 * | 1720 * |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1791 * | 1791 * |
| 1792 * Returns the xmlEnumerationPtr just created or NULL in case | 1792 * Returns the xmlEnumerationPtr just created or NULL in case |
| 1793 * of error. | 1793 * of error. |
| 1794 */ | 1794 */ |
| 1795 xmlEnumerationPtr | 1795 xmlEnumerationPtr |
| 1796 xmlCopyEnumeration(xmlEnumerationPtr cur) { | 1796 xmlCopyEnumeration(xmlEnumerationPtr cur) { |
| 1797 xmlEnumerationPtr ret; | 1797 xmlEnumerationPtr ret; |
| 1798 | 1798 |
| 1799 if (cur == NULL) return(NULL); | 1799 if (cur == NULL) return(NULL); |
| 1800 ret = xmlCreateEnumeration((xmlChar *) cur->name); | 1800 ret = xmlCreateEnumeration((xmlChar *) cur->name); |
| 1801 if (ret == NULL) return(NULL); |
| 1801 | 1802 |
| 1802 if (cur->next != NULL) ret->next = xmlCopyEnumeration(cur->next); | 1803 if (cur->next != NULL) ret->next = xmlCopyEnumeration(cur->next); |
| 1803 else ret->next = NULL; | 1804 else ret->next = NULL; |
| 1804 | 1805 |
| 1805 return(ret); | 1806 return(ret); |
| 1806 } | 1807 } |
| 1807 #endif /* LIBXML_TREE_ENABLED */ | 1808 #endif /* LIBXML_TREE_ENABLED */ |
| 1808 | 1809 |
| 1809 #ifdef LIBXML_OUTPUT_ENABLED | 1810 #ifdef LIBXML_OUTPUT_ENABLED |
| 1810 /** | 1811 /** |
| 1811 * xmlDumpEnumeration: | 1812 * xmlDumpEnumeration: |
| 1812 * @buf: the XML buffer output | 1813 * @buf: the XML buffer output |
| 1813 * @enum: An enumeration | 1814 * @enum: An enumeration |
| 1814 * | 1815 * |
| 1815 * This will dump the content of the enumeration | 1816 * This will dump the content of the enumeration |
| 1816 */ | 1817 */ |
| 1817 static void | 1818 static void |
| 1818 xmlDumpEnumeration(xmlBufferPtr buf, xmlEnumerationPtr cur) { | 1819 xmlDumpEnumeration(xmlBufferPtr buf, xmlEnumerationPtr cur) { |
| 1819 if ((buf == NULL) || (cur == NULL)) | 1820 if ((buf == NULL) || (cur == NULL)) |
| 1820 return; | 1821 return; |
| 1821 | 1822 |
| 1822 xmlBufferWriteCHAR(buf, cur->name); | 1823 xmlBufferWriteCHAR(buf, cur->name); |
| 1823 if (cur->next == NULL) | 1824 if (cur->next == NULL) |
| 1824 xmlBufferWriteChar(buf, ")"); | 1825 xmlBufferWriteChar(buf, ")"); |
| 1825 else { | 1826 else { |
| 1826 xmlBufferWriteChar(buf, " | "); | 1827 xmlBufferWriteChar(buf, " | "); |
| 1827 xmlDumpEnumeration(buf, cur->next); | 1828 xmlDumpEnumeration(buf, cur->next); |
| 1828 } | 1829 } |
| 1829 } | 1830 } |
| 1830 #endif /* LIBXML_OUTPUT_ENABLED */ | 1831 #endif /* LIBXML_OUTPUT_ENABLED */ |
| 1831 | 1832 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1966 break; | 1967 break; |
| 1967 case XML_ATTRIBUTE_NMTOKEN: | 1968 case XML_ATTRIBUTE_NMTOKEN: |
| 1968 break; | 1969 break; |
| 1969 case XML_ATTRIBUTE_NMTOKENS: | 1970 case XML_ATTRIBUTE_NMTOKENS: |
| 1970 break; | 1971 break; |
| 1971 case XML_ATTRIBUTE_ENUMERATION: | 1972 case XML_ATTRIBUTE_ENUMERATION: |
| 1972 break; | 1973 break; |
| 1973 case XML_ATTRIBUTE_NOTATION: | 1974 case XML_ATTRIBUTE_NOTATION: |
| 1974 break; | 1975 break; |
| 1975 default: | 1976 default: |
| 1976 » xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR, | 1977 » xmlErrValid(ctxt, XML_ERR_INTERNAL_ERROR, |
| 1977 "Internal: ATTRIBUTE struct corrupted invalid type\n", | 1978 "Internal: ATTRIBUTE struct corrupted invalid type\n", |
| 1978 NULL); | 1979 NULL); |
| 1979 xmlFreeEnumeration(tree); | 1980 xmlFreeEnumeration(tree); |
| 1980 return(NULL); | 1981 return(NULL); |
| 1981 } | 1982 } |
| 1982 if ((defaultValue != NULL) && | 1983 if ((defaultValue != NULL) && |
| 1983 (!xmlValidateAttributeValueInternal(dtd->doc, type, defaultValue))) { | 1984 (!xmlValidateAttributeValueInternal(dtd->doc, type, defaultValue))) { |
| 1984 xmlErrValidNode(ctxt, (xmlNodePtr) dtd, XML_DTD_ATTRIBUTE_DEFAULT, | 1985 xmlErrValidNode(ctxt, (xmlNodePtr) dtd, XML_DTD_ATTRIBUTE_DEFAULT, |
| 1985 "Attribute %s of %s: invalid default value\n", | 1986 "Attribute %s of %s: invalid default value\n", |
| 1986 elem, name, defaultValue); | 1987 elem, name, defaultValue); |
| 1987 defaultValue = NULL; | 1988 defaultValue = NULL; |
| 1988 if (ctxt != NULL) | 1989 if (ctxt != NULL) |
| 1989 ctxt->valid = 0; | 1990 ctxt->valid = 0; |
| 1990 } | 1991 } |
| 1991 #endif /* LIBXML_VALID_ENABLED */ | 1992 #endif /* LIBXML_VALID_ENABLED */ |
| 1992 | 1993 |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2146 xmlFreeAttributeTable(xmlAttributeTablePtr table) { | 2147 xmlFreeAttributeTable(xmlAttributeTablePtr table) { |
| 2147 xmlHashFree(table, (xmlHashDeallocator) xmlFreeAttribute); | 2148 xmlHashFree(table, (xmlHashDeallocator) xmlFreeAttribute); |
| 2148 } | 2149 } |
| 2149 | 2150 |
| 2150 #ifdef LIBXML_TREE_ENABLED | 2151 #ifdef LIBXML_TREE_ENABLED |
| 2151 /** | 2152 /** |
| 2152 * xmlCopyAttribute: | 2153 * xmlCopyAttribute: |
| 2153 * @attr: An attribute | 2154 * @attr: An attribute |
| 2154 * | 2155 * |
| 2155 * Build a copy of an attribute. | 2156 * Build a copy of an attribute. |
| 2156 * | 2157 * |
| 2157 * Returns the new xmlAttributePtr or NULL in case of error. | 2158 * Returns the new xmlAttributePtr or NULL in case of error. |
| 2158 */ | 2159 */ |
| 2159 static xmlAttributePtr | 2160 static xmlAttributePtr |
| 2160 xmlCopyAttribute(xmlAttributePtr attr) { | 2161 xmlCopyAttribute(xmlAttributePtr attr) { |
| 2161 xmlAttributePtr cur; | 2162 xmlAttributePtr cur; |
| 2162 | 2163 |
| 2163 cur = (xmlAttributePtr) xmlMalloc(sizeof(xmlAttribute)); | 2164 cur = (xmlAttributePtr) xmlMalloc(sizeof(xmlAttribute)); |
| 2164 if (cur == NULL) { | 2165 if (cur == NULL) { |
| 2165 xmlVErrMemory(NULL, "malloc failed"); | 2166 xmlVErrMemory(NULL, "malloc failed"); |
| 2166 return(NULL); | 2167 return(NULL); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2179 if (attr->defaultValue != NULL) | 2180 if (attr->defaultValue != NULL) |
| 2180 cur->defaultValue = xmlStrdup(attr->defaultValue); | 2181 cur->defaultValue = xmlStrdup(attr->defaultValue); |
| 2181 return(cur); | 2182 return(cur); |
| 2182 } | 2183 } |
| 2183 | 2184 |
| 2184 /** | 2185 /** |
| 2185 * xmlCopyAttributeTable: | 2186 * xmlCopyAttributeTable: |
| 2186 * @table: An attribute table | 2187 * @table: An attribute table |
| 2187 * | 2188 * |
| 2188 * Build a copy of an attribute table. | 2189 * Build a copy of an attribute table. |
| 2189 * | 2190 * |
| 2190 * Returns the new xmlAttributeTablePtr or NULL in case of error. | 2191 * Returns the new xmlAttributeTablePtr or NULL in case of error. |
| 2191 */ | 2192 */ |
| 2192 xmlAttributeTablePtr | 2193 xmlAttributeTablePtr |
| 2193 xmlCopyAttributeTable(xmlAttributeTablePtr table) { | 2194 xmlCopyAttributeTable(xmlAttributeTablePtr table) { |
| 2194 return((xmlAttributeTablePtr) xmlHashCopy(table, | 2195 return((xmlAttributeTablePtr) xmlHashCopy(table, |
| 2195 (xmlHashCopier) xmlCopyAttribute)); | 2196 (xmlHashCopier) xmlCopyAttribute)); |
| 2196 } | 2197 } |
| 2197 #endif /* LIBXML_TREE_ENABLED */ | 2198 #endif /* LIBXML_TREE_ENABLED */ |
| 2198 | 2199 |
| 2199 #ifdef LIBXML_OUTPUT_ENABLED | 2200 #ifdef LIBXML_OUTPUT_ENABLED |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2244 break; | 2245 break; |
| 2245 case XML_ATTRIBUTE_ENUMERATION: | 2246 case XML_ATTRIBUTE_ENUMERATION: |
| 2246 xmlBufferWriteChar(buf, " ("); | 2247 xmlBufferWriteChar(buf, " ("); |
| 2247 xmlDumpEnumeration(buf, attr->tree); | 2248 xmlDumpEnumeration(buf, attr->tree); |
| 2248 break; | 2249 break; |
| 2249 case XML_ATTRIBUTE_NOTATION: | 2250 case XML_ATTRIBUTE_NOTATION: |
| 2250 xmlBufferWriteChar(buf, " NOTATION ("); | 2251 xmlBufferWriteChar(buf, " NOTATION ("); |
| 2251 xmlDumpEnumeration(buf, attr->tree); | 2252 xmlDumpEnumeration(buf, attr->tree); |
| 2252 break; | 2253 break; |
| 2253 default: | 2254 default: |
| 2254 » xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR, | 2255 » xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR, |
| 2255 "Internal: ATTRIBUTE struct corrupted invalid type\n", | 2256 "Internal: ATTRIBUTE struct corrupted invalid type\n", |
| 2256 NULL); | 2257 NULL); |
| 2257 } | 2258 } |
| 2258 switch (attr->def) { | 2259 switch (attr->def) { |
| 2259 case XML_ATTRIBUTE_NONE: | 2260 case XML_ATTRIBUTE_NONE: |
| 2260 break; | 2261 break; |
| 2261 case XML_ATTRIBUTE_REQUIRED: | 2262 case XML_ATTRIBUTE_REQUIRED: |
| 2262 xmlBufferWriteChar(buf, " #REQUIRED"); | 2263 xmlBufferWriteChar(buf, " #REQUIRED"); |
| 2263 break; | 2264 break; |
| 2264 case XML_ATTRIBUTE_IMPLIED: | 2265 case XML_ATTRIBUTE_IMPLIED: |
| 2265 xmlBufferWriteChar(buf, " #IMPLIED"); | 2266 xmlBufferWriteChar(buf, " #IMPLIED"); |
| 2266 break; | 2267 break; |
| 2267 case XML_ATTRIBUTE_FIXED: | 2268 case XML_ATTRIBUTE_FIXED: |
| 2268 xmlBufferWriteChar(buf, " #FIXED"); | 2269 xmlBufferWriteChar(buf, " #FIXED"); |
| 2269 break; | 2270 break; |
| 2270 default: | 2271 default: |
| 2271 » xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR, | 2272 » xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR, |
| 2272 "Internal: ATTRIBUTE struct corrupted invalid def\n", | 2273 "Internal: ATTRIBUTE struct corrupted invalid def\n", |
| 2273 NULL); | 2274 NULL); |
| 2274 } | 2275 } |
| 2275 if (attr->defaultValue != NULL) { | 2276 if (attr->defaultValue != NULL) { |
| 2276 xmlBufferWriteChar(buf, " "); | 2277 xmlBufferWriteChar(buf, " "); |
| 2277 xmlBufferWriteQuotedString(buf, attr->defaultValue); | 2278 xmlBufferWriteQuotedString(buf, attr->defaultValue); |
| 2278 } | 2279 } |
| 2279 xmlBufferWriteChar(buf, ">\n"); | 2280 xmlBufferWriteChar(buf, ">\n"); |
| 2280 } | 2281 } |
| 2281 | 2282 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2391 ret->SystemID = xmlStrdup(SystemID); | 2392 ret->SystemID = xmlStrdup(SystemID); |
| 2392 if (PublicID != NULL) | 2393 if (PublicID != NULL) |
| 2393 ret->PublicID = xmlStrdup(PublicID); | 2394 ret->PublicID = xmlStrdup(PublicID); |
| 2394 | 2395 |
| 2395 /* | 2396 /* |
| 2396 * Validity Check: | 2397 * Validity Check: |
| 2397 * Check the DTD for previous declarations of the ATTLIST | 2398 * Check the DTD for previous declarations of the ATTLIST |
| 2398 */ | 2399 */ |
| 2399 if (xmlHashAddEntry(table, name, ret)) { | 2400 if (xmlHashAddEntry(table, name, ret)) { |
| 2400 #ifdef LIBXML_VALID_ENABLED | 2401 #ifdef LIBXML_VALID_ENABLED |
| 2401 » xmlErrValid(NULL, XML_DTD_NOTATION_REDEFINED, | 2402 » xmlErrValid(NULL, XML_DTD_NOTATION_REDEFINED, |
| 2402 "xmlAddNotationDecl: %s already defined\n", | 2403 "xmlAddNotationDecl: %s already defined\n", |
| 2403 (const char *) name); | 2404 (const char *) name); |
| 2404 #endif /* LIBXML_VALID_ENABLED */ | 2405 #endif /* LIBXML_VALID_ENABLED */ |
| 2405 xmlFreeNotation(ret); | 2406 xmlFreeNotation(ret); |
| 2406 return(NULL); | 2407 return(NULL); |
| 2407 } | 2408 } |
| 2408 return(ret); | 2409 return(ret); |
| 2409 } | 2410 } |
| 2410 | 2411 |
| 2411 /** | 2412 /** |
| 2412 * xmlFreeNotationTable: | 2413 * xmlFreeNotationTable: |
| 2413 * @table: An notation table | 2414 * @table: An notation table |
| 2414 * | 2415 * |
| 2415 * Deallocate the memory used by an entities hash table. | 2416 * Deallocate the memory used by an entities hash table. |
| 2416 */ | 2417 */ |
| 2417 void | 2418 void |
| 2418 xmlFreeNotationTable(xmlNotationTablePtr table) { | 2419 xmlFreeNotationTable(xmlNotationTablePtr table) { |
| 2419 xmlHashFree(table, (xmlHashDeallocator) xmlFreeNotation); | 2420 xmlHashFree(table, (xmlHashDeallocator) xmlFreeNotation); |
| 2420 } | 2421 } |
| 2421 | 2422 |
| 2422 #ifdef LIBXML_TREE_ENABLED | 2423 #ifdef LIBXML_TREE_ENABLED |
| 2423 /** | 2424 /** |
| 2424 * xmlCopyNotation: | 2425 * xmlCopyNotation: |
| 2425 * @nota: A notation | 2426 * @nota: A notation |
| 2426 * | 2427 * |
| 2427 * Build a copy of a notation. | 2428 * Build a copy of a notation. |
| 2428 * | 2429 * |
| 2429 * Returns the new xmlNotationPtr or NULL in case of error. | 2430 * Returns the new xmlNotationPtr or NULL in case of error. |
| 2430 */ | 2431 */ |
| 2431 static xmlNotationPtr | 2432 static xmlNotationPtr |
| 2432 xmlCopyNotation(xmlNotationPtr nota) { | 2433 xmlCopyNotation(xmlNotationPtr nota) { |
| 2433 xmlNotationPtr cur; | 2434 xmlNotationPtr cur; |
| 2434 | 2435 |
| 2435 cur = (xmlNotationPtr) xmlMalloc(sizeof(xmlNotation)); | 2436 cur = (xmlNotationPtr) xmlMalloc(sizeof(xmlNotation)); |
| 2436 if (cur == NULL) { | 2437 if (cur == NULL) { |
| 2437 xmlVErrMemory(NULL, "malloc failed"); | 2438 xmlVErrMemory(NULL, "malloc failed"); |
| 2438 return(NULL); | 2439 return(NULL); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2450 else | 2451 else |
| 2451 cur->SystemID = NULL; | 2452 cur->SystemID = NULL; |
| 2452 return(cur); | 2453 return(cur); |
| 2453 } | 2454 } |
| 2454 | 2455 |
| 2455 /** | 2456 /** |
| 2456 * xmlCopyNotationTable: | 2457 * xmlCopyNotationTable: |
| 2457 * @table: A notation table | 2458 * @table: A notation table |
| 2458 * | 2459 * |
| 2459 * Build a copy of a notation table. | 2460 * Build a copy of a notation table. |
| 2460 * | 2461 * |
| 2461 * Returns the new xmlNotationTablePtr or NULL in case of error. | 2462 * Returns the new xmlNotationTablePtr or NULL in case of error. |
| 2462 */ | 2463 */ |
| 2463 xmlNotationTablePtr | 2464 xmlNotationTablePtr |
| 2464 xmlCopyNotationTable(xmlNotationTablePtr table) { | 2465 xmlCopyNotationTable(xmlNotationTablePtr table) { |
| 2465 return((xmlNotationTablePtr) xmlHashCopy(table, | 2466 return((xmlNotationTablePtr) xmlHashCopy(table, |
| 2466 (xmlHashCopier) xmlCopyNotation)); | 2467 (xmlHashCopier) xmlCopyNotation)); |
| 2467 } | 2468 } |
| 2468 #endif /* LIBXML_TREE_ENABLED */ | 2469 #endif /* LIBXML_TREE_ENABLED */ |
| 2469 | 2470 |
| 2470 #ifdef LIBXML_OUTPUT_ENABLED | 2471 #ifdef LIBXML_OUTPUT_ENABLED |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2528 * * | 2529 * * |
| 2529 ************************************************************************/ | 2530 ************************************************************************/ |
| 2530 /** | 2531 /** |
| 2531 * DICT_FREE: | 2532 * DICT_FREE: |
| 2532 * @str: a string | 2533 * @str: a string |
| 2533 * | 2534 * |
| 2534 * Free a string if it is not owned by the "dict" dictionnary in the | 2535 * Free a string if it is not owned by the "dict" dictionnary in the |
| 2535 * current scope | 2536 * current scope |
| 2536 */ | 2537 */ |
| 2537 #define DICT_FREE(str) \ | 2538 #define DICT_FREE(str) \ |
| 2538 » if ((str) && ((!dict) || » » » » \ | 2539 » if ((str) && ((!dict) ||» » » » \ |
| 2539 (xmlDictOwns(dict, (const xmlChar *)(str)) == 0))) \ | 2540 (xmlDictOwns(dict, (const xmlChar *)(str)) == 0))) \ |
| 2540 xmlFree((char *)(str)); | 2541 xmlFree((char *)(str)); |
| 2541 | 2542 |
| 2542 /** | 2543 /** |
| 2543 * xmlFreeID: | 2544 * xmlFreeID: |
| 2544 * @not: A id | 2545 * @not: A id |
| 2545 * | 2546 * |
| 2546 * Deallocate the memory used by an id definition | 2547 * Deallocate the memory used by an id definition |
| 2547 */ | 2548 */ |
| 2548 static void | 2549 static void |
| (...skipping 17 matching lines...) Expand all Loading... |
| 2566 * xmlAddID: | 2567 * xmlAddID: |
| 2567 * @ctxt: the validation context | 2568 * @ctxt: the validation context |
| 2568 * @doc: pointer to the document | 2569 * @doc: pointer to the document |
| 2569 * @value: the value name | 2570 * @value: the value name |
| 2570 * @attr: the attribute holding the ID | 2571 * @attr: the attribute holding the ID |
| 2571 * | 2572 * |
| 2572 * Register a new id declaration | 2573 * Register a new id declaration |
| 2573 * | 2574 * |
| 2574 * Returns NULL if not, otherwise the new xmlIDPtr | 2575 * Returns NULL if not, otherwise the new xmlIDPtr |
| 2575 */ | 2576 */ |
| 2576 xmlIDPtr | 2577 xmlIDPtr |
| 2577 xmlAddID(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value, | 2578 xmlAddID(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value, |
| 2578 xmlAttrPtr attr) { | 2579 xmlAttrPtr attr) { |
| 2579 xmlIDPtr ret; | 2580 xmlIDPtr ret; |
| 2580 xmlIDTablePtr table; | 2581 xmlIDTablePtr table; |
| 2581 | 2582 |
| 2582 if (doc == NULL) { | 2583 if (doc == NULL) { |
| 2583 return(NULL); | 2584 return(NULL); |
| 2584 } | 2585 } |
| 2585 if (value == NULL) { | 2586 if (value == NULL) { |
| 2586 return(NULL); | 2587 return(NULL); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2626 ret->attr = attr; | 2627 ret->attr = attr; |
| 2627 ret->name = NULL; | 2628 ret->name = NULL; |
| 2628 } | 2629 } |
| 2629 ret->lineno = xmlGetLineNo(attr->parent); | 2630 ret->lineno = xmlGetLineNo(attr->parent); |
| 2630 | 2631 |
| 2631 if (xmlHashAddEntry(table, value, ret) < 0) { | 2632 if (xmlHashAddEntry(table, value, ret) < 0) { |
| 2632 #ifdef LIBXML_VALID_ENABLED | 2633 #ifdef LIBXML_VALID_ENABLED |
| 2633 /* | 2634 /* |
| 2634 * The id is already defined in this DTD. | 2635 * The id is already defined in this DTD. |
| 2635 */ | 2636 */ |
| 2636 » if ((ctxt != NULL) && (ctxt->error != NULL)) { | 2637 » xmlErrValidNode(ctxt, attr->parent, XML_DTD_ID_REDEFINED, |
| 2637 » xmlErrValidNode(ctxt, attr->parent, XML_DTD_ID_REDEFINED, | 2638 » » » "ID %s already defined\n", value, NULL, NULL); |
| 2638 » "ID %s already defined\n", | |
| 2639 » » » value, NULL, NULL); | |
| 2640 » } | |
| 2641 #endif /* LIBXML_VALID_ENABLED */ | 2639 #endif /* LIBXML_VALID_ENABLED */ |
| 2642 xmlFreeID(ret); | 2640 xmlFreeID(ret); |
| 2643 return(NULL); | 2641 return(NULL); |
| 2644 } | 2642 } |
| 2645 if (attr != NULL) | 2643 if (attr != NULL) |
| 2646 attr->atype = XML_ATTRIBUTE_ID; | 2644 attr->atype = XML_ATTRIBUTE_ID; |
| 2647 return(ret); | 2645 return(ret); |
| 2648 } | 2646 } |
| 2649 | 2647 |
| 2650 /** | 2648 /** |
| (...skipping 29 matching lines...) Expand all Loading... |
| 2680 return(1); | 2678 return(1); |
| 2681 if (doc == NULL) return(0); | 2679 if (doc == NULL) return(0); |
| 2682 if ((doc->intSubset == NULL) && (doc->extSubset == NULL) && | 2680 if ((doc->intSubset == NULL) && (doc->extSubset == NULL) && |
| 2683 (doc->type != XML_HTML_DOCUMENT_NODE)) { | 2681 (doc->type != XML_HTML_DOCUMENT_NODE)) { |
| 2684 return(0); | 2682 return(0); |
| 2685 } else if (doc->type == XML_HTML_DOCUMENT_NODE) { | 2683 } else if (doc->type == XML_HTML_DOCUMENT_NODE) { |
| 2686 if ((xmlStrEqual(BAD_CAST "id", attr->name)) || | 2684 if ((xmlStrEqual(BAD_CAST "id", attr->name)) || |
| 2687 ((xmlStrEqual(BAD_CAST "name", attr->name)) && | 2685 ((xmlStrEqual(BAD_CAST "name", attr->name)) && |
| 2688 ((elem == NULL) || (xmlStrEqual(elem->name, BAD_CAST "a"))))) | 2686 ((elem == NULL) || (xmlStrEqual(elem->name, BAD_CAST "a"))))) |
| 2689 return(1); | 2687 return(1); |
| 2690 » return(0); | 2688 » return(0); |
| 2691 } else if (elem == NULL) { | 2689 } else if (elem == NULL) { |
| 2692 return(0); | 2690 return(0); |
| 2693 } else { | 2691 } else { |
| 2694 xmlAttributePtr attrDecl = NULL; | 2692 xmlAttributePtr attrDecl = NULL; |
| 2695 | 2693 |
| 2696 xmlChar felem[50], fattr[50]; | 2694 xmlChar felem[50], fattr[50]; |
| 2697 xmlChar *fullelemname, *fullattrname; | 2695 xmlChar *fullelemname, *fullattrname; |
| 2698 | 2696 |
| 2699 fullelemname = (elem->ns != NULL && elem->ns->prefix != NULL) ? | 2697 fullelemname = (elem->ns != NULL && elem->ns->prefix != NULL) ? |
| 2700 xmlBuildQName(elem->name, elem->ns->prefix, felem, 50) : | 2698 xmlBuildQName(elem->name, elem->ns->prefix, felem, 50) : |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2733 * Returns -1 if the lookup failed and 0 otherwise | 2731 * Returns -1 if the lookup failed and 0 otherwise |
| 2734 */ | 2732 */ |
| 2735 int | 2733 int |
| 2736 xmlRemoveID(xmlDocPtr doc, xmlAttrPtr attr) { | 2734 xmlRemoveID(xmlDocPtr doc, xmlAttrPtr attr) { |
| 2737 xmlIDTablePtr table; | 2735 xmlIDTablePtr table; |
| 2738 xmlIDPtr id; | 2736 xmlIDPtr id; |
| 2739 xmlChar *ID; | 2737 xmlChar *ID; |
| 2740 | 2738 |
| 2741 if (doc == NULL) return(-1); | 2739 if (doc == NULL) return(-1); |
| 2742 if (attr == NULL) return(-1); | 2740 if (attr == NULL) return(-1); |
| 2741 |
| 2743 table = (xmlIDTablePtr) doc->ids; | 2742 table = (xmlIDTablePtr) doc->ids; |
| 2744 if (table == NULL) | 2743 if (table == NULL) |
| 2745 return(-1); | 2744 return(-1); |
| 2746 | 2745 |
| 2747 if (attr == NULL) | |
| 2748 return(-1); | |
| 2749 ID = xmlNodeListGetString(doc, attr->children, 1); | 2746 ID = xmlNodeListGetString(doc, attr->children, 1); |
| 2750 if (ID == NULL) | 2747 if (ID == NULL) |
| 2751 » return(-1); | 2748 return(-1); |
| 2749 |
| 2752 id = xmlHashLookup(table, ID); | 2750 id = xmlHashLookup(table, ID); |
| 2753 if (id == NULL || id->attr != attr) { | 2751 if (id == NULL || id->attr != attr) { |
| 2754 » xmlFree(ID); | 2752 xmlFree(ID); |
| 2755 » return(-1); | 2753 return(-1); |
| 2756 } | 2754 } |
| 2755 |
| 2757 xmlHashRemoveEntry(table, ID, (xmlHashDeallocator) xmlFreeID); | 2756 xmlHashRemoveEntry(table, ID, (xmlHashDeallocator) xmlFreeID); |
| 2758 xmlFree(ID); | 2757 xmlFree(ID); |
| 2759 » attr->atype = 0; | 2758 attr->atype = 0; |
| 2760 return(0); | 2759 return(0); |
| 2761 } | 2760 } |
| 2762 | 2761 |
| 2763 /** | 2762 /** |
| 2764 * xmlGetID: | 2763 * xmlGetID: |
| 2765 * @doc: pointer to the document | 2764 * @doc: pointer to the document |
| 2766 * @ID: the ID value | 2765 * @ID: the ID value |
| 2767 * | 2766 * |
| 2768 * Search the attribute declaring the given ID | 2767 * Search the attribute declaring the given ID |
| 2769 * | 2768 * |
| 2770 * Returns NULL if not found, otherwise the xmlAttrPtr defining the ID | 2769 * Returns NULL if not found, otherwise the xmlAttrPtr defining the ID |
| 2771 */ | 2770 */ |
| 2772 xmlAttrPtr | 2771 xmlAttrPtr |
| 2773 xmlGetID(xmlDocPtr doc, const xmlChar *ID) { | 2772 xmlGetID(xmlDocPtr doc, const xmlChar *ID) { |
| 2774 xmlIDTablePtr table; | 2773 xmlIDTablePtr table; |
| 2775 xmlIDPtr id; | 2774 xmlIDPtr id; |
| 2776 | 2775 |
| 2777 if (doc == NULL) { | 2776 if (doc == NULL) { |
| 2778 return(NULL); | 2777 return(NULL); |
| 2779 } | 2778 } |
| 2780 | 2779 |
| 2781 if (ID == NULL) { | 2780 if (ID == NULL) { |
| 2782 return(NULL); | 2781 return(NULL); |
| 2783 } | 2782 } |
| 2784 | 2783 |
| 2785 table = (xmlIDTablePtr) doc->ids; | 2784 table = (xmlIDTablePtr) doc->ids; |
| 2786 if (table == NULL) | 2785 if (table == NULL) |
| 2787 return(NULL); | 2786 return(NULL); |
| 2788 | 2787 |
| 2789 id = xmlHashLookup(table, ID); | 2788 id = xmlHashLookup(table, ID); |
| 2790 if (id == NULL) | 2789 if (id == NULL) |
| 2791 return(NULL); | 2790 return(NULL); |
| 2792 if (id->attr == NULL) { | 2791 if (id->attr == NULL) { |
| 2793 /* | 2792 /* |
| 2794 * We are operating on a stream, return a well known reference | 2793 * We are operating on a stream, return a well known reference |
| 2795 * since the attribute node doesn't exist anymore | 2794 * since the attribute node doesn't exist anymore |
| 2796 */ | 2795 */ |
| 2797 return((xmlAttrPtr) doc); | 2796 return((xmlAttrPtr) doc); |
| 2798 } | 2797 } |
| 2799 return(id->attr); | 2798 return(id->attr); |
| 2800 } | 2799 } |
| 2801 | 2800 |
| 2802 /************************************************************************ | 2801 /************************************************************************ |
| 2803 * * | 2802 * * |
| 2804 * Refs * | 2803 * Refs * |
| 2805 * * | 2804 * * |
| 2806 ************************************************************************/ | 2805 ************************************************************************/ |
| 2807 typedef struct xmlRemoveMemo_t | 2806 typedef struct xmlRemoveMemo_t |
| 2808 { | 2807 { |
| 2809 xmlListPtr l; | 2808 xmlListPtr l; |
| 2810 xmlAttrPtr ap; | 2809 xmlAttrPtr ap; |
| 2811 } xmlRemoveMemo; | 2810 } xmlRemoveMemo; |
| 2812 | 2811 |
| 2813 typedef xmlRemoveMemo *xmlRemoveMemoPtr; | 2812 typedef xmlRemoveMemo *xmlRemoveMemoPtr; |
| 2814 | 2813 |
| 2815 typedef struct xmlValidateMemo_t | 2814 typedef struct xmlValidateMemo_t |
| 2816 { | 2815 { |
| 2817 xmlValidCtxtPtr ctxt; | 2816 xmlValidCtxtPtr ctxt; |
| 2818 const xmlChar *name; | 2817 const xmlChar *name; |
| 2819 } xmlValidateMemo; | 2818 } xmlValidateMemo; |
| 2820 | 2819 |
| 2821 typedef xmlValidateMemo *xmlValidateMemoPtr; | 2820 typedef xmlValidateMemo *xmlValidateMemoPtr; |
| 2822 | 2821 |
| 2823 /** | 2822 /** |
| 2824 * xmlFreeRef: | 2823 * xmlFreeRef: |
| 2825 * @lk: A list link | 2824 * @lk: A list link |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2888 * xmlAddRef: | 2887 * xmlAddRef: |
| 2889 * @ctxt: the validation context | 2888 * @ctxt: the validation context |
| 2890 * @doc: pointer to the document | 2889 * @doc: pointer to the document |
| 2891 * @value: the value name | 2890 * @value: the value name |
| 2892 * @attr: the attribute holding the Ref | 2891 * @attr: the attribute holding the Ref |
| 2893 * | 2892 * |
| 2894 * Register a new ref declaration | 2893 * Register a new ref declaration |
| 2895 * | 2894 * |
| 2896 * Returns NULL if not, otherwise the new xmlRefPtr | 2895 * Returns NULL if not, otherwise the new xmlRefPtr |
| 2897 */ | 2896 */ |
| 2898 xmlRefPtr | 2897 xmlRefPtr |
| 2899 xmlAddRef(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value, | 2898 xmlAddRef(xmlValidCtxtPtr ctxt, xmlDocPtr doc, const xmlChar *value, |
| 2900 xmlAttrPtr attr) { | 2899 xmlAttrPtr attr) { |
| 2901 xmlRefPtr ret; | 2900 xmlRefPtr ret; |
| 2902 xmlRefTablePtr table; | 2901 xmlRefTablePtr table; |
| 2903 xmlListPtr ref_list; | 2902 xmlListPtr ref_list; |
| 2904 | 2903 |
| 2905 if (doc == NULL) { | 2904 if (doc == NULL) { |
| 2906 return(NULL); | 2905 return(NULL); |
| 2907 } | 2906 } |
| 2908 if (value == NULL) { | 2907 if (value == NULL) { |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3016 return(0); | 3015 return(0); |
| 3017 if (doc == NULL) { | 3016 if (doc == NULL) { |
| 3018 doc = attr->doc; | 3017 doc = attr->doc; |
| 3019 if (doc == NULL) return(0); | 3018 if (doc == NULL) return(0); |
| 3020 } | 3019 } |
| 3021 | 3020 |
| 3022 if ((doc->intSubset == NULL) && (doc->extSubset == NULL)) { | 3021 if ((doc->intSubset == NULL) && (doc->extSubset == NULL)) { |
| 3023 return(0); | 3022 return(0); |
| 3024 } else if (doc->type == XML_HTML_DOCUMENT_NODE) { | 3023 } else if (doc->type == XML_HTML_DOCUMENT_NODE) { |
| 3025 /* TODO @@@ */ | 3024 /* TODO @@@ */ |
| 3026 return(0); | 3025 return(0); |
| 3027 } else { | 3026 } else { |
| 3028 xmlAttributePtr attrDecl; | 3027 xmlAttributePtr attrDecl; |
| 3029 | 3028 |
| 3030 if (elem == NULL) return(0); | 3029 if (elem == NULL) return(0); |
| 3031 attrDecl = xmlGetDtdAttrDesc(doc->intSubset, elem->name, attr->name); | 3030 attrDecl = xmlGetDtdAttrDesc(doc->intSubset, elem->name, attr->name); |
| 3032 if ((attrDecl == NULL) && (doc->extSubset != NULL)) | 3031 if ((attrDecl == NULL) && (doc->extSubset != NULL)) |
| 3033 attrDecl = xmlGetDtdAttrDesc(doc->extSubset, | 3032 attrDecl = xmlGetDtdAttrDesc(doc->extSubset, |
| 3034 elem->name, attr->name); | 3033 elem->name, attr->name); |
| 3035 | 3034 |
| 3036 if ((attrDecl != NULL) && | 3035 if ((attrDecl != NULL) && |
| (...skipping 15 matching lines...) Expand all Loading... |
| 3052 */ | 3051 */ |
| 3053 int | 3052 int |
| 3054 xmlRemoveRef(xmlDocPtr doc, xmlAttrPtr attr) { | 3053 xmlRemoveRef(xmlDocPtr doc, xmlAttrPtr attr) { |
| 3055 xmlListPtr ref_list; | 3054 xmlListPtr ref_list; |
| 3056 xmlRefTablePtr table; | 3055 xmlRefTablePtr table; |
| 3057 xmlChar *ID; | 3056 xmlChar *ID; |
| 3058 xmlRemoveMemo target; | 3057 xmlRemoveMemo target; |
| 3059 | 3058 |
| 3060 if (doc == NULL) return(-1); | 3059 if (doc == NULL) return(-1); |
| 3061 if (attr == NULL) return(-1); | 3060 if (attr == NULL) return(-1); |
| 3061 |
| 3062 table = (xmlRefTablePtr) doc->refs; | 3062 table = (xmlRefTablePtr) doc->refs; |
| 3063 if (table == NULL) | 3063 if (table == NULL) |
| 3064 return(-1); | 3064 return(-1); |
| 3065 | 3065 |
| 3066 if (attr == NULL) | |
| 3067 return(-1); | |
| 3068 ID = xmlNodeListGetString(doc, attr->children, 1); | 3066 ID = xmlNodeListGetString(doc, attr->children, 1); |
| 3069 if (ID == NULL) | 3067 if (ID == NULL) |
| 3070 return(-1); | 3068 return(-1); |
| 3069 |
| 3071 ref_list = xmlHashLookup(table, ID); | 3070 ref_list = xmlHashLookup(table, ID); |
| 3072 | |
| 3073 if(ref_list == NULL) { | 3071 if(ref_list == NULL) { |
| 3074 xmlFree(ID); | 3072 xmlFree(ID); |
| 3075 return (-1); | 3073 return (-1); |
| 3076 } | 3074 } |
| 3075 |
| 3077 /* At this point, ref_list refers to a list of references which | 3076 /* At this point, ref_list refers to a list of references which |
| 3078 * have the same key as the supplied attr. Our list of references | 3077 * have the same key as the supplied attr. Our list of references |
| 3079 * is ordered by reference address and we don't have that information | 3078 * is ordered by reference address and we don't have that information |
| 3080 * here to use when removing. We'll have to walk the list and | 3079 * here to use when removing. We'll have to walk the list and |
| 3081 * check for a matching attribute, when we find one stop the walk | 3080 * check for a matching attribute, when we find one stop the walk |
| 3082 * and remove the entry. | 3081 * and remove the entry. |
| 3083 * The list is ordered by reference, so that means we don't have the | 3082 * The list is ordered by reference, so that means we don't have the |
| 3084 * key. Passing the list and the reference to the walker means we | 3083 * key. Passing the list and the reference to the walker means we |
| 3085 * will have enough data to be able to remove the entry. | 3084 * will have enough data to be able to remove the entry. |
| 3086 */ | 3085 */ |
| 3087 target.l = ref_list; | 3086 target.l = ref_list; |
| 3088 target.ap = attr; | 3087 target.ap = attr; |
| 3089 | 3088 |
| 3090 /* Remove the supplied attr from our list */ | 3089 /* Remove the supplied attr from our list */ |
| 3091 xmlListWalk(ref_list, xmlWalkRemoveRef, &target); | 3090 xmlListWalk(ref_list, xmlWalkRemoveRef, &target); |
| 3092 | 3091 |
| 3093 /*If the list is empty then remove the list entry in the hash */ | 3092 /*If the list is empty then remove the list entry in the hash */ |
| 3094 if (xmlListEmpty(ref_list)) | 3093 if (xmlListEmpty(ref_list)) |
| 3095 xmlHashUpdateEntry(table, ID, NULL, (xmlHashDeallocator) | 3094 xmlHashUpdateEntry(table, ID, NULL, (xmlHashDeallocator) |
| 3096 xmlFreeRefList); | 3095 xmlFreeRefList); |
| 3097 xmlFree(ID); | 3096 xmlFree(ID); |
| 3098 return(0); | 3097 return(0); |
| 3099 } | 3098 } |
| 3100 | 3099 |
| 3101 /** | 3100 /** |
| 3102 * xmlGetRefs: | 3101 * xmlGetRefs: |
| 3103 * @doc: pointer to the document | 3102 * @doc: pointer to the document |
| 3104 * @ID: the ID value | 3103 * @ID: the ID value |
| 3105 * | 3104 * |
| 3106 * Find the set of references for the supplied ID. | 3105 * Find the set of references for the supplied ID. |
| 3107 * | 3106 * |
| 3108 * Returns NULL if not found, otherwise node set for the ID. | 3107 * Returns NULL if not found, otherwise node set for the ID. |
| 3109 */ | 3108 */ |
| 3110 xmlListPtr | 3109 xmlListPtr |
| 3111 xmlGetRefs(xmlDocPtr doc, const xmlChar *ID) { | 3110 xmlGetRefs(xmlDocPtr doc, const xmlChar *ID) { |
| 3112 xmlRefTablePtr table; | 3111 xmlRefTablePtr table; |
| 3113 | 3112 |
| 3114 if (doc == NULL) { | 3113 if (doc == NULL) { |
| 3115 return(NULL); | 3114 return(NULL); |
| 3116 } | 3115 } |
| 3117 | 3116 |
| 3118 if (ID == NULL) { | 3117 if (ID == NULL) { |
| 3119 return(NULL); | 3118 return(NULL); |
| 3120 } | 3119 } |
| 3121 | 3120 |
| 3122 table = (xmlRefTablePtr) doc->refs; | 3121 table = (xmlRefTablePtr) doc->refs; |
| 3123 if (table == NULL) | 3122 if (table == NULL) |
| 3124 return(NULL); | 3123 return(NULL); |
| 3125 | 3124 |
| 3126 return (xmlHashLookup(table, ID)); | 3125 return (xmlHashLookup(table, ID)); |
| 3127 } | 3126 } |
| 3128 | 3127 |
| 3129 /************************************************************************ | 3128 /************************************************************************ |
| 3130 * * | 3129 * * |
| 3131 * Routines for validity checking * | 3130 * Routines for validity checking * |
| 3132 * * | 3131 * * |
| 3133 ************************************************************************/ | 3132 ************************************************************************/ |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3178 xmlElementPtr cur; | 3177 xmlElementPtr cur; |
| 3179 xmlChar *uqname = NULL, *prefix = NULL; | 3178 xmlChar *uqname = NULL, *prefix = NULL; |
| 3180 | 3179 |
| 3181 if (dtd == NULL) return(NULL); | 3180 if (dtd == NULL) return(NULL); |
| 3182 if (dtd->elements == NULL) { | 3181 if (dtd->elements == NULL) { |
| 3183 xmlDictPtr dict = NULL; | 3182 xmlDictPtr dict = NULL; |
| 3184 | 3183 |
| 3185 if (dtd->doc != NULL) | 3184 if (dtd->doc != NULL) |
| 3186 dict = dtd->doc->dict; | 3185 dict = dtd->doc->dict; |
| 3187 | 3186 |
| 3188 » if (!create) | 3187 » if (!create) |
| 3189 return(NULL); | 3188 return(NULL); |
| 3190 /* | 3189 /* |
| 3191 * Create the Element table if needed. | 3190 * Create the Element table if needed. |
| 3192 */ | 3191 */ |
| 3193 table = (xmlElementTablePtr) dtd->elements; | 3192 table = (xmlElementTablePtr) dtd->elements; |
| 3194 if (table == NULL) { | 3193 if (table == NULL) { |
| 3195 table = xmlHashCreateDict(0, dict); | 3194 table = xmlHashCreateDict(0, dict); |
| 3196 dtd->elements = (void *) table; | 3195 dtd->elements = (void *) table; |
| 3197 } | 3196 } |
| 3198 if (table == NULL) { | 3197 if (table == NULL) { |
| (...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3791 * [ VC: IDREF ] | 3790 * [ VC: IDREF ] |
| 3792 * Values of type IDREF must match the Name production, and values | 3791 * Values of type IDREF must match the Name production, and values |
| 3793 * of type IDREFS must match Names ... | 3792 * of type IDREFS must match Names ... |
| 3794 * | 3793 * |
| 3795 * [ VC: Entity Name ] | 3794 * [ VC: Entity Name ] |
| 3796 * Values of type ENTITY must match the Name production, values | 3795 * Values of type ENTITY must match the Name production, values |
| 3797 * of type ENTITIES must match Names ... | 3796 * of type ENTITIES must match Names ... |
| 3798 * | 3797 * |
| 3799 * [ VC: Name Token ] | 3798 * [ VC: Name Token ] |
| 3800 * Values of type NMTOKEN must match the Nmtoken production; values | 3799 * Values of type NMTOKEN must match the Nmtoken production; values |
| 3801 * of type NMTOKENS must match Nmtokens. | 3800 * of type NMTOKENS must match Nmtokens. |
| 3802 * | 3801 * |
| 3803 * returns 1 if valid or 0 otherwise | 3802 * returns 1 if valid or 0 otherwise |
| 3804 */ | 3803 */ |
| 3805 int | 3804 int |
| 3806 xmlValidateAttributeValue(xmlAttributeType type, const xmlChar *value) { | 3805 xmlValidateAttributeValue(xmlAttributeType type, const xmlChar *value) { |
| 3807 return(xmlValidateAttributeValueInternal(NULL, type, value)); | 3806 return(xmlValidateAttributeValueInternal(NULL, type, value)); |
| 3808 } | 3807 } |
| 3809 | 3808 |
| 3810 /** | 3809 /** |
| 3811 * xmlValidateAttributeValue2: | 3810 * xmlValidateAttributeValue2: |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3850 case XML_ATTRIBUTE_CDATA: | 3849 case XML_ATTRIBUTE_CDATA: |
| 3851 break; | 3850 break; |
| 3852 case XML_ATTRIBUTE_ENTITY: { | 3851 case XML_ATTRIBUTE_ENTITY: { |
| 3853 xmlEntityPtr ent; | 3852 xmlEntityPtr ent; |
| 3854 | 3853 |
| 3855 ent = xmlGetDocEntity(doc, value); | 3854 ent = xmlGetDocEntity(doc, value); |
| 3856 /* yeah it's a bit messy... */ | 3855 /* yeah it's a bit messy... */ |
| 3857 if ((ent == NULL) && (doc->standalone == 1)) { | 3856 if ((ent == NULL) && (doc->standalone == 1)) { |
| 3858 doc->standalone = 0; | 3857 doc->standalone = 0; |
| 3859 ent = xmlGetDocEntity(doc, value); | 3858 ent = xmlGetDocEntity(doc, value); |
| 3860 » } | 3859 » } |
| 3861 if (ent == NULL) { | 3860 if (ent == NULL) { |
| 3862 xmlErrValidNode(ctxt, (xmlNodePtr) doc, | 3861 xmlErrValidNode(ctxt, (xmlNodePtr) doc, |
| 3863 XML_DTD_UNKNOWN_ENTITY, | 3862 XML_DTD_UNKNOWN_ENTITY, |
| 3864 "ENTITY attribute %s reference an unknown entity \"%s\"\n", | 3863 "ENTITY attribute %s reference an unknown entity \"%s\"\n", |
| 3865 name, value, NULL); | 3864 name, value, NULL); |
| 3866 ret = 0; | 3865 ret = 0; |
| 3867 } else if (ent->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) { | 3866 } else if (ent->etype != XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) { |
| 3868 xmlErrValidNode(ctxt, (xmlNodePtr) doc, | 3867 xmlErrValidNode(ctxt, (xmlNodePtr) doc, |
| 3869 XML_DTD_ENTITY_TYPE, | 3868 XML_DTD_ENTITY_TYPE, |
| 3870 "ENTITY attribute %s reference an entity \"%s\" of wrong type\n", | 3869 "ENTITY attribute %s reference an entity \"%s\" of wrong type\n", |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3961 int extsubset = 0; | 3960 int extsubset = 0; |
| 3962 | 3961 |
| 3963 if (doc == NULL) return(NULL); | 3962 if (doc == NULL) return(NULL); |
| 3964 if (elem == NULL) return(NULL); | 3963 if (elem == NULL) return(NULL); |
| 3965 if (name == NULL) return(NULL); | 3964 if (name == NULL) return(NULL); |
| 3966 if (value == NULL) return(NULL); | 3965 if (value == NULL) return(NULL); |
| 3967 | 3966 |
| 3968 if ((elem->ns != NULL) && (elem->ns->prefix != NULL)) { | 3967 if ((elem->ns != NULL) && (elem->ns->prefix != NULL)) { |
| 3969 xmlChar fn[50]; | 3968 xmlChar fn[50]; |
| 3970 xmlChar *fullname; | 3969 xmlChar *fullname; |
| 3971 » | 3970 |
| 3972 fullname = xmlBuildQName(elem->name, elem->ns->prefix, fn, 50); | 3971 fullname = xmlBuildQName(elem->name, elem->ns->prefix, fn, 50); |
| 3973 if (fullname == NULL) | 3972 if (fullname == NULL) |
| 3974 return(NULL); | 3973 return(NULL); |
| 3975 attrDecl = xmlGetDtdAttrDesc(doc->intSubset, fullname, name); | 3974 attrDecl = xmlGetDtdAttrDesc(doc->intSubset, fullname, name); |
| 3976 if ((attrDecl == NULL) && (doc->extSubset != NULL)) { | 3975 if ((attrDecl == NULL) && (doc->extSubset != NULL)) { |
| 3977 attrDecl = xmlGetDtdAttrDesc(doc->extSubset, fullname, name); | 3976 attrDecl = xmlGetDtdAttrDesc(doc->extSubset, fullname, name); |
| 3978 if (attrDecl != NULL) | 3977 if (attrDecl != NULL) |
| 3979 extsubset = 1; | 3978 extsubset = 1; |
| 3980 } | 3979 } |
| 3981 if ((fullname != fn) && (fullname != elem->name)) | 3980 if ((fullname != fn) && (fullname != elem->name)) |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4160 * element in the external subset. | 4159 * element in the external subset. |
| 4161 */ | 4160 */ |
| 4162 nbId = 0; | 4161 nbId = 0; |
| 4163 if (doc->intSubset != NULL) { | 4162 if (doc->intSubset != NULL) { |
| 4164 table = (xmlAttributeTablePtr) doc->intSubset->attributes; | 4163 table = (xmlAttributeTablePtr) doc->intSubset->attributes; |
| 4165 xmlHashScan3(table, NULL, NULL, attr->elem, (xmlHashScanner) | 4164 xmlHashScan3(table, NULL, NULL, attr->elem, (xmlHashScanner) |
| 4166 xmlValidateAttributeIdCallback, &nbId); | 4165 xmlValidateAttributeIdCallback, &nbId); |
| 4167 } | 4166 } |
| 4168 } | 4167 } |
| 4169 if (nbId > 1) { | 4168 if (nbId > 1) { |
| 4170 » | 4169 |
| 4171 xmlErrValidNodeNr(ctxt, (xmlNodePtr) attr, XML_DTD_ID_SUBSET, | 4170 xmlErrValidNodeNr(ctxt, (xmlNodePtr) attr, XML_DTD_ID_SUBSET, |
| 4172 "Element %s has %d ID attribute defined in the internal subset : %s\n", | 4171 "Element %s has %d ID attribute defined in the internal subset : %s\n", |
| 4173 attr->elem, nbId, attr->name); | 4172 attr->elem, nbId, attr->name); |
| 4174 } else if (doc->extSubset != NULL) { | 4173 } else if (doc->extSubset != NULL) { |
| 4175 int extId = 0; | 4174 int extId = 0; |
| 4176 elem = xmlGetDtdElementDesc(doc->extSubset, attr->elem); | 4175 elem = xmlGetDtdElementDesc(doc->extSubset, attr->elem); |
| 4177 if (elem != NULL) { | 4176 if (elem != NULL) { |
| 4178 extId = xmlScanIDAttributeDecl(NULL, elem, 0); | 4177 extId = xmlScanIDAttributeDecl(NULL, elem, 0); |
| 4179 } | 4178 } |
| 4180 if (extId > 1) { | 4179 if (extId > 1) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4223 * returns 1 if valid or 0 otherwise | 4222 * returns 1 if valid or 0 otherwise |
| 4224 */ | 4223 */ |
| 4225 | 4224 |
| 4226 int | 4225 int |
| 4227 xmlValidateElementDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc, | 4226 xmlValidateElementDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc, |
| 4228 xmlElementPtr elem) { | 4227 xmlElementPtr elem) { |
| 4229 int ret = 1; | 4228 int ret = 1; |
| 4230 xmlElementPtr tst; | 4229 xmlElementPtr tst; |
| 4231 | 4230 |
| 4232 CHECK_DTD; | 4231 CHECK_DTD; |
| 4233 | 4232 |
| 4234 if (elem == NULL) return(1); | 4233 if (elem == NULL) return(1); |
| 4235 | 4234 |
| 4236 #if 0 | 4235 #if 0 |
| 4237 #ifdef LIBXML_REGEXP_ENABLED | 4236 #ifdef LIBXML_REGEXP_ENABLED |
| 4238 /* Build the regexp associated to the content model */ | 4237 /* Build the regexp associated to the content model */ |
| 4239 ret = xmlValidBuildContentModel(ctxt, elem); | 4238 ret = xmlValidBuildContentModel(ctxt, elem); |
| 4240 #endif | 4239 #endif |
| 4241 #endif | 4240 #endif |
| 4242 | 4241 |
| 4243 /* No Duplicate Types */ | 4242 /* No Duplicate Types */ |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4340 * - [ VC: Entity Name ] | 4339 * - [ VC: Entity Name ] |
| 4341 * - [ VC: Notation Attributes ] | 4340 * - [ VC: Notation Attributes ] |
| 4342 * | 4341 * |
| 4343 * The ID/IDREF uniqueness and matching are done separately | 4342 * The ID/IDREF uniqueness and matching are done separately |
| 4344 * | 4343 * |
| 4345 * returns 1 if valid or 0 otherwise | 4344 * returns 1 if valid or 0 otherwise |
| 4346 */ | 4345 */ |
| 4347 | 4346 |
| 4348 int | 4347 int |
| 4349 xmlValidateOneAttribute(xmlValidCtxtPtr ctxt, xmlDocPtr doc, | 4348 xmlValidateOneAttribute(xmlValidCtxtPtr ctxt, xmlDocPtr doc, |
| 4350 xmlNodePtr elem, xmlAttrPtr attr, const xmlChar *value) | 4349 xmlNodePtr elem, xmlAttrPtr attr, const xmlChar *value) |
| 4351 { | 4350 { |
| 4352 xmlAttributePtr attrDecl = NULL; | 4351 xmlAttributePtr attrDecl = NULL; |
| 4353 int val; | 4352 int val; |
| 4354 int ret = 1; | 4353 int ret = 1; |
| 4355 | 4354 |
| 4356 CHECK_DTD; | 4355 CHECK_DTD; |
| 4357 if ((elem == NULL) || (elem->name == NULL)) return(0); | 4356 if ((elem == NULL) || (elem->name == NULL)) return(0); |
| 4358 if ((attr == NULL) || (attr->name == NULL)) return(0); | 4357 if ((attr == NULL) || (attr->name == NULL)) return(0); |
| 4359 | 4358 |
| 4360 if ((elem->ns != NULL) && (elem->ns->prefix != NULL)) { | 4359 if ((elem->ns != NULL) && (elem->ns->prefix != NULL)) { |
| 4361 xmlChar fn[50]; | 4360 xmlChar fn[50]; |
| 4362 xmlChar *fullname; | 4361 xmlChar *fullname; |
| 4363 » | 4362 |
| 4364 fullname = xmlBuildQName(elem->name, elem->ns->prefix, fn, 50); | 4363 fullname = xmlBuildQName(elem->name, elem->ns->prefix, fn, 50); |
| 4365 if (fullname == NULL) | 4364 if (fullname == NULL) |
| 4366 return(0); | 4365 return(0); |
| 4367 if (attr->ns != NULL) { | 4366 if (attr->ns != NULL) { |
| 4368 attrDecl = xmlGetDtdQAttrDesc(doc->intSubset, fullname, | 4367 attrDecl = xmlGetDtdQAttrDesc(doc->intSubset, fullname, |
| 4369 attr->name, attr->ns->prefix); | 4368 attr->name, attr->ns->prefix); |
| 4370 if ((attrDecl == NULL) && (doc->extSubset != NULL)) | 4369 if ((attrDecl == NULL) && (doc->extSubset != NULL)) |
| 4371 attrDecl = xmlGetDtdQAttrDesc(doc->extSubset, fullname, | 4370 attrDecl = xmlGetDtdQAttrDesc(doc->extSubset, fullname, |
| 4372 attr->name, attr->ns->prefix); | 4371 attr->name, attr->ns->prefix); |
| 4373 } else { | 4372 } else { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4437 | 4436 |
| 4438 /* Validity Constraint: Notation Attributes */ | 4437 /* Validity Constraint: Notation Attributes */ |
| 4439 if (attrDecl->atype == XML_ATTRIBUTE_NOTATION) { | 4438 if (attrDecl->atype == XML_ATTRIBUTE_NOTATION) { |
| 4440 xmlEnumerationPtr tree = attrDecl->tree; | 4439 xmlEnumerationPtr tree = attrDecl->tree; |
| 4441 xmlNotationPtr nota; | 4440 xmlNotationPtr nota; |
| 4442 | 4441 |
| 4443 /* First check that the given NOTATION was declared */ | 4442 /* First check that the given NOTATION was declared */ |
| 4444 nota = xmlGetDtdNotationDesc(doc->intSubset, value); | 4443 nota = xmlGetDtdNotationDesc(doc->intSubset, value); |
| 4445 if (nota == NULL) | 4444 if (nota == NULL) |
| 4446 nota = xmlGetDtdNotationDesc(doc->extSubset, value); | 4445 nota = xmlGetDtdNotationDesc(doc->extSubset, value); |
| 4447 » | 4446 |
| 4448 if (nota == NULL) { | 4447 if (nota == NULL) { |
| 4449 xmlErrValidNode(ctxt, elem, XML_DTD_UNKNOWN_NOTATION, | 4448 xmlErrValidNode(ctxt, elem, XML_DTD_UNKNOWN_NOTATION, |
| 4450 "Value \"%s\" for attribute %s of %s is not a declared Notation\n", | 4449 "Value \"%s\" for attribute %s of %s is not a declared Notation\n", |
| 4451 value, attr->name, elem->name); | 4450 value, attr->name, elem->name); |
| 4452 ret = 0; | 4451 ret = 0; |
| 4453 } | 4452 } |
| 4454 | 4453 |
| 4455 /* Second, verify that it's among the list */ | 4454 /* Second, verify that it's among the list */ |
| 4456 while (tree != NULL) { | 4455 while (tree != NULL) { |
| 4457 if (xmlStrEqual(tree->name, value)) break; | 4456 if (xmlStrEqual(tree->name, value)) break; |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4530 int val; | 4529 int val; |
| 4531 int ret = 1; | 4530 int ret = 1; |
| 4532 | 4531 |
| 4533 CHECK_DTD; | 4532 CHECK_DTD; |
| 4534 if ((elem == NULL) || (elem->name == NULL)) return(0); | 4533 if ((elem == NULL) || (elem->name == NULL)) return(0); |
| 4535 if ((ns == NULL) || (ns->href == NULL)) return(0); | 4534 if ((ns == NULL) || (ns->href == NULL)) return(0); |
| 4536 | 4535 |
| 4537 if (prefix != NULL) { | 4536 if (prefix != NULL) { |
| 4538 xmlChar fn[50]; | 4537 xmlChar fn[50]; |
| 4539 xmlChar *fullname; | 4538 xmlChar *fullname; |
| 4540 » | 4539 |
| 4541 fullname = xmlBuildQName(elem->name, prefix, fn, 50); | 4540 fullname = xmlBuildQName(elem->name, prefix, fn, 50); |
| 4542 if (fullname == NULL) { | 4541 if (fullname == NULL) { |
| 4543 xmlVErrMemory(ctxt, "Validating namespace"); | 4542 xmlVErrMemory(ctxt, "Validating namespace"); |
| 4544 return(0); | 4543 return(0); |
| 4545 } | 4544 } |
| 4546 if (ns->prefix != NULL) { | 4545 if (ns->prefix != NULL) { |
| 4547 attrDecl = xmlGetDtdQAttrDesc(doc->intSubset, fullname, | 4546 attrDecl = xmlGetDtdQAttrDesc(doc->intSubset, fullname, |
| 4548 ns->prefix, BAD_CAST "xmlns"); | 4547 ns->prefix, BAD_CAST "xmlns"); |
| 4549 if ((attrDecl == NULL) && (doc->extSubset != NULL)) | 4548 if ((attrDecl == NULL) && (doc->extSubset != NULL)) |
| 4550 attrDecl = xmlGetDtdQAttrDesc(doc->extSubset, fullname, | 4549 attrDecl = xmlGetDtdQAttrDesc(doc->extSubset, fullname, |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4634 | 4633 |
| 4635 /* Validity Constraint: Notation Attributes */ | 4634 /* Validity Constraint: Notation Attributes */ |
| 4636 if (attrDecl->atype == XML_ATTRIBUTE_NOTATION) { | 4635 if (attrDecl->atype == XML_ATTRIBUTE_NOTATION) { |
| 4637 xmlEnumerationPtr tree = attrDecl->tree; | 4636 xmlEnumerationPtr tree = attrDecl->tree; |
| 4638 xmlNotationPtr nota; | 4637 xmlNotationPtr nota; |
| 4639 | 4638 |
| 4640 /* First check that the given NOTATION was declared */ | 4639 /* First check that the given NOTATION was declared */ |
| 4641 nota = xmlGetDtdNotationDesc(doc->intSubset, value); | 4640 nota = xmlGetDtdNotationDesc(doc->intSubset, value); |
| 4642 if (nota == NULL) | 4641 if (nota == NULL) |
| 4643 nota = xmlGetDtdNotationDesc(doc->extSubset, value); | 4642 nota = xmlGetDtdNotationDesc(doc->extSubset, value); |
| 4644 » | 4643 |
| 4645 if (nota == NULL) { | 4644 if (nota == NULL) { |
| 4646 if (ns->prefix != NULL) { | 4645 if (ns->prefix != NULL) { |
| 4647 xmlErrValidNode(ctxt, elem, XML_DTD_UNKNOWN_NOTATION, | 4646 xmlErrValidNode(ctxt, elem, XML_DTD_UNKNOWN_NOTATION, |
| 4648 "Value \"%s\" for attribute xmlns:%s of %s is not a declared Notation\n", | 4647 "Value \"%s\" for attribute xmlns:%s of %s is not a declared Notation\n", |
| 4649 value, ns->prefix, elem->name); | 4648 value, ns->prefix, elem->name); |
| 4650 } else { | 4649 } else { |
| 4651 xmlErrValidNode(ctxt, elem, XML_DTD_UNKNOWN_NOTATION, | 4650 xmlErrValidNode(ctxt, elem, XML_DTD_UNKNOWN_NOTATION, |
| 4652 "Value \"%s\" for attribute xmlns of %s is not a declared Notation\n", | 4651 "Value \"%s\" for attribute xmlns of %s is not a declared Notation\n", |
| 4653 value, elem->name, NULL); | 4652 value, elem->name, NULL); |
| 4654 } | 4653 } |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4770 */ | 4769 */ |
| 4771 | 4770 |
| 4772 static int | 4771 static int |
| 4773 xmlValidateElementType(xmlValidCtxtPtr ctxt) { | 4772 xmlValidateElementType(xmlValidCtxtPtr ctxt) { |
| 4774 int ret = -1; | 4773 int ret = -1; |
| 4775 int determinist = 1; | 4774 int determinist = 1; |
| 4776 | 4775 |
| 4777 NODE = xmlValidateSkipIgnorable(NODE); | 4776 NODE = xmlValidateSkipIgnorable(NODE); |
| 4778 if ((NODE == NULL) && (CONT == NULL)) | 4777 if ((NODE == NULL) && (CONT == NULL)) |
| 4779 return(1); | 4778 return(1); |
| 4780 if ((NODE == NULL) && | 4779 if ((NODE == NULL) && |
| 4781 ((CONT->ocur == XML_ELEMENT_CONTENT_MULT) || | 4780 ((CONT->ocur == XML_ELEMENT_CONTENT_MULT) || |
| 4782 (CONT->ocur == XML_ELEMENT_CONTENT_OPT))) { | 4781 (CONT->ocur == XML_ELEMENT_CONTENT_OPT))) { |
| 4783 return(1); | 4782 return(1); |
| 4784 } | 4783 } |
| 4785 if (CONT == NULL) return(-1); | 4784 if (CONT == NULL) return(-1); |
| 4786 if ((NODE != NULL) && (NODE->type == XML_ENTITY_REF_NODE)) | 4785 if ((NODE != NULL) && (NODE->type == XML_ENTITY_REF_NODE)) |
| 4787 return(-2); | 4786 return(-2); |
| 4788 | 4787 |
| 4789 /* | 4788 /* |
| 4790 * We arrive here when more states need to be examined | 4789 * We arrive here when more states need to be examined |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5229 xmlValidateElementContent(xmlValidCtxtPtr ctxt, xmlNodePtr child, | 5228 xmlValidateElementContent(xmlValidCtxtPtr ctxt, xmlNodePtr child, |
| 5230 xmlElementPtr elemDecl, int warn, xmlNodePtr parent) { | 5229 xmlElementPtr elemDecl, int warn, xmlNodePtr parent) { |
| 5231 int ret = 1; | 5230 int ret = 1; |
| 5232 #ifndef LIBXML_REGEXP_ENABLED | 5231 #ifndef LIBXML_REGEXP_ENABLED |
| 5233 xmlNodePtr repl = NULL, last = NULL, tmp; | 5232 xmlNodePtr repl = NULL, last = NULL, tmp; |
| 5234 #endif | 5233 #endif |
| 5235 xmlNodePtr cur; | 5234 xmlNodePtr cur; |
| 5236 xmlElementContentPtr cont; | 5235 xmlElementContentPtr cont; |
| 5237 const xmlChar *name; | 5236 const xmlChar *name; |
| 5238 | 5237 |
| 5239 if (elemDecl == NULL) | 5238 if ((elemDecl == NULL) || (parent == NULL) || (ctxt == NULL)) |
| 5240 return(-1); | 5239 return(-1); |
| 5241 cont = elemDecl->content; | 5240 cont = elemDecl->content; |
| 5242 name = elemDecl->name; | 5241 name = elemDecl->name; |
| 5243 | 5242 |
| 5244 #ifdef LIBXML_REGEXP_ENABLED | 5243 #ifdef LIBXML_REGEXP_ENABLED |
| 5245 /* Build the regexp associated to the content model */ | 5244 /* Build the regexp associated to the content model */ |
| 5246 if (elemDecl->contModel == NULL) | 5245 if (elemDecl->contModel == NULL) |
| 5247 ret = xmlValidBuildContentModel(ctxt, elemDecl); | 5246 ret = xmlValidBuildContentModel(ctxt, elemDecl); |
| 5248 if (elemDecl->contModel == NULL) { | 5247 if (elemDecl->contModel == NULL) { |
| 5249 return(-1); | 5248 return(-1); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 5279 ret = 0; | 5278 ret = 0; |
| 5280 goto fail; | 5279 goto fail; |
| 5281 case XML_CDATA_SECTION_NODE: | 5280 case XML_CDATA_SECTION_NODE: |
| 5282 /* TODO */ | 5281 /* TODO */ |
| 5283 ret = 0; | 5282 ret = 0; |
| 5284 goto fail; | 5283 goto fail; |
| 5285 case XML_ELEMENT_NODE: | 5284 case XML_ELEMENT_NODE: |
| 5286 if ((cur->ns != NULL) && (cur->ns->prefix != NULL)) { | 5285 if ((cur->ns != NULL) && (cur->ns->prefix != NULL)) { |
| 5287 xmlChar fn[50]; | 5286 xmlChar fn[50]; |
| 5288 xmlChar *fullname; | 5287 xmlChar *fullname; |
| 5289 » » » | 5288 |
| 5290 fullname = xmlBuildQName(cur->name, | 5289 fullname = xmlBuildQName(cur->name, |
| 5291 cur->ns->prefix, fn, 50); | 5290 cur->ns->prefix, fn, 50); |
| 5292 if (fullname == NULL) { | 5291 if (fullname == NULL) { |
| 5293 ret = -1; | 5292 ret = -1; |
| 5294 goto fail; | 5293 goto fail; |
| 5295 } | 5294 } |
| 5296 ret = xmlRegExecPushString(exec, fullname, NULL); | 5295 ret = xmlRegExecPushString(exec, fullname, NULL); |
| 5297 if ((fullname != fn) && (fullname != cur->name)) | 5296 if ((fullname != fn) && (fullname != cur->name)) |
| 5298 xmlFree(fullname); | 5297 xmlFree(fullname); |
| 5299 } else { | 5298 } else { |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5393 tmp->ns = cur->ns; | 5392 tmp->ns = cur->ns; |
| 5394 tmp->next = NULL; | 5393 tmp->next = NULL; |
| 5395 tmp->content = NULL; | 5394 tmp->content = NULL; |
| 5396 if (repl == NULL) | 5395 if (repl == NULL) |
| 5397 repl = last = tmp; | 5396 repl = last = tmp; |
| 5398 else { | 5397 else { |
| 5399 last->next = tmp; | 5398 last->next = tmp; |
| 5400 last = tmp; | 5399 last = tmp; |
| 5401 } | 5400 } |
| 5402 if (cur->type == XML_CDATA_SECTION_NODE) { | 5401 if (cur->type == XML_CDATA_SECTION_NODE) { |
| 5403 » » » /* | 5402 » » » /* |
| 5404 * E59 spaces in CDATA does not match the | 5403 * E59 spaces in CDATA does not match the |
| 5405 * nonterminal S | 5404 * nonterminal S |
| 5406 */ | 5405 */ |
| 5407 tmp->content = xmlStrdup(BAD_CAST "CDATA"); | 5406 tmp->content = xmlStrdup(BAD_CAST "CDATA"); |
| 5408 } | 5407 } |
| 5409 break; | 5408 break; |
| 5410 default: | 5409 default: |
| 5411 break; | 5410 break; |
| 5412 } | 5411 } |
| 5413 /* | 5412 /* |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5510 * Check that an element follows #CDATA | 5509 * Check that an element follows #CDATA |
| 5511 * | 5510 * |
| 5512 * returns 1 if valid or 0 otherwise | 5511 * returns 1 if valid or 0 otherwise |
| 5513 */ | 5512 */ |
| 5514 static int | 5513 static int |
| 5515 xmlValidateOneCdataElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc, | 5514 xmlValidateOneCdataElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc, |
| 5516 xmlNodePtr elem) { | 5515 xmlNodePtr elem) { |
| 5517 int ret = 1; | 5516 int ret = 1; |
| 5518 xmlNodePtr cur, child; | 5517 xmlNodePtr cur, child; |
| 5519 | 5518 |
| 5520 if ((ctxt == NULL) || (doc == NULL) || (elem == NULL)) | 5519 if ((ctxt == NULL) || (doc == NULL) || (elem == NULL) || |
| 5520 (elem->type != XML_ELEMENT_NODE)) |
| 5521 return(0); | 5521 return(0); |
| 5522 | 5522 |
| 5523 child = elem->children; | 5523 child = elem->children; |
| 5524 | 5524 |
| 5525 cur = child; | 5525 cur = child; |
| 5526 while (cur != NULL) { | 5526 while (cur != NULL) { |
| 5527 switch (cur->type) { | 5527 switch (cur->type) { |
| 5528 case XML_ENTITY_REF_NODE: | 5528 case XML_ENTITY_REF_NODE: |
| 5529 /* | 5529 /* |
| 5530 * Push the current node to be able to roll back | 5530 * Push the current node to be able to roll back |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5591 return(1); | 5591 return(1); |
| 5592 } else if ((cont->type == XML_ELEMENT_CONTENT_OR) && | 5592 } else if ((cont->type == XML_ELEMENT_CONTENT_OR) && |
| 5593 (cont->c1 != NULL) && | 5593 (cont->c1 != NULL) && |
| 5594 (cont->c1->type == XML_ELEMENT_CONTENT_ELEMENT)){ | 5594 (cont->c1->type == XML_ELEMENT_CONTENT_ELEMENT)){ |
| 5595 if ((cont->c1->prefix == NULL) && | 5595 if ((cont->c1->prefix == NULL) && |
| 5596 (xmlStrEqual(cont->c1->name, qname))) | 5596 (xmlStrEqual(cont->c1->name, qname))) |
| 5597 return(1); | 5597 return(1); |
| 5598 } else if ((cont->type != XML_ELEMENT_CONTENT_OR) || | 5598 } else if ((cont->type != XML_ELEMENT_CONTENT_OR) || |
| 5599 (cont->c1 == NULL) || | 5599 (cont->c1 == NULL) || |
| 5600 (cont->c1->type != XML_ELEMENT_CONTENT_PCDATA)){ | 5600 (cont->c1->type != XML_ELEMENT_CONTENT_PCDATA)){ |
| 5601 » » xmlErrValid(NULL, XML_DTD_MIXED_CORRUPT, | 5601 » » xmlErrValid(NULL, XML_DTD_MIXED_CORRUPT, |
| 5602 "Internal: MIXED struct corrupted\n", | 5602 "Internal: MIXED struct corrupted\n", |
| 5603 NULL); | 5603 NULL); |
| 5604 break; | 5604 break; |
| 5605 } | 5605 } |
| 5606 cont = cont->c2; | 5606 cont = cont->c2; |
| 5607 } | 5607 } |
| 5608 } else { | 5608 } else { |
| 5609 while (cont != NULL) { | 5609 while (cont != NULL) { |
| 5610 if (cont->type == XML_ELEMENT_CONTENT_ELEMENT) { | 5610 if (cont->type == XML_ELEMENT_CONTENT_ELEMENT) { |
| 5611 if ((cont->prefix != NULL) && | 5611 if ((cont->prefix != NULL) && |
| 5612 (xmlStrncmp(cont->prefix, qname, plen) == 0) && | 5612 (xmlStrncmp(cont->prefix, qname, plen) == 0) && |
| 5613 (xmlStrEqual(cont->name, name))) | 5613 (xmlStrEqual(cont->name, name))) |
| 5614 return(1); | 5614 return(1); |
| 5615 } else if ((cont->type == XML_ELEMENT_CONTENT_OR) && | 5615 } else if ((cont->type == XML_ELEMENT_CONTENT_OR) && |
| 5616 (cont->c1 != NULL) && | 5616 (cont->c1 != NULL) && |
| 5617 (cont->c1->type == XML_ELEMENT_CONTENT_ELEMENT)){ | 5617 (cont->c1->type == XML_ELEMENT_CONTENT_ELEMENT)){ |
| 5618 if ((cont->c1->prefix != NULL) && | 5618 if ((cont->c1->prefix != NULL) && |
| 5619 (xmlStrncmp(cont->c1->prefix, qname, plen) == 0) && | 5619 (xmlStrncmp(cont->c1->prefix, qname, plen) == 0) && |
| 5620 (xmlStrEqual(cont->c1->name, name))) | 5620 (xmlStrEqual(cont->c1->name, name))) |
| 5621 return(1); | 5621 return(1); |
| 5622 } else if ((cont->type != XML_ELEMENT_CONTENT_OR) || | 5622 } else if ((cont->type != XML_ELEMENT_CONTENT_OR) || |
| 5623 (cont->c1 == NULL) || | 5623 (cont->c1 == NULL) || |
| 5624 (cont->c1->type != XML_ELEMENT_CONTENT_PCDATA)){ | 5624 (cont->c1->type != XML_ELEMENT_CONTENT_PCDATA)){ |
| 5625 » » xmlErrValid(ctxt, XML_DTD_MIXED_CORRUPT, | 5625 » » xmlErrValid(ctxt, XML_DTD_MIXED_CORRUPT, |
| 5626 "Internal: MIXED struct corrupted\n", | 5626 "Internal: MIXED struct corrupted\n", |
| 5627 NULL); | 5627 NULL); |
| 5628 break; | 5628 break; |
| 5629 } | 5629 } |
| 5630 cont = cont->c2; | 5630 cont = cont->c2; |
| 5631 } | 5631 } |
| 5632 } | 5632 } |
| 5633 return(0); | 5633 return(0); |
| 5634 } | 5634 } |
| 5635 | 5635 |
| 5636 /** | 5636 /** |
| 5637 * xmlValidGetElemDecl: | 5637 * xmlValidGetElemDecl: |
| 5638 * @ctxt: the validation context | 5638 * @ctxt: the validation context |
| 5639 * @doc: a document instance | 5639 * @doc: a document instance |
| 5640 * @elem: an element instance | 5640 * @elem: an element instance |
| 5641 * @extsubset: pointer, (out) indicate if the declaration was found | 5641 * @extsubset: pointer, (out) indicate if the declaration was found |
| 5642 * in the external subset. | 5642 * in the external subset. |
| 5643 * | 5643 * |
| 5644 * Finds a declaration associated to an element in the document. | 5644 * Finds a declaration associated to an element in the document. |
| 5645 * | 5645 * |
| 5646 * returns the pointer to the declaration or NULL if not found. | 5646 * returns the pointer to the declaration or NULL if not found. |
| 5647 */ | 5647 */ |
| 5648 static xmlElementPtr | 5648 static xmlElementPtr |
| 5649 xmlValidGetElemDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc, | 5649 xmlValidGetElemDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc, |
| 5650 xmlNodePtr elem, int *extsubset) { | 5650 xmlNodePtr elem, int *extsubset) { |
| 5651 xmlElementPtr elemDecl = NULL; | 5651 xmlElementPtr elemDecl = NULL; |
| 5652 const xmlChar *prefix = NULL; | 5652 const xmlChar *prefix = NULL; |
| 5653 | 5653 |
| 5654 if ((ctxt == NULL) || (doc == NULL) || | 5654 if ((ctxt == NULL) || (doc == NULL) || |
| 5655 (elem == NULL) || (elem->name == NULL)) | 5655 (elem == NULL) || (elem->name == NULL)) |
| 5656 return(NULL); | 5656 return(NULL); |
| 5657 if (extsubset != NULL) | 5657 if (extsubset != NULL) |
| 5658 *extsubset = 0; | 5658 *extsubset = 0; |
| 5659 | 5659 |
| 5660 /* | 5660 /* |
| 5661 * Fetch the declaration for the qualified name | 5661 * Fetch the declaration for the qualified name |
| 5662 */ | 5662 */ |
| 5663 if ((elem->ns != NULL) && (elem->ns->prefix != NULL)) | 5663 if ((elem->ns != NULL) && (elem->ns->prefix != NULL)) |
| 5664 prefix = elem->ns->prefix; | 5664 prefix = elem->ns->prefix; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5788 } | 5788 } |
| 5789 eDecl = xmlValidGetElemDecl(ctxt, doc, elem, &extsubset); | 5789 eDecl = xmlValidGetElemDecl(ctxt, doc, elem, &extsubset); |
| 5790 vstateVPush(ctxt, eDecl, elem); | 5790 vstateVPush(ctxt, eDecl, elem); |
| 5791 return(ret); | 5791 return(ret); |
| 5792 } | 5792 } |
| 5793 | 5793 |
| 5794 /** | 5794 /** |
| 5795 * xmlValidatePushCData: | 5795 * xmlValidatePushCData: |
| 5796 * @ctxt: the validation context | 5796 * @ctxt: the validation context |
| 5797 * @data: some character data read | 5797 * @data: some character data read |
| 5798 * @len: the lenght of the data | 5798 * @len: the length of the data |
| 5799 * | 5799 * |
| 5800 * check the CData parsed for validation in the current stack | 5800 * check the CData parsed for validation in the current stack |
| 5801 * | 5801 * |
| 5802 * returns 1 if no validation problem was found or 0 otherwise | 5802 * returns 1 if no validation problem was found or 0 otherwise |
| 5803 */ | 5803 */ |
| 5804 int | 5804 int |
| 5805 xmlValidatePushCData(xmlValidCtxtPtr ctxt, const xmlChar *data, int len) { | 5805 xmlValidatePushCData(xmlValidCtxtPtr ctxt, const xmlChar *data, int len) { |
| 5806 int ret = 1; | 5806 int ret = 1; |
| 5807 | 5807 |
| 5808 /* printf("CDATA %s %d\n", data, len); */ | 5808 /* printf("CDATA %s %d\n", data, len); */ |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6010 } | 6010 } |
| 6011 | 6011 |
| 6012 /* | 6012 /* |
| 6013 * Fetch the declaration | 6013 * Fetch the declaration |
| 6014 */ | 6014 */ |
| 6015 elemDecl = xmlValidGetElemDecl(ctxt, doc, elem, &extsubset); | 6015 elemDecl = xmlValidGetElemDecl(ctxt, doc, elem, &extsubset); |
| 6016 if (elemDecl == NULL) | 6016 if (elemDecl == NULL) |
| 6017 return(0); | 6017 return(0); |
| 6018 | 6018 |
| 6019 /* | 6019 /* |
| 6020 * If vstateNr is not zero that means continuous validation is | 6020 * If vstateNr is not zero that means continuous validation is |
| 6021 * activated, do not try to check the content model at that level. | 6021 * activated, do not try to check the content model at that level. |
| 6022 */ | 6022 */ |
| 6023 if (ctxt->vstateNr == 0) { | 6023 if (ctxt->vstateNr == 0) { |
| 6024 /* Check that the element content matches the definition */ | 6024 /* Check that the element content matches the definition */ |
| 6025 switch (elemDecl->etype) { | 6025 switch (elemDecl->etype) { |
| 6026 case XML_ELEMENT_TYPE_UNDEFINED: | 6026 case XML_ELEMENT_TYPE_UNDEFINED: |
| 6027 xmlErrValidNode(ctxt, elem, XML_DTD_UNKNOWN_ELEM, | 6027 xmlErrValidNode(ctxt, elem, XML_DTD_UNKNOWN_ELEM, |
| 6028 "No declaration for element %s\n", | 6028 "No declaration for element %s\n", |
| 6029 elem->name, NULL, NULL); | 6029 elem->name, NULL, NULL); |
| 6030 return(0); | 6030 return(0); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 6053 break; | 6053 break; |
| 6054 } | 6054 } |
| 6055 child = elem->children; | 6055 child = elem->children; |
| 6056 /* Hum, this start to get messy */ | 6056 /* Hum, this start to get messy */ |
| 6057 while (child != NULL) { | 6057 while (child != NULL) { |
| 6058 if (child->type == XML_ELEMENT_NODE) { | 6058 if (child->type == XML_ELEMENT_NODE) { |
| 6059 name = child->name; | 6059 name = child->name; |
| 6060 if ((child->ns != NULL) && (child->ns->prefix != NULL)) { | 6060 if ((child->ns != NULL) && (child->ns->prefix != NULL)) { |
| 6061 xmlChar fn[50]; | 6061 xmlChar fn[50]; |
| 6062 xmlChar *fullname; | 6062 xmlChar *fullname; |
| 6063 » » » | 6063 |
| 6064 fullname = xmlBuildQName(child->name, child->ns->prefix, | 6064 fullname = xmlBuildQName(child->name, child->ns->prefix, |
| 6065 fn, 50); | 6065 fn, 50); |
| 6066 if (fullname == NULL) | 6066 if (fullname == NULL) |
| 6067 return(0); | 6067 return(0); |
| 6068 cont = elemDecl->content; | 6068 cont = elemDecl->content; |
| 6069 while (cont != NULL) { | 6069 while (cont != NULL) { |
| 6070 if (cont->type == XML_ELEMENT_CONTENT_ELEMENT) { | 6070 if (cont->type == XML_ELEMENT_CONTENT_ELEMENT) { |
| 6071 if (xmlStrEqual(cont->name, fullname)) | 6071 if (xmlStrEqual(cont->name, fullname)) |
| 6072 break; | 6072 break; |
| 6073 } else if ((cont->type == XML_ELEMENT_CONTENT_OR) && | 6073 } else if ((cont->type == XML_ELEMENT_CONTENT_OR) && |
| 6074 (cont->c1 != NULL) && | 6074 (cont->c1 != NULL) && |
| 6075 (cont->c1->type == XML_ELEMENT_CONTENT_ELEMENT)){ | 6075 (cont->c1->type == XML_ELEMENT_CONTENT_ELEMENT)){ |
| 6076 if (xmlStrEqual(cont->c1->name, fullname)) | 6076 if (xmlStrEqual(cont->c1->name, fullname)) |
| 6077 break; | 6077 break; |
| 6078 } else if ((cont->type != XML_ELEMENT_CONTENT_OR) || | 6078 } else if ((cont->type != XML_ELEMENT_CONTENT_OR) || |
| 6079 (cont->c1 == NULL) || | 6079 (cont->c1 == NULL) || |
| 6080 (cont->c1->type != XML_ELEMENT_CONTENT_PCDATA)){ | 6080 (cont->c1->type != XML_ELEMENT_CONTENT_PCDATA)){ |
| 6081 » » » » xmlErrValid(NULL, XML_DTD_MIXED_CORRUPT, | 6081 » » » » xmlErrValid(NULL, XML_DTD_MIXED_CORRUPT, |
| 6082 "Internal: MIXED struct corrupted\n", | 6082 "Internal: MIXED struct corrupted\n", |
| 6083 NULL); | 6083 NULL); |
| 6084 break; | 6084 break; |
| 6085 } | 6085 } |
| 6086 cont = cont->c2; | 6086 cont = cont->c2; |
| 6087 } | 6087 } |
| 6088 if ((fullname != fn) && (fullname != child->name)) | 6088 if ((fullname != fn) && (fullname != child->name)) |
| 6089 xmlFree(fullname); | 6089 xmlFree(fullname); |
| 6090 if (cont != NULL) | 6090 if (cont != NULL) |
| 6091 goto child_ok; | 6091 goto child_ok; |
| 6092 } | 6092 } |
| 6093 cont = elemDecl->content; | 6093 cont = elemDecl->content; |
| 6094 while (cont != NULL) { | 6094 while (cont != NULL) { |
| 6095 if (cont->type == XML_ELEMENT_CONTENT_ELEMENT) { | 6095 if (cont->type == XML_ELEMENT_CONTENT_ELEMENT) { |
| 6096 if (xmlStrEqual(cont->name, name)) break; | 6096 if (xmlStrEqual(cont->name, name)) break; |
| 6097 } else if ((cont->type == XML_ELEMENT_CONTENT_OR) && | 6097 } else if ((cont->type == XML_ELEMENT_CONTENT_OR) && |
| 6098 (cont->c1 != NULL) && | 6098 (cont->c1 != NULL) && |
| 6099 (cont->c1->type == XML_ELEMENT_CONTENT_ELEMENT)) { | 6099 (cont->c1->type == XML_ELEMENT_CONTENT_ELEMENT)) { |
| 6100 if (xmlStrEqual(cont->c1->name, name)) break; | 6100 if (xmlStrEqual(cont->c1->name, name)) break; |
| 6101 } else if ((cont->type != XML_ELEMENT_CONTENT_OR) || | 6101 } else if ((cont->type != XML_ELEMENT_CONTENT_OR) || |
| 6102 (cont->c1 == NULL) || | 6102 (cont->c1 == NULL) || |
| 6103 (cont->c1->type != XML_ELEMENT_CONTENT_PCDATA)) { | 6103 (cont->c1->type != XML_ELEMENT_CONTENT_PCDATA)) { |
| 6104 » » » xmlErrValid(ctxt, XML_DTD_MIXED_CORRUPT, | 6104 » » » xmlErrValid(ctxt, XML_DTD_MIXED_CORRUPT, |
| 6105 "Internal: MIXED struct corrupted\n", | 6105 "Internal: MIXED struct corrupted\n", |
| 6106 NULL); | 6106 NULL); |
| 6107 break; | 6107 break; |
| 6108 } | 6108 } |
| 6109 cont = cont->c2; | 6109 cont = cont->c2; |
| 6110 } | 6110 } |
| 6111 if (cont == NULL) { | 6111 if (cont == NULL) { |
| 6112 xmlErrValidNode(ctxt, elem, XML_DTD_INVALID_CHILD, | 6112 xmlErrValidNode(ctxt, elem, XML_DTD_INVALID_CHILD, |
| 6113 "Element %s is not declared in %s list of possible children\n", | 6113 "Element %s is not declared in %s list of possible children\n", |
| 6114 name, elem->name, NULL); | 6114 name, elem->name, NULL); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6174 xmlNsPtr ns; | 6174 xmlNsPtr ns; |
| 6175 | 6175 |
| 6176 ns = elem->nsDef; | 6176 ns = elem->nsDef; |
| 6177 while (ns != NULL) { | 6177 while (ns != NULL) { |
| 6178 if (xmlStrEqual(attr->name, ns->prefix)) | 6178 if (xmlStrEqual(attr->name, ns->prefix)) |
| 6179 goto found; | 6179 goto found; |
| 6180 ns = ns->next; | 6180 ns = ns->next; |
| 6181 } | 6181 } |
| 6182 } else { | 6182 } else { |
| 6183 xmlAttrPtr attrib; | 6183 xmlAttrPtr attrib; |
| 6184 » » | 6184 |
| 6185 attrib = elem->properties; | 6185 attrib = elem->properties; |
| 6186 while (attrib != NULL) { | 6186 while (attrib != NULL) { |
| 6187 if (xmlStrEqual(attrib->name, attr->name)) { | 6187 if (xmlStrEqual(attrib->name, attr->name)) { |
| 6188 if (attr->prefix != NULL) { | 6188 if (attr->prefix != NULL) { |
| 6189 xmlNsPtr nameSpace = attrib->ns; | 6189 xmlNsPtr nameSpace = attrib->ns; |
| 6190 | 6190 |
| 6191 if (nameSpace == NULL) | 6191 if (nameSpace == NULL) |
| 6192 nameSpace = elem->ns; | 6192 nameSpace = elem->ns; |
| 6193 /* | 6193 /* |
| 6194 * qualified names handling is problematic, having a | 6194 * qualified names handling is problematic, having a |
| 6195 * different prefix should be possible but DTDs don'
t | 6195 * different prefix should be possible but DTDs don'
t |
| 6196 * allow to define the URI instead of the prefix :-( | 6196 * allow to define the URI instead of the prefix :-( |
| 6197 */ | 6197 */ |
| 6198 if (nameSpace == NULL) { | 6198 if (nameSpace == NULL) { |
| 6199 » » » » if (qualified < 0) | 6199 » » » » if (qualified < 0) |
| 6200 qualified = 0; | 6200 qualified = 0; |
| 6201 } else if (!xmlStrEqual(nameSpace->prefix, | 6201 } else if (!xmlStrEqual(nameSpace->prefix, |
| 6202 attr->prefix)) { | 6202 attr->prefix)) { |
| 6203 » » » » if (qualified < 1) | 6203 » » » » if (qualified < 1) |
| 6204 qualified = 1; | 6204 qualified = 1; |
| 6205 } else | 6205 } else |
| 6206 goto found; | 6206 goto found; |
| 6207 } else { | 6207 } else { |
| 6208 /* | 6208 /* |
| 6209 * We should allow applications to define namespaces | 6209 * We should allow applications to define namespaces |
| 6210 » » » * for their application even if the DTD doesn't | 6210 » » » * for their application even if the DTD doesn't |
| 6211 * carry one, otherwise, basically we would always | 6211 * carry one, otherwise, basically we would always |
| 6212 * break. | 6212 * break. |
| 6213 */ | 6213 */ |
| 6214 goto found; | 6214 goto found; |
| 6215 } | 6215 } |
| 6216 } | 6216 } |
| 6217 attrib = attrib->next; | 6217 attrib = attrib->next; |
| 6218 } | 6218 } |
| 6219 } | 6219 } |
| 6220 if (qualified == -1) { | 6220 if (qualified == -1) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6273 "Element %s namespace name for %s does not match the DTD\n", | 6273 "Element %s namespace name for %s does not match the DTD\n", |
| 6274 elem->name, ns->prefix, NULL); | 6274 elem->name, ns->prefix, NULL); |
| 6275 ret = 0; | 6275 ret = 0; |
| 6276 } | 6276 } |
| 6277 goto found; | 6277 goto found; |
| 6278 } | 6278 } |
| 6279 ns = ns->next; | 6279 ns = ns->next; |
| 6280 } | 6280 } |
| 6281 } | 6281 } |
| 6282 } | 6282 } |
| 6283 found:» | 6283 found: |
| 6284 attr = attr->nexth; | 6284 attr = attr->nexth; |
| 6285 } | 6285 } |
| 6286 return(ret); | 6286 return(ret); |
| 6287 } | 6287 } |
| 6288 | 6288 |
| 6289 /** | 6289 /** |
| 6290 * xmlValidateRoot: | 6290 * xmlValidateRoot: |
| 6291 * @ctxt: the validation context | 6291 * @ctxt: the validation context |
| 6292 * @doc: a document instance | 6292 * @doc: a document instance |
| 6293 * | 6293 * |
| (...skipping 26 matching lines...) Expand all Loading... |
| 6320 */ | 6320 */ |
| 6321 if ((doc->intSubset != NULL) && | 6321 if ((doc->intSubset != NULL) && |
| 6322 (doc->intSubset->name != NULL)) { | 6322 (doc->intSubset->name != NULL)) { |
| 6323 /* | 6323 /* |
| 6324 * Check first the document root against the NQName | 6324 * Check first the document root against the NQName |
| 6325 */ | 6325 */ |
| 6326 if (!xmlStrEqual(doc->intSubset->name, root->name)) { | 6326 if (!xmlStrEqual(doc->intSubset->name, root->name)) { |
| 6327 if ((root->ns != NULL) && (root->ns->prefix != NULL)) { | 6327 if ((root->ns != NULL) && (root->ns->prefix != NULL)) { |
| 6328 xmlChar fn[50]; | 6328 xmlChar fn[50]; |
| 6329 xmlChar *fullname; | 6329 xmlChar *fullname; |
| 6330 » » | 6330 |
| 6331 fullname = xmlBuildQName(root->name, root->ns->prefix, fn, 50); | 6331 fullname = xmlBuildQName(root->name, root->ns->prefix, fn, 50); |
| 6332 if (fullname == NULL) { | 6332 if (fullname == NULL) { |
| 6333 xmlVErrMemory(ctxt, NULL); | 6333 xmlVErrMemory(ctxt, NULL); |
| 6334 return(0); | 6334 return(0); |
| 6335 } | 6335 } |
| 6336 ret = xmlStrEqual(doc->intSubset->name, fullname); | 6336 ret = xmlStrEqual(doc->intSubset->name, fullname); |
| 6337 if ((fullname != fn) && (fullname != root->name)) | 6337 if ((fullname != fn) && (fullname != root->name)) |
| 6338 xmlFree(fullname); | 6338 xmlFree(fullname); |
| 6339 if (ret == 1) | 6339 if (ret == 1) |
| 6340 goto name_ok; | 6340 goto name_ok; |
| 6341 » } | 6341 » } |
| 6342 if ((xmlStrEqual(doc->intSubset->name, BAD_CAST "HTML")) && | 6342 if ((xmlStrEqual(doc->intSubset->name, BAD_CAST "HTML")) && |
| 6343 (xmlStrEqual(root->name, BAD_CAST "html"))) | 6343 (xmlStrEqual(root->name, BAD_CAST "html"))) |
| 6344 goto name_ok; | 6344 goto name_ok; |
| 6345 xmlErrValidNode(ctxt, root, XML_DTD_ROOT_NAME, | 6345 xmlErrValidNode(ctxt, root, XML_DTD_ROOT_NAME, |
| 6346 "root and DTD name do not match '%s' and '%s'\n", | 6346 "root and DTD name do not match '%s' and '%s'\n", |
| 6347 root->name, doc->intSubset->name, NULL); | 6347 root->name, doc->intSubset->name, NULL); |
| 6348 return(0); | 6348 return(0); |
| 6349 } | 6349 } |
| 6350 } | 6350 } |
| 6351 name_ok: | 6351 name_ok: |
| 6352 return(1); | 6352 return(1); |
| 6353 } | 6353 } |
| 6354 | 6354 |
| 6355 | 6355 |
| 6356 /** | 6356 /** |
| 6357 * xmlValidateElement: | 6357 * xmlValidateElement: |
| 6358 * @ctxt: the validation context | 6358 * @ctxt: the validation context |
| 6359 * @doc: a document instance | 6359 * @doc: a document instance |
| 6360 * @elem: an element instance | 6360 * @elem: an element instance |
| 6361 * | 6361 * |
| 6362 * Try to validate the subtree under an element | 6362 * Try to validate the subtree under an element |
| 6363 * | 6363 * |
| 6364 * returns 1 if valid or 0 otherwise | 6364 * returns 1 if valid or 0 otherwise |
| 6365 */ | 6365 */ |
| 6366 | 6366 |
| 6367 int | 6367 int |
| 6368 xmlValidateElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem) { | 6368 xmlValidateElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlNodePtr elem) { |
| 6369 xmlNodePtr child; | 6369 xmlNodePtr child; |
| 6370 xmlAttrPtr attr; | 6370 xmlAttrPtr attr; |
| 6371 xmlNsPtr ns; | 6371 xmlNsPtr ns; |
| 6372 const xmlChar *value; | 6372 const xmlChar *value; |
| 6373 int ret = 1; | 6373 int ret = 1; |
| 6374 | 6374 |
| 6375 if (elem == NULL) return(0); | 6375 if (elem == NULL) return(0); |
| 6376 | 6376 |
| 6377 /* | 6377 /* |
| 6378 * XInclude elements were added after parsing in the infoset, | 6378 * XInclude elements were added after parsing in the infoset, |
| 6379 * they don't really mean anything validation wise. | 6379 * they don't really mean anything validation wise. |
| 6380 */ | 6380 */ |
| 6381 if ((elem->type == XML_XINCLUDE_START) || | 6381 if ((elem->type == XML_XINCLUDE_START) || |
| 6382 » (elem->type == XML_XINCLUDE_END)) | 6382 » (elem->type == XML_XINCLUDE_END) || |
| 6383 » (elem->type == XML_NAMESPACE_DECL)) |
| 6383 return(1); | 6384 return(1); |
| 6384 | 6385 |
| 6385 CHECK_DTD; | 6386 CHECK_DTD; |
| 6386 | 6387 |
| 6387 /* | 6388 /* |
| 6388 * Entities references have to be handled separately | 6389 * Entities references have to be handled separately |
| 6389 */ | 6390 */ |
| 6390 if (elem->type == XML_ENTITY_REF_NODE) { | 6391 if (elem->type == XML_ENTITY_REF_NODE) { |
| 6391 return(1); | 6392 return(1); |
| 6392 } | 6393 } |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6531 xmlValidateCheckRefCallback(xmlListPtr ref_list, xmlValidCtxtPtr ctxt, | 6532 xmlValidateCheckRefCallback(xmlListPtr ref_list, xmlValidCtxtPtr ctxt, |
| 6532 const xmlChar *name) { | 6533 const xmlChar *name) { |
| 6533 xmlValidateMemo memo; | 6534 xmlValidateMemo memo; |
| 6534 | 6535 |
| 6535 if (ref_list == NULL) | 6536 if (ref_list == NULL) |
| 6536 return; | 6537 return; |
| 6537 memo.ctxt = ctxt; | 6538 memo.ctxt = ctxt; |
| 6538 memo.name = name; | 6539 memo.name = name; |
| 6539 | 6540 |
| 6540 xmlListWalk(ref_list, xmlWalkValidateList, &memo); | 6541 xmlListWalk(ref_list, xmlWalkValidateList, &memo); |
| 6541 | 6542 |
| 6542 } | 6543 } |
| 6543 | 6544 |
| 6544 /** | 6545 /** |
| 6545 * xmlValidateDocumentFinal: | 6546 * xmlValidateDocumentFinal: |
| 6546 * @ctxt: the validation context | 6547 * @ctxt: the validation context |
| 6547 * @doc: a document instance | 6548 * @doc: a document instance |
| 6548 * | 6549 * |
| 6549 * Does the final step for the document validation once all the | 6550 * Does the final step for the document validation once all the |
| 6550 * incremental validation steps have been completed | 6551 * incremental validation steps have been completed |
| 6551 * | 6552 * |
| 6552 * basically it does the following checks described by the XML Rec | 6553 * basically it does the following checks described by the XML Rec |
| 6553 * | 6554 * |
| 6554 * Check all the IDREF/IDREFS attributes definition for validity | 6555 * Check all the IDREF/IDREFS attributes definition for validity |
| 6555 * | 6556 * |
| 6556 * returns 1 if valid or 0 otherwise | 6557 * returns 1 if valid or 0 otherwise |
| 6557 */ | 6558 */ |
| 6558 | 6559 |
| 6559 int | 6560 int |
| 6560 xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt, xmlDocPtr doc) { | 6561 xmlValidateDocumentFinal(xmlValidCtxtPtr ctxt, xmlDocPtr doc) { |
| 6561 xmlRefTablePtr table; | 6562 xmlRefTablePtr table; |
| 6563 unsigned int save; |
| 6562 | 6564 |
| 6563 if (ctxt == NULL) | 6565 if (ctxt == NULL) |
| 6564 return(0); | 6566 return(0); |
| 6565 if (doc == NULL) { | 6567 if (doc == NULL) { |
| 6566 xmlErrValid(ctxt, XML_DTD_NO_DOC, | 6568 xmlErrValid(ctxt, XML_DTD_NO_DOC, |
| 6567 "xmlValidateDocumentFinal: doc == NULL\n", NULL); | 6569 "xmlValidateDocumentFinal: doc == NULL\n", NULL); |
| 6568 return(0); | 6570 return(0); |
| 6569 } | 6571 } |
| 6570 | 6572 |
| 6573 /* trick to get correct line id report */ |
| 6574 save = ctxt->finishDtd; |
| 6575 ctxt->finishDtd = 0; |
| 6576 |
| 6571 /* | 6577 /* |
| 6572 * Check all the NOTATION/NOTATIONS attributes | 6578 * Check all the NOTATION/NOTATIONS attributes |
| 6573 */ | 6579 */ |
| 6574 /* | 6580 /* |
| 6575 * Check all the ENTITY/ENTITIES attributes definition for validity | 6581 * Check all the ENTITY/ENTITIES attributes definition for validity |
| 6576 */ | 6582 */ |
| 6577 /* | 6583 /* |
| 6578 * Check all the IDREF/IDREFS attributes definition for validity | 6584 * Check all the IDREF/IDREFS attributes definition for validity |
| 6579 */ | 6585 */ |
| 6580 table = (xmlRefTablePtr) doc->refs; | 6586 table = (xmlRefTablePtr) doc->refs; |
| 6581 ctxt->doc = doc; | 6587 ctxt->doc = doc; |
| 6582 ctxt->valid = 1; | 6588 ctxt->valid = 1; |
| 6583 xmlHashScan(table, (xmlHashScanner) xmlValidateCheckRefCallback, ctxt); | 6589 xmlHashScan(table, (xmlHashScanner) xmlValidateCheckRefCallback, ctxt); |
| 6590 |
| 6591 ctxt->finishDtd = save; |
| 6584 return(ctxt->valid); | 6592 return(ctxt->valid); |
| 6585 } | 6593 } |
| 6586 | 6594 |
| 6587 /** | 6595 /** |
| 6588 * xmlValidateDtd: | 6596 * xmlValidateDtd: |
| 6589 * @ctxt: the validation context | 6597 * @ctxt: the validation context |
| 6590 * @doc: a document instance | 6598 * @doc: a document instance |
| 6591 * @dtd: a dtd instance | 6599 * @dtd: a dtd instance |
| 6592 * | 6600 * |
| 6593 * Try to validate the document against the dtd instance | 6601 * Try to validate the document against the dtd instance |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6668 case XML_ATTRIBUTE_IDREF : | 6676 case XML_ATTRIBUTE_IDREF : |
| 6669 case XML_ATTRIBUTE_IDREFS: | 6677 case XML_ATTRIBUTE_IDREFS: |
| 6670 case XML_ATTRIBUTE_NMTOKEN: | 6678 case XML_ATTRIBUTE_NMTOKEN: |
| 6671 case XML_ATTRIBUTE_NMTOKENS: | 6679 case XML_ATTRIBUTE_NMTOKENS: |
| 6672 case XML_ATTRIBUTE_ENUMERATION: | 6680 case XML_ATTRIBUTE_ENUMERATION: |
| 6673 break; | 6681 break; |
| 6674 case XML_ATTRIBUTE_ENTITY: | 6682 case XML_ATTRIBUTE_ENTITY: |
| 6675 case XML_ATTRIBUTE_ENTITIES: | 6683 case XML_ATTRIBUTE_ENTITIES: |
| 6676 case XML_ATTRIBUTE_NOTATION: | 6684 case XML_ATTRIBUTE_NOTATION: |
| 6677 if (cur->defaultValue != NULL) { | 6685 if (cur->defaultValue != NULL) { |
| 6678 » » | 6686 |
| 6679 ret = xmlValidateAttributeValue2(ctxt, ctxt->doc, cur->name, | 6687 ret = xmlValidateAttributeValue2(ctxt, ctxt->doc, cur->name, |
| 6680 cur->atype, cur->defaultValue); | 6688 cur->atype, cur->defaultValue); |
| 6681 if ((ret == 0) && (ctxt->valid == 1)) | 6689 if ((ret == 0) && (ctxt->valid == 1)) |
| 6682 ctxt->valid = 0; | 6690 ctxt->valid = 0; |
| 6683 } | 6691 } |
| 6684 if (cur->tree != NULL) { | 6692 if (cur->tree != NULL) { |
| 6685 xmlEnumerationPtr tree = cur->tree; | 6693 xmlEnumerationPtr tree = cur->tree; |
| 6686 while (tree != NULL) { | 6694 while (tree != NULL) { |
| 6687 ret = xmlValidateAttributeValue2(ctxt, ctxt->doc, | 6695 ret = xmlValidateAttributeValue2(ctxt, ctxt->doc, |
| 6688 cur->name, cur->atype, tree->name); | 6696 cur->name, cur->atype, tree->name); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6725 | 6733 |
| 6726 /** | 6734 /** |
| 6727 * xmlValidateDtdFinal: | 6735 * xmlValidateDtdFinal: |
| 6728 * @ctxt: the validation context | 6736 * @ctxt: the validation context |
| 6729 * @doc: a document instance | 6737 * @doc: a document instance |
| 6730 * | 6738 * |
| 6731 * Does the final step for the dtds validation once all the | 6739 * Does the final step for the dtds validation once all the |
| 6732 * subsets have been parsed | 6740 * subsets have been parsed |
| 6733 * | 6741 * |
| 6734 * basically it does the following checks described by the XML Rec | 6742 * basically it does the following checks described by the XML Rec |
| 6735 * - check that ENTITY and ENTITIES type attributes default or | 6743 * - check that ENTITY and ENTITIES type attributes default or |
| 6736 * possible values matches one of the defined entities. | 6744 * possible values matches one of the defined entities. |
| 6737 * - check that NOTATION type attributes default or | 6745 * - check that NOTATION type attributes default or |
| 6738 * possible values matches one of the defined notations. | 6746 * possible values matches one of the defined notations. |
| 6739 * | 6747 * |
| 6740 * returns 1 if valid or 0 if invalid and -1 if not well-formed | 6748 * returns 1 if valid or 0 if invalid and -1 if not well-formed |
| 6741 */ | 6749 */ |
| 6742 | 6750 |
| 6743 int | 6751 int |
| 6744 xmlValidateDtdFinal(xmlValidCtxtPtr ctxt, xmlDocPtr doc) { | 6752 xmlValidateDtdFinal(xmlValidCtxtPtr ctxt, xmlDocPtr doc) { |
| 6745 xmlDtdPtr dtd; | 6753 xmlDtdPtr dtd; |
| 6746 xmlAttributeTablePtr table; | 6754 xmlAttributeTablePtr table; |
| 6747 xmlEntitiesTablePtr entities; | 6755 xmlEntitiesTablePtr entities; |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6798 if ((doc->intSubset == NULL) && (doc->extSubset == NULL)) { | 6806 if ((doc->intSubset == NULL) && (doc->extSubset == NULL)) { |
| 6799 xmlErrValid(ctxt, XML_DTD_NO_DTD, | 6807 xmlErrValid(ctxt, XML_DTD_NO_DTD, |
| 6800 "no DTD found!\n", NULL); | 6808 "no DTD found!\n", NULL); |
| 6801 return(0); | 6809 return(0); |
| 6802 } | 6810 } |
| 6803 if ((doc->intSubset != NULL) && ((doc->intSubset->SystemID != NULL) || | 6811 if ((doc->intSubset != NULL) && ((doc->intSubset->SystemID != NULL) || |
| 6804 (doc->intSubset->ExternalID != NULL)) && (doc->extSubset == NULL)) { | 6812 (doc->intSubset->ExternalID != NULL)) && (doc->extSubset == NULL)) { |
| 6805 xmlChar *sysID; | 6813 xmlChar *sysID; |
| 6806 if (doc->intSubset->SystemID != NULL) { | 6814 if (doc->intSubset->SystemID != NULL) { |
| 6807 sysID = xmlBuildURI(doc->intSubset->SystemID, | 6815 sysID = xmlBuildURI(doc->intSubset->SystemID, |
| 6808 » » » doc->URL); | 6816 » » » doc->URL); |
| 6809 if (sysID == NULL) { | 6817 if (sysID == NULL) { |
| 6810 xmlErrValid(ctxt, XML_DTD_LOAD_ERROR, | 6818 xmlErrValid(ctxt, XML_DTD_LOAD_ERROR, |
| 6811 "Could not build URI for external subset \"%s\"\n", | 6819 "Could not build URI for external subset \"%s\"\n", |
| 6812 (const char *) doc->intSubset->SystemID); | 6820 (const char *) doc->intSubset->SystemID); |
| 6813 return 0; | 6821 return 0; |
| 6814 } | 6822 } |
| 6815 } else | 6823 } else |
| 6816 sysID = NULL; | 6824 sysID = NULL; |
| 6817 doc->extSubset = xmlParseDTD(doc->intSubset->ExternalID, | 6825 doc->extSubset = xmlParseDTD(doc->intSubset->ExternalID, |
| 6818 (const xmlChar *)sysID); | 6826 (const xmlChar *)sysID); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6871 xmlValidGetPotentialChildren(xmlElementContent *ctree, | 6879 xmlValidGetPotentialChildren(xmlElementContent *ctree, |
| 6872 const xmlChar **names, | 6880 const xmlChar **names, |
| 6873 int *len, int max) { | 6881 int *len, int max) { |
| 6874 int i; | 6882 int i; |
| 6875 | 6883 |
| 6876 if ((ctree == NULL) || (names == NULL) || (len == NULL)) | 6884 if ((ctree == NULL) || (names == NULL) || (len == NULL)) |
| 6877 return(-1); | 6885 return(-1); |
| 6878 if (*len >= max) return(*len); | 6886 if (*len >= max) return(*len); |
| 6879 | 6887 |
| 6880 switch (ctree->type) { | 6888 switch (ctree->type) { |
| 6881 » case XML_ELEMENT_CONTENT_PCDATA: | 6889 » case XML_ELEMENT_CONTENT_PCDATA: |
| 6882 for (i = 0; i < *len;i++) | 6890 for (i = 0; i < *len;i++) |
| 6883 if (xmlStrEqual(BAD_CAST "#PCDATA", names[i])) return(*len); | 6891 if (xmlStrEqual(BAD_CAST "#PCDATA", names[i])) return(*len); |
| 6884 names[(*len)++] = BAD_CAST "#PCDATA"; | 6892 names[(*len)++] = BAD_CAST "#PCDATA"; |
| 6885 break; | 6893 break; |
| 6886 » case XML_ELEMENT_CONTENT_ELEMENT: | 6894 » case XML_ELEMENT_CONTENT_ELEMENT: |
| 6887 for (i = 0; i < *len;i++) | 6895 for (i = 0; i < *len;i++) |
| 6888 if (xmlStrEqual(ctree->name, names[i])) return(*len); | 6896 if (xmlStrEqual(ctree->name, names[i])) return(*len); |
| 6889 names[(*len)++] = ctree->name; | 6897 names[(*len)++] = ctree->name; |
| 6890 break; | 6898 break; |
| 6891 » case XML_ELEMENT_CONTENT_SEQ: | 6899 » case XML_ELEMENT_CONTENT_SEQ: |
| 6892 xmlValidGetPotentialChildren(ctree->c1, names, len, max); | 6900 xmlValidGetPotentialChildren(ctree->c1, names, len, max); |
| 6893 xmlValidGetPotentialChildren(ctree->c2, names, len, max); | 6901 xmlValidGetPotentialChildren(ctree->c2, names, len, max); |
| 6894 break; | 6902 break; |
| 6895 case XML_ELEMENT_CONTENT_OR: | 6903 case XML_ELEMENT_CONTENT_OR: |
| 6896 xmlValidGetPotentialChildren(ctree->c1, names, len, max); | 6904 xmlValidGetPotentialChildren(ctree->c1, names, len, max); |
| 6897 xmlValidGetPotentialChildren(ctree->c2, names, len, max); | 6905 xmlValidGetPotentialChildren(ctree->c2, names, len, max); |
| 6898 break; | 6906 break; |
| 6899 } | 6907 } |
| 6900 | 6908 |
| 6901 return(*len); | 6909 return(*len); |
| 6902 } | 6910 } |
| 6903 | 6911 |
| 6904 /* | 6912 /* |
| 6905 * Dummy function to suppress messages while we try out valid elements | 6913 * Dummy function to suppress messages while we try out valid elements |
| 6906 */ | 6914 */ |
| 6907 static void XMLCDECL xmlNoValidityErr(void *ctx ATTRIBUTE_UNUSED, | 6915 static void XMLCDECL xmlNoValidityErr(void *ctx ATTRIBUTE_UNUSED, |
| 6908 const char *msg ATTRIBUTE_UNUSED, ...) { | 6916 const char *msg ATTRIBUTE_UNUSED, ...) { |
| 6909 return; | 6917 return; |
| 6910 } | 6918 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 6932 * returns the number of element in the list, or -1 in case of error. If | 6940 * returns the number of element in the list, or -1 in case of error. If |
| 6933 * the function returns the value @max the caller is invited to grow the | 6941 * the function returns the value @max the caller is invited to grow the |
| 6934 * receiving array and retry. | 6942 * receiving array and retry. |
| 6935 */ | 6943 */ |
| 6936 | 6944 |
| 6937 int | 6945 int |
| 6938 xmlValidGetValidElements(xmlNode *prev, xmlNode *next, const xmlChar **names, | 6946 xmlValidGetValidElements(xmlNode *prev, xmlNode *next, const xmlChar **names, |
| 6939 int max) { | 6947 int max) { |
| 6940 xmlValidCtxt vctxt; | 6948 xmlValidCtxt vctxt; |
| 6941 int nb_valid_elements = 0; | 6949 int nb_valid_elements = 0; |
| 6942 const xmlChar *elements[256]; | 6950 const xmlChar *elements[256]={0}; |
| 6943 int nb_elements = 0, i; | 6951 int nb_elements = 0, i; |
| 6944 const xmlChar *name; | 6952 const xmlChar *name; |
| 6945 | 6953 |
| 6946 xmlNode *ref_node; | 6954 xmlNode *ref_node; |
| 6947 xmlNode *parent; | 6955 xmlNode *parent; |
| 6948 xmlNode *test_node; | 6956 xmlNode *test_node; |
| 6949 | 6957 |
| 6950 xmlNode *prev_next; | 6958 xmlNode *prev_next; |
| 6951 xmlNode *next_prev; | 6959 xmlNode *next_prev; |
| 6952 xmlNode *parent_childs; | 6960 xmlNode *parent_childs; |
| 6953 xmlNode *parent_last; | 6961 xmlNode *parent_last; |
| 6954 | 6962 |
| 6955 xmlElement *element_desc; | 6963 xmlElement *element_desc; |
| 6956 | 6964 |
| 6957 if (prev == NULL && next == NULL) | 6965 if (prev == NULL && next == NULL) |
| 6958 return(-1); | 6966 return(-1); |
| 6959 | 6967 |
| 6960 if (names == NULL) return(-1); | 6968 if (names == NULL) return(-1); |
| 6961 if (max <= 0) return(-1); | 6969 if (max <= 0) return(-1); |
| 6962 | 6970 |
| 6963 memset(&vctxt, 0, sizeof (xmlValidCtxt)); | 6971 memset(&vctxt, 0, sizeof (xmlValidCtxt)); |
| 6964 vctxt.error = xmlNoValidityErr; /* this suppresses err/warn output */ | 6972 vctxt.error = xmlNoValidityErr; /* this suppresses err/warn output */ |
| 6965 | 6973 |
| 6966 nb_valid_elements = 0; | 6974 nb_valid_elements = 0; |
| 6967 ref_node = prev ? prev : next; | 6975 ref_node = prev ? prev : next; |
| 6968 parent = ref_node->parent; | 6976 parent = ref_node->parent; |
| 6969 | 6977 |
| 6970 /* | 6978 /* |
| 6971 * Retrieves the parent element declaration | 6979 * Retrieves the parent element declaration |
| 6972 */ | 6980 */ |
| 6973 element_desc = xmlGetDtdElementDesc(parent->doc->intSubset, | 6981 element_desc = xmlGetDtdElementDesc(parent->doc->intSubset, |
| 6974 parent->name); | 6982 parent->name); |
| 6975 if ((element_desc == NULL) && (parent->doc->extSubset != NULL)) | 6983 if ((element_desc == NULL) && (parent->doc->extSubset != NULL)) |
| 6976 element_desc = xmlGetDtdElementDesc(parent->doc->extSubset, | 6984 element_desc = xmlGetDtdElementDesc(parent->doc->extSubset, |
| 6977 parent->name); | 6985 parent->name); |
| 6978 if (element_desc == NULL) return(-1); | 6986 if (element_desc == NULL) return(-1); |
| 6979 » | 6987 |
| 6980 /* | 6988 /* |
| 6981 * Do a backup of the current tree structure | 6989 * Do a backup of the current tree structure |
| 6982 */ | 6990 */ |
| 6983 prev_next = prev ? prev->next : NULL; | 6991 prev_next = prev ? prev->next : NULL; |
| 6984 next_prev = next ? next->prev : NULL; | 6992 next_prev = next ? next->prev : NULL; |
| 6985 parent_childs = parent->children; | 6993 parent_childs = parent->children; |
| 6986 parent_last = parent->last; | 6994 parent_last = parent->last; |
| 6987 | 6995 |
| 6988 /* | 6996 /* |
| 6989 * Creates a dummy node and insert it into the tree | 6997 * Creates a dummy node and insert it into the tree |
| 6990 */ | 6998 */ |
| 6991 test_node = xmlNewDocNode (ref_node->doc, NULL, BAD_CAST "<!dummy?>", NULL); | 6999 test_node = xmlNewDocNode (ref_node->doc, NULL, BAD_CAST "<!dummy?>", NULL); |
| 7000 if (test_node == NULL) |
| 7001 return(-1); |
| 7002 |
| 6992 test_node->parent = parent; | 7003 test_node->parent = parent; |
| 6993 test_node->prev = prev; | 7004 test_node->prev = prev; |
| 6994 test_node->next = next; | 7005 test_node->next = next; |
| 6995 name = test_node->name; | 7006 name = test_node->name; |
| 6996 | 7007 |
| 6997 if (prev) prev->next = test_node; | 7008 if (prev) prev->next = test_node; |
| 6998 else parent->children = test_node; | 7009 else parent->children = test_node; |
| 6999 » » | 7010 |
| 7000 if (next) next->prev = test_node; | 7011 if (next) next->prev = test_node; |
| 7001 else parent->last = test_node; | 7012 else parent->last = test_node; |
| 7002 | 7013 |
| 7003 /* | 7014 /* |
| 7004 * Insert each potential child node and check if the parent is | 7015 * Insert each potential child node and check if the parent is |
| 7005 * still valid | 7016 * still valid |
| 7006 */ | 7017 */ |
| 7007 nb_elements = xmlValidGetPotentialChildren(element_desc->content, | 7018 nb_elements = xmlValidGetPotentialChildren(element_desc->content, |
| 7008 elements, &nb_elements, 256); | 7019 elements, &nb_elements, 256); |
| 7009 | 7020 |
| 7010 for (i = 0;i < nb_elements;i++) { | 7021 for (i = 0;i < nb_elements;i++) { |
| 7011 test_node->name = elements[i]; | 7022 test_node->name = elements[i]; |
| 7012 if (xmlValidateOneElement(&vctxt, parent->doc, parent)) { | 7023 if (xmlValidateOneElement(&vctxt, parent->doc, parent)) { |
| 7013 int j; | 7024 int j; |
| 7014 | 7025 |
| 7015 for (j = 0; j < nb_valid_elements;j++) | 7026 for (j = 0; j < nb_valid_elements;j++) |
| 7016 if (xmlStrEqual(elements[i], names[j])) break; | 7027 if (xmlStrEqual(elements[i], names[j])) break; |
| 7017 names[nb_valid_elements++] = elements[i]; | 7028 names[nb_valid_elements++] = elements[i]; |
| 7018 if (nb_valid_elements >= max) break; | 7029 if (nb_valid_elements >= max) break; |
| 7019 } | 7030 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 7032 */ | 7043 */ |
| 7033 test_node->name = name; | 7044 test_node->name = name; |
| 7034 xmlFreeNode(test_node); | 7045 xmlFreeNode(test_node); |
| 7035 | 7046 |
| 7036 return(nb_valid_elements); | 7047 return(nb_valid_elements); |
| 7037 } | 7048 } |
| 7038 #endif /* LIBXML_VALID_ENABLED */ | 7049 #endif /* LIBXML_VALID_ENABLED */ |
| 7039 | 7050 |
| 7040 #define bottom_valid | 7051 #define bottom_valid |
| 7041 #include "elfgcchack.h" | 7052 #include "elfgcchack.h" |
| OLD | NEW |