diff options
Diffstat (limited to 'bindings/xml')
-rw-r--r-- | bindings/xml/xmlbinding.c | 37 | ||||
-rw-r--r-- | bindings/xml/xmlparser.c | 20 |
2 files changed, 36 insertions, 21 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 */ diff --git a/bindings/xml/xmlparser.c b/bindings/xml/xmlparser.c index 93c2506..6f1516b 100644 --- a/bindings/xml/xmlparser.c +++ b/bindings/xml/xmlparser.c @@ -637,7 +637,7 @@ void xml_parser_add_node(xml_parser *parser, struct dom_node *parent, void xml_parser_add_element_node(xml_parser *parser, struct dom_node *parent, xmlNodePtr child) { - struct dom_element *el, *ins_el; + struct dom_element *el, *ins_el = NULL; xmlAttrPtr a; dom_exception err; @@ -896,7 +896,7 @@ cleanup: void xml_parser_add_text_node(xml_parser *parser, struct dom_node *parent, xmlNodePtr child) { - struct dom_text *text, *ins_text; + struct dom_text *text, *ins_text = NULL; struct dom_string *data; dom_exception err; @@ -957,7 +957,7 @@ void xml_parser_add_text_node(xml_parser *parser, struct dom_node *parent, void xml_parser_add_cdata_section(xml_parser *parser, struct dom_node *parent, xmlNodePtr child) { - struct dom_cdata_section *cdata, *ins_cdata; + struct dom_cdata_section *cdata, *ins_cdata = NULL; struct dom_string *data; dom_exception err; @@ -1018,7 +1018,7 @@ void xml_parser_add_cdata_section(xml_parser *parser, void xml_parser_add_entity_reference(xml_parser *parser, struct dom_node *parent, xmlNodePtr child) { - struct dom_entity_reference *entity, *ins_entity; + struct dom_entity_reference *entity, *ins_entity = NULL; struct dom_string *name; xmlNodePtr c; dom_exception err; @@ -1086,7 +1086,7 @@ void xml_parser_add_entity_reference(xml_parser *parser, void xml_parser_add_comment(xml_parser *parser, struct dom_node *parent, xmlNodePtr child) { - struct dom_comment *comment, *ins_comment; + struct dom_comment *comment, *ins_comment = NULL; struct dom_string *data; dom_exception err; @@ -1148,7 +1148,7 @@ void xml_parser_add_document_type(xml_parser *parser, struct dom_node *parent, xmlNodePtr child) { xmlDtdPtr dtd = (xmlDtdPtr) child; - struct dom_document_type *doctype; + struct dom_document_type *doctype, *ins_doctype = NULL; struct dom_string *qname, *public_id, *system_id; dom_exception err; @@ -1207,8 +1207,8 @@ void xml_parser_add_document_type(xml_parser *parser, dom_string_unref(qname); /* Add doctype to document */ - err = dom_document_set_doctype((struct dom_document *) parent, - doctype); + err = dom_node_append_child(parent, (struct dom_node *) doctype, + (struct dom_node **) &ins_doctype); if (err != DOM_NO_ERR) { dom_node_unref((struct dom_node *) doctype); parser->msg(XML_MSG_CRITICAL, parser->mctx, @@ -1216,6 +1216,10 @@ void xml_parser_add_document_type(xml_parser *parser, return; } + /* Not interested in inserted node */ + if (ins_doctype != NULL) + dom_node_unref((struct dom_node *) ins_doctype); + /* Link nodes together */ err = xml_parser_link_nodes(parser, (struct dom_node *) doctype, child); |