[4suite-checkins] In 4Suite/Ft/Xml/src/domlette, files domlette.c,
domlette_interface.h, nss.c
Jeremy Kloth
jkloth at 4suite.org
Tue Nov 7 14:42:53 MST 2006
Modified Files:
domlette.c domlette_interface.h nss.c
Log Message:
Fixed error with default namespaces in GetAllNs().
ViewCVS diff:
http://cvs.4suite.org/viewcvs/4Suite/Ft/Xml/src/domlette/domlette.c.diff?r1=1.56&r2=1.57
ViewCVS view:
http://cvs.4suite.org/viewcvs/4Suite/Ft/Xml/src/domlette/domlette.c?rev=1.57&content-type=text/vnd.viewcvs-markup
Index: domlette.c
===================================================================
RCS file: /var/local/cvsroot/4Suite/Ft/Xml/src/domlette/domlette.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -U2 -r1.56 -r1.57
--- domlette.c 25 Sep 2006 17:33:11 -0000 1.56
+++ domlette.c 7 Nov 2006 21:42:53 -0000 1.57
@@ -276,4 +276,5 @@
static Domlette_APIObject Domlette_API = {
&DomletteDOMImplementation_Type,
+ &DomletteNode_Type,
&DomletteDocument_Type,
&DomletteElement_Type,
@@ -283,4 +284,5 @@
&DomletteProcessingInstruction_Type,
&DomletteDocumentFragment_Type,
+ &DomletteXPathNamespace_Type,
};
ViewCVS diff:
http://cvs.4suite.org/viewcvs/4Suite/Ft/Xml/src/domlette/domlette_interface.h.diff?r1=1.1&r2=1.2
ViewCVS view:
http://cvs.4suite.org/viewcvs/4Suite/Ft/Xml/src/domlette/domlette_interface.h?rev=1.2&content-type=text/vnd.viewcvs-markup
Index: domlette_interface.h
===================================================================
RCS file: /var/local/cvsroot/4Suite/Ft/Xml/src/domlette/domlette_interface.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -U2 -r1.1 -r1.2
--- domlette_interface.h 19 Mar 2005 08:53:35 -0000 1.1
+++ domlette_interface.h 7 Nov 2006 21:42:53 -0000 1.2
@@ -23,4 +23,5 @@
/* Domlette Node C Types */
PyTypeObject *DOMImplementation_Type;
+ PyTypeObject *Node_Type;
PyTypeObject *Document_Type;
PyTypeObject *Element_Type;
@@ -30,4 +31,5 @@
PyTypeObject *ProcessingInstruction_Type;
PyTypeObject *DocumentFragment_Type;
+ PyTypeObject *XPathNamespace_Type;
} Domlette_APIObject;
ViewCVS diff:
http://cvs.4suite.org/viewcvs/4Suite/Ft/Xml/src/domlette/nss.c.diff?r1=1.8&r2=1.9
ViewCVS view:
http://cvs.4suite.org/viewcvs/4Suite/Ft/Xml/src/domlette/nss.c?rev=1.9&content-type=text/vnd.viewcvs-markup
Index: nss.c
===================================================================
RCS file: /var/local/cvsroot/4Suite/Ft/Xml/src/domlette/nss.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -U2 -r1.8 -r1.9
--- nss.c 13 Aug 2006 22:07:04 -0000 1.8
+++ nss.c 7 Nov 2006 21:42:53 -0000 1.9
@@ -33,6 +33,5 @@
/* add the declaration if prefix is not already defined */
- if (PyElement_NAMESPACE_URI(node) != Py_None &&
- PyDict_GetItem(nss, prefix) == NULL) {
+ if (PyDict_GetItem(nss, prefix) == NULL) {
if (PyDict_SetItem(nss, prefix, PyElement_NAMESPACE_URI(node)) < 0) {
Py_DECREF(prefix);
@@ -41,5 +40,5 @@
}
Py_DECREF(prefix);
-
+
/* now process this element's attributes */
i = 0;
@@ -54,5 +53,5 @@
if (prefix == NULL) return -1;
break;
- case 1:
+ case 1:
/* namespace attribute */
namespaceURI = PyAttr_NODE_VALUE(attr);
@@ -88,5 +87,5 @@
Py_DECREF(prefix);
}
- }
+ }
if (Node_GET_PARENT(node) != (PyNodeObject *) Py_None) {
@@ -118,5 +117,5 @@
}
Py_DECREF(prefix);
-
+
/* now process this element's attributes */
i = 0;
@@ -133,5 +132,5 @@
if (prefix == NULL) return NULL;
break;
- case 1:
+ case 1:
/* namespace attribute */
namespaceURI = PyAttr_NODE_VALUE(attr);
@@ -218,7 +217,7 @@
return -1;
}
-
+
/* add the declaration if prefix is not already defined */
- if (namespaceURI != Py_None && PyDict_GetItem(nss, prefix) == NULL) {
+ if (PyDict_GetItem(nss, prefix) == NULL) {
if (PyDict_SetItem(nss, prefix, namespaceURI) == -1) {
Py_DECREF(namespaceURI);
@@ -229,5 +228,5 @@
Py_DECREF(namespaceURI);
Py_DECREF(prefix);
-
+
/* now process this element's attributes */
obj = PyObject_GetAttrString(node, "attributes");
@@ -272,5 +271,5 @@
/* normal attribute */
break;
- case 1:
+ case 1:
/* namespace attribute */
Py_DECREF(namespaceURI);
@@ -320,13 +319,13 @@
}
}
-
+
Py_DECREF(namespaceURI);
Py_DECREF(prefix);
}
-
+
Py_DECREF(tuple);
}
-
- if (nodeType == ATTRIBUTE_NODE)
+
+ if (nodeType == ATTRIBUTE_NODE)
obj = PyObject_GetAttrString(node, "ownerElement");
else
@@ -386,5 +385,5 @@
Py_DECREF(namespaceURI);
Py_DECREF(prefix);
-
+
/* now process this element's attributes */
obj = PyObject_GetAttrString(node, "attributes");
@@ -424,10 +423,10 @@
/* get the prefix/namespaceURI pair to add */
- switch (PyObject_RichCompareBool(namespaceURI, g_xmlnsNamespace,
+ switch (PyObject_RichCompareBool(namespaceURI, g_xmlnsNamespace,
Py_EQ)) {
case 0:
/* normal attribute */
break;
- case 1:
+ case 1:
/* namespace attribute */
Py_DECREF(namespaceURI);
@@ -477,5 +476,5 @@
}
}
-
+
Py_DECREF(namespaceURI);
Py_DECREF(prefix);
@@ -503,5 +502,5 @@
}
Py_DECREF(tuple);
-
+
return nss;
}
@@ -529,5 +528,5 @@
}
Py_DECREF(prefix);
-
+
if (get_all_ns_domlette(node, nss) == -1) {
Py_DECREF(nss);
@@ -535,4 +534,12 @@
}
+ /* don't expose the implied default namespace */
+ if (PyDict_GetItem(nss, Py_None) == Py_None) {
+ if (PyDict_DelItem(nss, Py_None) == -1) {
+ Py_DECREF(nss);
+ return NULL;
+ }
+ }
+
return nss;
}
@@ -568,6 +575,6 @@
}
Py_DECREF(prefix);
-
- if (PyNode_Check(node))
+
+ if (PyNode_Check(node))
result = get_all_ns_domlette((PyNodeObject *) node, nss);
else
@@ -579,4 +586,12 @@
}
+ /* don't expose the implied default namespace */
+ if (PyDict_GetItem(nss, Py_None) == Py_None) {
+ if (PyDict_DelItem(nss, Py_None) == -1) {
+ Py_DECREF(nss);
+ return NULL;
+ }
+ }
+
return nss;
}
@@ -599,5 +614,5 @@
if (nss == NULL) return NULL;
- if (PyNode_Check(node))
+ if (PyNode_Check(node))
result = seek_nss_domlette((PyNodeObject *)node, nss);
else
More information about the 4suite-checkins
mailing list