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
12 diff --git a/SAX2.c b/SAX2.c
13 index c0482c0..0c48d65 100644
16 @@ -2163,6 +2163,7 @@ xmlSAX2StartElementNs(void *ctx,
18 xmlNsPtr last = NULL, ns;
19 const xmlChar *uri, *pref;
20 + xmlChar *lname = NULL;
23 if (ctx == NULL) return;
24 @@ -2182,6 +2183,20 @@ 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 @@ -2194,7 +2209,10 @@ xmlSAX2StartElementNs(void *ctx,
47 ret->name = localname;
49 - ret->name = xmlStrdup(localname);
51 + ret->name = xmlStrdup(localname);
54 if (ret->name == NULL) {
55 xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
57 @@ -2206,8 +2224,11 @@ xmlSAX2StartElementNs(void *ctx,
59 ret = xmlNewDocNodeEatName(ctxt->myDoc, NULL,
60 (xmlChar *) localname, NULL);
62 + else if (lname == NULL)
63 ret = xmlNewDocNode(ctxt->myDoc, NULL, localname, NULL);
65 + ret = xmlNewDocNodeEatName(ctxt->myDoc, NULL,
66 + (xmlChar *) lname, NULL);
68 xmlSAX2ErrMemory(ctxt, "xmlSAX2StartElementNs");
70 diff --git a/result/namespaces/err_7.xml b/result/namespaces/err_7.xml
71 index f4e5164..4b4c662 100644
72 --- a/result/namespaces/err_7.xml
73 +++ b/result/namespaces/err_7.xml
78 diff --git a/result/xmlid/id_tst2.xml b/result/xmlid/id_tst2.xml
79 index 33ee896..856a320 100644
80 --- a/result/xmlid/id_tst2.xml
81 +++ b/result/xmlid/id_tst2.xml
83 Object is a Node Set :
90 diff --git a/result/xmlid/id_tst3.xml b/result/xmlid/id_tst3.xml
91 index e2f8228..6d8865c 100644
92 --- a/result/xmlid/id_tst3.xml
93 +++ b/result/xmlid/id_tst3.xml
95 Object is a Node Set :
102 commit 1c989278d9650daafc79e55750bec5a5a224a553
103 Author: Daniel Veillard <veillard@redhat.com>
104 Date: Thu Jan 26 19:43:06 2012 +0800
106 Fix SAX2 builder in case of undefined attributes namespace
108 To follow the early XML-1.0 REC, the new localname is "prefix:localname"
109 and there is obviously now namespace.
111 diff --git a/SAX2.c b/SAX2.c
112 index 0c48d65..e230cea 100644
115 @@ -2335,8 +2335,33 @@ xmlSAX2StartElementNs(void *ctx,
117 if (nb_attributes > 0) {
118 for (j = 0,i = 0;i < nb_attributes;i++,j+=5) {
120 + * Handle the rare case of an undefined atribute prefix
122 + if ((attributes[j+1] != NULL) && (attributes[j+2] == NULL)) {
123 + if (ctxt->dictNames) {
124 + const xmlChar *fullname;
126 + fullname = xmlDictQLookup(ctxt->dict, attributes[j+1],
128 + if (fullname != NULL) {
129 + xmlSAX2AttributeNs(ctxt, fullname, NULL,
130 + attributes[j+3], attributes[j+4]);
134 + lname = xmlBuildQName(attributes[j], attributes[j+1],
136 + if (lname != NULL) {
137 + xmlSAX2AttributeNs(ctxt, lname, NULL,
138 + attributes[j+3], attributes[j+4]);
144 xmlSAX2AttributeNs(ctxt, attributes[j], attributes[j+1],
145 - attributes[j+3], attributes[j+4]);
146 + attributes[j+3], attributes[j+4]);