summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2012-11-02 19:11:31 +0000
committerDaniel Silverstone <dsilvers@digital-scurf.org>2012-11-02 19:11:31 +0000
commit794c89e1bafafcfb35ec640afa2005b5a3bf29d4 (patch)
tree05d761d4c4498cc976a8473fd383b317cc38b8ac
parentab88f11bb45322003b5882a98f35e9e4e9061e5b (diff)
downloadlibdom-794c89e1bafafcfb35ec640afa2005b5a3bf29d4.tar.gz
libdom-794c89e1bafafcfb35ec640afa2005b5a3bf29d4.tar.bz2
Move generation of id_name into document by default. Since 'id' is the most common name of the 'id' attribute
-rw-r--r--bindings/xml/libxml_xmlparser.c10
-rw-r--r--src/core/document.c10
2 files changed, 8 insertions, 12 deletions
diff --git a/bindings/xml/libxml_xmlparser.c b/bindings/xml/libxml_xmlparser.c
index 1c2442a..4729058 100644
--- a/bindings/xml/libxml_xmlparser.c
+++ b/bindings/xml/libxml_xmlparser.c
@@ -282,16 +282,6 @@ dom_xml_error dom_xml_parser_completed(dom_xml_parser *parser)
parser->complete = true;
- /* TODO: In future, this string "id" should be extracted from the
- * document schema file instead of just setting it as "id".
- */
- derr = dom_string_create((const uint8_t *) "id", SLEN("id"), &name);
- if (derr != DOM_NO_ERR)
- return derr;
-
- _dom_document_set_id_name(parser->doc, name);
- dom_string_unref(name);
-
return DOM_XML_OK;
}
diff --git a/src/core/document.c b/src/core/document.c
index 6284897..d668c0e 100644
--- a/src/core/document.c
+++ b/src/core/document.c
@@ -132,13 +132,18 @@ dom_exception _dom_document_initialise(dom_document *doc,
list_init(&doc->pending_nodes);
- doc->id_name = NULL;
+ err = dom_string_create_interned((const uint8_t *) "id",
+ SLEN("id"), &doc->id_name);
+ if (err != DOM_NO_ERR)
+ return err;
doc->quirks = DOM_DOCUMENT_QUIRKS_MODE_NONE;
err = dom_string_create_interned((const uint8_t *) "class",
SLEN("class"), &doc->class_string);
- if (err != DOM_NO_ERR)
+ if (err != DOM_NO_ERR) {
+ dom_string_unref(doc->id_name);
return err;
+ }
/* Intern the empty string. The use of a space in the constant
* is to prevent the compiler warning about an empty string.
@@ -146,6 +151,7 @@ dom_exception _dom_document_initialise(dom_document *doc,
err = dom_string_create_interned((const uint8_t *) " ", 0,
&doc->_memo_empty);
if (err != DOM_NO_ERR) {
+ dom_string_unref(doc->id_name);
dom_string_unref(doc->class_string);
return err;
}