From 6837c5789f492460f610a4ce074606eac5268a98 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sat, 22 Sep 2007 17:38:47 +0000 Subject: Implement dom_node_get_child_nodes() Implement dom_node_get_attributes() svn path=/trunk/dom/; revision=3570 --- src/core/node.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'src/core') diff --git a/src/core/node.c b/src/core/node.c index eab1809..db65fab 100644 --- a/src/core/node.c +++ b/src/core/node.c @@ -408,15 +408,21 @@ dom_exception dom_node_get_parent_node(struct dom_node *node, * \param result Pointer to location to receive child list * \return DOM_NO_ERR. * - * \todo Work out reference counting semantics of dom_nodelist + * The returned NodeList will be referenced. It is the responsibility + * of the caller to unref the list once it has finished with it. */ dom_exception dom_node_get_child_nodes(struct dom_node *node, struct dom_nodelist **result) { - UNUSED(node); - UNUSED(result); + /* Can't do anything without an owning document. + * This is only a problem for DocumentType nodes + * which are not yet attached to a document. + * DocumentType nodes have no children, anyway. */ + if (node->owner == NULL) + return DOM_NOT_SUPPORTED_ERR; - return DOM_NOT_SUPPORTED_ERR; + return dom_document_get_nodelist(node->owner, node, + NULL, NULL, NULL, result); } /** @@ -518,15 +524,22 @@ dom_exception dom_node_get_next_sibling(struct dom_node *node, * \param result Pointer to location to receive attribute map * \return DOM_NO_ERR. * - * \todo Work out reference counting semantics of dom_namednodemap + * The returned NamedNodeMap will be referenced. It is the responsibility + * of the caller to unref the map once it has finished with it. + * + * If ::node is not an Element, then NULL will be returned. */ dom_exception dom_node_get_attributes(struct dom_node *node, struct dom_namednodemap **result) { - UNUSED(node); - UNUSED(result); + if (node->type != DOM_ELEMENT_NODE) { + *result = NULL; - return DOM_NOT_SUPPORTED_ERR; + return DOM_NO_ERR; + } + + return dom_document_get_namednodemap(node->owner, node, + DOM_ATTRIBUTE_NODE, result); } /** -- cgit v1.2.3