1 commit 77b77b1301e052d90e6a0967534a698506afcd86
2 Author: Daniel Veillard <veillard@redhat.com>
3 Date: Thu Jan 26 19:11:02 2012 +0800
5 Fix SAX2 builder in case of undefined element namespaces
7 Work as in XML-1.0 before namespaces, and use prefix:localname
8 as the new element name (and no namespace of course)
9 Also fix 3 cases in the regression tests where the prefix: was
10 erroneously dropped in such case
13 ===================================================================
16 @@ -2162,7 +2162,6 @@ xmlSAX2StartElementNs(void *ctx,
18 xmlNsPtr last = NULL, ns;
19 const xmlChar *uri, *pref;
20 - xmlChar *lname = NULL;
23 if (ctx == NULL) return;
24 @@ -2182,20 +2181,6 @@ xmlSAX2StartElementNs(void *ctx,
28 - * Take care of the rare case of an undefined namespace prefix
30 - if ((prefix != NULL) && (URI == NULL)) {
31 - if (ctxt->dictNames) {
32 - const xmlChar *fullname;
34 - fullname = xmlDictQLookup(ctxt->dict, prefix, localname);
35 - if (fullname != NULL)
36 - localname = fullname;
38 - lname = xmlBuildQName(localname, prefix, NULL, 0);
44 if (ctxt->freeElems != NULL) {
45 @@ -2208,10 +2193,7 @@ xmlSAX2StartElementNs(void *ctx,
47 ret->name = localname;
50 - ret->name = xmlStrdup(localname);
53 + ret->name = xmlStrdup(localname);
54 if (ret->name == NULL) {
55 xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
57 @@ -2223,11 +2205,8 @@ xmlSAX2StartElementNs(void *ctx,
59 ret = xmlNewDocNodeEatName(ctxt->myDoc, NULL,
60 (xmlChar *) localname, NULL);
61 - else if (lname == NULL)
62 - ret = xmlNewDocNode(ctxt->myDoc, NULL, localname, NULL);
64 - ret = xmlNewDocNodeEatName(ctxt->myDoc, NULL,
65 - (xmlChar *) lname, NULL);
66 + ret = xmlNewDocNode(ctxt->myDoc, NULL, localname, NULL);
68 xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
70 @@ -2334,33 +2313,8 @@ xmlSAX2StartElementNs(void *ctx,
72 if (nb_attributes > 0) {
73 for (j = 0,i = 0;i < nb_attributes;i++,j+=5) {
75 - * Handle the rare case of an undefined atribute prefix
77 - if ((attributes[j+1] != NULL) && (attributes[j+2] == NULL)) {
78 - if (ctxt->dictNames) {
79 - const xmlChar *fullname;
81 - fullname = xmlDictQLookup(ctxt->dict, attributes[j+1],
83 - if (fullname != NULL) {
84 - xmlSAX2AttributeNs(ctxt, fullname, NULL,
85 - attributes[j+3], attributes[j+4]);
89 - lname = xmlBuildQName(attributes[j], attributes[j+1],
91 - if (lname != NULL) {
92 - xmlSAX2AttributeNs(ctxt, lname, NULL,
93 - attributes[j+3], attributes[j+4]);
99 xmlSAX2AttributeNs(ctxt, attributes[j], attributes[j+1],
100 - attributes[j+3], attributes[j+4]);
101 + attributes[j+3], attributes[j+4]);
105 Index: result/namespaces/err_7.xml
106 ===================================================================
107 --- result/namespaces/err_7.xml.orig
108 +++ result/namespaces/err_7.xml
110 <?xml version="1.0"?>
113 Index: result/xmlid/id_tst2.xml
114 ===================================================================
115 --- result/xmlid/id_tst2.xml.orig
116 +++ result/xmlid/id_tst2.xml
118 Object is a Node Set :
119 Set contains 1 nodes:
125 Index: result/xmlid/id_tst3.xml
126 ===================================================================
127 --- result/xmlid/id_tst3.xml.orig
128 +++ result/xmlid/id_tst3.xml
130 Object is a Node Set :
131 Set contains 1 nodes: