summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2007-07-26 13:17:08 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2007-07-26 13:17:08 +0000
commitd208ad37e9dea0e3854e70eef40e33716c54aff0 (patch)
treedb63c1840db873ab4b0170a3fb030de80d8aa2e5
parentb134f8403b4b38e4539488547ca84fc47e7f06ca (diff)
downloadlibdom-d208ad37e9dea0e3854e70eef40e33716c54aff0.tar.gz
libdom-d208ad37e9dea0e3854e70eef40e33716c54aff0.tar.bz2
Add ability to set a document's doctype after the document has been created
svn path=/trunk/dom/; revision=3462
-rw-r--r--bindings/xml/xmlparser.c11
-rw-r--r--include/dom/bootstrap/implpriv.h7
-rw-r--r--src/core/document.c30
3 files changed, 45 insertions, 3 deletions
diff --git a/bindings/xml/xmlparser.c b/bindings/xml/xmlparser.c
index 5c63b29..9e907d6 100644
--- a/bindings/xml/xmlparser.c
+++ b/bindings/xml/xmlparser.c
@@ -13,6 +13,7 @@
#include <libxml/SAX2.h>
#include <libxml/xmlerror.h>
+#include <dom/bootstrap/implpriv.h>
#include <dom/dom.h>
#include "xmlerror.h"
@@ -1089,9 +1090,13 @@ void xml_parser_add_document_type(xml_parser *parser,
dom_string_unref(public_id);
dom_string_unref(qname);
- /** \todo Add doctype to document (requires some libdom-internal API
- * -- doctypes are immutable in the DOM) */
- UNUSED(parent);
+ /* Add doctype to document */
+ err = dom_document_set_doctype((struct dom_document *) parent,
+ doctype);
+ if (err != DOM_NO_ERR) {
+ dom_node_unref((struct dom_node *) doctype);
+ return;
+ }
/* Link nodes together */
err = xml_parser_link_nodes(parser, (struct dom_node *) doctype,
diff --git a/include/dom/bootstrap/implpriv.h b/include/dom/bootstrap/implpriv.h
index aa123e0..d9cc787 100644
--- a/include/dom/bootstrap/implpriv.h
+++ b/include/dom/bootstrap/implpriv.h
@@ -12,6 +12,9 @@
* The DOMImplementation and DOMImplementationList implementations also
* include this, as those types are defined here.
*
+ * The Document implementation includes this as it needs the declaration of
+ * dom_document_set_doctype.
+ *
* No other client should be including this.
*/
@@ -241,4 +244,8 @@ struct dom_implementation_source {
dom_exception dom_register_source(struct dom_implementation_source *source,
dom_alloc alloc, void *pw);
+/* Set a Document's DocumentType */
+dom_exception dom_document_set_doctype(struct dom_document *doc,
+ struct dom_document_type *doctype);
+
#endif
diff --git a/src/core/document.c b/src/core/document.c
index b73f5e3..0552c22 100644
--- a/src/core/document.c
+++ b/src/core/document.c
@@ -6,6 +6,7 @@
*/
#include <dom/functypes.h>
+#include <dom/bootstrap/implpriv.h>
#include <dom/core/document.h>
#include "core/characterdata.h"
@@ -752,6 +753,35 @@ dom_exception dom_document_rename_node(struct dom_document *doc,
return DOM_NOT_SUPPORTED_ERR;
}
+/* */
+/* ----------------------------------------------------------------------- */
+/* */
+
+/**
+ * Set a Document's Document Type
+ *
+ * \param doc Document to set type of
+ * \param doctype The doctype to apply
+ * \return DOM_NO_ERR on success,
+ * DOM_INVALID_MODIFICATION_ERR if ::doc already has a doctype.
+ *
+ * The doctype will have its reference count increased. It is the
+ * responsibility of the caller to unref the doctype once it has finished
+ * with it.
+ */
+dom_exception dom_document_set_doctype(struct dom_document *doc,
+ struct dom_document_type *doctype)
+{
+ UNUSED(doc);
+ UNUSED(doctype);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/* */
+/* ----------------------------------------------------------------------- */
+/* */
+
/**
* Acquire a pointer to the base of the document buffer
*