summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2007-07-11 02:23:16 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2007-07-11 02:23:16 +0000
commitac59d3ca209e444175d406bc07cf03d0452ebdc5 (patch)
tree54865872f758e87aa1b14047af41c7d2b877dcea /src
parent55a744d439f54289c6e470e46ec45a75c6d8478b (diff)
downloadlibdom-ac59d3ca209e444175d406bc07cf03d0452ebdc5.tar.gz
libdom-ac59d3ca209e444175d406bc07cf03d0452ebdc5.tar.bz2
Add Element.
Fix Attr's get_schema_type_info to have the right name. svn path=/trunk/dom/; revision=3400
Diffstat (limited to 'src')
-rw-r--r--src/core/Makefile3
-rw-r--r--src/core/attr.c2
-rw-r--r--src/core/element.c513
3 files changed, 516 insertions, 2 deletions
diff --git a/src/core/Makefile b/src/core/Makefile
index e30fd05..9d21bf7 100644
--- a/src/core/Makefile
+++ b/src/core/Makefile
@@ -22,7 +22,8 @@
CFLAGS += -I$(CURDIR)
# Objects
-OBJS = attr characterdata document namednodemap node nodelist string text
+OBJS = attr characterdata document element namednodemap node nodelist \
+ string text
.PHONY: clean debug distclean export release setup test
diff --git a/src/core/attr.c b/src/core/attr.c
index 52fc314..bcdc0ce 100644
--- a/src/core/attr.c
+++ b/src/core/attr.c
@@ -135,7 +135,7 @@ dom_exception dom_attr_get_owner(struct dom_attr *attr,
* The returned type info will have its reference count increased. The caller
* should unref it once it has finished with it.
*/
-dom_exception dom_attr_get_type_info(struct dom_attr *attr,
+dom_exception dom_attr_get_schema_type_info(struct dom_attr *attr,
struct dom_type_info **result)
{
UNUSED(attr);
diff --git a/src/core/element.c b/src/core/element.c
new file mode 100644
index 0000000..3fce4b9
--- /dev/null
+++ b/src/core/element.c
@@ -0,0 +1,513 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
+ */
+
+#include <dom/core/element.h>
+
+#include "core/node.h"
+#include "utils/utils.h"
+
+/**
+ * DOM element node
+ */
+struct dom_element {
+ struct dom_node base; /**< Base node */
+
+ struct dom_type_info *schema_type_info; /**< Type information */
+};
+
+/**
+ * Retrieve an element's tag name
+ *
+ * \param element The element to retrieve the name from
+ * \param name Pointer to location to receive name
+ * \return DOM_NO_ERR.
+ *
+ * The returned string will have its reference count increased. It is
+ * the responsibility of the caller to unref the string once it has
+ * finished with it.
+ */
+dom_exception dom_element_get_tag_name(struct dom_element *element,
+ struct dom_string **name)
+{
+ UNUSED(element);
+ UNUSED(name);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve an attribute from an element by name
+ *
+ * \param element The element to retrieve attribute from
+ * \param name The attribute's name
+ * \param value Pointer to location to receive attribute's value
+ * \return DOM_NO_ERR.
+ *
+ * The returned string will have its reference count increased. It is
+ * the responsibility of the caller to unref the string once it has
+ * finished with it.
+ */
+dom_exception dom_element_get_attribute(struct dom_element *element,
+ struct dom_string *name, struct dom_string **value)
+{
+ UNUSED(element);
+ UNUSED(name);
+ UNUSED(value);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Set an attribute on an element by name
+ *
+ * \param element The element to set attribute on
+ * \param name The attribute's name
+ * \param value The attribute's value
+ * \return DOM_NO_ERR on success,
+ * DOM_INVALID_CHARACTER_ERR if ::name is invalid,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if ::element is readonly.
+ */
+dom_exception dom_element_set_attribute(struct dom_element *element,
+ struct dom_string *name, struct dom_string *value)
+{
+ UNUSED(element);
+ UNUSED(name);
+ UNUSED(value);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Remove an attribute from an element by name
+ *
+ * \param element The element to remove attribute from
+ * \param name The name of the attribute to remove
+ * \return DOM_NO_ERR on success,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if ::element is readonly.
+ */
+dom_exception dom_element_remove_attribute(struct dom_element *element,
+ struct dom_string *name)
+{
+ UNUSED(element);
+ UNUSED(name);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve an attribute node from an element by name
+ *
+ * \param element The element to retrieve attribute node from
+ * \param name The attribute's name
+ * \param result Pointer to location to receive attribute node
+ * \return DOM_NO_ERR.
+ *
+ * The returned node will have its reference count increased. It is
+ * the responsibility of the caller to unref the node once it has
+ * finished with it.
+ */
+dom_exception dom_element_get_attribute_node(struct dom_element *element,
+ struct dom_string *name, struct dom_attr **result)
+{
+ UNUSED(element);
+ UNUSED(name);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Set an attribute node on an element, replacing existing node, if present
+ *
+ * \param element The element to add a node to
+ * \param attr The attribute node to add
+ * \param result Pointer to location to recieve previous node
+ * \return DOM_NO_ERR on success,
+ * DOM_WRONG_DOCUMENT_ERR if ::attr does not belong to the
+ * same document as ::element,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if ::element is readonly,
+ * DOM_INUSE_ATTRIBUTE_ERR if ::attr is already an attribute
+ * of another Element node.
+ *
+ * The returned node will have its reference count increased. It is
+ * the responsibility of the caller to unref the node once it has
+ * finished with it.
+ */
+dom_exception dom_element_set_attribute_node(struct dom_element *element,
+ struct dom_attr *attr, struct dom_attr **result)
+{
+ UNUSED(element);
+ UNUSED(attr);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Remove an attribute node from an element by name
+ *
+ * \param element The element to remove attribute node from
+ * \param attr The attribute node to remove
+ * \param result Pointer to location to receive attribute node
+ * \return DOM_NO_ERR on success,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if ::element is readonly,
+ * DOM_NOT_FOUND_ERR if ::attr is not an attribute of
+ * ::element.
+ *
+ * The returned node will have its reference count increased. It is
+ * the responsibility of the caller to unref the node once it has
+ * finished with it.
+ */
+dom_exception dom_element_remove_attribute_node(struct dom_element *element,
+ struct dom_attr *attr, struct dom_attr **result)
+{
+ UNUSED(element);
+ UNUSED(attr);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve a list of descendant elements of an element which match a given
+ * tag name
+ *
+ * \param element The root of the subtree to search
+ * \param name The tag name to match (or "*" for all tags)
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ *
+ * The returned nodelist will have its reference count increased. It is
+ * the responsibility of the caller to unref the nodelist once it has
+ * finished with it.
+ */
+dom_exception dom_element_get_elements_by_tag_name(
+ struct dom_element *element, struct dom_string *name,
+ struct dom_nodelist **result)
+{
+ UNUSED(element);
+ UNUSED(name);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve an attribute from an element by namespace/localname
+ *
+ * \param element The element to retrieve attribute from
+ * \param namespace The attribute's namespace URI
+ * \param localname The attribute's local name
+ * \param value Pointer to location to receive attribute's value
+ * \return DOM_NO_ERR on success,
+ * DOM_NOT_SUPPORTED_ERR if the implementation does not support
+ * the feature "XML" and the language exposed
+ * through the Document does not support
+ * Namespaces.
+ *
+ * The returned string will have its reference count increased. It is
+ * the responsibility of the caller to unref the string once it has
+ * finished with it.
+ */
+dom_exception dom_element_get_attribute_ns(struct dom_element *element,
+ struct dom_string *namespace, struct dom_string *localname,
+ struct dom_string **value)
+{
+ UNUSED(element);
+ UNUSED(namespace);
+ UNUSED(localname);
+ UNUSED(value);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Set an attribute on an element by namespace/qualified name
+ *
+ * \param element The element to set attribute on
+ * \param namespace The attribute's namespace URI
+ * \param qname The attribute's qualified name
+ * \param value The attribute's value
+ * \return DOM_NO_ERR on success,
+ * DOM_INVALID_CHARACTER_ERR if ::qname is invalid,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if ::element is readonly,
+ * DOM_NAMESPACE_ERR if ::qname is malformed, or
+ * ::qname has a prefix and
+ * ::namespace is null, or ::qname
+ * has a prefix "xml" and
+ * ::namespace is not
+ * "http://www.w3.org/XML/1998/namespace",
+ * or ::qname has a prefix "xmlns"
+ * and ::namespace is not
+ * "http://www.w3.org/2000/xmlns",
+ * or ::namespace is
+ * "http://www.w3.org/2000/xmlns"
+ * and ::qname is not prefixed
+ * "xmlns",
+ * DOM_NOT_SUPPORTED_ERR if the implementation does not
+ * support the feature "XML" and the
+ * language exposed through the
+ * Document does not support
+ * Namespaces.
+ */
+dom_exception dom_element_set_attribute_ns(struct dom_element *element,
+ struct dom_string *namespace, struct dom_string *qname,
+ struct dom_string *value)
+{
+ UNUSED(element);
+ UNUSED(namespace);
+ UNUSED(qname);
+ UNUSED(value);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Remove an attribute from an element by namespace/localname
+ *
+ * \param element The element to remove attribute from
+ * \param namespace The attribute's namespace URI
+ * \param localname The attribute's local name
+ * \return DOM_NO_ERR on success,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if ::element is readonly,
+ * DOM_NOT_SUPPORTED_ERR if the implementation does not
+ * support the feature "XML" and the
+ * language exposed through the
+ * Document does not support
+ * Namespaces.
+ */
+dom_exception dom_element_remove_attribute_ns(struct dom_element *element,
+ struct dom_string *namespace, struct dom_string *localname)
+{
+ UNUSED(element);
+ UNUSED(namespace);
+ UNUSED(localname);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve an attribute node from an element by namespace/localname
+ *
+ * \param element The element to retrieve attribute from
+ * \param namespace The attribute's namespace URI
+ * \param localname The attribute's local name
+ * \param result Pointer to location to receive attribute node
+ * \return DOM_NO_ERR on success,
+ * DOM_NOT_SUPPORTED_ERR if the implementation does not support
+ * the feature "XML" and the language exposed
+ * through the Document does not support
+ * Namespaces.
+ *
+ * The returned node will have its reference count increased. It is
+ * the responsibility of the caller to unref the node once it has
+ * finished with it.
+ */
+dom_exception dom_element_get_attribute_node_ns(struct dom_element *element,
+ struct dom_string *namespace, struct dom_string *localname,
+ struct dom_attr **result)
+{
+ UNUSED(element);
+ UNUSED(namespace);
+ UNUSED(localname);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Set an attribute node on an element, replacing existing node, if present
+ *
+ * \param element The element to add a node to
+ * \param attr The attribute node to add
+ * \param result Pointer to location to recieve previous node
+ * \return DOM_NO_ERR on success,
+ * DOM_WRONG_DOCUMENT_ERR if ::attr does not belong to the
+ * same document as ::element,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if ::element is readonly,
+ * DOM_INUSE_ATTRIBUTE_ERR if ::attr is already an attribute
+ * of another Element node.
+ * DOM_NOT_SUPPORTED_ERR if the implementation does not
+ * support the feature "XML" and the
+ * language exposed through the
+ * Document does not support
+ * Namespaces.
+ *
+ * The returned node will have its reference count increased. It is
+ * the responsibility of the caller to unref the node once it has
+ * finished with it.
+ */
+dom_exception dom_element_set_attribute_node_ns(struct dom_element *element,
+ struct dom_attr *attr, struct dom_attr **result)
+{
+ UNUSED(element);
+ UNUSED(attr);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve a list of descendant elements of an element which match a given
+ * namespace/localname pair.
+ *
+ * \param element The root of the subtree to search
+ * \param namespace The namespace URI to match (or "*" for all)
+ * \param localname The local name to match (or "*" for all)
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR on success,
+ * DOM_NOT_SUPPORTED_ERR if the implementation does not support
+ * the feature "XML" and the language exposed
+ * through the Document does not support
+ * Namespaces.
+ *
+ * The returned nodelist will have its reference count increased. It is
+ * the responsibility of the caller to unref the nodelist once it has
+ * finished with it.
+ */
+dom_exception dom_element_get_elements_by_tag_name_ns(
+ struct dom_element *element, struct dom_string *namespace,
+ struct dom_string *localname, struct dom_nodelist **result)
+{
+ UNUSED(element);
+ UNUSED(namespace);
+ UNUSED(localname);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Determine if an element possesses and attribute with the given name
+ *
+ * \param element The element to query
+ * \param name The attribute name to look for
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR.
+ */
+dom_exception dom_element_has_attribute(struct dom_element *element,
+ struct dom_string *name, bool *result)
+{
+ UNUSED(element);
+ UNUSED(name);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Determine if an element possesses and attribute with the given
+ * namespace/localname pair.
+ *
+ * \param element The element to query
+ * \param namespace The attribute namespace URI to look for
+ * \param localname The attribute local name to look for
+ * \param result Pointer to location to receive result
+ * \return DOM_NO_ERR on success,
+ * DOM_NOT_SUPPORTED_ERR if the implementation does not support
+ * the feature "XML" and the language exposed
+ * through the Document does not support
+ * Namespaces.
+ */
+dom_exception dom_element_has_attribute_ns(struct dom_element *element,
+ struct dom_string *namespace, struct dom_string *localname,
+ bool *result)
+{
+ UNUSED(element);
+ UNUSED(namespace);
+ UNUSED(localname);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Retrieve the type information associated with an element
+ *
+ * \param element The element to retrieve type information from
+ * \param result Pointer to location to receive type information
+ * \return DOM_NO_ERR.
+ *
+ * The returned typeinfo will have its reference count increased. It is
+ * the responsibility of the caller to unref the typeinfo once it has
+ * finished with it.
+ */
+dom_exception dom_element_get_schema_type_info(struct dom_element *element,
+ struct dom_type_info **result)
+{
+ UNUSED(element);
+ UNUSED(result);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * (Un)declare an attribute as being an element's ID by name
+ *
+ * \param element The element containing the attribute
+ * \param name The attribute's name
+ * \param is_id Whether the attribute is an ID
+ * \return DOM_NO_ERR on success,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if ::element is readonly,
+ * DOM_NOT_FOUND_ERR if the specified node is not an
+ * attribute of ::element.
+ */
+dom_exception dom_element_set_id_attribute(struct dom_element *element,
+ struct dom_string *name, bool is_id)
+{
+ UNUSED(element);
+ UNUSED(name);
+ UNUSED(is_id);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * (Un)declare an attribute as being an element's ID by namespace/localname
+ *
+ * \param element The element containing the attribute
+ * \param namespace The attribute's namespace URI
+ * \param localname The attribute's local name
+ * \param is_id Whether the attribute is an ID
+ * \return DOM_NO_ERR on success,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if ::element is readonly,
+ * DOM_NOT_FOUND_ERR if the specified node is not an
+ * attribute of ::element.
+ */
+dom_exception dom_element_set_id_attribute_ns(struct dom_element *element,
+ struct dom_string *namespace, struct dom_string *localname,
+ bool is_id)
+{
+ UNUSED(element);
+ UNUSED(namespace);
+ UNUSED(localname);
+ UNUSED(is_id);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * (Un)declare an attribute node as being an element's ID
+ *
+ * \param element The element containing the attribute
+ * \param id_attr The attribute node
+ * \param is_id Whether the attribute is an ID
+ * \return DOM_NO_ERR on success,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if ::element is readonly,
+ * DOM_NOT_FOUND_ERR if the specified node is not an
+ * attribute of ::element.
+ */
+dom_exception dom_element_set_id_attribute_node(struct dom_element *element,
+ struct dom_attr *id_attr, bool is_id)
+{
+ UNUSED(element);
+ UNUSED(id_attr);
+ UNUSED(is_id);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+