summaryrefslogtreecommitdiff
path: root/src/core/element.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2007-09-26 23:55:36 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2007-09-26 23:55:36 +0000
commit6a274638b1458f1c98a228255c7058f32d400199 (patch)
tree4fbbf2458c260e4e097f23484d12f10fcadf6a0b /src/core/element.c
parent1dd1a95d56b2c927f7889cda030a4696e31ba232 (diff)
downloadlibdom-6a274638b1458f1c98a228255c7058f32d400199.tar.gz
libdom-6a274638b1458f1c98a228255c7058f32d400199.tar.bz2
Begin to cater for XML namespaces.
The localname member of Node has been removed. The name member already caters for this. Fix NodeList to cope with this and add some pointer vs NULL comparisons for sanity. Replace implementation of dom_element_get_tag_name() with a simple call to dom_node_get_node_name(), which is where the gory details lie. Add the QName building stuff to dom_node_get_node_name() (as per previous implementation of dom_element_get_tag_name()). Implement dom_node_set_prefix(). Ensure dom_node_get_local_name() returns NULL for nodes created by non-namespace-aware methods (nodes must also be Elements or Attributes) svn path=/trunk/dom/; revision=3596
Diffstat (limited to 'src/core/element.c')
-rw-r--r--src/core/element.c38
1 files changed, 3 insertions, 35 deletions
diff --git a/src/core/element.c b/src/core/element.c
index 1b351ce..027d597 100644
--- a/src/core/element.c
+++ b/src/core/element.c
@@ -9,6 +9,7 @@
#include <dom/core/attr.h>
#include <dom/core/element.h>
+#include <dom/core/node.h>
#include <dom/core/string.h>
#include "core/attr.h"
@@ -156,41 +157,8 @@ void dom_element_destroy(struct dom_document *doc,
dom_exception dom_element_get_tag_name(struct dom_element *element,
struct dom_string **name)
{
- struct dom_node *e = (struct dom_node *) element;
- struct dom_string *tag_name;
-
- if (e->localname != NULL) {
- /* Has a localname, so build a qname string */
- size_t local_len = 0, prefix_len = 0;
- const uint8_t *local = NULL, *prefix = NULL;
- dom_exception err;
-
- if (e->prefix != NULL)
- dom_string_get_data(e->prefix, &prefix, &prefix_len);
-
- dom_string_get_data(e->localname, &local, &local_len);
-
- uint8_t qname[prefix_len + 1 /* : */ + local_len + 1 /* \0 */];
-
- sprintf((char *) qname, "%s:%s",
- prefix ? (const char *) prefix : "",
- (const char *) local);
-
- err = dom_string_create_from_ptr(e->owner, qname,
- prefix_len + 1 + local_len, &tag_name);
- if (err != DOM_NO_ERR)
- return err;
-
- /* tag_name is referenced for us */
- } else {
- tag_name = e->name;
-
- dom_string_ref(tag_name);
- }
-
- *name = tag_name;
-
- return DOM_NO_ERR;
+ /* This is the same as nodeName */
+ return dom_node_get_node_name((struct dom_node *) element, name);
}
/**