On Sat, 2009-08-01 at 02:32 +0000, [email protected] wrote:
> Modified: branches/struggleyb/libdom-remain/bindings/xml/xmlparser.c
> URL:
> http://source.netsurf-browser.org/branches/struggleyb/libdom-remain/bindings/xml/xmlparser.c?rev=8936&r1=8935&r2=8936&view=diff
> ==============================================================================
> --- branches/struggleyb/libdom-remain/bindings/xml/xmlparser.c (original)
> +++ branches/struggleyb/libdom-remain/bindings/xml/xmlparser.c Fri Jul 31
> 21:32:27 2009
> @@ -297,6 +297,8 @@
> dom_xml_error dom_xml_parser_completed(dom_xml_parser *parser)
> {
> xmlParserErrors err;
> + lwc_string *name = NULL;
> + lwc_error lerr;
>
> err = xmlParseChunk(parser->xml_ctx, "", 0, 1);
> if (err != XML_ERR_OK) {
> @@ -306,6 +308,13 @@
> }
>
> parser->complete = true;
> +
> + lerr = lwc_context_intern(parser->ctx, "id", strlen("id"), &name);
> + if (lerr != lwc_error_ok)
> + return DOM_XML_LIBXML_ERR | lerr;
You probably want a todo here mentioning that the id attribute name
should be extracted from the schema.
> Modified: branches/struggleyb/libdom-remain/src/core/document.c
> URL:
> http://source.netsurf-browser.org/branches/struggleyb/libdom-remain/src/core/document.c?rev=8936&r1=8935&r2=8936&view=diff
> ==============================================================================
> --- branches/struggleyb/libdom-remain/src/core/document.c (original)
> +++ branches/struggleyb/libdom-remain/src/core/document.c Fri Jul 31 21:32:27
> 2009
> @@ -143,12 +143,15 @@
> doc->alloc = alloc;
> doc->pw = pw;
> doc->context = ctx;
> + lwc_context_ref(ctx);
This is better:
doc->context = lwc_context_ref(ctx);
> @@ -182,6 +185,9 @@
> * non-zero as these data structures reference the document because
> * they are held by the client. */
> doc->nodelists = NULL;
> +
> + lwc_context_string_unref(doc->context, doc->id_name);
id_name may be NULL here.
> +/**
> + * Set the ID attribute name of this document
> + *
> + * \param doc The document object
> + * \param name The ID name of the elements in this document
> + *
> + * @note: The lwc_context of the param 'name' must be the same one with
> + * document's, this should be assured by the client.
> + */
> +void _dom_document_set_id_name(dom_document *doc, struct lwc_string_s *name)
> +{
> + lwc_context_string_unref(doc->context, doc->id_name);
> + doc->id_name = name;
> + lwc_context_string_ref(doc->context, name);
Similarly, doc->id_name = lwc_context_string_ref(doc->context, name);
> Modified: branches/struggleyb/libdom-remain/src/core/element.c
> URL:
> http://source.netsurf-browser.org/branches/struggleyb/libdom-remain/src/core/element.c?rev=8936&r1=8935&r2=8936&view=diff
> ==============================================================================
> --- branches/struggleyb/libdom-remain/src/core/element.c (original)
> +++ branches/struggleyb/libdom-remain/src/core/element.c Fri Jul 31 21:32:27
> 2009
> @@ -1652,10 +1646,9 @@
> if (err != DOM_NO_ERR) {
> return err;
> }
> -
> } else {
> - err = _dom_document_create_string(doc, (uint8_t *)
> ID_ATTRIBUTE,
> - strlen(ID_ATTRIBUTE), &name);
> + err = _dom_document_create_string_from_lwcstring(doc,
> + _dom_document_get_id_name(doc), &name);
What if it's NULL?
J.