[gdome] DOM compliance: Null strings to DOM *NS functions
- From: Andrew Miller <ak miller auckland ac nz>
- To: gdome gnome org
- Subject: [gdome] DOM compliance: Null strings to DOM *NS functions
- Date: Fri, 24 Feb 2006 15:43:00 +1300
>From the DOM Level 2 specification...
"Applications must use the value null as the namespaceURI parameter for methods
if they wish to have no namespace."
However, this results in a failure if you try it in Gdome.
A patch to fix this is attached.
Best regards,
Andrew Miller
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
diff -udr gdome2-0.8.1/libgdome/gdomecore/gdome-xml-element.c gdome2-0.8.1-myfixes/libgdome/gdomecore/gdome-xml-element.c
--- gdome2-0.8.1/libgdome/gdomecore/gdome-xml-element.c 2003-10-04 03:53:33.000000000 +1200
+++ gdome2-0.8.1-myfixes/libgdome/gdomecore/gdome-xml-element.c 2006-02-24 15:31:38.986424223 +1300
@@ -502,7 +502,6 @@
g_return_val_if_fail (priv != NULL, NULL);
g_return_val_if_fail (GDOME_XML_IS_EL (priv), NULL);
- g_return_val_if_fail (namespaceURI != NULL, NULL);
g_return_val_if_fail (localName != NULL, NULL);
g_return_val_if_fail (exc != NULL, NULL);
@@ -529,15 +528,16 @@
g_return_val_if_fail (priv != NULL, NULL);
g_return_val_if_fail (GDOME_XML_IS_EL (priv), NULL);
- g_return_val_if_fail (namespaceURI != NULL, NULL);
g_return_val_if_fail (localName != NULL, NULL);
g_return_val_if_fail (exc != NULL, NULL);
- value = xmlGetNsProp (priv->n, localName->str, namespaceURI->str);
+ value = xmlGetNsProp (priv->n, localName->str,
+ namespaceURI ? namespaceURI->str : NULL);
if (value != NULL)
return gdome_xml_str_mkref_own (value);
- else if (xmlStrEqual(namespaceURI->str, GDOME_XMLNS_NAMESPACE)) {
+ else if (namespaceURI &&
+ xmlStrEqual(namespaceURI->str, GDOME_XMLNS_NAMESPACE)) {
ns = gdome_xmlGetNsDecl(priv->n, localName->str);
if (ns != NULL)
return gdome_xml_str_mkref_dup ((gchar *)ns->href);
@@ -578,7 +578,6 @@
g_return_if_fail (priv != NULL);
g_return_if_fail (GDOME_XML_IS_EL (priv));
- g_return_if_fail (namespaceURI != NULL);
g_return_if_fail (qualifiedName != NULL);
g_return_if_fail (value != NULL);
g_return_if_fail (exc != NULL);
@@ -596,15 +595,15 @@
} else {
prefix = g_strdup(strs[0]);
localName = g_strdup(strs[1]);
- if ((!strcmp (prefix, "xml") && strcmp(namespaceURI->str, "http://www.w3.org/XML/1998/namespace"))) {
+ if ((!strcmp (prefix, "xml") &&
+ (!namespaceURI ||
+ strcmp(namespaceURI->str, "http://www.w3.org/XML/1998/namespace")))) {
*exc = GDOME_NAMESPACE_ERR;
}
}
} else if (!strs[1] && namespaceURI != NULL) { /* there's no ':' */
prefix = g_strdup("");
localName = g_strdup(strs[0]);
- if (strcmp (localName, "xmlns"))
- *exc = GDOME_NAMESPACE_ERR;
} else if (strs[0] && strs[1] && strs[2]) { /* there are more than one ':' */
*exc = GDOME_NAMESPACE_ERR;
}
@@ -623,13 +622,20 @@
(xmlChar *)value->str);
} else {
xmlDoc * doc = gdome_xmlGetOwner(priv->n);
- ns = xmlSearchNsByHref (doc, priv->n, (xmlChar *)namespaceURI->str);
- if(ns == NULL || !xmlStrEqual((xmlChar *)prefix, ns->prefix)) {
- ns = gdome_xmlNewNs (doc, namespaceURI->str, prefix);
+ if (namespaceURI != NULL)
+ {
+ ns = xmlSearchNsByHref (doc, priv->n, (xmlChar *)namespaceURI->str);
+ if(ns == NULL || !xmlStrEqual((xmlChar *)prefix, ns->prefix)) {
+ ns = gdome_xmlNewNs (doc, namespaceURI->str, prefix);
+ }
+ prevValue = gdome_xml_str_mkref_own (xmlGetNsProp (priv->n,
+ (xmlChar *)localName,
+ namespaceURI ? (xmlChar *)namespaceURI->str : NULL));
+ }
+ else
+ {
+ ns = NULL;
}
- prevValue = gdome_xml_str_mkref_own (xmlGetNsProp (priv->n,
- (xmlChar *)localName,
- (xmlChar *)namespaceURI->str));
attr = gdome_xml_n_mkref ((xmlNode *)xmlSetNsProp(priv->n, ns,
(xmlChar *)localName,
(xmlChar *)value->str));
@@ -708,7 +714,6 @@
g_return_if_fail (priv != NULL);
g_return_if_fail (GDOME_XML_IS_EL (priv));
- g_return_if_fail (namespaceURI != NULL);
g_return_if_fail (localName != NULL);
g_return_if_fail (exc != NULL);
@@ -746,7 +751,6 @@
g_return_val_if_fail (priv != NULL, NULL);
g_return_val_if_fail (GDOME_XML_IS_EL (priv), NULL);
- g_return_val_if_fail (namespaceURI != NULL, NULL);
g_return_val_if_fail (localName != NULL, NULL);
g_return_val_if_fail (exc != NULL, NULL);
@@ -863,16 +867,15 @@
g_return_val_if_fail (priv != NULL, 0);
g_return_val_if_fail (GDOME_XML_IS_EL (priv), 0);
- g_return_val_if_fail (namespaceURI != NULL, 0);
g_return_val_if_fail (localName != NULL, 0);
g_return_val_if_fail (exc != NULL, 0);
- val = xmlGetNsProp (priv->n, localName->str, namespaceURI->str);
+ val = xmlGetNsProp (priv->n, localName->str, namespaceURI ? namespaceURI->str : NULL);
if (val != NULL) {
xmlFree(val);
return 1;
- } else if (xmlStrEqual(namespaceURI->str, GDOME_XMLNS_NAMESPACE)) {
+ } else if (namespaceURI && xmlStrEqual(namespaceURI->str, GDOME_XMLNS_NAMESPACE)) {
ns = gdome_xmlGetNsDecl(priv->n, localName->str);
if (ns != NULL)
return 1;
diff -udr gdome2-0.8.1/libgdome/gdomecore/gdome-xml-xmlutil.c gdome2-0.8.1-myfixes/libgdome/gdomecore/gdome-xml-xmlutil.c
--- gdome2-0.8.1/libgdome/gdomecore/gdome-xml-xmlutil.c 2003-10-04 03:53:33.000000000 +1200
+++ gdome2-0.8.1-myfixes/libgdome/gdomecore/gdome-xml-xmlutil.c 2006-02-21 12:20:59.292818135 +1300
@@ -1090,8 +1090,8 @@
while (cur != NULL &&
((cur->prefix == NULL && prefix != NULL) ||
(cur->prefix != NULL && prefix == NULL) ||
- !xmlStrEqual (cur->prefix, prefix)) &&
- !xmlStrEqual (cur->href, href))
+ (!xmlStrEqual (cur->prefix, prefix) ||
+ !xmlStrEqual (cur->href, href))))
cur = cur->next;
if (cur == NULL) {
[
Date Prev][Date Next] [
Thread Prev][Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]