summaryrefslogtreecommitdiff
path: root/bindings/xml/xmlbinding.c
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2007-09-19 22:06:26 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2007-09-19 22:06:26 +0000
commit016dd743cf77b2536015e4e9594716dfdc81d02d (patch)
treef03cc1aae39835468e3e581aa46dcb0e9bc0ff17 /bindings/xml/xmlbinding.c
parent802104d9b0f45c55f16326b755f2b1612eb4ef87 (diff)
downloadlibdom-016dd743cf77b2536015e4e9594716dfdc81d02d.tar.gz
libdom-016dd743cf77b2536015e4e9594716dfdc81d02d.tar.bz2
Begin implementation of DocumentType class
Remove dom_document_set_doctype() -- dom_node_insert_before() (and thus _append_child()) can be used to achieve the same effect. DocumentType node is now a child of the Document node (as it should have been) rather than a hidden field. Make dom_node_destroy() aware of DocumentType nodes potentially having no owner. Make dom_node_finalise() aware of it, too. Make dom_node_get_owner_document() return NULL for Document nodes, as per the spec. Fix bug in dom_node_insert_before() -- previously it failed to catch attempts to insert a second root element. Make dom_node_insert_before() handle DocumentType nodes appropriately. Implement XML binding's dom_implementation_create_document_type() function. Fix XML binding's dom_implementation_create_document() implementation to cope with changed API relating to doctype insertion. Fix up XML parser wrapper to cater for new doctype insertion mechanism. Also sprinkle some NULL about for paranoia purposes. svn path=/trunk/dom/; revision=3551
Diffstat (limited to 'bindings/xml/xmlbinding.c')
-rw-r--r--bindings/xml/xmlbinding.c37
1 files changed, 24 insertions, 13 deletions
diff --git a/bindings/xml/xmlbinding.c b/bindings/xml/xmlbinding.c
index 9809b56..3660015 100644
--- a/bindings/xml/xmlbinding.c
+++ b/bindings/xml/xmlbinding.c
@@ -193,11 +193,7 @@ dom_exception xml_dom_implementation_has_feature(
* \param pw Pointer to client-specific private data
* \return DOM_NO_ERR on success,
* DOM_INVALID_CHARACTER_ERR if ::qname is invalid,
- * DOM_NAMESPACE_ERR if ::qname is malformed,
- * DOM_NOT_SUPPORTED_ERR if ::impl does not support the
- * feature "XML" and the language
- * exposed through Document does
- * not support XML namespaces.
+ * DOM_NAMESPACE_ERR if ::qname is malformed.
*
* Any memory allocated by this call should be allocated using
* the provided memory (de)allocation function.
@@ -214,15 +210,23 @@ dom_exception xml_dom_implementation_create_document_type(
struct dom_document_type **doctype,
dom_alloc alloc, void *pw)
{
+ struct dom_document_type *d;
+ dom_exception err;
+
+ /* We have no use for the impl -- we only have one */
UNUSED(impl);
- UNUSED(qname);
- UNUSED(public_id);
- UNUSED(system_id);
- UNUSED(doctype);
- UNUSED(alloc);
- UNUSED(pw);
- return DOM_NOT_SUPPORTED_ERR;
+ /** \todo validate qname */
+
+ /* Create the doctype */
+ err = dom_document_type_create(qname, public_id, system_id,
+ alloc, pw, &d);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ *doctype = d;
+
+ return DOM_NO_ERR;
}
/**
@@ -281,11 +285,18 @@ dom_exception xml_dom_implementation_create_document(
/* Set its doctype, if necessary */
if (doctype != NULL) {
- err = dom_document_set_doctype(d, doctype);
+ struct dom_node *ins_doctype = NULL;
+
+ err = dom_node_append_child((struct dom_node *) d,
+ (struct dom_node *) doctype, &ins_doctype);
if (err != DOM_NO_ERR) {
dom_node_unref((struct dom_node *) d);
return err;
}
+
+ /* Not interested in inserted doctype */
+ if (ins_doctype != NULL)
+ dom_node_unref(ins_doctype);
}
/* Create root element and attach it to document */