summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBo Yang <struggleyb.nku@gmail.com>2009-08-11 11:17:23 +0000
committerBo Yang <struggleyb.nku@gmail.com>2009-08-11 11:17:23 +0000
commit399da01ae4eb5c5e3e9349bacc2063c946c3d4a1 (patch)
tree433c8bcde94fc7a6e6f2e5cbf23842a84db98146
parenteec057c7437e19b59ca1e698ce548cb56ce37240 (diff)
downloadlibdom-399da01ae4eb5c5e3e9349bacc2063c946c3d4a1.tar.gz
libdom-399da01ae4eb5c5e3e9349bacc2063c946c3d4a1.tar.bz2
Merge the branches/struggleyb/libdom-remain back to trunk.
svn path=/trunk/dom/; revision=9191
-rw-r--r--Makefile3
-rw-r--r--bindings/hubbub/README21
-rw-r--r--bindings/hubbub/parser.c163
-rw-r--r--bindings/hubbub/parser.h5
-rw-r--r--bindings/xml/Makefile2
-rw-r--r--bindings/xml/README21
-rw-r--r--bindings/xml/xmlbinding.h19
-rw-r--r--bindings/xml/xmlparser.c133
-rw-r--r--bindings/xml/xmlparser.h4
-rw-r--r--include/dom/bootstrap/implpriv.h42
-rw-r--r--include/dom/bootstrap/implregistry.h10
-rw-r--r--include/dom/core/attr.h20
-rw-r--r--include/dom/core/characterdata.h8
-rw-r--r--include/dom/core/comment.h18
-rw-r--r--include/dom/core/document.h6
-rw-r--r--include/dom/core/element.h7
-rw-r--r--include/dom/core/exceptions.h3
-rw-r--r--include/dom/core/implementation.h11
-rw-r--r--include/dom/core/namednodemap.h9
-rw-r--r--include/dom/core/node.h40
-rw-r--r--include/dom/core/string.h16
-rw-r--r--include/dom/core/typeinfo.h48
-rw-r--r--include/dom/dom.h20
-rw-r--r--src/bootstrap/Makefile2
-rw-r--r--src/bootstrap/implementation.c (renamed from bindings/xml/xmlbinding.c)197
-rw-r--r--src/bootstrap/implementation.h14
-rw-r--r--src/bootstrap/implregistry.c71
-rw-r--r--src/bootstrap/init_fini.c19
-rw-r--r--src/core/Makefile13
-rw-r--r--src/core/attr.c342
-rw-r--r--src/core/attr.h98
-rw-r--r--src/core/cdatasection.c66
-rw-r--r--src/core/cdatasection.h24
-rw-r--r--src/core/characterdata.c83
-rw-r--r--src/core/characterdata.h29
-rw-r--r--src/core/comment.c67
-rw-r--r--src/core/comment.h23
-rw-r--r--src/core/doc_fragment.c95
-rw-r--r--src/core/doc_fragment.h23
-rw-r--r--src/core/document.c1001
-rw-r--r--src/core/document.h108
-rw-r--r--src/core/document_type.c224
-rw-r--r--src/core/document_type.h28
-rw-r--r--src/core/element.c2031
-rw-r--r--src/core/element.h108
-rw-r--r--src/core/entity_ref.c98
-rw-r--r--src/core/entity_ref.h31
-rw-r--r--src/core/implementation.c25
-rw-r--r--src/core/impllist.c19
-rw-r--r--src/core/namednodemap.c361
-rw-r--r--src/core/namednodemap.h50
-rw-r--r--src/core/node.c1147
-rw-r--r--src/core/node.h144
-rw-r--r--src/core/nodelist.c214
-rw-r--r--src/core/nodelist.h26
-rw-r--r--src/core/pi.c65
-rw-r--r--src/core/pi.h22
-rw-r--r--src/core/string.c358
-rw-r--r--src/core/string.h32
-rw-r--r--src/core/text.c320
-rw-r--r--src/core/text.h46
-rw-r--r--src/core/typeinfo.c80
-rw-r--r--src/utils/Makefile3
-rw-r--r--src/utils/character_valid.c217
-rw-r--r--src/utils/character_valid.h54
-rw-r--r--src/utils/hashtable.c492
-rw-r--r--src/utils/hashtable.h42
-rw-r--r--src/utils/list.h61
-rw-r--r--src/utils/namespace.c71
-rw-r--r--src/utils/namespace.h7
-rw-r--r--src/utils/resource_mgr.c105
-rw-r--r--src/utils/resource_mgr.h45
-rw-r--r--src/utils/validate.c177
-rw-r--r--src/utils/validate.h26
-rw-r--r--test/DOMTSHandler.pm1541
-rw-r--r--test/INDEX4
-rw-r--r--test/Makefile13
-rw-r--r--test/binding.c35
-rwxr-xr-xtest/build-test.sh31
-rw-r--r--test/data/Aliases (renamed from test/data/binding/Aliases)3
-rw-r--r--test/data/binding/sample.html11
-rw-r--r--test/data/binding/staff.xml57
-rw-r--r--test/dom1-interfaces.xml (renamed from test/transform/dom1-interfaces.xml)0
-rw-r--r--test/dom2-core-interface.xml35
-rw-r--r--test/dom3-core-interface.xml45
-rwxr-xr-xtest/leak-test.sh45
-rw-r--r--test/lib/comparators.c5
-rw-r--r--test/lib/exceptions.h42
-rw-r--r--test/lib/testassert.c64
-rw-r--r--test/lib/testassert.h34
-rw-r--r--test/lib/testobject.c233
-rw-r--r--test/lib/testobject.h22
-rwxr-xr-xtest/run-single-test.sh144
-rwxr-xr-xtest/run-test.sh146
-rw-r--r--test/test-list.c56
-rw-r--r--test/testutils.h11
-rw-r--r--test/testutils/comparators.c80
-rw-r--r--test/testutils/comparators.h (renamed from test/lib/comparators.h)7
-rw-r--r--test/testutils/domts.h25
-rw-r--r--test/testutils/domtsasserts.c253
-rw-r--r--test/testutils/domtsasserts.h61
-rw-r--r--test/testutils/domtscondition.c32
-rw-r--r--test/testutils/domtscondition.h18
-rw-r--r--test/testutils/foreach.c96
-rw-r--r--test/testutils/foreach.h41
-rw-r--r--test/testutils/list.c (renamed from test/lib/list.c)27
-rw-r--r--test/testutils/list.h (renamed from test/lib/list.h)21
-rw-r--r--test/testutils/load.c151
-rw-r--r--test/testutils/utils.c (renamed from test/lib/utils.c)0
-rw-r--r--test/testutils/utils.h (renamed from test/lib/utils.h)0
-rwxr-xr-xtest/transform.pl21
-rw-r--r--test/transform/ctypes.xml71
-rw-r--r--test/transform/string.xsl1233
-rw-r--r--test/transform/test-to-c.xsl511
-rw-r--r--test/xml/tests/dom1.dtd2500
115 files changed, 10173 insertions, 7185 deletions
diff --git a/Makefile b/Makefile
index 7f7fe87..5ef0ae5 100644
--- a/Makefile
+++ b/Makefile
@@ -47,7 +47,8 @@ INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/element.h;$(Is)/exceptions.h
INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/implementation.h;$(Is)/impllist.h
INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/namednodemap.h;$(Is)/node.h
INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/nodelist.h;$(Is)/string.h
-INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/text.h
+INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/text.h;$(Is)/typeinfo.h
+INSTALL_ITEMS := $(INSTALL_ITEMS) $(I):$(Is)/comment.h
INSTALL_ITEMS := $(INSTALL_ITEMS) /lib/pkgconfig:lib$(COMPONENT).pc.in
INSTALL_ITEMS := $(INSTALL_ITEMS) /lib:$(OUTPUT)
diff --git a/bindings/hubbub/README b/bindings/hubbub/README
index 43b7be7..ab498a0 100644
--- a/bindings/hubbub/README
+++ b/bindings/hubbub/README
@@ -1,29 +1,8 @@
Hubbub binding for libdom
=========================
-Overview
---------
-
- This is an example binding of hubbub to libdom. It consists of two,
- orthogonal, parts:
-
- 1) hubbub parser wrapper
- 2) hubbub-specific DOMImplementationSource for libdom
-
-Push parser wrapper
--------------------
-
This is a wrapper around hubbub's parser API, to facilitate
construction of a libdom DOM tree. The basic premise is that the wrapper
intercepts the SAX-like events emitted by hubbub's tokeniser then builds
a libdom DOM tree from them.
-DOMImplementationSource
------------------------
-
- The DOMImplementationSource exposes the APIs needed to create a new
- document based upon the hubbub binding. It also provides the utility
- functions that libdom uses when performing some operations (such as
- document normalization). This is needed as libdom is document language
- agnostic; therefore, it requires support from the binding to perform
- some operations.
diff --git a/bindings/hubbub/parser.c b/bindings/hubbub/parser.c
index 1c8859c..4551f13 100644
--- a/bindings/hubbub/parser.c
+++ b/bindings/hubbub/parser.c
@@ -7,6 +7,7 @@
*/
#include <stdio.h>
+#include <string.h>
#include <hubbub/errors.h>
#include <hubbub/hubbub.h>
@@ -17,6 +18,10 @@
#include "parser.h"
#include "utils.h"
+#include "core/document.h"
+
+#include <libwapcaplet/libwapcaplet.h>
+
/**
* libdom Hubbub parser context
*/
@@ -38,12 +43,15 @@ struct dom_hubbub_parser {
dom_alloc alloc; /**< Memory (de)allocation function */
void *pw; /**< Pointer to client data */
- dom_msg msg; /**< Informational messaging function */
- void *mctx; /**< Pointer to client data */
+ dom_msg msg; /**< Informational messaging function */
+ void *mctx; /**< Pointer to client data */
+
+ struct lwc_context_s *ctx; /**< The string intern context */
};
-static hubbub_error create_comment(void *parser, const hubbub_string *data,
+/* The callbacks declarations */
+static hubbub_error create_comment(void *parser, const hubbub_string *data,
void **result);
static hubbub_error create_doctype(void *parser, const hubbub_doctype *doctype,
void **result);
@@ -109,7 +117,8 @@ static bool __initialised = false;
*/
dom_hubbub_parser *dom_hubbub_parser_create(const char *aliases,
const char *enc, bool fix_enc,
- dom_alloc alloc, void *pw, dom_msg msg, void *mctx)
+ dom_alloc alloc, void *pw, dom_msg msg, void *mctx,
+ lwc_context *ctx)
{
dom_hubbub_parser *parser;
hubbub_parser_optparams params;
@@ -118,7 +127,8 @@ dom_hubbub_parser *dom_hubbub_parser_create(const char *aliases,
struct dom_string *features;
if (__initialised == false) {
- error = hubbub_initialise(aliases, alloc, pw);
+ error = hubbub_initialise(aliases,
+ (hubbub_allocator_fn) alloc, pw);
if (error != HUBBUB_OK) {
msg(DOM_MSG_ERROR, mctx,
"Failed initialising hubbub");
@@ -147,6 +157,7 @@ dom_hubbub_parser *dom_hubbub_parser_create(const char *aliases,
parser->pw = pw;
parser->msg = msg;
parser->mctx = mctx;
+ parser->ctx = ctx;
error = hubbub_parser_create(enc, fix_enc, alloc, pw, &parser->parser);
if (error != HUBBUB_OK) {
@@ -155,7 +166,6 @@ dom_hubbub_parser *dom_hubbub_parser_create(const char *aliases,
return NULL;
}
- /* Get DOM implementation */
/* Create string representation of the features we want */
err = dom_string_create(alloc, pw,
(const uint8_t *) "HTML", SLEN("HTML"), &features);
@@ -168,7 +178,7 @@ dom_hubbub_parser *dom_hubbub_parser_create(const char *aliases,
/* Now, try to get an appropriate implementation from the registry */
err = dom_implregistry_get_dom_implementation(features,
- &parser->impl, alloc, pw);
+ &parser->impl);
if (err != DOM_NO_ERR) {
dom_string_unref(features);
hubbub_parser_destroy(parser->parser);
@@ -177,11 +187,11 @@ dom_hubbub_parser *dom_hubbub_parser_create(const char *aliases,
return NULL;
}
- /* no longer need the features string */
+ /* No longer need the feature string */
dom_string_unref(features);
err = dom_implementation_create_document(parser->impl, NULL, NULL, NULL,
- &parser->doc, alloc, pw);
+ alloc, pw, ctx, &parser->doc);
if (err != DOM_NO_ERR) {
hubbub_parser_destroy(parser->parser);
alloc(parser, 0, pw);
@@ -204,7 +214,11 @@ dom_hubbub_parser *dom_hubbub_parser_create(const char *aliases,
return parser;
}
-/* Destroy a Hubbub parser instance */
+/**
+ * Destroy a Hubbub parser instance
+ *
+ * \param parser The Hubbub parser object
+ */
void dom_hubbub_parser_destroy(dom_hubbub_parser *parser)
{
dom_implementation_unref(parser->impl);
@@ -219,6 +233,15 @@ void dom_hubbub_parser_destroy(dom_hubbub_parser *parser)
parser->alloc(parser, 0, parser->pw);
}
+/**
+ * Parse data with Hubbub parser
+ *
+ * \param parser The parser object
+ * \param data The data to be parsed
+ * \param len The length of the data to be parsed
+ * \return DOM_HUBBUB_OK on success,
+ * DOM_HUBBUB_HUBBUB_ERR | <hubbub_error> on failure
+ */
dom_hubbub_error dom_hubbub_parser_parse_chunk(dom_hubbub_parser *parser,
uint8_t *data, size_t len)
{
@@ -231,9 +254,19 @@ dom_hubbub_error dom_hubbub_parser_parse_chunk(dom_hubbub_parser *parser,
return DOM_HUBBUB_OK;
}
+/**
+ * Notify the parser to complete parsing
+ *
+ * \param parser The parser object
+ * \return DOM_HUBBUB_OK on success,
+ * DOM_HUBBUB_HUBBUB_ERR | <hubbub_error> on underlaying parser failure
+ * DOMHUBBUB_UNKNOWN | <lwc_error> on libwapcaplet failure
+ */
dom_hubbub_error dom_hubbub_parser_completed(dom_hubbub_parser *parser)
{
hubbub_error err;
+ lwc_string *name = NULL;
+ lwc_error lerr;
err = hubbub_parser_completed(parser->parser);
if (err != DOM_HUBBUB_OK) {
@@ -244,9 +277,22 @@ dom_hubbub_error dom_hubbub_parser_completed(dom_hubbub_parser *parser)
parser->complete = true;
+ lerr = lwc_context_intern(parser->ctx, "id", strlen("id"), &name);
+ if (lerr != lwc_error_ok)
+ return HUBBUB_UNKNOWN;
+
+ _dom_document_set_id_name(parser->doc, name);
+ lwc_context_string_unref(parser->ctx, name);
+
return DOM_HUBBUB_OK;
}
+/**
+ * Fetch the Document object from the parser
+ *
+ * \param parser The parser object
+ * \return the created document on success, NULL on failure
+ */
struct dom_document *dom_hubbub_parser_get_document(dom_hubbub_parser *parser)
{
struct dom_document *doc = NULL;
@@ -259,6 +305,13 @@ struct dom_document *dom_hubbub_parser_get_document(dom_hubbub_parser *parser)
return doc;
}
+/**
+ * Retrieve the encoding
+ *
+ * \param parser The parser object
+ * \param source The encoding_source
+ * \return the encoding name
+ */
const char *dom_hubbub_parser_get_encoding(dom_hubbub_parser *parser,
dom_hubbub_encoding_source *source)
{
@@ -268,8 +321,9 @@ const char *dom_hubbub_parser_get_encoding(dom_hubbub_parser *parser,
: "Windows-1252";
}
-/* The callbacks definitions */
-hubbub_error create_comment(void *parser, const hubbub_string *data,
+
+/*--------------------- The callbacks definitions --------------------*/
+static hubbub_error create_comment(void *parser, const hubbub_string *data,
void **result)
{
dom_hubbub_parser *dom_parser = (dom_hubbub_parser *) parser;
@@ -284,7 +338,7 @@ hubbub_error create_comment(void *parser, const hubbub_string *data,
if (err != DOM_NO_ERR) {
dom_parser->msg(DOM_MSG_CRITICAL, dom_parser->mctx,
"Can't create comment node text");
- return HUBBUB_NOMEM;
+ return HUBBUB_UNKNOWN;
}
err = dom_document_create_comment(dom_parser->doc, str, &comment);
@@ -293,7 +347,7 @@ hubbub_error create_comment(void *parser, const hubbub_string *data,
dom_parser->msg(DOM_MSG_CRITICAL, dom_parser->mctx,
"Can't create comment node with text '%.*s'",
data->len, data->ptr);
- return HUBBUB_NOMEM;
+ return HUBBUB_UNKNOWN;
}
*result = comment;
@@ -303,7 +357,7 @@ hubbub_error create_comment(void *parser, const hubbub_string *data,
return HUBBUB_OK;
}
-hubbub_error create_doctype(void *parser, const hubbub_doctype *doctype,
+static hubbub_error create_doctype(void *parser, const hubbub_doctype *doctype,
void **result)
{
dom_hubbub_parser *dom_parser = (dom_hubbub_parser *) parser;
@@ -350,8 +404,8 @@ hubbub_error create_doctype(void *parser, const hubbub_doctype *doctype,
}
err = dom_implementation_create_document_type(dom_parser->impl, qname,
- public_id, system_id, &dtype, dom_parser->alloc,
- dom_parser->pw);
+ public_id, system_id, dom_parser->alloc,
+ dom_parser->pw, dom_parser->ctx, &dtype);
if (err != DOM_NO_ERR) {
dom_parser->msg(DOM_MSG_CRITICAL, dom_parser->mctx,
"Can't create the document type");
@@ -371,17 +425,19 @@ clean1:
fail:
if (*result == NULL)
- return HUBBUB_NOMEM;
+ return HUBBUB_UNKNOWN;
else
return HUBBUB_OK;
}
-hubbub_error create_element(void *parser, const hubbub_tag *tag, void **result)
+static hubbub_error create_element(void *parser, const hubbub_tag *tag,
+ void **result)
{
dom_hubbub_parser *dom_parser = (dom_hubbub_parser *) parser;
dom_exception err;
struct dom_string *name;
struct dom_element *element = NULL;
+ hubbub_error herr;
*result = NULL;
@@ -412,17 +468,27 @@ hubbub_error create_element(void *parser, const hubbub_tag *tag, void **result)
}
*result = element;
+ if (element != NULL) {
+ if (tag->n_attributes != 0) {
+ herr = add_attributes(parser, element, tag->attributes,
+ tag->n_attributes);
+ if (herr != HUBBUB_OK)
+ return herr;
+ }
+ }
+
clean1:
dom_string_unref(name);
fail:
if (*result == NULL)
- return HUBBUB_NOMEM;
+ return HUBBUB_UNKNOWN;
else
return HUBBUB_OK;
}
-hubbub_error create_text(void *parser, const hubbub_string *data, void **result)
+static hubbub_error create_text(void *parser, const hubbub_string *data,
+ void **result)
{
dom_hubbub_parser *dom_parser = (dom_hubbub_parser *) parser;
dom_exception err;
@@ -453,13 +519,13 @@ clean1:
fail:
if (*result == NULL)
- return HUBBUB_NOMEM;
+ return HUBBUB_UNKNOWN;
else
return HUBBUB_OK;
}
-hubbub_error ref_node(void *parser, void *node)
+static hubbub_error ref_node(void *parser, void *node)
{
struct dom_node *dnode = (struct dom_node *) node;
@@ -470,7 +536,7 @@ hubbub_error ref_node(void *parser, void *node)
return HUBBUB_OK;
}
-hubbub_error unref_node(void *parser, void *node)
+static hubbub_error unref_node(void *parser, void *node)
{
struct dom_node *dnode = (struct dom_node *) node;
@@ -481,7 +547,8 @@ hubbub_error unref_node(void *parser, void *node)
return HUBBUB_OK;
}
-hubbub_error append_child(void *parser, void *parent, void *child, void **result)
+static hubbub_error append_child(void *parser, void *parent, void *child,
+ void **result)
{
dom_hubbub_parser *dom_parser = (dom_hubbub_parser *) parser;
dom_exception err;
@@ -493,13 +560,13 @@ hubbub_error append_child(void *parser, void *parent, void *child, void **result
dom_parser->msg(DOM_MSG_CRITICAL, dom_parser->mctx,
"Can't append child '%p' for parent '%p'",
child, parent);
- return HUBBUB_NOMEM;
+ return HUBBUB_UNKNOWN;
}
return HUBBUB_OK;
}
-hubbub_error insert_before(void *parser, void *parent, void *child,
+static hubbub_error insert_before(void *parser, void *parent, void *child,
void *ref_child, void **result)
{
dom_hubbub_parser *dom_parser = (dom_hubbub_parser *) parser;
@@ -513,13 +580,14 @@ hubbub_error insert_before(void *parser, void *parent, void *child,
dom_parser->msg(DOM_MSG_CRITICAL, dom_parser->mctx,
"Can't insert node '%p' before node '%p'",
child, ref_child);
- return HUBBUB_NOMEM;
+ return HUBBUB_UNKNOWN;
}
return HUBBUB_OK;
}
-hubbub_error remove_child(void *parser, void *parent, void *child, void **result)
+static hubbub_error remove_child(void *parser, void *parent, void *child,
+ void **result)
{
dom_hubbub_parser *dom_parser = (dom_hubbub_parser *) parser;
dom_exception err;
@@ -530,13 +598,14 @@ hubbub_error remove_child(void *parser, void *parent, void *child, void **result
if (err != DOM_NO_ERR) {
dom_parser->msg(DOM_MSG_CRITICAL, dom_parser->mctx,
"Can't remove child '%p'", child);
- return HUBBUB_NOMEM;
+ return HUBBUB_UNKNOWN;
}
return HUBBUB_OK;
}
-hubbub_error clone_node(void *parser, void *node, bool deep, void **result)
+static hubbub_error clone_node(void *parser, void *node, bool deep,
+ void **result)
{
dom_hubbub_parser *dom_parser = (dom_hubbub_parser *) parser;
dom_exception err;
@@ -546,13 +615,14 @@ hubbub_error clone_node(void *parser, void *node, bool deep, void **result)
if (err != DOM_NO_ERR) {
dom_parser->msg(DOM_MSG_CRITICAL, dom_parser->mctx,
"Can't clone node '%p'", node);
- return HUBBUB_NOMEM;
+ return HUBBUB_UNKNOWN;
}
return HUBBUB_OK;
}
-hubbub_error reparent_children(void *parser, void *node, void *new_parent)
+static hubbub_error reparent_children(void *parser, void *node,
+ void *new_parent)
{
dom_hubbub_parser *dom_parser = (dom_hubbub_parser *) parser;
dom_exception err;
@@ -564,7 +634,7 @@ hubbub_error reparent_children(void *parser, void *node, void *new_parent)
if (err != DOM_NO_ERR) {
dom_parser->msg(DOM_MSG_CRITICAL, dom_parser->mctx,
"Error in dom_note_get_first_child");
- return HUBBUB_NOMEM;
+ return HUBBUB_UNKNOWN;
}
if (child == NULL)
break;
@@ -592,10 +662,10 @@ hubbub_error reparent_children(void *parser, void *node, void *new_parent)
fail:
dom_node_unref(child);
- return HUBBUB_NOMEM;
+ return HUBBUB_UNKNOWN;
}
-hubbub_error get_parent(void *parser, void *node, bool element_only,
+static hubbub_error get_parent(void *parser, void *node, bool element_only,
void **result)
{
dom_hubbub_parser *dom_parser = (dom_hubbub_parser *) parser;
@@ -608,7 +678,7 @@ hubbub_error get_parent(void *parser, void *node, bool element_only,
if (err != DOM_NO_ERR) {
dom_parser->msg(DOM_MSG_CRITICAL, dom_parser->mctx,
"Error in dom_node_get_parent");
- return HUBBUB_NOMEM;
+ return HUBBUB_UNKNOWN;
}
if (element_only == false) {
*result = parent;
@@ -623,18 +693,20 @@ hubbub_error get_parent(void *parser, void *node, bool element_only,
}
if (type == DOM_ELEMENT_NODE) {
*result = parent;
+ return HUBBUB_OK;
} else {
*result = NULL;
dom_node_unref(parent);
+ return HUBBUB_OK;
}
return HUBBUB_OK;
fail:
dom_node_unref(parent);
- return HUBBUB_NOMEM;
+ return HUBBUB_UNKNOWN;
}
-hubbub_error has_children(void *parser, void *node, bool *result)
+static hubbub_error has_children(void *parser, void *node, bool *result)
{
dom_hubbub_parser *dom_parser = (dom_hubbub_parser *) parser;
dom_exception err;
@@ -645,13 +717,12 @@ hubbub_error has_children(void *parser, void *node, bool *result)
if (err != DOM_NO_ERR) {
dom_parser->msg(DOM_MSG_CRITICAL, dom_parser->mctx,
"Error in dom_node_has_child_nodes");
- return HUBBUB_NOMEM;
+ return HUBBUB_UNKNOWN;
}
-
return HUBBUB_OK;
}
-hubbub_error form_associate(void *parser, void *form, void *node)
+static hubbub_error form_associate(void *parser, void *form, void *node)
{
UNUSED(parser);
UNUSED(form);
@@ -660,7 +731,7 @@ hubbub_error form_associate(void *parser, void *form, void *node)
return HUBBUB_OK;
}
-hubbub_error add_attributes(void *parser, void *node,
+static hubbub_error add_attributes(void *parser, void *node,
const hubbub_attribute *attributes, uint32_t n_attributes)
{
dom_hubbub_parser *dom_parser = (dom_hubbub_parser *) parser;
@@ -719,10 +790,10 @@ hubbub_error add_attributes(void *parser, void *node,
return HUBBUB_OK;
fail:
- return HUBBUB_NOMEM;
+ return HUBBUB_UNKNOWN;
}
-hubbub_error set_quirks_mode(void *parser, hubbub_quirks_mode mode)
+static hubbub_error set_quirks_mode(void *parser, hubbub_quirks_mode mode)
{
UNUSED(parser);
UNUSED(mode);
@@ -730,7 +801,7 @@ hubbub_error set_quirks_mode(void *parser, hubbub_quirks_mode mode)
return HUBBUB_OK;
}
-hubbub_error change_encoding(void *parser, const char *charset)
+static hubbub_error change_encoding(void *parser, const char *charset)
{
dom_hubbub_parser *dom_parser = (dom_hubbub_parser *) parser;
uint32_t source;
diff --git a/bindings/hubbub/parser.h b/bindings/hubbub/parser.h
index 7e28916..8b2218d 100644
--- a/bindings/hubbub/parser.h
+++ b/bindings/hubbub/parser.h
@@ -16,6 +16,7 @@
#include "errors.h"
struct dom_document;
+struct lwc_context_s;
typedef struct dom_hubbub_parser dom_hubbub_parser;
@@ -50,7 +51,8 @@ typedef enum dom_hubub_encoding_source {
/* Create a Hubbub parser instance */
dom_hubbub_parser *dom_hubbub_parser_create(const char *aliases,
const char *enc, bool fix_enc,
- dom_alloc alloc, void *pw, dom_msg msg, void *mctx);
+ dom_alloc alloc, void *pw, dom_msg msg, void *mctx,
+ struct lwc_context_s *ctx);
/* Destroy a Hubbub parser instance */
void dom_hubbub_parser_destroy(dom_hubbub_parser *parser);
@@ -68,4 +70,5 @@ struct dom_document *dom_hubbub_parser_get_document(dom_hubbub_parser *parser);
/* Retrieve the document's encoding */
const char *dom_hubbub_parser_get_encoding(dom_hubbub_parser *parser,
dom_hubbub_encoding_source *source);
+
#endif
diff --git a/bindings/xml/Makefile b/bindings/xml/Makefile
index 6fc3c83..c5f0198 100644
--- a/bindings/xml/Makefile
+++ b/bindings/xml/Makefile
@@ -1,5 +1,5 @@
ifeq ($(WITH_LIBXML_BINDING),yes)
- DIR_SOURCES := xmlbinding.c xmlparser.c
+ DIR_SOURCES := xmlparser.c
DIR_INSTALL_ITEMS := /include/dom/bindings/libxml:xmlbinding.h;xmlerror.h;xmlparser.h
diff --git a/bindings/xml/README b/bindings/xml/README
index 0e427c7..2e70fde 100644
--- a/bindings/xml/README
+++ b/bindings/xml/README
@@ -1,18 +1,6 @@
LibXML binding for libdom
=========================
-Overview
---------
-
- This is an example binding of libxml2 to libdom. It consists of two,
- orthogonal, parts:
-
- 1) libxml push parser wrapper
- 2) libxml-specific DOMImplementationSource for libdom
-
-Push parser wrapper
--------------------
-
This is a wrapper around libxml's push parser API, to facilitate
construction of a libdom DOM tree. The basic premise is that the wrapper
intercepts the SAX events emitted by libxml's tokeniser then invokes
@@ -24,12 +12,3 @@ Push parser wrapper
DOM tree using libxml api, should it need to (e.g. for normalization
purposes).
-DOMImplementationSource
------------------------
-
- The DOMImplementationSource exposes the APIs needed to create a new
- document based upon the libxml binding. It also provides the utility
- functions that libdom uses when performing some operations (such as
- document normalization). This is needed as libdom is document language
- agnostic; therefore, it requires support from the binding to perform
- some operations.
diff --git a/bindings/xml/xmlbinding.h b/bindings/xml/xmlbinding.h
deleted file mode 100644
index 1a8c207..0000000
--- a/bindings/xml/xmlbinding.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * This file is part of libdom.
- * Licensed under the MIT License,
- * http://www.opensource.org/licenses/mit-license.php
- * Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
- */
-
-#ifndef xml_xmlbinding_h_
-#define xml_xmlbinding_h_
-
-#include "xmlerror.h"
-
-/* Initialise the XML DOM binding */
-dom_xml_error dom_xml_binding_initialise(dom_alloc alloc, void *pw);
-
-/* Finalise the XML DOM binding */
-dom_xml_error dom_xml_binding_finalise(void);
-
-#endif
diff --git a/bindings/xml/xmlparser.c b/bindings/xml/xmlparser.c
index 73fbcd1..e451699 100644
--- a/bindings/xml/xmlparser.c
+++ b/bindings/xml/xmlparser.c
@@ -7,6 +7,7 @@
#include <stdbool.h>
#include <string.h>
+#include <assert.h>
#include <libxml/parser.h>
#include <libxml/SAX2.h>
@@ -15,10 +16,14 @@
#include <dom/bootstrap/implpriv.h>
#include <dom/dom.h>
+#include <libwapcaplet/libwapcaplet.h>
+
#include "xmlerror.h"
#include "xmlparser.h"
#include "utils.h"
+#include "core/document.h"
+
static void xml_parser_start_document(void *ctx);
static void xml_parser_end_document(void *ctx);
static void xml_parser_start_element_ns(void *ctx, const xmlChar *localname,
@@ -42,6 +47,8 @@ static void xml_parser_add_cdata_section(dom_xml_parser *parser,
struct dom_node *parent, xmlNodePtr child);
static void xml_parser_add_entity_reference(dom_xml_parser *parser,
struct dom_node *parent, xmlNodePtr child);
+static void xml_parser_add_entity(dom_xml_parser *parser,
+ struct dom_node *parent, xmlNodePtr child);
static void xml_parser_add_comment(dom_xml_parser *parser,
struct dom_node *parent, xmlNodePtr child);
static void xml_parser_add_document_type(dom_xml_parser *parser,
@@ -95,8 +102,10 @@ struct dom_xml_parser {
dom_alloc alloc; /**< Memory (de)allocation function */
void *pw; /**< Pointer to client data */
- dom_msg msg; /**< Informational message function */
- void *mctx; /**< Pointer to client data */
+ dom_msg msg; /**< Informational message function */
+ void *mctx; /**< Pointer to client data */
+
+ struct lwc_context_s *ctx; /**< The lwc_context of the parser */
};
/**
@@ -153,11 +162,13 @@ static xmlSAXHandler sax_handler = {
* parser encoding is not yet implemented
*/
dom_xml_parser *dom_xml_parser_create(const char *enc, const char *int_enc,
- dom_alloc alloc, void *pw, dom_msg msg, void *mctx)
+ dom_alloc alloc, void *pw, dom_msg msg, void *mctx,
+ lwc_context *ctx)
{
dom_xml_parser *parser;
struct dom_string *features;
dom_exception err;
+ int ret;
UNUSED(enc);
UNUSED(int_enc);
@@ -176,6 +187,11 @@ dom_xml_parser *dom_xml_parser_create(const char *enc, const char *int_enc,
return NULL;
}
+ /* Set options of parsing context */
+ ret = xmlCtxtUseOptions(parser->xml_ctx, XML_PARSE_DTDATTR |
+ XML_PARSE_DTDLOAD);
+ assert(ret == 0);
+
parser->doc = NULL;
parser->complete = false;
@@ -191,7 +207,6 @@ dom_xml_parser *dom_xml_parser_create(const char *enc, const char *int_enc,
return NULL;
}
- /* Get DOM implementation */
/* Create a string representation of the features we want */
err = dom_string_create((dom_alloc) alloc, pw,
(const uint8_t *) "XML", SLEN("XML"), &features);
@@ -205,7 +220,7 @@ dom_xml_parser *dom_xml_parser_create(const char *enc, const char *int_enc,
/* Now, try to get an appropriate implementation from the registry */
err = dom_implregistry_get_dom_implementation(features,
- &parser->impl, (dom_alloc) alloc, pw);
+ &parser->impl);
if (err != DOM_NO_ERR) {
dom_string_unref(features);
dom_string_unref(parser->udkey);
@@ -215,7 +230,7 @@ dom_xml_parser *dom_xml_parser_create(const char *enc, const char *int_enc,
return NULL;
}
- /* No longer need the features string */
+ /* No longer need the feature string */
dom_string_unref(features);
parser->alloc = alloc;
@@ -224,6 +239,8 @@ dom_xml_parser *dom_xml_parser_create(const char *enc, const char *int_enc,
parser->msg = msg;
parser->mctx = mctx;
+ parser->ctx = ctx;
+
return parser;
}
@@ -240,9 +257,7 @@ void dom_xml_parser_destroy(dom_xml_parser *parser)
xmlFreeParserCtxt(parser->xml_ctx);
- /** \todo Do we want to clean up the document here, too? */
- /* Obviously, document cleanup wouldn't happen if the client has
- * claimed the document from us via xml_parser_get_document() */
+ xmlFreeDoc(parser->xml_ctx->myDoc);
parser->alloc(parser, 0, parser->pw);
}
@@ -281,6 +296,8 @@ dom_xml_error dom_xml_parser_parse_chunk(dom_xml_parser *parser,
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) {
@@ -291,6 +308,16 @@ 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".
+ */
+ lerr = lwc_context_intern(parser->ctx, "id", SLEN("id"), &name);
+ if (lerr != lwc_error_ok)
+ return _dom_exception_from_lwc_error(lerr);
+
+ _dom_document_set_id_name(parser->doc, name);
+ lwc_context_string_unref(parser->ctx, name);
+
return DOM_XML_OK;
}
@@ -326,9 +353,8 @@ void xml_parser_start_document(void *ctx)
/* namespace */ NULL,
/* qname */ NULL,
/* doctype */ NULL,
- &doc,
- (dom_alloc) parser->alloc,
- parser->pw);
+ parser->alloc, parser->pw, parser->ctx,
+ &doc);
if (err != DOM_NO_ERR) {
parser->msg(DOM_MSG_CRITICAL, parser->mctx,
"Failed creating document");
@@ -620,6 +646,9 @@ void xml_parser_add_node(dom_xml_parser *parser, struct dom_node *parent,
case XML_DTD_NODE:
xml_parser_add_document_type(parser, parent, child);
break;
+ case XML_ENTITY_DECL:
+ xml_parser_add_entity(parser, parent, child);
+ break;
default:
parser->msg(DOM_MSG_NOTICE, parser->mctx,
"Unsupported node type: %s",
@@ -647,7 +676,7 @@ void xml_parser_add_element_node(dom_xml_parser *parser,
struct dom_string *tag_name;
/* Create tag name DOM string */
- err = dom_document_create_string(parser->doc,
+ err = _dom_document_create_string(parser->doc,
child->name, strlen((const char *) child->name),
&tag_name);
if (err != DOM_NO_ERR) {
@@ -680,7 +709,7 @@ void xml_parser_add_element_node(dom_xml_parser *parser,
uint8_t qnamebuf[qnamelen + 1 /* '\0' */];
/* Create namespace DOM string */
- err = dom_document_create_string(parser->doc,
+ err = _dom_document_create_string(parser->doc,
child->ns->href,
strlen((const char *) child->ns->href),
&namespace);
@@ -699,7 +728,7 @@ void xml_parser_add_element_node(dom_xml_parser *parser,
(const char *) child->name);
/* Create qname DOM string */
- err = dom_document_create_string(parser->doc,
+ err = _dom_document_create_string(parser->doc,
qnamebuf,
qnamelen,
&qname);
@@ -738,7 +767,7 @@ void xml_parser_add_element_node(dom_xml_parser *parser,
struct dom_string *name;
/* Create attribute name DOM string */
- err = dom_document_create_string(parser->doc,
+ err = _dom_document_create_string(parser->doc,
a->name,
strlen((const char *) a->name),
&name);
@@ -754,8 +783,8 @@ void xml_parser_add_element_node(dom_xml_parser *parser,
if (err != DOM_NO_ERR) {
dom_string_unref(name);
parser->msg(DOM_MSG_CRITICAL, parser->mctx,
- "Failed creating attribute '%s'",
- a->name);
+ "Failed creating attribute \
+ '%s'", a->name);
goto cleanup;
}
@@ -772,7 +801,7 @@ void xml_parser_add_element_node(dom_xml_parser *parser,
uint8_t qnamebuf[qnamelen + 1 /* '\0' */];
/* Create namespace DOM string */
- err = dom_document_create_string(parser->doc,
+ err = _dom_document_create_string(parser->doc,
a->ns->href,
strlen((const char *) a->ns->href),
&namespace);
@@ -791,7 +820,7 @@ void xml_parser_add_element_node(dom_xml_parser *parser,
(const char *) a->name);
/* Create qname DOM string */
- err = dom_document_create_string(parser->doc,
+ err = _dom_document_create_string(parser->doc,
qnamebuf,
qnamelen,
&qname);
@@ -809,8 +838,8 @@ void xml_parser_add_element_node(dom_xml_parser *parser,
dom_string_unref(namespace);
dom_string_unref(qname);
parser->msg(DOM_MSG_CRITICAL, parser->mctx,
- "Failed creating attribute '%s'",
- qnamebuf);
+ "Failed creating attribute \
+ '%s'", qnamebuf);
return;
}
@@ -833,18 +862,31 @@ void xml_parser_add_element_node(dom_xml_parser *parser,
goto cleanup;
}
- /* And add attribute to the element */
- err = dom_element_set_attribute_node(el, attr, &prev_attr);
- if (err != DOM_NO_ERR) {
- dom_node_unref((struct dom_node *) attr);
- parser->msg(DOM_MSG_ERROR, parser->mctx,
- "Failed attaching attribute '%s'",
- a->name);
- goto cleanup;
+ if (a->ns == NULL) {
+ /* And add attribute to the element */
+ err = dom_element_set_attribute_node(el, attr,
+ &prev_attr);
+ if (err != DOM_NO_ERR) {
+ dom_node_unref((struct dom_node *) attr);
+ parser->msg(DOM_MSG_ERROR, parser->mctx,
+ "Failed attaching attribute \
+ '%s'", a->name);
+ goto cleanup;
+ }
+ } else {
+ err = dom_element_set_attribute_node_ns(el, attr,
+ &prev_attr);
+ if (err != DOM_NO_ERR) {
+ dom_node_unref((struct dom_node *) attr);
+ parser->msg(DOM_MSG_ERROR, parser->mctx,
+ "Failed attaching attribute \
+ '%s'", a->name);
+ goto cleanup;
+ }
}
/* We're not interested in the previous attribute (if any) */
- if (prev_attr != NULL)
+ if (prev_attr != NULL && prev_attr != attr)
dom_node_unref((struct dom_node *) prev_attr);
/* We're no longer interested in the attribute node */
@@ -900,7 +942,7 @@ void xml_parser_add_text_node(dom_xml_parser *parser, struct dom_node *parent,
dom_exception err;
/* Create DOM string data for text node */
- err = dom_document_create_string(parser->doc, child->content,
+ err = _dom_document_create_string(parser->doc, child->content,
strlen((const char *) child->content), &data);
if (err != DOM_NO_ERR) {
parser->msg(DOM_MSG_CRITICAL, parser->mctx,
@@ -961,7 +1003,7 @@ void xml_parser_add_cdata_section(dom_xml_parser *parser,
dom_exception err;
/* Create DOM string data for cdata section */
- err = dom_document_create_string(parser->doc, child->content,
+ err = _dom_document_create_string(parser->doc, child->content,
strlen((const char *) child->content), &data);
if (err != DOM_NO_ERR) {
parser->msg(DOM_MSG_CRITICAL, parser->mctx,
@@ -1023,7 +1065,7 @@ void xml_parser_add_entity_reference(dom_xml_parser *parser,
dom_exception err;
/* Create name of entity reference */
- err = dom_document_create_string(parser->doc, child->name,
+ err = _dom_document_create_string(parser->doc, child->name,
strlen((const char *) child->name), &name);
if (err != DOM_NO_ERR) {
parser->msg(DOM_MSG_CRITICAL, parser->mctx,
@@ -1075,6 +1117,14 @@ void xml_parser_add_entity_reference(dom_xml_parser *parser,
dom_node_unref((struct dom_node *) entity);
}
+static void xml_parser_add_entity(dom_xml_parser *parser,
+ struct dom_node *parent, xmlNodePtr child)
+{
+ UNUSED(parser);
+ UNUSED(parent);
+ UNUSED(child);
+}
+
/**
* Add a comment to the DOM
*
@@ -1090,7 +1140,7 @@ void xml_parser_add_comment(dom_xml_parser *parser, struct dom_node *parent,
dom_exception err;
/* Create DOM string data for comment */
- err = dom_document_create_string(parser->doc, child->content,
+ err = _dom_document_create_string(parser->doc, child->content,
strlen((const char *) child->content), &data);
if (err != DOM_NO_ERR) {
parser->msg(DOM_MSG_CRITICAL, parser->mctx,
@@ -1152,7 +1202,7 @@ void xml_parser_add_document_type(dom_xml_parser *parser,
dom_exception err;
/* Create qname for doctype */
- err = dom_document_create_string(parser->doc, dtd->name,
+ err = _dom_document_create_string(parser->doc, dtd->name,
strlen((const char *) dtd->name), &qname);
if (err != DOM_NO_ERR) {
parser->msg(DOM_MSG_CRITICAL, parser->mctx,
@@ -1161,7 +1211,7 @@ void xml_parser_add_document_type(dom_xml_parser *parser,
}
/* Create public ID for doctype */
- err = dom_document_create_string(parser->doc,
+ err = _dom_document_create_string(parser->doc,
dtd->ExternalID,
(dtd->ExternalID == NULL) ? 0
: strlen((const char *) dtd->ExternalID),
@@ -1174,7 +1224,7 @@ void xml_parser_add_document_type(dom_xml_parser *parser,
}
/* Create system ID for doctype */
- err = dom_document_create_string(parser->doc,
+ err = _dom_document_create_string(parser->doc,
dtd->SystemID,
(dtd->SystemID == NULL) ? 0
: strlen((const char *) dtd->SystemID),
@@ -1189,8 +1239,8 @@ void xml_parser_add_document_type(dom_xml_parser *parser,
/* Create doctype */
err = dom_implementation_create_document_type(parser->impl,
- qname, public_id, system_id, &doctype,
- (dom_alloc) parser->alloc, parser->pw);
+ qname, public_id, system_id,
+ parser->alloc, parser->pw, parser->ctx, &doctype);
if (err != DOM_NO_ERR) {
dom_string_unref(system_id);
dom_string_unref(public_id);
@@ -1231,9 +1281,8 @@ void xml_parser_add_document_type(dom_xml_parser *parser,
dom_node_unref((struct dom_node *) doctype);
}
-/* */
/* ------------------------------------------------------------------------*/
-/* */
+
void xml_parser_internal_subset(void *ctx, const xmlChar *name,
const xmlChar *ExternalID, const xmlChar *SystemID)
{
diff --git a/bindings/xml/xmlparser.h b/bindings/xml/xmlparser.h
index 7bf3807..366ceec 100644
--- a/bindings/xml/xmlparser.h
+++ b/bindings/xml/xmlparser.h
@@ -16,12 +16,14 @@
#include "xmlerror.h"
struct dom_document;
+struct lwc_context_s;
typedef struct dom_xml_parser dom_xml_parser;
/* Create an XML parser instance */
dom_xml_parser *dom_xml_parser_create(const char *enc, const char *int_enc,
- dom_alloc alloc, void *pw, dom_msg msg, void *mctx);
+ dom_alloc alloc, void *pw, dom_msg msg, void *mctx,
+ struct lwc_context_s *ctx);
/* Destroy an XML parser instance */
void dom_xml_parser_destroy(dom_xml_parser *parser);
diff --git a/include/dom/bootstrap/implpriv.h b/include/dom/bootstrap/implpriv.h
index c99a9d2..f6a7eb2 100644
--- a/include/dom/bootstrap/implpriv.h
+++ b/include/dom/bootstrap/implpriv.h
@@ -33,6 +33,7 @@
struct dom_document;
struct dom_document_type;
+struct lwc_context_s;
/**
* DOM Implementation
@@ -61,8 +62,6 @@ struct dom_implementation {
* \param public_id The external subset public identifier
* \param system_id The external subset system identifier
* \param doctype Pointer to location to receive result
- * \param alloc Memory (de)allocation function
- * \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,
@@ -83,8 +82,8 @@ struct dom_implementation {
struct dom_string *qname,
struct dom_string *public_id,
struct dom_string *system_id,
- struct dom_document_type **doctype,
- dom_alloc alloc, void *pw);
+ dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ struct dom_document_type **doctype);
/**
* Create a document node
@@ -94,8 +93,6 @@ struct dom_implementation {
* \param qname The qualified name of the document element
* \param doctype The type of document to create
* \param doc Pointer to location to receive result
- * \param alloc Memory (de)allocation function
- * \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, or if
@@ -128,8 +125,8 @@ struct dom_implementation {
struct dom_string *namespace,
struct dom_string *qname,
struct dom_document_type *doctype,
- struct dom_document **doc,
- dom_alloc alloc, void *pw);
+ dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ struct dom_document **doc);
/**
* Retrieve a specialized object which implements the specified
@@ -139,8 +136,6 @@ struct dom_implementation {
* \param feature The requested feature
* \param version The version number of the feature
* \param object Pointer to location to receive object
- * \param alloc Memory (de)allocation function
- * \param pw Pointer to client-specific private data
* \return DOM_NO_ERR.
*
* Any memory allocated by this call should be allocated using
@@ -149,8 +144,7 @@ struct dom_implementation {
dom_exception (*get_feature)(struct dom_implementation *impl,
struct dom_string *feature,
struct dom_string *version,
- void **object,
- dom_alloc alloc, void *pw);
+ void **object);
/**
* Destroy a DOM implementation instance
@@ -179,10 +173,14 @@ struct dom_implementation_list_item {
struct dom_implementation_list {
struct dom_implementation_list_item *head; /**< Head of list */
- dom_alloc alloc; /**< Memory (de)allocation function */
- void *pw; /**< Pointer to client data */
-
uint32_t refcnt; /**< Reference count */
+
+ /**
+ * Destroy a DOM implementation instance
+ *
+ * \param impl The instance to destroy
+ */
+ void (*destroy)(struct dom_implementation_list *impllist);
};
@@ -213,8 +211,7 @@ struct dom_implementation_source {
*/
dom_exception (*get_dom_implementation)(
struct dom_string *features,
- struct dom_implementation **impl,
- dom_alloc alloc, void *pw);
+ struct dom_implementation **impl);
/**
* Get a list of DOM implementations that support the requested
@@ -239,17 +236,16 @@ struct dom_implementation_source {
*/
dom_exception (*get_dom_implementation_list)(
struct dom_string *features,
- struct dom_implementation_list **list,
- dom_alloc alloc, void *pw);
+ struct dom_implementation_list **list);
};
/* Register a source with the DOM library */
-dom_exception dom_register_source(struct dom_implementation_source *source,
- dom_alloc alloc, void *pw);
+dom_exception dom_register_source(struct dom_implementation_source *source);
/* Create a DOM document */
dom_exception dom_document_create(struct dom_implementation *impl,
- dom_alloc alloc, void *pw, struct dom_document **doc);
+ dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ struct dom_document **doc);
/* Set a document's buffer */
void dom_document_set_buffer(struct dom_document *doc, uint8_t *buffer,
@@ -259,7 +255,7 @@ void dom_document_set_buffer(struct dom_document *doc, uint8_t *buffer,
dom_exception dom_document_type_create(struct dom_string *qname,
struct dom_string *public_id,
struct dom_string *system_id,
- dom_alloc alloc, void *pw,
+ dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
struct dom_document_type **doctype);
#endif
diff --git a/include/dom/bootstrap/implregistry.h b/include/dom/bootstrap/implregistry.h
index 1e93ea6..e14738c 100644
--- a/include/dom/bootstrap/implregistry.h
+++ b/include/dom/bootstrap/implregistry.h
@@ -15,16 +15,18 @@ struct dom_implementation;
struct dom_implementation_list;
struct dom_string;
+/* Initialise the implementation registry */
+dom_exception dom_implregistry_initialise(
+ dom_alloc allocator, void *ptr);
+
/* Retrieve a DOM implementation from the registry */
dom_exception dom_implregistry_get_dom_implementation(
struct dom_string *features,
- struct dom_implementation **impl,
- dom_alloc alloc, void *pw);
+ struct dom_implementation **impl);
/* Get a list of DOM implementations that support the requested features */
dom_exception dom_implregistry_get_dom_implementation_list(
struct dom_string *features,
- struct dom_implementation_list **list,
- dom_alloc alloc, void *pw);
+ struct dom_implementation_list **list);
#endif
diff --git a/include/dom/core/attr.h b/include/dom/core/attr.h
index b0d98c1..7ac3956 100644
--- a/include/dom/core/attr.h
+++ b/include/dom/core/attr.h
@@ -27,12 +27,13 @@ typedef struct dom_attr_vtable {
dom_exception (*dom_attr_get_name)(struct dom_attr *attr,
struct dom_string **result);
- dom_exception (*dom_attr_get_specified)(struct dom_attr *attr, bool *result);
+ dom_exception (*dom_attr_get_specified)(struct dom_attr *attr,
+ bool *result);
dom_exception (*dom_attr_get_value)(struct dom_attr *attr,
struct dom_string **result);
dom_exception (*dom_attr_set_value)(struct dom_attr *attr,
struct dom_string *value);
- dom_exception (*dom_attr_get_owner)(struct dom_attr *attr,
+ dom_exception (*dom_attr_get_owner_element)(struct dom_attr *attr,
struct dom_element **result);
dom_exception (*dom_attr_get_schema_type_info)(struct dom_attr *attr,
struct dom_type_info **result);
@@ -48,7 +49,8 @@ static inline dom_exception dom_attr_get_name(struct dom_attr *attr,
#define dom_attr_get_name(a, r) dom_attr_get_name((struct dom_attr *) (a), \
(struct dom_string **) (r))
-static inline dom_exception dom_attr_get_specified(struct dom_attr *attr, bool *result)
+static inline dom_exception dom_attr_get_specified(struct dom_attr *attr,
+ bool *result)
{
return ((dom_attr_vtable *) ((dom_node *) attr)->vtable)->
dom_attr_get_specified(attr, result);
@@ -74,17 +76,17 @@ static inline dom_exception dom_attr_set_value(struct dom_attr *attr,
#define dom_attr_set_value(a, v) dom_attr_set_value((struct dom_attr *) (a), \
(struct dom_string *) (v))
-static inline dom_exception dom_attr_get_owner(struct dom_attr *attr,
+static inline dom_exception dom_attr_get_owner_element(struct dom_attr *attr,
struct dom_element **result)
{
return ((dom_attr_vtable *) ((dom_node *) attr)->vtable)->
- dom_attr_get_owner(attr, result);
+ dom_attr_get_owner_element(attr, result);
}
-#define dom_attr_get_owner(a, r) dom_attr_get_owner((struct dom_attr *) (a), \
- (struct dom_element **) (r))
+#define dom_attr_get_owner_element(a, r) dom_attr_get_owner_element(\
+ (struct dom_attr *) (a), (struct dom_element **) (r))
-static inline dom_exception dom_attr_get_schema_type_info(struct dom_attr *attr,
- struct dom_type_info **result)
+static inline dom_exception dom_attr_get_schema_type_info(
+ struct dom_attr *attr, struct dom_type_info **result)
{
return ((dom_attr_vtable *) ((dom_node *) attr)->vtable)->
dom_attr_get_schema_type_info(attr, result);
diff --git a/include/dom/core/characterdata.h b/include/dom/core/characterdata.h
index de65c5a..745407c 100644
--- a/include/dom/core/characterdata.h
+++ b/include/dom/core/characterdata.h
@@ -113,7 +113,7 @@ static inline dom_exception dom_characterdata_delete_data(
return ((dom_characterdata_vtable *) ((dom_node *) cdata)->vtable)->
dom_characterdata_delete_data(cdata, offset, count);
}
-#define dom_characterdata_delete_data(c, o, ct) dom_characterdata_delete_data( \
+#define dom_characterdata_delete_data(c, o, ct) dom_characterdata_delete_data(\
(struct dom_characterdata *) (c), (unsigned long) (o), \
(unsigned long) (ct))
@@ -126,8 +126,8 @@ static inline dom_exception dom_characterdata_replace_data(
data);
}
#define dom_characterdata_replace_data(c, o, ct, d) \
- dom_characterdata_replace_data((struct dom_characterdata *) (c),\
- (unsigned long) (o), (unsigned long) (ct), \
- (struct dom_string *) (d))
+ dom_characterdata_replace_data(\
+ (struct dom_characterdata *) (c), (unsigned long) (o),\
+ (unsigned long) (ct), (struct dom_string *) (d))
#endif
diff --git a/include/dom/core/comment.h b/include/dom/core/comment.h
new file mode 100644
index 0000000..43b48c2
--- /dev/null
+++ b/include/dom/core/comment.h
@@ -0,0 +1,18 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+ */
+
+#ifndef dom_core_comment_h_
+#define dom_core_comment_h_
+
+#include <stdbool.h>
+
+#include <dom/core/exceptions.h>
+#include <dom/core/characterdata.h>
+
+typedef struct dom_comment dom_comment;
+
+#endif
diff --git a/include/dom/core/document.h b/include/dom/core/document.h
index 193c084..1fe9752 100644
--- a/include/dom/core/document.h
+++ b/include/dom/core/document.h
@@ -9,6 +9,8 @@
#define dom_core_document_h_
#include <stdbool.h>
+#include <inttypes.h>
+#include <stddef.h>
#include <stdint.h>
#include <dom/core/exceptions.h>
@@ -29,6 +31,7 @@ struct dom_nodelist;
struct dom_processing_instruction;
struct dom_string;
struct dom_text;
+struct lwc_string_s;
typedef struct dom_document dom_document;
@@ -114,9 +117,6 @@ typedef struct dom_document_vtable {
struct dom_string *qname, struct dom_node **result);
} dom_document_vtable;
-dom_exception dom_document_create_string(struct dom_document *doc,
- const uint8_t *data, size_t len, struct dom_string **result);
-
static inline dom_exception dom_document_get_doctype(struct dom_document *doc,
struct dom_document_type **result)
{
diff --git a/include/dom/core/element.h b/include/dom/core/element.h
index c56e32c..4cffa2c 100644
--- a/include/dom/core/element.h
+++ b/include/dom/core/element.h
@@ -46,8 +46,9 @@ typedef struct dom_element_vtable {
struct dom_nodelist **result);
dom_exception (*dom_element_get_attribute_ns)(
struct dom_element *element,
- struct dom_string *namespace,
- struct dom_string *localname, struct dom_string **value);
+ struct dom_string *namespace,
+ struct dom_string *localname,
+ struct dom_string **value);
dom_exception (*dom_element_set_attribute_ns)(
struct dom_element *element,
struct dom_string *namespace, struct dom_string *qname,
@@ -211,7 +212,7 @@ static inline dom_exception dom_element_remove_attribute_ns(
dom_element_remove_attribute_ns(element, namespace,
localname);
}
-#define dom_element_remove_attribute_ns(e, n, l, v) \
+#define dom_element_remove_attribute_ns(e, n, l) \
dom_element_remove_attribute_ns((dom_element *) (e), \
(struct dom_string *) (n), (struct dom_string *) (l))
diff --git a/include/dom/core/exceptions.h b/include/dom/core/exceptions.h
index 18a2b6e..fc5e247 100644
--- a/include/dom/core/exceptions.h
+++ b/include/dom/core/exceptions.h
@@ -28,7 +28,8 @@ typedef enum {
DOM_INVALID_ACCESS_ERR = 15,
DOM_VALIDATION_ERR = 16,
DOM_TYPE_MISMATCH_ERR = 17,
- DOM_NO_MEM_ERR = (1<<16) /* our own internal error */
+ DOM_NO_MEM_ERR = (1<<16)
+ /* our own internal error */
} dom_exception;
#endif
diff --git a/include/dom/core/implementation.h b/include/dom/core/implementation.h
index d8959e6..cb95f84 100644
--- a/include/dom/core/implementation.h
+++ b/include/dom/core/implementation.h
@@ -30,20 +30,19 @@ dom_exception dom_implementation_has_feature(
dom_exception dom_implementation_create_document_type(
struct dom_implementation *impl, struct dom_string *qname,
struct dom_string *public_id, struct dom_string *system_id,
- struct dom_document_type **doctype,
- dom_alloc alloc, void *pw);
+ dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ struct dom_document_type **doctype);
dom_exception dom_implementation_create_document(
struct dom_implementation *impl,
struct dom_string *namespace, struct dom_string *qname,
struct dom_document_type *doctype,
- struct dom_document **doc,
- dom_alloc alloc, void *pw);
+ dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ struct dom_document **doc);
dom_exception dom_implementation_get_feature(
struct dom_implementation *impl,
struct dom_string *feature, struct dom_string *version,
- void **object,
- dom_alloc alloc, void *pw);
+ void **object);
#endif
diff --git a/include/dom/core/namednodemap.h b/include/dom/core/namednodemap.h
index fd2b754..a39983e 100644
--- a/include/dom/core/namednodemap.h
+++ b/include/dom/core/namednodemap.h
@@ -43,7 +43,7 @@ dom_exception _dom_namednodemap_remove_named_item(
#define dom_namednodemap_remove_named_item(m, n, r) \
_dom_namednodemap_remove_named_item((dom_namednodemap *) (m), \
- (dom_string *) (n), (dom_node **) (n))
+ (dom_string *) (n), (dom_node **) (r))
dom_exception _dom_namednodemap_item(struct dom_namednodemap *map,
@@ -60,7 +60,7 @@ dom_exception _dom_namednodemap_get_named_item_ns(
#define dom_namednodemap_get_named_item_ns(m, n, l, r) \
_dom_namednodemap_get_named_item_ns((dom_namednodemap *) (m), \
- (dom_string *) (n), (dom_string *) (l), (dom_node **) (n))
+ (dom_string *) (n), (dom_string *) (l), (dom_node **) (r))
dom_exception _dom_namednodemap_set_named_item_ns(
@@ -77,7 +77,8 @@ dom_exception _dom_namednodemap_remove_named_item_ns(
struct dom_string *localname, struct dom_node **node);
#define dom_namednodemap_remove_named_item_ns(m, n, l, r) \
- _dom_namednodemap_remove_named_item_ns((dom_namednodemap *) (m), \
- (dom_string *) (n), (dom_string *) (l), (dom_node **) (r))
+ _dom_namednodemap_remove_named_item_ns(\
+ (dom_namednodemap *) (m), (dom_string *) (n),\
+ (dom_string *) (l), (dom_node **) (r))
#endif
diff --git a/include/dom/core/node.h b/include/dom/core/node.h
index f525d0b..5e2d89a 100644
--- a/include/dom/core/node.h
+++ b/include/dom/core/node.h
@@ -127,7 +127,7 @@ typedef struct dom_node_vtable {
dom_node_internal **result);
dom_exception (*dom_node_normalize)(dom_node_internal *node);
dom_exception (*dom_node_is_supported)(dom_node_internal *node,
- struct dom_string *feature, dom_node_internal *version,
+ struct dom_string *feature, struct dom_string *version,
bool *result);
dom_exception (*dom_node_get_namespace)(dom_node_internal *node,
struct dom_string **result);
@@ -250,10 +250,11 @@ static inline dom_exception dom_node_get_last_child(struct dom_node *node,
#define dom_node_get_last_child(n, r) dom_node_get_last_child( \
(dom_node *) (n), (dom_node **) (r))
-static inline dom_exception dom_node_get_previous_sibling(struct dom_node *node,
- dom_node **result)
+static inline dom_exception dom_node_get_previous_sibling(
+ struct dom_node *node, dom_node **result)
{
- return ((dom_node_vtable *) node->vtable)->dom_node_get_previous_sibling(
+ return ((dom_node_vtable *) node->vtable)->
+ dom_node_get_previous_sibling(
(dom_node_internal *) node,
(dom_node_internal **) result);
}
@@ -367,16 +368,16 @@ static inline dom_exception dom_node_normalize(struct dom_node *node)
#define dom_node_normalize(n) dom_node_normalize((dom_node *) (n))
static inline dom_exception dom_node_is_supported(struct dom_node *node,
- struct dom_string *feature, struct dom_node *version,
+ struct dom_string *feature, struct dom_string *version,
bool *result)
{
return ((dom_node_vtable *) node->vtable)->dom_node_is_supported(
(dom_node_internal *) node, feature,
- (dom_node_internal *) version, result);
+ version, result);
}
#define dom_node_is_supported(n, f, v, r) dom_node_is_supported( \
- (dom_node *) (n), (struct dom_string *) (f), (dom_node *) (v),\
- (bool *) (r))
+ (dom_node *) (n), (struct dom_string *) (f), \
+ (struct dom_string *) (v), (bool *) (r))
static inline dom_exception dom_node_get_namespace(struct dom_node *node,
struct dom_string **result)
@@ -385,7 +386,7 @@ static inline dom_exception dom_node_get_namespace(struct dom_node *node,
(dom_node_internal *) node, result);
}
#define dom_node_get_namespace(n, r) dom_node_get_namespace((dom_node *) (n), \
- (struct dom_string *) (r))
+ (struct dom_string **) (r))
static inline dom_exception dom_node_get_prefix(struct dom_node *node,
struct dom_string **result)
@@ -394,7 +395,7 @@ static inline dom_exception dom_node_get_prefix(struct dom_node *node,
(dom_node_internal *) node, result);
}
#define dom_node_get_prefix(n, r) dom_node_get_prefix((dom_node *) (n), \
- (struct dom_string *) (r))
+ (struct dom_string **) (r))
static inline dom_exception dom_node_set_prefix(struct dom_node *node,
struct dom_string *prefix)
@@ -412,7 +413,7 @@ static inline dom_exception dom_node_get_local_name(struct dom_node *node,
(dom_node_internal *) node, result);
}
#define dom_node_get_local_name(n, r) dom_node_get_local_name((dom_node *) (n),\
- (struct dom_string *) (r))
+ (struct dom_string **) (r))
static inline dom_exception dom_node_has_attributes(struct dom_node *node,
bool *result)
@@ -436,9 +437,10 @@ static inline dom_exception dom_node_compare_document_position(
struct dom_node *node, struct dom_node *other,
uint16_t *result)
{
- return ((dom_node_vtable *) node->vtable)->dom_node_compare_document_position(
- (dom_node_internal *) node, (dom_node_internal *) other,
- result);
+ return ((dom_node_vtable *) node->vtable)->
+ dom_node_compare_document_position(
+ (dom_node_internal *) node,
+ (dom_node_internal *) other, result);
}
#define dom_node_compare_document_position(n, o, r) \
dom_node_compare_document_position((dom_node *) (n), \
@@ -483,13 +485,15 @@ static inline dom_exception dom_node_lookup_prefix(struct dom_node *node,
(dom_node *) (n), (struct dom_string *) (ns), \
(struct dom_string **) (r))
-static inline dom_exception dom_node_is_default_namespace(struct dom_node *node,
- struct dom_string *namespace, bool *result)
+static inline dom_exception dom_node_is_default_namespace(
+ struct dom_node *node, struct dom_string *namespace,
+ bool *result)
{
- return ((dom_node_vtable *) node->vtable)->dom_node_is_default_namespace(
+ return ((dom_node_vtable *) node->vtable)->
+ dom_node_is_default_namespace(
(dom_node_internal *) node, namespace, result);
}
-#define dom_node_is_default_namesapce(n, ns, r) dom_node_is_default_namespace(\
+#define dom_node_is_default_namespace(n, ns, r) dom_node_is_default_namespace(\
(dom_node *) (n), (struct dom_string *) (ns), (bool *) (r))
static inline dom_exception dom_node_lookup_namespace(struct dom_node *node,
diff --git a/include/dom/core/string.h b/include/dom/core/string.h
index 37d78d6..2502623 100644
--- a/include/dom/core/string.h
+++ b/include/dom/core/string.h
@@ -10,10 +10,12 @@
#include <inttypes.h>
#include <stddef.h>
+#include <libwapcaplet/libwapcaplet.h>
#include <dom/functypes.h>
#include <dom/core/exceptions.h>
+
typedef struct dom_string dom_string;
/* Claim a reference on a DOM string */
@@ -25,6 +27,14 @@ void dom_string_unref(struct dom_string *str);
dom_exception dom_string_create(dom_alloc alloc, void *pw,
const uint8_t *ptr, size_t len, struct dom_string **str);
+/* Clone a dom_string */
+dom_exception dom_string_clone(dom_alloc alloc, void *pw,
+ struct dom_string *str, struct dom_string **ret);
+
+/* Get the internal lwc_string */
+dom_exception dom_string_get_intern(struct dom_string *str,
+ struct lwc_context_s **ctx, struct lwc_string_s **lwcstr);
+
/* Case sensitively compare two DOM strings */
int dom_string_cmp(struct dom_string *s1, struct dom_string *s2);
/* Case insensitively compare two DOM strings */
@@ -38,6 +48,12 @@ uint32_t dom_string_rindex(struct dom_string *str, uint32_t chr);
/* Get the length, in characters, of a dom string */
uint32_t dom_string_length(struct dom_string *str);
+/* Get the UCS-4 character at position index, the index should be in
+ * [0, length), and length can be get by calling dom_string_length
+ */
+dom_exception dom_string_at(struct dom_string *str, uint32_t index,
+ uint32_t *ch);
+
/* Concatenate two dom strings */
dom_exception dom_string_concat(struct dom_string *s1, struct dom_string *s2,
struct dom_string **result);
diff --git a/include/dom/core/typeinfo.h b/include/dom/core/typeinfo.h
new file mode 100644
index 0000000..f285799
--- /dev/null
+++ b/include/dom/core/typeinfo.h
@@ -0,0 +1,48 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+ */
+
+#ifndef dom_core_typeinfo_h_
+#define dom_core_typeinfo_h_
+
+#include <stdbool.h>
+
+#include <dom/core/exceptions.h>
+
+struct dom_string;
+
+typedef struct dom_type_info dom_type_info;
+
+typedef enum {
+ DOM_TYPE_INFO_DERIVATION_RESTRICTION = 0x00000001,
+ DOM_TYPE_INFO_DERIVATION_EXTENSION = 0x00000002,
+ DOM_TYPE_INFO_DERIVATION_UNION = 0x00000004,
+ DOM_TYPE_INFO_DERIVATION_LIST = 0x00000008
+} dom_type_info_derivation_method;
+
+dom_exception _dom_type_info_get_type_name(dom_type_info *ti,
+ struct dom_string **ret);
+#define dom_type_info_get_type_name(t, r) _dom_type_info_get_type_name( \
+ (dom_type_info *) (t), (struct dom_string **) (r))
+
+
+dom_exception _dom_type_info_get_type_namespace(dom_type_info *ti,
+ struct dom_string **ret);
+#define dom_type_info_get_type_namespace(t, r) \
+ _dom_type_info_get_type_namespace((dom_type_info *) (t),\
+ (struct dom_string **) (r))
+
+
+dom_exception _dom_type_info_is_derived(dom_type_info *ti,
+ struct dom_string *namespace, struct dom_string *name,
+ dom_type_info_derivation_method method, bool *ret);
+#define dom_type_info_is_derived(t, s, n, m, r) _dom_type_info_is_derived(\
+ (dom_type_info *) (t), (struct dom_string *) (s), \
+ (struct dom_string *) (n), \
+ (dom_type_info_derivation_method) (m), (bool *) (r))
+
+
+#endif
diff --git a/include/dom/dom.h b/include/dom/dom.h
index 286a51b..7a882b8 100644
--- a/include/dom/dom.h
+++ b/include/dom/dom.h
@@ -38,17 +38,19 @@
#include <dom/core/string.h>
#include <dom/core/text.h>
#include <dom/core/pi.h>
+#include <dom/core/typeinfo.h>
+#include <dom/core/comment.h>
typedef enum dom_namespace {
- DOM_NAMESPACE_NULL = 0,
- DOM_NAMESPACE_HTML = 1,
- DOM_NAMESPACE_MATHML = 2,
- DOM_NAMESPACE_SVG = 3,
- DOM_NAMESPACE_XLINK = 4,
- DOM_NAMESPACE_XML = 5,
- DOM_NAMESPACE_XMLNS = 6,
-
- DOM_NAMESPACE_COUNT = 7
+ DOM_NAMESPACE_NULL = 0,
+ DOM_NAMESPACE_HTML = 1,
+ DOM_NAMESPACE_MATHML = 2,
+ DOM_NAMESPACE_SVG = 3,
+ DOM_NAMESPACE_XLINK = 4,
+ DOM_NAMESPACE_XML = 5,
+ DOM_NAMESPACE_XMLNS = 6,
+
+ DOM_NAMESPACE_COUNT = 7
} dom_namespace;
extern struct dom_string *dom_namespaces[DOM_NAMESPACE_COUNT];
diff --git a/src/bootstrap/Makefile b/src/bootstrap/Makefile
index 820a4f4..e969d87 100644
--- a/src/bootstrap/Makefile
+++ b/src/bootstrap/Makefile
@@ -1,3 +1,3 @@
-DIR_SOURCES := implregistry.c init_fini.c
+DIR_SOURCES := implregistry.c init_fini.c implementation.c
include build/makefiles/Makefile.subdir
diff --git a/bindings/xml/xmlbinding.c b/src/bootstrap/implementation.c
index b03b7af..d14fa5b 100644
--- a/bindings/xml/xmlbinding.c
+++ b/src/bootstrap/implementation.c
@@ -3,68 +3,82 @@
* Licensed under the MIT License,
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+ */
+
+/**
+ * Note: The DOMImplementation Object here is a singleton object. It is
+ * initialised when the libDOM is initialised, it registers itself into
+ * the implreg and clients of it can get it by calling:
+ *
+ * dom_implregistry_get_dom_implementation or
+ * dom_implregistry_get_dom_implementation_list
+ *
*/
#include <dom/bootstrap/implpriv.h>
#include <dom/bootstrap/implregistry.h>
#include <dom/dom.h>
-#include "xmlbinding.h"
-#include "utils.h"
+#include <libwapcaplet/libwapcaplet.h>
+
+#include "core/node.h"
+#include "core/document_type.h"
+
+#include "utils/utils.h"
+#include "utils/validate.h"
+#include "utils/namespace.h"
-static dom_exception xml_dom_get_dom_implementation(
+#include "bootstrap/implementation.h"
+
+static dom_alloc _alloc;
+static void *_pw;
+
+static dom_exception impl_get_dom_implementation(
struct dom_string *features,
- struct dom_implementation **impl, dom_alloc alloc, void *pw);
-static dom_exception xml_dom_get_dom_implementation_list(
+ struct dom_implementation **impl);
+static dom_exception impl_get_dom_implementation_list(
struct dom_string *features,
- struct dom_implementation_list **list,
- dom_alloc alloc, void *pw);
+ struct dom_implementation_list **list);
-static dom_exception xml_dom_implementation_has_feature(
+static dom_exception impl_implementation_has_feature(
struct dom_implementation *impl,
struct dom_string *feature,
struct dom_string *version,
bool *result);
-static dom_exception xml_dom_implementation_create_document_type(
+static dom_exception impl_implementation_create_document_type(
struct dom_implementation *impl,
struct dom_string *qname,
struct dom_string *public_id,
struct dom_string *system_id,
- struct dom_document_type **doctype,
- dom_alloc alloc, void *pw);
-static dom_exception xml_dom_implementation_create_document(
+ dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ struct dom_document_type **doctype);
+static dom_exception impl_implementation_create_document(
struct dom_implementation *impl,
struct dom_string *namespace,
struct dom_string *qname,
struct dom_document_type *doctype,
- struct dom_document **doc,
- dom_alloc alloc, void *pw);
-static dom_exception xml_dom_implementation_get_feature(
+ dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ struct dom_document **doc);
+static dom_exception impl_implementation_get_feature(
struct dom_implementation *impl,
struct dom_string *feature,
struct dom_string *version,
- void **object,
- dom_alloc alloc, void *pw);
-static void xml_dom_implementation_destroy(struct dom_implementation *impl);
+ void **object);
+static void dom_implementation_destroy(struct dom_implementation *impl);
-/**
- * DOM implementation source for XML documents
- */
-static struct dom_implementation_source xml_dom_impl_src = {
- xml_dom_get_dom_implementation,
- xml_dom_get_dom_implementation_list
+static struct dom_implementation_source dom_impl_src = {
+ impl_get_dom_implementation,
+ impl_get_dom_implementation_list
};
-/**
- * DOM implementation for XML documents
- */
-static struct dom_implementation xml_dom_impl = {
- xml_dom_implementation_has_feature,
- xml_dom_implementation_create_document_type,
- xml_dom_implementation_create_document,
- xml_dom_implementation_get_feature,
- xml_dom_implementation_destroy,
+static struct dom_implementation dom_impl = {
+ impl_implementation_has_feature,
+ impl_implementation_create_document_type,
+ impl_implementation_create_document,
+ impl_implementation_get_feature,
+ dom_implementation_destroy,
0
};
@@ -73,8 +87,6 @@ static struct dom_implementation xml_dom_impl = {
*
* \param features String containing required features
* \param impl Pointer to location to receive implementation
- * \param alloc Function to (de)allocate memory
- * \param pw Pointer to client-specific private data
* \return DOM_NO_ERR on success, DOM_NO_MEM_ERR on memory exhaustion
*
* Any memory allocated by this call should be allocated using
@@ -85,17 +97,15 @@ static struct dom_implementation xml_dom_impl = {
* do this explicitly. The client must unref the implementation
* once it has finished with it.
*/
-dom_exception xml_dom_get_dom_implementation(
+dom_exception impl_get_dom_implementation(
struct dom_string *features,
- struct dom_implementation **impl, dom_alloc alloc, void *pw)
+ struct dom_implementation **impl)
{
UNUSED(features);
- UNUSED(alloc);
- UNUSED(pw);
- xml_dom_impl.refcnt++;
+ dom_impl.refcnt++;
- *impl = &xml_dom_impl;
+ *impl = &dom_impl;
return DOM_NO_ERR;
}
@@ -106,8 +116,6 @@ dom_exception xml_dom_get_dom_implementation(
*
* \param features String containing required features
* \param list Pointer to location to receive list
- * \param alloc Function to (de)allocate memory
- * \param pw Pointer to client-specific private data
* \return DOM_NO_ERR on success, DOM_NO_MEM_ERR on memory exhaustion
*
* Any memory allocated by this call should be allocated using
@@ -121,33 +129,30 @@ dom_exception xml_dom_get_dom_implementation(
* explicitly. The client must unref the list once it has finished
* with it.
*/
-dom_exception xml_dom_get_dom_implementation_list(
+dom_exception impl_get_dom_implementation_list(
struct dom_string *features,
- struct dom_implementation_list **list,
- dom_alloc alloc, void *pw)
+ struct dom_implementation_list **list)
{
struct dom_implementation_list *l;
struct dom_implementation_list_item *i;
UNUSED(features);
- l = alloc(NULL, sizeof(struct dom_implementation_list), pw);
+ l = _alloc(NULL, sizeof(struct dom_implementation_list), _pw);
if (l == NULL)
return DOM_NO_MEM_ERR;
- i = alloc(NULL, sizeof(struct dom_implementation_list_item), pw);
+ i = _alloc(NULL, sizeof(struct dom_implementation_list_item), _pw);
if (i == NULL) {
- alloc(l, 0, pw);
+ _alloc(l, 0, _pw);
return DOM_NO_MEM_ERR;
}
- i->impl = &xml_dom_impl;
+ i->impl = &dom_impl;
i->next = NULL;
i->prev = NULL;
l->head = i;
- l->alloc = alloc;
- l->pw = pw;
l->refcnt = 1;
@@ -166,7 +171,7 @@ dom_exception xml_dom_get_dom_implementation_list(
* \param result Pointer to location to receive result
* \return DOM_NO_ERR.
*/
-dom_exception xml_dom_implementation_has_feature(
+dom_exception impl_implementation_has_feature(
struct dom_implementation *impl,
struct dom_string *feature,
struct dom_string *version,
@@ -188,8 +193,6 @@ dom_exception xml_dom_implementation_has_feature(
* \param public_id The external subset public identifier
* \param system_id The external subset system identifier
* \param doctype Pointer to location to receive result
- * \param alloc Memory (de)allocation function
- * \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.
@@ -201,29 +204,42 @@ dom_exception xml_dom_implementation_has_feature(
* explicitly. The client must unref the doctype once it has
* finished with it.
*/
-dom_exception xml_dom_implementation_create_document_type(
+dom_exception impl_implementation_create_document_type(
struct dom_implementation *impl,
struct dom_string *qname,
struct dom_string *public_id,
struct dom_string *system_id,
- struct dom_document_type **doctype,
- dom_alloc alloc, void *pw)
+ dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ struct dom_document_type **doctype)
{
struct dom_document_type *d;
+ struct dom_string *prefix = NULL, *lname = NULL;
dom_exception err;
- /* We have no use for the impl -- we only have one */
UNUSED(impl);
- /** \todo validate qname */
+ if (qname != NULL && _dom_validate_name(qname) == false)
+ return DOM_INVALID_CHARACTER_ERR;
+
+ err = _dom_namespace_split_qname(qname, &prefix, &lname);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ if ((prefix != NULL && _dom_validate_ncname(prefix) == false) ||
+ (lname != NULL && _dom_validate_ncname(lname) == false))
+ return DOM_NAMESPACE_ERR;
/* Create the doctype */
err = dom_document_type_create(qname, public_id, system_id,
- alloc, pw, &d);
+ alloc, pw, ctx, &d);
if (err != DOM_NO_ERR)
return err;
*doctype = d;
+ if (prefix != NULL)
+ dom_string_unref(prefix);
+ if (lname != NULL)
+ dom_string_unref(lname);
return DOM_NO_ERR;
}
@@ -236,8 +252,6 @@ dom_exception xml_dom_implementation_create_document_type(
* \param qname The qualified name of the document element
* \param doctype The type of document to create
* \param doc Pointer to location to receive result
- * \param alloc Memory (de)allocation function
- * \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, or if
@@ -266,19 +280,33 @@ dom_exception xml_dom_implementation_create_document_type(
* explicitly. The client must unref the document once it has
* finished with it.
*/
-dom_exception xml_dom_implementation_create_document(
+dom_exception impl_implementation_create_document(
struct dom_implementation *impl,
struct dom_string *namespace,
struct dom_string *qname,
struct dom_document_type *doctype,
- struct dom_document **doc,
- dom_alloc alloc, void *pw)
+ dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ struct dom_document **doc)
{
struct dom_document *d;
dom_exception err;
+ if (qname != NULL && _dom_validate_name(qname) == false)
+ return DOM_INVALID_CHARACTER_ERR;
+
+ err = _dom_namespace_validate_qname(qname, namespace);
+ if (err != DOM_NO_ERR)
+ return DOM_NAMESPACE_ERR;
+
+ if (doctype != NULL) {
+ if (dom_node_get_parent(doctype) != NULL ||
+ _dom_document_type_get_impl(doctype) !=
+ impl)
+ return DOM_WRONG_DOCUMENT_ERR;
+ }
+
/* Create document object */
- err = dom_document_create(impl, alloc, pw, &d);
+ err = dom_document_create(impl, alloc, pw, ctx, &d);
if (err != DOM_NO_ERR)
return err;
@@ -337,26 +365,21 @@ dom_exception xml_dom_implementation_create_document(
* \param feature The requested feature
* \param version The version number of the feature
* \param object Pointer to location to receive object
- * \param alloc Memory (de)allocation function
- * \param pw Pointer to client-specific private data
* \return DOM_NO_ERR.
*
* Any memory allocated by this call should be allocated using
* the provided memory (de)allocation function.
*/
-dom_exception xml_dom_implementation_get_feature(
+dom_exception impl_implementation_get_feature(
struct dom_implementation *impl,
struct dom_string *feature,
struct dom_string *version,
- void **object,
- dom_alloc alloc, void *pw)
+ void **object)
{
UNUSED(impl);
UNUSED(feature);
UNUSED(version);
UNUSED(object);
- UNUSED(alloc);
- UNUSED(pw);
return DOM_NOT_SUPPORTED_ERR;
}
@@ -366,7 +389,7 @@ dom_exception xml_dom_implementation_get_feature(
*
* \param impl The instance to destroy
*/
-void xml_dom_implementation_destroy(struct dom_implementation *impl)
+void dom_implementation_destroy(struct dom_implementation *impl)
{
UNUSED(impl);
@@ -374,31 +397,27 @@ void xml_dom_implementation_destroy(struct dom_implementation *impl)
}
/**
- * Initialise the XML DOM binding
+ * Initialise the DOM implementation
*
* \param alloc Pointer to memory (de)allocation function
* \param pw Pointer to client-specific private data
- * \return DOM_XML_OK on success, DOM_XML_NOMEM on memory exhaustion
+ * \return DOM_NO_ERR on success
*/
-dom_xml_error dom_xml_binding_initialise(dom_alloc alloc, void *pw)
+dom_exception _dom_implementation_initialise(dom_alloc alloc, void *pw)
{
- dom_exception err;
+ _alloc = alloc;
+ _pw = pw;
- err = dom_register_source(&xml_dom_impl_src, alloc, pw);
- if (err != DOM_NO_ERR)
- return DOM_XML_NOMEM;
-
- return DOM_XML_OK;
+ return dom_register_source(&dom_impl_src);
}
/**
- * Finalise the XML DOM binding
- *
- * \return DOM_XML_OK on success.
+ * Finalise the DOM implementation
*/
-dom_xml_error dom_xml_binding_finalise(void)
+void _dom_implementation_finalise(void)
{
- return DOM_XML_OK;
+ _alloc = NULL;
+ _pw = NULL;
}
diff --git a/src/bootstrap/implementation.h b/src/bootstrap/implementation.h
new file mode 100644
index 0000000..f62077c
--- /dev/null
+++ b/src/bootstrap/implementation.h
@@ -0,0 +1,14 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+ */
+
+#ifndef dom_bootstrap_implementation_h_
+#define dom_bootstrap_implementation_h_
+
+dom_exception _dom_implementation_initialise(dom_alloc alloc, void *pw);
+void _dom_implementation_finalise(void);
+
+#endif
diff --git a/src/bootstrap/implregistry.c b/src/bootstrap/implregistry.c
index 9407ee1..91e4068 100644
--- a/src/bootstrap/implregistry.c
+++ b/src/bootstrap/implregistry.c
@@ -11,6 +11,9 @@
#include <dom/bootstrap/implregistry.h>
#include <dom/core/impllist.h>
+#include <dom/core/implementation.h>
+
+void dom_implementation_list_destroy(struct dom_implementation_list *list);
/**
* Item in list of registered DOM implementation sources
@@ -23,14 +26,30 @@ struct dom_impl_src_item {
};
static struct dom_impl_src_item *sources; /**< List of registered sources */
+static dom_alloc alloc;
+static void *pw;
+
+/**
+ * Initialise the implementation registry
+ *
+ * \param allocator The memory allocator
+ * \param ptr Private data pointer of allocator
+ * \return DOM_NO_ERR on success
+ */
+dom_exception dom_implregistry_initialise(
+ dom_alloc allocator, void *ptr)
+{
+ alloc = allocator;
+ pw = ptr;
+
+ return DOM_NO_ERR;
+}
/**
* Retrieve a DOM implementation from the registry
*
* \param features String containing required features
* \param impl Pointer to location to receive implementation
- * \param alloc Function to (de)allocate memory
- * \param pw Pointer to client-specific private data
* \return DOM_NO_ERR on success, DOM_NO_MEM_ERR on memory exhaustion
*
* Any memory allocated by this call should be allocated using
@@ -43,16 +62,14 @@ static struct dom_impl_src_item *sources; /**< List of registered sources */
*/
dom_exception dom_implregistry_get_dom_implementation(
struct dom_string *features,
- struct dom_implementation **impl,
- dom_alloc alloc, void *pw)
+ struct dom_implementation **impl)
{
struct dom_impl_src_item *item;
struct dom_implementation *found = NULL;
dom_exception err;
for (item = sources; item; item = item->next) {
- err = item->source->get_dom_implementation(features, &found,
- alloc, pw);
+ err = item->source->get_dom_implementation(features, &found);
if (err != DOM_NO_ERR)
return err;
@@ -71,14 +88,10 @@ dom_exception dom_implregistry_get_dom_implementation(
*
* \param features String containing required features
* \param list Pointer to location to receive list
- * \param alloc Function to (de)allocate memory
- * \param pw Pointer to client-specific private data
* \return DOM_NO_ERR on success, DOM_NO_MEM_ERR on memory exhaustion
*
* Any memory allocated by this call should be allocated using
- * the provided memory (de)allocation function. The ::alloc/::pw
- * pair must be stored on the list object, such that the list
- * and its contents may be freed once they are no longer needed.
+ * the provided memory (de)allocation function.
*
* List nodes reference the implementation objects they point to.
*
@@ -88,8 +101,7 @@ dom_exception dom_implregistry_get_dom_implementation(
*/
dom_exception dom_implregistry_get_dom_implementation_list(
struct dom_string *features,
- struct dom_implementation_list **list,
- dom_alloc alloc, void *pw)
+ struct dom_implementation_list **list)
{
struct dom_implementation_list *l;
struct dom_impl_src_item *item;
@@ -100,16 +112,15 @@ dom_exception dom_implregistry_get_dom_implementation_list(
return DOM_NO_MEM_ERR;
l->head = NULL;
- l->alloc = alloc;
- l->pw = pw;
l->refcnt = 1;
+ l->destroy = dom_implementation_list_destroy;
for (item = sources; item; item = item->next) {
struct dom_implementation_list *plist = NULL;
struct dom_implementation_list_item *plast = NULL;
err = item->source->get_dom_implementation_list(features,
- &plist, alloc, pw);
+ &plist);
if (err != DOM_NO_ERR) {
dom_implementation_list_unref(l);
return err;
@@ -156,12 +167,9 @@ dom_exception dom_implregistry_get_dom_implementation_list(
* Register a DOM implementation source with the DOM library
*
* \param source The implementation source to register
- * \param alloc Memory (de)allocation function
- * \param pw Pointer to client-specific private data
* \return DOM_NO_ERR on success, DOM_NO_MEM_ERR on memory exhaustion.
*/
-dom_exception dom_register_source(struct dom_implementation_source *source,
- dom_alloc alloc, void *pw)
+dom_exception dom_register_source(struct dom_implementation_source *source)
{
struct dom_impl_src_item *item;
@@ -182,3 +190,26 @@ dom_exception dom_register_source(struct dom_implementation_source *source,
return DOM_NO_ERR;
}
+/**
+ * Destroy a dom_implementation_list
+ *
+ * \param list The list to destory
+ */
+void dom_implementation_list_destroy(struct dom_implementation_list *list)
+{
+ struct dom_implementation_list_item *i, *j;
+
+ /* Destroy all list entries */
+ for (i = list->head; i; i = j) {
+ j = i->next;
+
+ /* Unreference the implementation */
+ dom_implementation_unref(i->impl);
+
+ /* And free the entry */
+ alloc(i, 0, pw);
+ }
+
+ /* Free the list object */
+ alloc(list, 0, pw);
+}
diff --git a/src/bootstrap/init_fini.c b/src/bootstrap/init_fini.c
index a5a62a1..f3c7290 100644
--- a/src/bootstrap/init_fini.c
+++ b/src/bootstrap/init_fini.c
@@ -8,9 +8,10 @@
#include <stdbool.h>
#include <dom/bootstrap/init_fini.h>
+#include <dom/bootstrap/implregistry.h>
-#include "core/document.h"
#include "utils/namespace.h"
+#include "bootstrap/implementation.h"
static bool __initialised;
@@ -32,16 +33,21 @@ dom_exception dom_initialise(dom_alloc alloc, void *pw)
return DOM_NO_ERR;
}
- err = _dom_document_initialise(alloc, pw);
+ err = _dom_namespace_initialise(alloc, pw);
if (err != DOM_NO_ERR) {
return err;
}
- err = _dom_namespace_initialise(alloc, pw);
+ err = dom_implregistry_initialise(alloc, pw);
if (err != DOM_NO_ERR) {
return err;
}
+ err = _dom_implementation_initialise(alloc, pw);
+ if (err != DOM_NO_ERR) {
+ return err;
+ }
+
__initialised = true;
return DOM_NO_ERR;
@@ -63,12 +69,9 @@ dom_exception dom_finalise(void)
return DOM_NO_ERR;
}
- err = _dom_namespace_finalise();
- if (err != DOM_NO_ERR) {
- return err;
- }
+ _dom_implementation_finalise();
- err = _dom_document_finalise();
+ err = _dom_namespace_finalise();
if (err != DOM_NO_ERR) {
return err;
}
diff --git a/src/core/Makefile b/src/core/Makefile
index 9abadad..46cb48d 100644
--- a/src/core/Makefile
+++ b/src/core/Makefile
@@ -1,8 +1,11 @@
# Sources
-DIR_SOURCES := attr.c cdatasection.c characterdata.c comment.c \
- document.c document_type.c doc_fragment.c \
- element.c entity_ref.c implementation.c impllist.c \
- namednodemap.c node.c nodelist.c \
- pi.c string.c text.c
+DIR_SOURCES := \
+ string.c node.c \
+ attr.c characterdata.c element.c \
+ implementation.c impllist.c \
+ text.c typeinfo.c comment.c \
+ namednodemap.c nodelist.c \
+ cdatasection.c document_type.c entity_ref.c pi.c \
+ doc_fragment.c document.c
include build/makefiles/Makefile.subdir
diff --git a/src/core/attr.c b/src/core/attr.c
index 9fbb06f..df95482 100644
--- a/src/core/attr.c
+++ b/src/core/attr.c
@@ -3,10 +3,12 @@
* Licensed under the MIT License,
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
*/
#include <stddef.h>
#include <string.h>
+#include <assert.h>
#include <dom/core/attr.h>
#include <dom/core/document.h>
@@ -25,24 +27,34 @@ struct dom_element;
* DOM node attribute
*/
struct dom_attr {
- struct dom_node_internal base; /**< Base node */
+ struct dom_node_internal base; /**< Base node */
- bool specified; /**< Whether attribute was specified
- * or defaulted */
+ bool specified; /**< Whether the attribute is specified
+ * or default */
struct dom_type_info *schema_type_info; /**< Type information */
- bool is_id; /**< Attribute is of type ID */
+ bool is_id; /**< Whether this attribute is a ID attribute */
};
-/* The vtable for dom attr node */
+/* The vtable for dom_attr node */
static struct dom_attr_vtable attr_vtable = {
{
- DOM_NODE_VTABLE
+ DOM_NODE_VTABLE_ATTR
},
DOM_ATTR_VTABLE
};
+/* The protected vtable for dom_attr */
+static struct dom_node_protect_vtable attr_protect_vtable = {
+ DOM_ATTR_PROTECT_VTABLE
+};
+
+
+/* -------------------------------------------------------------------- */
+
+/* Constructor and destructor */
+
/**
* Create an attribute node
*
@@ -50,43 +62,69 @@ static struct dom_attr_vtable attr_vtable = {
* \param name The (local) name of the node to create
* \param namespace The namespace URI of the attribute, or NULL
* \param prefix The namespace prefix of the attribute, or NULL
+ * \param specified Whtether this attribute is specified
* \param result Pointer to location to receive created attribute
* \return DOM_NO_ERR on success,
- * DOM_INVALID_CHARACTER_ERR if ::name is invalid,
* DOM_NO_MEM_ERR on memory exhaustion.
*
- * ::doc and ::name will have their reference counts increased.
+ * ::doc and ::name will have their reference counts increased. The
+ * caller should make sure that ::name is a valid NCName here.
*
* The returned attribute will already be referenced.
*/
-dom_exception dom_attr_create(struct dom_document *doc,
- struct dom_string *name, struct dom_string *namespace,
- struct dom_string *prefix, struct dom_attr **result)
+dom_exception _dom_attr_create(struct dom_document *doc,
+ struct lwc_string_s *name, struct lwc_string_s *namespace,
+ struct lwc_string_s *prefix, bool specified,
+ struct dom_attr **result)
{
struct dom_attr *a;
dom_exception err;
- /** \todo Sanity check the attribute name */
-
- /* Allocate the element */
- a = dom_document_alloc(doc, NULL, sizeof(struct dom_attr));
+ /* Allocate the attribute node */
+ a = _dom_document_alloc(doc, NULL, sizeof(struct dom_attr));
if (a == NULL)
return DOM_NO_MEM_ERR;
/* Initialise the vtable */
a->base.base.vtable = &attr_vtable;
- a->base.destroy = _dom_attr_destroy;
+ a->base.vtable = &attr_protect_vtable;
+
+ /* Initialise the class */
+ err = _dom_attr_initialise(a, doc, name, namespace, prefix, specified,
+ result);
+ if (err != DOM_NO_ERR) {
+ _dom_document_alloc(doc, a, 0);
+ return err;
+ }
+ return DOM_NO_ERR;
+}
+
+/**
+ * Initialise a dom_attr
+ *
+ * \param a The dom_attr
+ * \param doc The document
+ * \param name The name of this attribute node
+ * \param namespace The namespace of this attribute
+ * \param prefix The prefix
+ * \param specified Whether this node is a specified one
+ * \param result The returned node
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_attr_initialise(dom_attr *a,
+ struct dom_document *doc, struct lwc_string_s *name,
+ struct lwc_string_s *namespace, struct lwc_string_s *prefix,
+ bool specified, struct dom_attr **result)
+{
+ dom_exception err;
- /* Initialise the base class */
- err = dom_node_initialise(&a->base, doc, DOM_ATTRIBUTE_NODE,
+ err = _dom_node_initialise(&a->base, doc, DOM_ATTRIBUTE_NODE,
name, NULL, namespace, prefix);
if (err != DOM_NO_ERR) {
- dom_document_alloc(doc, a, 0);
return err;
}
- /* Perform our type-specific initialisation */
- a->specified = false;
+ a->specified = specified;
a->schema_type_info = NULL;
a->is_id = false;
@@ -96,61 +134,48 @@ dom_exception dom_attr_create(struct dom_document *doc,
}
/**
- * Destroy an attribute node
+ * The destructor of dom_attr
*
- * \param doc The owning document
- * \param attr The attribute to destroy
- *
- * The contents of ::attr will be destroyed and ::attr will be freed
+ * \param doc The owner document
+ * \param attr The attribute
*/
-void dom_attr_destroy(struct dom_document *doc, struct dom_attr *attr)
+void _dom_attr_finalise(dom_document *doc, dom_attr *attr)
{
- struct dom_node_internal *c, *d;
-
- /* Destroy children of this node */
- for (c = attr->base.first_child; c != NULL; c = d) {
- d = c->next;
-
- /* Detach child */
- c->parent = NULL;
-
- if (c->refcnt > 0) {
- /* Something is using this child */
-
- /** \todo add to list of nodes pending deletion */
-
- continue;
- }
-
- /* Detach from sibling list */
- c->previous = NULL;
- c->next = NULL;
-
- dom_node_destroy(c);
- }
-
/* Now, clean up this node and destroy it */
if (attr->schema_type_info != NULL) {
/** \todo destroy schema type info */
}
- dom_node_finalise(doc, &attr->base);
-
- dom_document_alloc(doc, attr, 0);
+ _dom_node_finalise(doc, &attr->base);
}
-void _dom_attr_destroy(dom_node_internal *node)
+/**
+ * Destroy an attribute node
+ *
+ * \param doc The owning document
+ * \param attr The attribute to destroy
+ *
+ * The contents of ::attr will be destroyed and ::attr will be freed
+ */
+void _dom_attr_destroy(struct dom_document *doc, struct dom_attr *attr)
{
- UNUSED(node);
+ _dom_attr_finalise(doc, attr);
+
+ _dom_document_alloc(doc, attr, 0);
}
+
+/* -------------------------------------------------------------------- */
+
+/* The public virtual functions */
+
/**
* Retrieve an attribute's name
*
* \param attr Attribute to retrieve name from
* \param result Pointer to location to receive result
- * \return DOM_NO_ERR.
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure
*
* The returned string will have its reference count increased. It is
* the responsibility of the caller to unref the string once it has
@@ -164,7 +189,7 @@ dom_exception _dom_attr_get_name(struct dom_attr *attr,
}
/**
- * Determine if attribute was specified or defaulted
+ * Determine if attribute was specified or default
*
* \param attr Attribute to inspect
* \param result Pointer to location to receive result
@@ -182,7 +207,7 @@ dom_exception _dom_attr_get_specified(struct dom_attr *attr, bool *result)
*
* \param attr Attribute to retrieve value from
* \param result Pointer to location to receive result
- * \return DOM_NO_ERR.
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure
*
* The returned string will have its reference count increased. It is
* the responsibility of the caller to unref the string once it has
@@ -196,8 +221,8 @@ dom_exception _dom_attr_get_value(struct dom_attr *attr,
struct dom_string *value, *temp;
dom_exception err;
- err = dom_document_create_string(a->owner,
- (const uint8_t *) "", SLEN(""), &value);
+ err = _dom_document_create_string(a->owner,
+ NULL, 0, &value);
if (err != DOM_NO_ERR) {
return err;
}
@@ -221,7 +246,7 @@ dom_exception _dom_attr_get_value(struct dom_attr *attr,
struct dom_string *tr;
/* Get textual representation of entity */
- err = dom_entity_reference_get_textual_representation(
+ err = _dom_entity_reference_get_textual_representation(
(struct dom_entity_reference *) c,
&tr);
if (err != DOM_NO_ERR) {
@@ -285,24 +310,21 @@ dom_exception _dom_attr_set_value(struct dom_attr *attr,
/* Detach child */
c->parent = NULL;
- if (c->refcnt > 0) {
- /* Something is using this child */
-
- /** \todo add to list of nodes pending deletion */
-
- continue;
- }
-
/* Detach from sibling list */
c->previous = NULL;
c->next = NULL;
- dom_node_destroy(c);
+ dom_node_try_destroy(c);
}
/* And insert the text node as the value */
((struct dom_node_internal *) text)->parent = a;
a->first_child = a->last_child = (struct dom_node_internal *) text;
+ dom_node_unref(text);
+ dom_node_remove_pending(text);
+
+ /* Now the attribute node is specified */
+ attr->specified = true;
return DOM_NO_ERR;
}
@@ -336,7 +358,7 @@ dom_exception _dom_attr_get_owner(struct dom_attr *attr,
*
* \param attr The attribute to extract type information from
* \param result Pointer to location to receive result
- * \return DOM_NO_ERR.
+ * \return DOM_NOT_SUPPORTED_ERR, we don't support this API now.
*
* The returned type info will have its reference count increased. The caller
* should unref it once it has finished with it.
@@ -363,3 +385,179 @@ dom_exception _dom_attr_is_id(struct dom_attr *attr, bool *result)
return DOM_NO_ERR;
}
+
+/*------------- The overload virtual functions ------------------------*/
+
+/* Overload function of Node, please refer node.c for the detail of this
+ * function. */
+dom_exception _dom_attr_get_node_value(dom_node_internal *node,
+ struct dom_string **result)
+{
+ dom_attr *attr = (dom_attr *) node;
+
+ return _dom_attr_get_value(attr, result);
+}
+
+/* Overload function of Node, please refer node.c for the detail of this
+ * function. */
+dom_exception _dom_attr_clone_node(dom_node_internal *node, bool deep,
+ dom_node_internal **result)
+{
+ dom_exception err;
+ dom_attr *attr;
+
+ /* Discard the warnings */
+ UNUSED(deep);
+
+ /* Clone an Attr always clone all its children */
+ err = _dom_node_clone_node(node, true, result);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ attr = (dom_attr *) *result;
+ /* Clone an Attr always result a specified Attr,
+ * see DOM Level 3 Node.cloneNode */
+ attr->specified = true;
+
+ return DOM_NO_ERR;
+}
+
+/* Overload function of Node, please refer node.c for the detail of this
+ * function. */
+dom_exception _dom_attr_set_prefix(dom_node_internal *node,
+ struct dom_string *prefix)
+{
+ /* Really I don't know whether there should something
+ * special to do here */
+ return _dom_node_set_prefix(node, prefix);
+}
+
+/* Overload function of Node, please refer node.c for the detail of this
+ * function. */
+dom_exception _dom_attr_lookup_prefix(dom_node_internal *node,
+ struct dom_string *namespace, struct dom_string **result)
+{
+ struct dom_element *owner;
+ dom_exception err;
+
+ err = dom_attr_get_owner_element(node, &owner);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ if (owner == NULL) {
+ *result = NULL;
+ return DOM_NO_ERR;
+ }
+
+ return dom_node_lookup_prefix(owner, namespace, result);
+}
+
+/* Overload function of Node, please refer node.c for the detail of this
+ * function. */
+dom_exception _dom_attr_is_default_namespace(dom_node_internal *node,
+ struct dom_string *namespace, bool *result)
+{
+ struct dom_element *owner;
+ dom_exception err;
+
+ err = dom_attr_get_owner_element(node, &owner);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ if (owner == NULL) {
+ *result = false;
+ return DOM_NO_ERR;
+ }
+
+ return dom_node_is_default_namespace(owner, namespace, result);
+}
+
+/* Overload function of Node, please refer node.c for the detail of this
+ * function. */
+dom_exception _dom_attr_lookup_namespace(dom_node_internal *node,
+ struct dom_string *prefix, struct dom_string **result)
+{
+ struct dom_element *owner;
+ dom_exception err;
+
+ err = dom_attr_get_owner_element(node, &owner);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ if (owner == NULL) {
+ *result = NULL;
+ return DOM_NO_ERR;
+ }
+
+ return dom_node_lookup_namespace(owner, prefix, result);
+}
+
+
+/*----------------------------------------------------------------------*/
+
+/* The protected virtual functions */
+
+/* The virtual destroy function of this class */
+void __dom_attr_destroy(dom_node_internal *node)
+{
+ dom_document *doc = node->owner;
+
+ assert(doc != NULL);
+ _dom_attr_destroy(doc, (dom_attr *) node);
+}
+
+/* The memory allocator of this class */
+dom_exception _dom_attr_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret)
+{
+ UNUSED(n);
+ dom_attr *a;
+
+ a = _dom_document_alloc(doc, NULL, sizeof(struct dom_attr));
+ if (a == NULL)
+ return DOM_NO_MEM_ERR;
+
+ *ret = (dom_node_internal *) a;
+ dom_node_set_owner(*ret, doc);
+
+ return DOM_NO_ERR;
+}
+
+/* The copy constructor of this class */
+dom_exception _dom_attr_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old)
+{
+ dom_attr *na = (dom_attr *) new;
+ dom_attr *oa = (dom_attr *) old;
+
+ na->specified = oa->specified;
+ na->is_id = oa->is_id;
+
+ /* TODO: deal with dom_type_info, it get no definition ! */
+
+ return _dom_node_copy(new, old);
+}
+
+
+/**
+ * Set/Unset whether this attribute is a ID attribute
+ *
+ * \param attr The attribute
+ * \param is_id Whether it is a ID attribute
+ */
+void _dom_attr_set_isid(struct dom_attr *attr, bool is_id)
+{
+ attr->is_id = is_id;
+}
+
+/**
+ * Set/Unset whether the attribute is a specified one.
+ *
+ * \param attr The attribute node
+ * \param specified Whether this attribute is a specified one
+ */
+void _dom_attr_set_specified(struct dom_attr *attr, bool specified)
+{
+ attr->specified = specified;
+}
+
diff --git a/src/core/attr.h b/src/core/attr.h
index 2a3cd67..84b741f 100644
--- a/src/core/attr.h
+++ b/src/core/attr.h
@@ -13,26 +13,31 @@
struct dom_document;
struct dom_string;
struct dom_type_info;
+struct lwc_string_s;
-dom_exception dom_attr_create(struct dom_document *doc,
- struct dom_string *name, struct dom_string *namespace,
- struct dom_string *prefix, struct dom_attr **result);
-void dom_attr_destroy(struct dom_document *doc, struct dom_attr *attr);
-/* The virtual destroy function */
-void _dom_attr_destroy(dom_node_internal *node);
+dom_exception _dom_attr_create(struct dom_document *doc,
+ struct lwc_string_s *name, struct lwc_string_s *namespace,
+ struct lwc_string_s *prefix, bool specified,
+ struct dom_attr **result);
+void _dom_attr_destroy(struct dom_document *doc, struct dom_attr *attr);
+dom_exception _dom_attr_initialise(struct dom_attr *a,
+ struct dom_document *doc, struct lwc_string_s *name,
+ struct lwc_string_s *namespace, struct lwc_string_s *prefix,
+ bool specified, struct dom_attr **result);
+void _dom_attr_finalise(dom_document *doc, struct dom_attr *attr);
-/* Virtual functions for dom attr */
+/* Virtual functions for dom_attr */
dom_exception _dom_attr_get_name(struct dom_attr *attr,
- struct dom_string **result);
+ struct dom_string **result);
dom_exception _dom_attr_get_specified(struct dom_attr *attr, bool *result);
dom_exception _dom_attr_get_value(struct dom_attr *attr,
- struct dom_string **result);
+ struct dom_string **result);
dom_exception _dom_attr_set_value(struct dom_attr *attr,
- struct dom_string *value);
+ struct dom_string *value);
dom_exception _dom_attr_get_owner(struct dom_attr *attr,
- struct dom_element **result);
+ struct dom_element **result);
dom_exception _dom_attr_get_schema_type_info(struct dom_attr *attr,
- struct dom_type_info **result);
+ struct dom_type_info **result);
dom_exception _dom_attr_is_id(struct dom_attr *attr, bool *result);
#define DOM_ATTR_VTABLE \
@@ -44,4 +49,73 @@ dom_exception _dom_attr_is_id(struct dom_attr *attr, bool *result);
_dom_attr_get_schema_type_info, \
_dom_attr_is_id
+/* Overloading dom_node functions */
+dom_exception _dom_attr_get_node_value(dom_node_internal *node,
+ struct dom_string **result);
+dom_exception _dom_attr_clone_node(dom_node_internal *node, bool deep,
+ dom_node_internal **result);
+dom_exception _dom_attr_set_prefix(dom_node_internal *node,
+ struct dom_string *prefix);
+dom_exception _dom_attr_normalize(dom_node_internal *node);
+dom_exception _dom_attr_lookup_prefix(dom_node_internal *node,
+ struct dom_string *namespace, struct dom_string **result);
+dom_exception _dom_attr_is_default_namespace(dom_node_internal *node,
+ struct dom_string *namespace, bool *result);
+dom_exception _dom_attr_lookup_namespace(dom_node_internal *node,
+ struct dom_string *prefix, struct dom_string **result);
+#define DOM_NODE_VTABLE_ATTR \
+ _dom_node_get_node_name, \
+ _dom_attr_get_node_value, /*overload*/\
+ _dom_node_set_node_value, \
+ _dom_node_get_node_type, \
+ _dom_node_get_parent_node, \
+ _dom_node_get_child_nodes, \
+ _dom_node_get_first_child, \
+ _dom_node_get_last_child, \
+ _dom_node_get_previous_sibling, \
+ _dom_node_get_next_sibling, \
+ _dom_node_get_attributes, \
+ _dom_node_get_owner_document, \
+ _dom_node_insert_before, \
+ _dom_node_replace_child, \
+ _dom_node_remove_child, \
+ _dom_node_append_child, \
+ _dom_node_has_child_nodes, \
+ _dom_attr_clone_node, /*overload*/\
+ _dom_node_normalize, \
+ _dom_node_is_supported, \
+ _dom_node_get_namespace, \
+ _dom_node_get_prefix, \
+ _dom_attr_set_prefix, /*overload*/\
+ _dom_node_get_local_name, \
+ _dom_node_has_attributes, \
+ _dom_node_get_base, \
+ _dom_node_compare_document_position, \
+ _dom_node_get_text_content, \
+ _dom_node_set_text_content, \
+ _dom_node_is_same, \
+ _dom_attr_lookup_prefix, /*overload*/\
+ _dom_attr_is_default_namespace, /*overload*/\
+ _dom_attr_lookup_namespace, /*overload*/\
+ _dom_node_is_equal, \
+ _dom_node_get_feature, \
+ _dom_node_set_user_data, \
+ _dom_node_get_user_data
+
+/* The protected virtual functions */
+void __dom_attr_destroy(dom_node_internal *node);
+dom_exception _dom_attr_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret);
+dom_exception _dom_attr_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old);
+
+#define DOM_ATTR_PROTECT_VTABLE \
+ __dom_attr_destroy, \
+ _dom_attr_alloc, \
+ _dom_attr_copy
+
+
+inline void _dom_attr_set_isid(struct dom_attr *attr, bool is_id);
+inline void _dom_attr_set_specified(struct dom_attr *attr, bool specified);
+
#endif
diff --git a/src/core/cdatasection.c b/src/core/cdatasection.c
index 71d3d43..b470df2 100644
--- a/src/core/cdatasection.c
+++ b/src/core/cdatasection.c
@@ -3,11 +3,13 @@
* Licensed under the MIT License,
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
*/
#include "core/cdatasection.h"
#include "core/document.h"
#include "core/text.h"
+#include "utils/utils.h"
/**
* A DOM CDATA section
@@ -16,6 +18,10 @@ struct dom_cdata_section {
struct dom_text base; /**< Base node */
};
+static struct dom_node_protect_vtable cdata_section_protect_vtable = {
+ DOM_CDATA_SECTION_PROTECT_VTABLE
+};
+
/**
* Create a CDATA section
*
@@ -30,23 +36,27 @@ struct dom_cdata_section {
*
* The returned node will already be referenced.
*/
-dom_exception dom_cdata_section_create(struct dom_document *doc,
- struct dom_string *name, struct dom_string *value,
+dom_exception _dom_cdata_section_create(struct dom_document *doc,
+ struct lwc_string_s *name, struct dom_string *value,
struct dom_cdata_section **result)
{
struct dom_cdata_section *c;
dom_exception err;
/* Allocate the comment node */
- c = dom_document_alloc(doc, NULL, sizeof(struct dom_cdata_section));
+ c = _dom_document_alloc(doc, NULL, sizeof(struct dom_cdata_section));
if (c == NULL)
return DOM_NO_MEM_ERR;
+
+ /* Set up vtable */
+ ((dom_node_internal *) c)->base.vtable = &text_vtable;
+ ((dom_node_internal *) c)->vtable = &cdata_section_protect_vtable;
/* And initialise the node */
- err = dom_text_initialise(&c->base, doc, DOM_CDATA_SECTION_NODE,
- name, value);
+ err = _dom_cdata_section_initialise(&c->base, doc,
+ DOM_CDATA_SECTION_NODE, name, value);
if (err != DOM_NO_ERR) {
- dom_document_alloc(doc, c, 0);
+ _dom_document_alloc(doc, c, 0);
return err;
}
@@ -63,12 +73,50 @@ dom_exception dom_cdata_section_create(struct dom_document *doc,
*
* The contents of ::cdata will be destroyed and ::cdata will be freed.
*/
-void dom_cdata_section_destroy(struct dom_document *doc,
+void _dom_cdata_section_destroy(struct dom_document *doc,
struct dom_cdata_section *cdata)
{
/* Clean up base node contents */
- dom_text_finalise(doc, &cdata->base);
+ _dom_cdata_section_finalise(doc, &cdata->base);
/* Destroy the node */
- dom_document_alloc(doc, cdata, 0);
+ _dom_document_alloc(doc, cdata, 0);
+}
+
+/*--------------------------------------------------------------------------*/
+
+/* The protected virtual functions */
+
+/* The virtual destroy function of this class */
+void __dom_cdata_section_destroy(struct dom_node_internal *node)
+{
+ struct dom_document *doc;
+ doc = dom_node_get_owner(node);
+
+ _dom_cdata_section_destroy(doc, (struct dom_cdata_section *) node);
+}
+
+/* The memory allocator of this class */
+dom_exception _dom_cdata_section_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret)
+{
+ UNUSED(n);
+ dom_cdata_section *a;
+
+ a = _dom_document_alloc(doc, NULL, sizeof(struct dom_cdata_section));
+ if (a == NULL)
+ return DOM_NO_MEM_ERR;
+
+ *ret = (dom_node_internal *) a;
+ dom_node_set_owner(*ret, doc);
+
+ return DOM_NO_ERR;
}
+
+/* The copy constructor of this class */
+dom_exception _dom_cdata_section_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old)
+{
+ return _dom_characterdata_copy(new, old);
+}
+
diff --git a/src/core/cdatasection.h b/src/core/cdatasection.h
index 740c7d7..94d45a2 100644
--- a/src/core/cdatasection.h
+++ b/src/core/cdatasection.h
@@ -9,16 +9,34 @@
#define dom_internal_core_cdatasection_h_
#include <dom/core/exceptions.h>
+#include <dom/core/cdatasection.h>
+struct dom_node_internal;
struct dom_cdata_section;
struct dom_document;
struct dom_string;
+struct lwc_string_s;
-dom_exception dom_cdata_section_create(struct dom_document *doc,
- struct dom_string *name, struct dom_string *value,
+dom_exception _dom_cdata_section_create(struct dom_document *doc,
+ struct lwc_string_s *name, struct dom_string *value,
struct dom_cdata_section **result);
-void dom_cdata_section_destroy(struct dom_document *doc,
+void _dom_cdata_section_destroy(struct dom_document *doc,
struct dom_cdata_section *cdata);
+#define _dom_cdata_section_initialise _dom_text_initialise
+#define _dom_cdata_section_finalise _dom_text_finalise
+
+/* Following comes the protected vtable */
+void __dom_cdata_section_destroy(struct dom_node_internal *node);
+dom_exception _dom_cdata_section_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret);
+dom_exception _dom_cdata_section_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old);
+
+#define DOM_CDATA_SECTION_PROTECT_VTABLE \
+ __dom_cdata_section_destroy, \
+ _dom_cdata_section_alloc, \
+ _dom_cdata_section_copy
+
#endif
diff --git a/src/core/characterdata.c b/src/core/characterdata.c
index 6beecbe..f5b4094 100644
--- a/src/core/characterdata.c
+++ b/src/core/characterdata.c
@@ -3,8 +3,11 @@
* Licensed under the MIT License,
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
*/
+#include <assert.h>
+
#include <dom/core/characterdata.h>
#include <dom/core/string.h>
@@ -13,28 +16,28 @@
#include "core/node.h"
#include "utils/utils.h"
-/* The virtual functions for dom_characterdata */
-static struct dom_characterdata_vtable characterdata_vtable = {
+/* The virtual functions for dom_characterdata, we make this vtable
+ * public to each child class */
+struct dom_characterdata_vtable characterdata_vtable = {
{
DOM_NODE_VTABLE
},
DOM_CHARACTERDATA_VTABLE
};
-/**
- * Create a DOM characterdata node and compose the vtable
- *
- * Return The new constructed DOM characterdata node of NULL if fail
- */
-dom_characterdata *dom_characterdata_create(struct dom_document *doc)
+
+/* Create a DOM characterdata node and compose the vtable */
+dom_characterdata *_dom_characterdata_create(struct dom_document *doc)
{
- dom_characterdata *cdata = dom_document_alloc(doc, NULL,
+ dom_characterdata *cdata = _dom_document_alloc(doc, NULL,
sizeof(struct dom_characterdata));
if (cdata == NULL)
return NULL;
cdata->base.base.vtable = &characterdata_vtable;
+ cdata->base.vtable = NULL;
+
return cdata;
}
@@ -50,11 +53,11 @@ dom_characterdata *dom_characterdata_create(struct dom_document *doc)
*
* ::doc, ::name and ::value will have their reference counts increased.
*/
-dom_exception dom_characterdata_initialise(struct dom_characterdata *cdata,
+dom_exception _dom_characterdata_initialise(struct dom_characterdata *cdata,
struct dom_document *doc, dom_node_type type,
- struct dom_string *name, struct dom_string *value)
+ lwc_string *name, struct dom_string *value)
{
- return dom_node_initialise(&cdata->base, doc, type,
+ return _dom_node_initialise(&cdata->base, doc, type,
name, value, NULL, NULL);
}
@@ -66,12 +69,17 @@ dom_exception dom_characterdata_initialise(struct dom_characterdata *cdata,
*
* The contents of ::cdata will be cleaned up. ::cdata will not be freed.
*/
-void dom_characterdata_finalise(struct dom_document *doc,
+void _dom_characterdata_finalise(struct dom_document *doc,
struct dom_characterdata *cdata)
{
- dom_node_finalise(doc, &cdata->base);
+ _dom_node_finalise(doc, &cdata->base);
}
+
+/*----------------------------------------------------------------------*/
+
+/* The public virtual functions */
+
/**
* Retrieve data from a character data node
*
@@ -182,7 +190,7 @@ dom_exception _dom_characterdata_substring_data(
len = 0;
}
- if (offset >= len) {
+ if (offset > len) {
return DOM_INDEX_SIZE_ERR;
}
@@ -210,9 +218,7 @@ dom_exception _dom_characterdata_append_data(struct dom_characterdata *cdata,
return DOM_NO_MODIFICATION_ALLOWED_ERR;
}
- err = dom_string_insert(c->value, data,
- c->value != NULL ? dom_string_length(c->value) : 0,
- &temp);
+ err = dom_string_concat(c->value, data, &temp);
if (err != DOM_NO_ERR) {
return err;
}
@@ -255,7 +261,7 @@ dom_exception _dom_characterdata_insert_data(struct dom_characterdata *cdata,
len = 0;
}
- if (offset >= len) {
+ if (offset > len) {
return DOM_INDEX_SIZE_ERR;
}
@@ -302,7 +308,7 @@ dom_exception _dom_characterdata_delete_data(struct dom_characterdata *cdata,
len = 0;
}
- if (offset >= len) {
+ if (offset > len) {
return DOM_INDEX_SIZE_ERR;
}
@@ -353,7 +359,7 @@ dom_exception _dom_characterdata_replace_data(struct dom_characterdata *cdata,
len = 0;
}
- if (offset >= len) {
+ if (offset > len) {
return DOM_INDEX_SIZE_ERR;
}
@@ -373,3 +379,38 @@ dom_exception _dom_characterdata_replace_data(struct dom_characterdata *cdata,
return DOM_NO_ERR;
}
+
+
+/*----------------------------------------------------------------------*/
+
+/* The protected virtual functions of Node, see core/node.h for details
+ *
+ * @note: the three following API never be called directly from the virtual
+ * functions dispatch mechanism, they are here for the code consistent.
+ */
+void _dom_characterdata_destroy(struct dom_node_internal *node)
+{
+ assert("Should never be here" == NULL);
+ UNUSED(node);
+}
+
+/* The memory allocator of this class */
+dom_exception _dom_characterdata_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret)
+{
+ assert("Should never be here" == NULL);
+ UNUSED(doc);
+ UNUSED(n);
+ UNUSED(ret);
+
+ return DOM_NO_ERR;
+}
+
+/* The copy constructor of this class
+ * The sub-class of characterdata should call this API */
+dom_exception _dom_characterdata_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old)
+{
+ return _dom_node_copy(new, old);
+}
+
diff --git a/src/core/characterdata.h b/src/core/characterdata.h
index 7076988..b5886ea 100644
--- a/src/core/characterdata.h
+++ b/src/core/characterdata.h
@@ -19,15 +19,17 @@ struct dom_characterdata {
struct dom_node_internal base; /**< Base node */
};
-dom_characterdata *dom_characterdata_create(struct dom_document *doc);
-dom_exception dom_characterdata_initialise(struct dom_characterdata *cdata,
+/* The CharacterData is a intermediate node type, so the following function
+ * may never be used */
+dom_characterdata *_dom_characterdata_create(struct dom_document *doc);
+dom_exception _dom_characterdata_initialise(struct dom_characterdata *cdata,
struct dom_document *doc, dom_node_type type,
- struct dom_string *name, struct dom_string *value);
+ struct lwc_string_s *name, struct dom_string *value);
-void dom_characterdata_finalise(struct dom_document *doc,
+void _dom_characterdata_finalise(struct dom_document *doc,
struct dom_characterdata *cdata);
-/* The virtual functions for characterdata */
+/* The virtual functions for dom_characterdata */
dom_exception _dom_characterdata_get_data(struct dom_characterdata *cdata,
struct dom_string **data);
dom_exception _dom_characterdata_set_data(struct dom_characterdata *cdata,
@@ -57,4 +59,21 @@ dom_exception _dom_characterdata_replace_data(struct dom_characterdata *cdata,
_dom_characterdata_delete_data, \
_dom_characterdata_replace_data
+/* Following comes the protected vtable
+ *
+ * Only the _copy function can be used by sub-class of this.
+ */
+void _dom_characterdata_destroy(struct dom_node_internal *node);
+dom_exception _dom_characterdata_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret);
+dom_exception _dom_characterdata_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old);
+
+#define DOM_CHARACTERDATA_PROTECT_VTABLE \
+ _dom_characterdata_destroy, \
+ _dom_characterdata_alloc, \
+ _dom_characterdata_copy
+
+extern struct dom_characterdata_vtable characterdata_vtable;
+
#endif
diff --git a/src/core/comment.c b/src/core/comment.c
index 2e1c323..564bcd8 100644
--- a/src/core/comment.c
+++ b/src/core/comment.c
@@ -3,19 +3,26 @@
* Licensed under the MIT License,
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
*/
#include "core/characterdata.h"
#include "core/comment.h"
#include "core/document.h"
+#include "utils/utils.h"
+
/**
- * A DOM comment node
+ * A DOM Comment node
*/
struct dom_comment {
struct dom_characterdata base; /**< Base node */
};
+static struct dom_node_protect_vtable comment_protect_vtable = {
+ DOM_COMMENT_PROTECT_VTABLE
+};
+
/**
* Create a comment node
*
@@ -30,23 +37,27 @@ struct dom_comment {
*
* The returned node will already be referenced.
*/
-dom_exception dom_comment_create(struct dom_document *doc,
- struct dom_string *name, struct dom_string *value,
+dom_exception _dom_comment_create(struct dom_document *doc,
+ struct lwc_string_s *name, struct dom_string *value,
struct dom_comment **result)
{
struct dom_comment *c;
dom_exception err;
/* Allocate the comment node */
- c = dom_document_alloc(doc, NULL, sizeof(struct dom_comment));
+ c = _dom_document_alloc(doc, NULL, sizeof(struct dom_comment));
if (c == NULL)
return DOM_NO_MEM_ERR;
+ /* Set the virtual table */
+ ((dom_node_internal *) c)->base.vtable = &characterdata_vtable;
+ ((dom_node_internal *) c)->vtable = &comment_protect_vtable;
+
/* And initialise the node */
- err = dom_characterdata_initialise(&c->base, doc, DOM_COMMENT_NODE,
+ err = _dom_characterdata_initialise(&c->base, doc, DOM_COMMENT_NODE,
name, value);
if (err != DOM_NO_ERR) {
- dom_document_alloc(doc, c, 0);
+ _dom_document_alloc(doc, c, 0);
return err;
}
@@ -63,12 +74,50 @@ dom_exception dom_comment_create(struct dom_document *doc,
*
* The contents of ::comment will be destroyed and ::comment will be freed
*/
-void dom_comment_destroy(struct dom_document *doc,
+void _dom_comment_destroy(struct dom_document *doc,
struct dom_comment *comment)
{
/* Finalise base class contents */
- dom_characterdata_finalise(doc, &comment->base);
+ _dom_characterdata_finalise(doc, &comment->base);
/* Free node */
- dom_document_alloc(doc, comment, 0);
+ _dom_document_alloc(doc, comment, 0);
}
+
+
+/*-----------------------------------------------------------------------*/
+/* The protected virtual functions */
+
+/* The virtual destroy function */
+void __dom_comment_destroy(struct dom_node_internal *node)
+{
+ struct dom_document *doc;
+ doc = dom_node_get_owner(node);
+
+ _dom_comment_destroy(doc, (struct dom_comment *) node);
+}
+
+/* The memory allocation function of this class */
+dom_exception _dom_comment_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret)
+{
+ UNUSED(n);
+ dom_comment *c;
+
+ c = _dom_document_alloc(doc, NULL, sizeof(struct dom_comment));
+ if (c == NULL)
+ return DOM_NO_MEM_ERR;
+
+ *ret = (dom_node_internal *) c;
+ dom_node_set_owner(*ret, doc);
+
+ return DOM_NO_ERR;
+}
+
+/* The copy constructor of this class */
+dom_exception _dom_comment_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old)
+{
+ return _dom_characterdata_copy(new, old);
+}
+
diff --git a/src/core/comment.h b/src/core/comment.h
index 38bb448..ef8791f 100644
--- a/src/core/comment.h
+++ b/src/core/comment.h
@@ -9,16 +9,33 @@
#define dom_internal_core_comment_h_
#include <dom/core/exceptions.h>
+#include <dom/core/comment.h>
struct dom_comment;
struct dom_document;
struct dom_string;
+struct lwc_string_s;
-dom_exception dom_comment_create(struct dom_document *doc,
- struct dom_string *name, struct dom_string *value,
+dom_exception _dom_comment_create(struct dom_document *doc,
+ struct lwc_string_s *name, struct dom_string *value,
struct dom_comment **result);
-void dom_comment_destroy(struct dom_document *doc,
+#define _dom_comment_initialise _dom_characterdata_initialise
+#define _dom_comment_finalise _dom_characterdata_finalise
+
+void _dom_comment_destroy(struct dom_document *doc,
struct dom_comment *comment);
+/* Following comes the protected vtable */
+void __dom_comment_destroy(struct dom_node_internal *node);
+dom_exception _dom_comment_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret);
+dom_exception _dom_comment_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old);
+
+#define DOM_COMMENT_PROTECT_VTABLE \
+ __dom_comment_destroy, \
+ _dom_comment_alloc, \
+ _dom_comment_copy
+
#endif
diff --git a/src/core/doc_fragment.c b/src/core/doc_fragment.c
index d9eb272..6b46696 100644
--- a/src/core/doc_fragment.c
+++ b/src/core/doc_fragment.c
@@ -3,13 +3,17 @@
* Licensed under the MIT License,
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
*/
+#include <libwapcaplet/libwapcaplet.h>
+
#include <dom/core/node.h>
#include "core/document.h"
#include "core/doc_fragment.h"
#include "core/node.h"
+#include "utils/utils.h"
/**
* A DOM document fragment
@@ -18,7 +22,13 @@ struct dom_document_fragment {
struct dom_node_internal base; /**< Base node */
};
-void _dom_document_fragment_destroy(struct dom_node_internal *node);
+static struct dom_node_vtable df_vtable = {
+ DOM_NODE_VTABLE
+};
+
+static struct dom_node_protect_vtable df_protect_vtable = {
+ DOM_DF_PROTECT_VTABLE
+};
/**
* Create a document fragment
@@ -34,30 +44,31 @@ void _dom_document_fragment_destroy(struct dom_node_internal *node);
*
* The returned node will already be referenced.
*/
-dom_exception dom_document_fragment_create(struct dom_document *doc,
- struct dom_string *name, struct dom_string *value,
+dom_exception _dom_document_fragment_create(struct dom_document *doc,
+ struct lwc_string_s *name, struct dom_string *value,
struct dom_document_fragment **result)
{
struct dom_document_fragment *f;
dom_exception err;
/* Allocate the comment node */
- f = dom_document_alloc(doc, NULL,
+ f = _dom_document_alloc(doc, NULL,
sizeof(struct dom_document_fragment));
if (f == NULL)
return DOM_NO_MEM_ERR;
+
+ f->base.base.vtable = &df_vtable;
+ f->base.vtable = &df_protect_vtable;
+
/* And initialise the node */
- err = dom_node_initialise(&f->base, doc, DOM_DOCUMENT_FRAGMENT_NODE,
- name, value, NULL, NULL);
+ err = _dom_document_fragment_initialise(&f->base, doc,
+ DOM_DOCUMENT_FRAGMENT_NODE, name, value, NULL, NULL);
if (err != DOM_NO_ERR) {
- dom_document_alloc(doc, f, 0);
+ _dom_document_alloc(doc, f, 0);
return err;
}
- /* Set the virtual function of destroy */
- f->base.destroy = &_dom_document_fragment_destroy;
-
*result = f;
return DOM_NO_ERR;
@@ -71,45 +82,49 @@ dom_exception dom_document_fragment_create(struct dom_document *doc,
*
* The contents of ::frag will be destroyed and ::frag will be freed.
*/
-void dom_document_fragment_destroy(struct dom_document *doc,
+void _dom_document_fragment_destroy(struct dom_document *doc,
struct dom_document_fragment *frag)
{
- struct dom_node_internal *c, *d;
-
- /* Destroy children of this node */
- for (c = frag->base.first_child; c != NULL; c = d) {
- d = c->next;
-
- /* Detach child */
- c->parent = NULL;
-
- if (c->refcnt > 0) {
- /* Something is using this child */
+ /* Finalise base class */
+ _dom_document_fragment_finalise(doc, &frag->base);
- /** \todo add to list of nodes pending deletion */
+ /* Destroy fragment */
+ _dom_document_alloc(doc, frag, 0);
+}
- continue;
- }
+/*-----------------------------------------------------------------------*/
- /* Detach from sibling list */
- c->previous = NULL;
- c->next = NULL;
+/* Overload protected functions */
- dom_node_destroy(c);
- }
+/* The virtual destroy function of this class */
+void _dom_df_destroy(struct dom_node_internal *node)
+{
+ _dom_document_fragment_destroy(node->owner,
+ (struct dom_document_fragment *) node);
+}
- /* Finalise base class */
- dom_node_finalise(doc, &frag->base);
+/* The memory allocator of this class */
+dom_exception _dom_df_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret)
+{
+ UNUSED(n);
+ struct dom_document_fragment *a;
+
+ a = _dom_document_alloc(doc, NULL,
+ sizeof(struct dom_document_fragment));
+ if (a == NULL)
+ return DOM_NO_MEM_ERR;
+
+ *ret = (dom_node_internal *) a;
+ dom_node_set_owner(*ret, doc);
- /* Destroy fragment */
- dom_document_alloc(doc, frag, 0);
+ return DOM_NO_ERR;
}
-void _dom_document_fragment_destroy(struct dom_node_internal *node)
+/* The copy constructor of this class */
+dom_exception _dom_df_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old)
{
- struct dom_document *doc;
- dom_node_get_owner_document(node, &doc);
-
- dom_document_fragment_destroy(doc,
- (struct dom_document_fragment *) node);
+ return _dom_node_copy(new, old);
}
+
diff --git a/src/core/doc_fragment.h b/src/core/doc_fragment.h
index 08e3422..9d3de76 100644
--- a/src/core/doc_fragment.h
+++ b/src/core/doc_fragment.h
@@ -13,12 +13,29 @@
struct dom_document_fragment;
struct dom_document;
struct dom_string;
+struct lwc_string_s;
-dom_exception dom_document_fragment_create(struct dom_document *doc,
- struct dom_string *name, struct dom_string *value,
+dom_exception _dom_document_fragment_create(struct dom_document *doc,
+ struct lwc_string_s *name, struct dom_string *value,
struct dom_document_fragment **result);
-void dom_document_fragment_destroy(struct dom_document *doc,
+void _dom_document_fragment_destroy(struct dom_document *doc,
struct dom_document_fragment *frag);
+#define _dom_document_fragment_initialise _dom_node_initialise
+#define _dom_document_fragment_finalise _dom_node_finalise
+
+
+/* Following comes the protected vtable */
+void _dom_df_destroy(struct dom_node_internal *node);
+dom_exception _dom_df_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret);
+dom_exception _dom_df_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old);
+
+#define DOM_DF_PROTECT_VTABLE \
+ _dom_df_destroy, \
+ _dom_df_alloc, \
+ _dom_df_copy
+
#endif
diff --git a/src/core/document.c b/src/core/document.c
index 355d7f8..7d7e64a 100644
--- a/src/core/document.c
+++ b/src/core/document.c
@@ -3,16 +3,21 @@
* Licensed under the MIT License,
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
*/
-#include <string.h>
+#include <assert.h>
+
+#include <libwapcaplet/libwapcaplet.h>
#include <dom/functypes.h>
#include <dom/bootstrap/implpriv.h>
+#include <dom/core/attr.h>
+#include <dom/core/element.h>
#include <dom/core/document.h>
#include <dom/core/implementation.h>
-#include <dom/core/string.h>
+#include "core/string.h"
#include "core/attr.h"
#include "core/cdatasection.h"
#include "core/comment.h"
@@ -24,6 +29,7 @@
#include "core/nodelist.h"
#include "core/pi.h"
#include "core/text.h"
+#include "utils/validate.h"
#include "utils/namespace.h"
#include "utils/utils.h"
@@ -37,21 +43,6 @@ struct dom_doc_nl {
struct dom_doc_nl *prev; /**< Previous item */
};
-/**
- * Item in list of active namednodemaps
- */
-struct dom_doc_nnm {
- struct dom_namednodemap *map; /**< Named node map */
-
- struct dom_doc_nnm *next; /**< Next map */
- struct dom_doc_nnm *prev; /**< Previous map */
-};
-
-
-/** Interned node name strings, indexed by node type */
-/* Index 0 is unused */
-static struct dom_string *__nodenames_utf8[DOM_NODE_TYPE_COUNT + 1];
-
/* The virtual functions of this dom_document */
static struct dom_document_vtable document_vtable = {
{
@@ -60,84 +51,31 @@ static struct dom_document_vtable document_vtable = {
DOM_DOCUMENT_VTABLE
};
-/**
- * Initialise the document module
- *
- * \param alloc Memory (de)allocation function
- * \param pw Pointer to client-specific private data
- * \return DOM_NO_ERR on success
- */
-dom_exception _dom_document_initialise(dom_alloc alloc, void *pw)
-{
- static struct {
- const char *name;
- size_t len;
- } names_utf8[DOM_NODE_TYPE_COUNT + 1] = {
- { NULL, 0 }, /* Unused */
- { NULL, 0 }, /* Element */
- { NULL, 0 }, /* Attr */
- { "#text", 5 }, /* Text */
- { "#cdata-section", 14 }, /* CDATA section */
- { NULL, 0 }, /* Entity reference */
- { NULL, 0 }, /* Entity */
- { NULL, 0 }, /* Processing instruction */
- { "#comment", 8 }, /* Comment */
- { "#document", 9 }, /* Document */
- { NULL, 0 }, /* Document type */
- { "#document-fragment", 18 }, /* Document fragment */
- { NULL, 0 } /* Notation */
- };
- dom_exception err;
+static struct dom_node_protect_vtable document_protect_vtable = {
+ DOM_DOCUMENT_PROTECT_VTABLE
+};
- /* Initialise interned node names */
- for (int i = 0; i <= DOM_NODE_TYPE_COUNT; i++) {
- if (names_utf8[i].name == NULL) {
- /* Nothing to intern; skip this entry */
- __nodenames_utf8[i] = NULL;
- continue;
- }
- /* Make string */
- err = dom_string_create(alloc, pw,
- (const uint8_t *) names_utf8[i].name,
- names_utf8[i].len, &__nodenames_utf8[i]);
- if (err != DOM_NO_ERR) {
- /* Failed, clean up strings we've created so far */
- for (int j = 0; j < i; j++) {
- if (__nodenames_utf8[j] != NULL) {
- dom_string_unref(__nodenames_utf8[j]);
- }
- }
- return err;
- }
- }
+/*----------------------------------------------------------------------*/
- return DOM_NO_ERR;
-}
+/* Internally used helper functions */
+static dom_exception dom_document_dup_node(dom_document *doc,
+ struct dom_node *node, bool deep, struct dom_node **result,
+ dom_node_operation opt);
-/**
- * Finalise the document module
- *
- * \return DOM_NO_ERR.
- */
-dom_exception _dom_document_finalise(void)
-{
- for (int i = 0; i <= DOM_NODE_TYPE_COUNT; i++) {
- if (__nodenames_utf8[i] != NULL) {
- dom_string_unref(__nodenames_utf8[i]);
- }
- }
- return DOM_NO_ERR;
-}
+/*----------------------------------------------------------------------*/
+
+/* The constructors and destructors */
/**
* Create a Document
*
- * \param impl The DOM implementation owning the document
- * \param alloc Memory (de)allocation function
- * \param pw Pointer to client-specific private data
- * \param doc Pointer to location to receive created document
+ * \param impl The DOM implementation owning the document
+ * \param alloc Memory (de)allocation function
+ * \param pw Pointer to client-specific private data
+ * \param doc Pointer to location to receive created document
+ * \param ctx The intern string context of this document
* \return DOM_NO_ERR on success, DOM_NO_MEM_ERR on memory exhaustion.
*
* ::impl will have its reference count increased.
@@ -145,7 +83,8 @@ dom_exception _dom_document_finalise(void)
* The returned document will already be referenced.
*/
dom_exception dom_document_create(struct dom_implementation *impl,
- dom_alloc alloc, void *pw, struct dom_document **doc)
+ dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ struct dom_document **doc)
{
struct dom_document *d;
dom_exception err;
@@ -155,103 +94,107 @@ dom_exception dom_document_create(struct dom_implementation *impl,
if (d == NULL)
return DOM_NO_MEM_ERR;
- /* Set up document allocation context - must be first */
- d->alloc = alloc;
- d->pw = pw;
-
/* Initialise the virtual table */
d->base.base.vtable = &document_vtable;
- d->base.destroy = &dom_document_destroy;
+ d->base.vtable = &document_protect_vtable;
/* Initialise base class -- the Document has no parent, so
* destruction will be attempted as soon as its reference count
* reaches zero. Documents own themselves (this simplifies the
* rest of the code, as it doesn't need to special case Documents)
*/
- err = dom_node_initialise(&d->base, d, DOM_DOCUMENT_NODE,
- NULL, NULL, NULL, NULL);
+ err = _dom_document_initialise(d, impl, alloc, pw, ctx);
if (err != DOM_NO_ERR) {
/* Clean up document */
alloc(d, 0, pw);
return err;
}
- /* Initialise remaining type-specific data */
- if (impl != NULL)
- dom_implementation_ref(impl);
- d->impl = impl;
-
- d->nodelists = NULL;
- d->maps = NULL;
-
- d->nodenames = __nodenames_utf8;
-
*doc = d;
return DOM_NO_ERR;
}
-/**
- * Destroy a document
- *
- * \param doc The document to destroy, which is passed in as a
- *
- * dom_node_internl
- *
- * The contents of ::doc will be destroyed and ::doc will be freed.
- */
-void dom_document_destroy(struct dom_node_internal *dnode)
+/* Initialise the document */
+dom_exception _dom_document_initialise(struct dom_document *doc,
+ struct dom_implementation *impl, dom_alloc alloc, void *pw,
+ struct lwc_context_s *ctx)
{
- struct dom_document *doc = (struct dom_document *) dnode;
- struct dom_node_internal *c, *d;
+ assert(ctx != NULL);
+ assert(alloc != NULL);
+ assert(impl != NULL);
- /* Destroy children of this node */
- for (c = doc->base.first_child; c != NULL; c = d) {
- d = c->next;
+ dom_exception err;
+ lwc_string *name;
+ lwc_error lerr;
+
+ lerr = lwc_context_intern(ctx, "#document", SLEN("#document"), &name);
+ if (lerr != lwc_error_ok)
+ return _dom_exception_from_lwc_error(lerr);
- /* Detach child */
- c->parent = NULL;
+ dom_implementation_ref(impl);
+ doc->impl = impl;
- if (c->refcnt > 0) {
- /* Something is using this child */
+ doc->nodelists = NULL;
- /** \todo add to list of nodes pending deletion */
+ /* Set up document allocation context - must be first */
+ doc->alloc = alloc;
+ doc->pw = pw;
+ doc->context = lwc_context_ref(ctx);
- continue;
- }
+ err = _dom_node_initialise(&doc->base, doc, DOM_DOCUMENT_NODE,
+ name, NULL, NULL, NULL);
+ lwc_context_string_unref(ctx, name);
- /* Detach from sibling list */
- c->previous = NULL;
- c->next = NULL;
+ list_init(&doc->pending_nodes);
- dom_node_destroy(c);
- }
+ doc->id_name = NULL;
- /** \todo Ensure list of nodes pending deletion is empty. If not,
+ return err;
+}
+
+
+/* Finalise the document */
+bool _dom_document_finalise(struct dom_document *doc)
+{
+ /* Finalise base class, delete the tree in force */
+ _dom_node_finalise(doc, &doc->base);
+
+ /* Now, the first_child and last_child should be null */
+ doc->base.first_child = NULL;
+ doc->base.last_child = NULL;
+
+ /* Ensure list of nodes pending deletion is empty. If not,
* then we can't yet destroy the document (its destruction will
* have to wait until the pending nodes are destroyed) */
+ if (doc->pending_nodes.next != &doc->pending_nodes)
+ return false;
/* Ok, the document tree is empty, as is the list of nodes pending
* deletion. Therefore, it is safe to destroy the document. */
-
if (doc->impl != NULL)
dom_implementation_unref(doc->impl);
doc->impl = NULL;
- /* This is paranoia -- if there are any remaining nodelists or
- * namednodemaps, then the document's reference count will be
+ /* This is paranoia -- if there are any remaining nodelists,
+ * then the document's reference count will be
* non-zero as these data structures reference the document because
* they are held by the client. */
doc->nodelists = NULL;
- doc->maps = NULL;
- /* Finalise base class */
- dom_node_finalise(doc, &doc->base);
+ if (doc->id_name != NULL)
+ lwc_context_string_unref(doc->context, doc->id_name);
+ lwc_context_unref(doc->context);
- /* Free document */
- doc->alloc(doc, 0, doc->pw);
+ return true;
}
+
+
+/*----------------------------------------------------------------------*/
+
+/* Public virtual functions */
+
/**
* Retrieve the doctype of a document
*
@@ -319,7 +262,7 @@ dom_exception _dom_document_get_document_element(struct dom_document *doc,
{
struct dom_node_internal *root;
- /* Find first element node in child list */
+ /* Find the first element node in child list */
for (root = doc->base.first_child; root != NULL; root = root->next) {
if (root->type == DOM_ELEMENT_NODE)
break;
@@ -351,7 +294,21 @@ dom_exception _dom_document_get_document_element(struct dom_document *doc,
dom_exception _dom_document_create_element(struct dom_document *doc,
struct dom_string *tag_name, struct dom_element **result)
{
- return dom_element_create(doc, tag_name, NULL, NULL, result);
+ lwc_string *name;
+ dom_exception err;
+
+ if (_dom_validate_name(tag_name) == false)
+ return DOM_INVALID_CHARACTER_ERR;
+
+ assert(doc->context != NULL);
+ err = _dom_string_intern(tag_name, doc->context, &name);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = _dom_element_create(doc, name, NULL, NULL, result);
+ lwc_context_string_unref(doc->context, name);
+
+ return err;
}
/**
@@ -368,9 +325,21 @@ dom_exception _dom_document_create_element(struct dom_document *doc,
dom_exception _dom_document_create_document_fragment(struct dom_document *doc,
struct dom_document_fragment **result)
{
- return dom_document_fragment_create(doc,
- doc->nodenames[DOM_DOCUMENT_FRAGMENT_NODE],
- NULL, result);
+ lwc_string *name;
+ dom_exception err;
+ lwc_error lerr;
+
+ assert(doc->context != NULL);
+
+ lerr = lwc_context_intern(doc->context, "#document-fragment",
+ SLEN("#document-fragment"), &name);
+ if (lerr != lwc_error_ok)
+ return _dom_exception_from_lwc_error(lerr);
+
+ err = _dom_document_fragment_create(doc, name, NULL, result);
+ lwc_context_string_unref(doc->context, name);
+
+ return err;
}
/**
@@ -388,8 +357,20 @@ dom_exception _dom_document_create_document_fragment(struct dom_document *doc,
dom_exception _dom_document_create_text_node(struct dom_document *doc,
struct dom_string *data, struct dom_text **result)
{
- return dom_text_create(doc, doc->nodenames[DOM_TEXT_NODE],
- data, result);
+ lwc_string *name;
+ dom_exception err;
+ lwc_error lerr;
+
+ assert(doc->context != NULL);
+
+ lerr = lwc_context_intern(doc->context, "#text", SLEN("#text"), &name);
+ if (lerr != lwc_error_ok)
+ return _dom_exception_from_lwc_error(lerr);
+
+ err = _dom_text_create(doc, name, data, result);
+ lwc_context_string_unref(doc->context, name);
+
+ return err;
}
/**
@@ -407,8 +388,21 @@ dom_exception _dom_document_create_text_node(struct dom_document *doc,
dom_exception _dom_document_create_comment(struct dom_document *doc,
struct dom_string *data, struct dom_comment **result)
{
- return dom_comment_create(doc, doc->nodenames[DOM_COMMENT_NODE],
- data, result);
+ lwc_string *name;
+ dom_exception err;
+ lwc_error lerr;
+
+ assert(doc->context != NULL);
+
+ lerr = lwc_context_intern(doc->context, "#comment", SLEN("#comment"),
+ &name);
+ if (lerr != lwc_error_ok)
+ return _dom_exception_from_lwc_error(lerr);
+
+ err = _dom_comment_create(doc, name, data, result);
+ lwc_context_string_unref(doc->context, name);
+
+ return err;
}
/**
@@ -427,9 +421,21 @@ dom_exception _dom_document_create_comment(struct dom_document *doc,
dom_exception _dom_document_create_cdata_section(struct dom_document *doc,
struct dom_string *data, struct dom_cdata_section **result)
{
- return dom_cdata_section_create(doc,
- doc->nodenames[DOM_CDATA_SECTION_NODE],
- data, result);
+ lwc_string *name;
+ dom_exception err;
+ lwc_error lerr;
+
+ assert(doc->context != NULL);
+
+ lerr = lwc_context_intern(doc->context, "#cdata-section",
+ SLEN("#cdata-section"), &name);
+ if (lerr != lwc_error_ok)
+ return _dom_exception_from_lwc_error(lerr);
+
+ err = _dom_cdata_section_create(doc, name, data, result);
+ lwc_context_string_unref(doc->context, name);
+
+ return err;
}
/**
@@ -452,7 +458,21 @@ dom_exception _dom_document_create_processing_instruction(
struct dom_string *data,
struct dom_processing_instruction **result)
{
- return dom_processing_instruction_create(doc, target, data, result);
+ lwc_string *name;
+ dom_exception err;
+
+ if (_dom_validate_name(target) == false)
+ return DOM_INVALID_CHARACTER_ERR;
+
+ assert(doc->context != NULL);
+ err = _dom_string_intern(target, doc->context, &name);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = _dom_processing_instruction_create(doc, name, data, result);
+ lwc_context_string_unref(doc->context, name);
+
+ return err;
}
/**
@@ -471,7 +491,20 @@ dom_exception _dom_document_create_processing_instruction(
dom_exception _dom_document_create_attribute(struct dom_document *doc,
struct dom_string *name, struct dom_attr **result)
{
- return dom_attr_create(doc, name, NULL, NULL, result);
+ lwc_string *n;
+ dom_exception err;
+
+ if (_dom_validate_name(name) == false)
+ return DOM_INVALID_CHARACTER_ERR;
+
+ assert(doc->context != NULL);
+ err = _dom_string_intern(name, doc->context, &n);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = _dom_attr_create(doc, n, NULL, NULL, true, result);
+ lwc_context_string_unref(doc->context, n);
+ return err;
}
/**
@@ -492,7 +525,20 @@ dom_exception _dom_document_create_entity_reference(struct dom_document *doc,
struct dom_string *name,
struct dom_entity_reference **result)
{
- return dom_entity_reference_create(doc, name, NULL, result);
+ lwc_string *n;
+ dom_exception err;
+
+ if (_dom_validate_name(name) == false)
+ return DOM_INVALID_CHARACTER_ERR;
+
+ assert(doc->context != NULL);
+ err = _dom_string_intern(name, doc->context, &n);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = _dom_entity_reference_create(doc, n, NULL, result);
+ lwc_context_string_unref(doc->context, n);
+ return err;
}
/**
@@ -510,8 +556,20 @@ dom_exception _dom_document_create_entity_reference(struct dom_document *doc,
dom_exception _dom_document_get_elements_by_tag_name(struct dom_document *doc,
struct dom_string *tagname, struct dom_nodelist **result)
{
- return dom_document_get_nodelist(doc, (struct dom_node_internal *) doc,
- tagname, NULL, NULL, result);
+ lwc_string *name;
+ dom_exception err;
+
+ assert(doc->context != NULL);
+ err = _dom_string_intern(tagname, doc->context, &name);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = _dom_document_get_nodelist(doc, DOM_NODELIST_BY_NAME,
+ (struct dom_node_internal *) doc, name, NULL, NULL,
+ result);
+ lwc_context_string_unref(doc->context, name);
+
+ return err;
}
/**
@@ -532,12 +590,10 @@ dom_exception _dom_document_get_elements_by_tag_name(struct dom_document *doc,
dom_exception _dom_document_import_node(struct dom_document *doc,
struct dom_node *node, bool deep, struct dom_node **result)
{
- UNUSED(doc);
- UNUSED(node);
- UNUSED(deep);
- UNUSED(result);
+ /* TODO: The DOM_INVALID_CHARACTER_ERR exception */
- return DOM_NOT_SUPPORTED_ERR;
+ return dom_document_dup_node(doc, node, deep, result,
+ DOM_NODE_IMPORTED);
}
/**
@@ -575,7 +631,8 @@ dom_exception _dom_document_create_element_ns(struct dom_document *doc,
struct dom_string *prefix, *localname;
dom_exception err;
- /** \todo ensure document supports XML feature */
+ if (_dom_validate_name(qname) == false)
+ return DOM_INVALID_CHARACTER_ERR;
/* Validate qname */
err = _dom_namespace_validate_qname(qname, namespace);
@@ -589,13 +646,57 @@ dom_exception _dom_document_create_element_ns(struct dom_document *doc,
return err;
}
+ /* Get the interned string from the dom_string */
+ assert(doc->context != NULL);
+ lwc_string *l = NULL, *n = NULL, *p = NULL;
+ if (localname != NULL) {
+ err = _dom_string_intern(localname, doc->context, &l);
+ if (err != DOM_NO_ERR) {
+ dom_string_unref(localname);
+ if (prefix != NULL)
+ dom_string_unref(prefix);
+
+ return err;
+ }
+ }
+ if (namespace != NULL) {
+ err = _dom_string_intern(namespace, doc->context, &n);
+ if (err != DOM_NO_ERR) {
+ lwc_context_string_unref(doc->context, l);
+ dom_string_unref(localname);
+ if (prefix != NULL)
+ dom_string_unref(prefix);
+
+ return err;
+ }
+ }
+ if (prefix != NULL) {
+ err = _dom_string_intern(prefix, doc->context, &p);
+ if (err != DOM_NO_ERR) {
+ lwc_context_string_unref(doc->context, l);
+ lwc_context_string_unref(doc->context, n);
+ dom_string_unref(localname);
+ if (prefix != NULL)
+ dom_string_unref(prefix);
+
+ return err;
+ }
+ }
+
/* Attempt to create element */
- err = dom_element_create(doc, localname, namespace, prefix, result);
+ err = _dom_element_create(doc, l, n, p, result);
/* Tidy up */
- dom_string_unref(localname);
+ if (localname != NULL) {
+ dom_string_unref(localname);
+ lwc_context_string_unref(doc->context, l);
+ }
if (prefix != NULL) {
dom_string_unref(prefix);
+ lwc_context_string_unref(doc->context, p);
+ }
+ if (namespace != NULL) {
+ lwc_context_string_unref(doc->context, n);
}
return err;
@@ -636,7 +737,8 @@ dom_exception _dom_document_create_attribute_ns(struct dom_document *doc,
struct dom_string *prefix, *localname;
dom_exception err;
- /** \todo ensure document supports XML feature */
+ if (_dom_validate_name(qname) == false)
+ return DOM_INVALID_CHARACTER_ERR;
/* Validate qname */
err = _dom_namespace_validate_qname(qname, namespace);
@@ -650,13 +752,56 @@ dom_exception _dom_document_create_attribute_ns(struct dom_document *doc,
return err;
}
+ /* Get the interned string from the dom_string */
+ assert(doc->context != NULL);
+ lwc_string *l = NULL, *n = NULL, *p = NULL;
+ if (localname != NULL) {
+ err = _dom_string_intern(localname, doc->context, &l);
+ if (err != DOM_NO_ERR) {
+ dom_string_unref(localname);
+ if (prefix != NULL)
+ dom_string_unref(prefix);
+
+ return err;
+ }
+ }
+ if (namespace != NULL) {
+ err = _dom_string_intern(namespace, doc->context, &n);
+ if (err != DOM_NO_ERR) {
+ lwc_context_string_unref(doc->context, l);
+ dom_string_unref(localname);
+ if (prefix != NULL)
+ dom_string_unref(prefix);
+
+ return err;
+ }
+ }
+ if (prefix != NULL) {
+ err = _dom_string_intern(prefix, doc->context, &p);
+ if (err != DOM_NO_ERR) {
+ lwc_context_string_unref(doc->context, l);
+ lwc_context_string_unref(doc->context, n);
+ dom_string_unref(localname);
+ if (prefix != NULL)
+ dom_string_unref(prefix);
+
+ return err;
+ }
+ }
/* Attempt to create attribute */
- err = dom_attr_create(doc, localname, namespace, prefix, result);
+ err = _dom_attr_create(doc, l, n, p, true, result);
/* Tidy up */
- dom_string_unref(localname);
+ if (localname != NULL) {
+ dom_string_unref(localname);
+ lwc_context_string_unref(doc->context, l);
+ }
if (prefix != NULL) {
dom_string_unref(prefix);
+ lwc_context_string_unref(doc->context, p);
+ }
+ if (namespace != NULL) {
+ lwc_context_string_unref(doc->context, n);
}
return err;
@@ -669,7 +814,7 @@ dom_exception _dom_document_create_attribute_ns(struct dom_document *doc,
* \param namespace The namespace URI
* \param localname The local name
* \param result Pointer to location to receive result
- * \return DOM_NO_ERR.
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
*
* The returned list will have its reference count increased. It is
* the responsibility of the caller to unref the list once it has
@@ -679,8 +824,33 @@ dom_exception _dom_document_get_elements_by_tag_name_ns(
struct dom_document *doc, struct dom_string *namespace,
struct dom_string *localname, struct dom_nodelist **result)
{
- return dom_document_get_nodelist(doc, (struct dom_node_internal *) doc,
- NULL, namespace, localname, result);
+ dom_exception err;
+ lwc_string *l = NULL, *n = NULL;
+
+ /* Get the interned string from the dom_string */
+ assert(doc->context != NULL);
+ if (localname != NULL) {
+ err = _dom_string_intern(localname, doc->context, &l);
+ if (err != DOM_NO_ERR)
+ return err;
+ }
+ if (namespace != NULL) {
+ err = _dom_string_intern(namespace, doc->context, &n);
+ if (err != DOM_NO_ERR) {
+ lwc_context_string_unref(doc->context, l);
+ return err;
+ }
+ }
+
+ err = _dom_document_get_nodelist(doc, DOM_NODELIST_BY_NAMESPACE,
+ (struct dom_node_internal *) doc, NULL, n, l, result);
+
+ if (l != NULL)
+ lwc_context_string_unref(doc->context, l);
+ if (n != NULL)
+ lwc_context_string_unref(doc->context, n);
+
+ return err;
}
/**
@@ -689,7 +859,7 @@ dom_exception _dom_document_get_elements_by_tag_name_ns(
* \param doc The document to search in
* \param id The ID to search for
* \param result Pointer to location to receive result
- * \return DOM_NO_ERR.
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
*
* The returned node will have its reference count increased. It is
* the responsibility of the caller to unref the node once it has
@@ -698,11 +868,25 @@ dom_exception _dom_document_get_elements_by_tag_name_ns(
dom_exception _dom_document_get_element_by_id(struct dom_document *doc,
struct dom_string *id, struct dom_element **result)
{
- UNUSED(doc);
- UNUSED(id);
- UNUSED(result);
+ lwc_string *i;
+ dom_node_internal *root;
+ dom_exception err;
- return DOM_NOT_SUPPORTED_ERR;
+ *result = NULL;
+
+ assert(doc->context != NULL);
+ err = _dom_string_intern(id, doc->context, &i);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = dom_document_get_document_element(doc, (void *) &root);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = _dom_find_element_by_id(root, i, result);
+ dom_node_unref(root);
+
+ return err;
}
/**
@@ -710,7 +894,7 @@ dom_exception _dom_document_get_element_by_id(struct dom_document *doc,
*
* \param doc The document to query
* \param result Pointer to location to receive result
- * \return DOM_NO_ERR.
+ * \return DOM_NOT_SUPPORTED_ERR, we don't support this API now.
*
* The returned string will have its reference count increased. It is
* the responsibility of the caller to unref the string once it has
@@ -730,7 +914,7 @@ dom_exception _dom_document_get_input_encoding(struct dom_document *doc,
*
* \param doc The document to query
* \param result Pointer to location to receive result
- * \return DOM_NO_ERR.
+ * \return DOM_NOT_SUPPORTED_ERR, we don't support this API now.
*
* The returned string will have its reference count increased. It is
* the responsibility of the caller to unref the string once it has
@@ -750,7 +934,7 @@ dom_exception _dom_document_get_xml_encoding(struct dom_document *doc,
*
* \param doc The document to query
* \param result Pointer to location to receive result
- * \return DOM_NO_ERR.
+ * \return DOM_NOT_SUPPORTED_ERR, we don't support this API now.
*/
dom_exception _dom_document_get_xml_standalone(struct dom_document *doc,
bool *result)
@@ -769,6 +953,9 @@ dom_exception _dom_document_get_xml_standalone(struct dom_document *doc,
* \return DOM_NO_ERR on success,
* DOM_NOT_SUPPORTED_ERR if the document does not support the "XML"
* feature.
+ *
+ * We don't support this API now, so the return value is always
+ * DOM_NOT_SUPPORTED_ERR.
*/
dom_exception _dom_document_set_xml_standalone(struct dom_document *doc,
bool standalone)
@@ -784,11 +971,14 @@ dom_exception _dom_document_set_xml_standalone(struct dom_document *doc,
*
* \param doc The document to query
* \param result Pointer to location to receive result
- * \return DOM_NO_ERR.
+ * \return DOM_NO_ERR
*
* The returned string will have its reference count increased. It is
* the responsibility of the caller to unref the string once it has
* finished with it.
+ *
+ * We don't support this API now, so the return value is always
+ * DOM_NOT_SUPPORTED_ERR.
*/
dom_exception _dom_document_get_xml_version(struct dom_document *doc,
struct dom_string **result)
@@ -807,6 +997,9 @@ dom_exception _dom_document_get_xml_version(struct dom_document *doc,
* \return DOM_NO_ERR on success,
* DOM_NOT_SUPPORTED_ERR if the document does not support the "XML"
* feature.
+ *
+ * We don't support this API now, so the return value is always
+ * DOM_NOT_SUPPORTED_ERR.
*/
dom_exception _dom_document_set_xml_version(struct dom_document *doc,
struct dom_string *version)
@@ -822,7 +1015,7 @@ dom_exception _dom_document_set_xml_version(struct dom_document *doc,
*
* \param doc The document to query
* \param result Pointer to location to receive result
- * \return DOM_NO_ERR.
+ * \return DOM_NOT_SUPPORTED_ERR, we don't support this API now.
*/
dom_exception _dom_document_get_strict_error_checking(
struct dom_document *doc, bool *result)
@@ -838,7 +1031,7 @@ dom_exception _dom_document_get_strict_error_checking(
*
* \param doc The document to query
* \param strict Whether to use strict error checking
- * \return DOM_NO_ERR.
+ * \return DOM_NOT_SUPPORTED_ERR, we don't support this API now.
*/
dom_exception _dom_document_set_strict_error_checking(
struct dom_document *doc, bool strict)
@@ -863,10 +1056,10 @@ dom_exception _dom_document_set_strict_error_checking(
dom_exception _dom_document_get_uri(struct dom_document *doc,
struct dom_string **result)
{
- UNUSED(doc);
- UNUSED(result);
+ dom_string_ref(doc->uri);
+ *result = doc->uri;
- return DOM_NOT_SUPPORTED_ERR;
+ return DOM_NO_ERR;
}
/**
@@ -883,10 +1076,11 @@ dom_exception _dom_document_get_uri(struct dom_document *doc,
dom_exception _dom_document_set_uri(struct dom_document *doc,
struct dom_string *uri)
{
- UNUSED(doc);
- UNUSED(uri);
+ dom_string_unref(doc->uri);
+ dom_string_ref(uri);
+ doc->uri = uri;
- return DOM_NOT_SUPPORTED_ERR;
+ return DOM_NO_ERR;
}
/**
@@ -903,15 +1097,62 @@ dom_exception _dom_document_set_uri(struct dom_document *doc,
* The returned node will have its reference count increased. It is
* the responsibility of the caller to unref the node once it has
* finished with it.
+ *
+ * @note: The spec said adoptNode may be light weight than the importNode
+ * because the former need no Node creation. But in our implementation
+ * this can't be ensured. Both adoptNode and importNode create new
+ * nodes using the importing/adopting document's resource manager. So,
+ * generally, the adoptNode and importNode call the same function
+ * dom_document_dup_node.
*/
dom_exception _dom_document_adopt_node(struct dom_document *doc,
struct dom_node *node, struct dom_node **result)
{
- UNUSED(doc);
- UNUSED(node);
- UNUSED(result);
+ dom_exception err;
+ dom_node_internal *n = (dom_node_internal *) node;
+
+ *result = NULL;
- return DOM_NOT_SUPPORTED_ERR;
+ if (n->type == DOM_DOCUMENT_NODE ||
+ n->type == DOM_DOCUMENT_TYPE_NODE) {
+ return DOM_NOT_SUPPORTED_ERR;
+ }
+
+ if (n->type == DOM_ENTITY_NODE ||
+ n->type == DOM_NOTATION_NODE ||
+ n->type == DOM_PROCESSING_INSTRUCTION_NODE ||
+ n->type == DOM_TEXT_NODE ||
+ n->type == DOM_CDATA_SECTION_NODE ||
+ n->type == DOM_COMMENT_NODE) {
+ *result = NULL;
+ return DOM_NO_ERR;
+ }
+
+ /* Support XML when necessary */
+ if (n->type == DOM_ENTITY_REFERENCE_NODE) {
+ return DOM_NOT_SUPPORTED_ERR;
+ }
+
+ err = dom_document_dup_node(doc, node, true, result, DOM_NODE_ADOPTED);
+ if (err != DOM_NO_ERR) {
+ *result = NULL;
+ return err;
+ }
+
+ dom_node_internal *parent = n->parent;
+ dom_node_internal *tmp;
+ if (parent != NULL) {
+ err = dom_node_remove_child(parent, node, (void *) &tmp);
+ if (err != DOM_NO_ERR) {
+ dom_node_unref(*result);
+ *result = NULL;
+ return err;
+ }
+ }
+
+ dom_node_unref(tmp);
+
+ return DOM_NO_ERR;
}
/**
@@ -919,7 +1160,7 @@ dom_exception _dom_document_adopt_node(struct dom_document *doc,
*
* \param doc The document to query
* \param result Pointer to location to receive result
- * \return DOM_NO_ERR.
+ * \return DOM_NOT_SUPPORTED_ERR, we don't support this API now.
*
* The returned object will have its reference count increased. It is
* the responsibility of the caller to unref the object once it has
@@ -938,7 +1179,7 @@ dom_exception _dom_document_get_dom_config(struct dom_document *doc,
* Normalize a document
*
* \param doc The document to normalize
- * \return DOM_NO_ERR.
+ * \return DOM_NOT_SUPPORTED_ERR, we don't support this API now.
*/
dom_exception _dom_document_normalize(struct dom_document *doc)
{
@@ -977,6 +1218,9 @@ dom_exception _dom_document_normalize(struct dom_document *doc)
* The returned node will have its reference count increased. It is
* the responsibility of the caller to unref the node once it has
* finished with it.
+ *
+ * We don't support this API now, so the return value is always
+ * DOM_NOT_SUPPORTED_ERR.
*/
dom_exception _dom_document_rename_node(struct dom_document *doc,
struct dom_node *node,
@@ -992,6 +1236,51 @@ dom_exception _dom_document_rename_node(struct dom_document *doc,
return DOM_NOT_SUPPORTED_ERR;
}
+/*-----------------------------------------------------------------------*/
+
+/* Overload protectd virtual functions */
+
+/* The virtual destroy function of this class */
+void _dom_document_destroy(struct dom_node_internal *node)
+{
+ struct dom_document *doc = (struct dom_document *) node;
+
+ if (_dom_document_finalise(doc) == true) {
+ doc->alloc(doc, 0, doc->pw);
+ }
+}
+
+/* The memory allocation function of this class */
+dom_exception __dom_document_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret)
+{
+ UNUSED(n);
+ struct dom_document *a;
+
+ a = _dom_document_alloc(doc, NULL, sizeof(struct dom_document));
+ if (a == NULL)
+ return DOM_NO_MEM_ERR;
+
+ *ret = (dom_node_internal *) a;
+ dom_node_set_owner(*ret, doc);
+
+ return DOM_NO_ERR;
+}
+
+/* The copy constructor function of this class */
+dom_exception _dom_document_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old)
+{
+ UNUSED(new);
+ UNUSED(old);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+
+/* ----------------------------------------------------------------------- */
+
+/* Helper functions */
/**
* Create a DOM string, using a document's allocation context
*
@@ -1007,15 +1296,96 @@ dom_exception _dom_document_rename_node(struct dom_document *doc,
* The string of characters passed in will be copied for use by the
* returned DOM string.
*/
-dom_exception dom_document_create_string(struct dom_document *doc,
+dom_exception _dom_document_create_string(struct dom_document *doc,
const uint8_t *data, size_t len, struct dom_string **result)
{
return dom_string_create(doc->alloc, doc->pw, data, len, result);
}
-/* */
-/* ----------------------------------------------------------------------- */
-/* */
+/*
+ * Create a lwc_string
+ *
+ * \param doc The document object
+ * \param data The raw string data
+ * \param len The raw string length
+ * \param result The resturned lwc_string
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_document_create_lwcstring(struct dom_document *doc,
+ const uint8_t *data, size_t len, struct lwc_string_s **result)
+{
+ lwc_error lerr;
+
+ assert(doc->context != NULL);
+
+ lerr = lwc_context_intern(doc->context, (const char *) data, len,
+ result);
+
+ return _dom_exception_from_lwc_error(lerr);
+}
+
+/* Simple accessor for lwc_context of this document */
+struct lwc_context_s *_dom_document_get_intern_context(
+ struct dom_document *doc)
+{
+ return doc->context;
+}
+
+/* Get the resource manager from the document */
+void _dom_document_get_resource_mgr(
+ struct dom_document *doc, struct dom_resource_mgr *rm)
+{
+ rm->alloc = doc->alloc;
+ rm->pw = doc->pw;
+ rm->ctx = doc->context;
+}
+
+/* Simple accessor for allocator data for this document */
+void _dom_document_get_allocator(struct dom_document *doc, dom_alloc *al,
+ void **pw)
+{
+ *al = doc->alloc;
+ *pw = doc->pw;
+}
+/*
+ * Create a dom_string from a lwc_string.
+ *
+ * \param doc The document object
+ * \param str The lwc_string object
+ * \param result The retured dom_string
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_document_create_string_from_lwcstring(
+ struct dom_document *doc, struct lwc_string_s *str,
+ struct dom_string **result)
+{
+ assert(doc->context != NULL);
+
+ return _dom_string_create_from_lwcstring(doc->alloc, doc->pw,
+ doc->context, str, result);
+}
+
+/**
+ * Create a hash_table
+ *
+ * \param doc The dom_document
+ * \param chains The number of chains
+ * \param f The hash function
+ * \param ht The returned hash_table
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_document_create_hashtable(struct dom_document *doc,
+ size_t chains, dom_hash_func f, struct dom_hash_table **ht)
+{
+ struct dom_hash_table *ret;
+
+ ret = _dom_hash_create(chains, f, doc->alloc, doc->pw);
+ if (ret == NULL)
+ return DOM_NO_MEM_ERR;
+
+ *ht = ret;
+ return DOM_NO_ERR;
+}
/**
* (De)allocate memory with a document's context
@@ -1028,7 +1398,7 @@ dom_exception dom_document_create_string(struct dom_document *doc,
* This call (modulo ::doc) has the same semantics as realloc().
* It is a thin veneer over the client-provided allocation function.
*/
-void *dom_document_alloc(struct dom_document *doc, void *ptr, size_t size)
+void *_dom_document_alloc(struct dom_document *doc, void *ptr, size_t size)
{
return doc->alloc(ptr, size, doc->pw);
}
@@ -1037,6 +1407,7 @@ void *dom_document_alloc(struct dom_document *doc, void *ptr, size_t size)
* Get a nodelist, creating one if necessary
*
* \param doc The document to get a nodelist for
+ * \param type The type of the NodeList
* \param root Root node of subtree that list applies to
* \param tagname Name of nodes in list (or NULL)
* \param namespace Namespace part of nodes in list (or NULL)
@@ -1048,16 +1419,16 @@ void *dom_document_alloc(struct dom_document *doc, void *ptr, size_t size)
* the responsibility of the caller to unref the list once it has
* finished with it.
*/
-dom_exception dom_document_get_nodelist(struct dom_document *doc,
- struct dom_node_internal *root, struct dom_string *tagname,
- struct dom_string *namespace, struct dom_string *localname,
- struct dom_nodelist **list)
+dom_exception _dom_document_get_nodelist(struct dom_document *doc,
+ nodelist_type type, struct dom_node_internal *root,
+ struct lwc_string_s *tagname, struct lwc_string_s *namespace,
+ struct lwc_string_s *localname, struct dom_nodelist **list)
{
struct dom_doc_nl *l;
dom_exception err;
for (l = doc->nodelists; l; l = l->next) {
- if (dom_nodelist_match(l->list, root, tagname,
+ if (_dom_nodelist_match(l->list, type, root, tagname,
namespace, localname))
break;
}
@@ -1074,7 +1445,7 @@ dom_exception dom_document_get_nodelist(struct dom_document *doc,
return DOM_NO_MEM_ERR;
/* Create nodelist */
- err = dom_nodelist_create(doc, root, tagname, namespace,
+ err = _dom_nodelist_create(doc, type, root, tagname, namespace,
localname, &l->list);
if (err != DOM_NO_ERR) {
doc->alloc(l, 0, doc->pw);
@@ -1093,7 +1464,7 @@ dom_exception dom_document_get_nodelist(struct dom_document *doc,
* If it did, the nodelist's reference count would never reach zero,
* and the list would remain indefinitely. This is not a problem as
* the list notifies the document of its destruction via
- * dom_document_remove_nodelist. */
+ * _dom_document_remove_nodelist. */
*list = l->list;
@@ -1106,7 +1477,7 @@ dom_exception dom_document_get_nodelist(struct dom_document *doc,
* \param doc The document to remove the list from
* \param list The list to remove
*/
-void dom_document_remove_nodelist(struct dom_document *doc,
+void _dom_document_remove_nodelist(struct dom_document *doc,
struct dom_nodelist *list)
{
struct dom_doc_nl *l;
@@ -1135,97 +1506,175 @@ void dom_document_remove_nodelist(struct dom_document *doc,
}
/**
- * Get a namednodemap, creating one if necessary
+ * Find element with certain ID in the subtree rooted at root
*
- * \param doc The document to get a namednodemap for
- * \param head Start of list containing items in map
- * \param type The type of items in map
- * \param map Pointer to location to receive map
- * \return DOM_NO_ERR on success, DOM_NO_MEM_ERR on memory exhaustion.
- *
- * The returned map will have its reference count increased. It is
- * the responsibility of the caller to unref the map once it has
- * finished with it.
+ * \param root The root element from where we start
+ * \param id The ID of the target element
+ * \param result The result element
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
*/
-dom_exception dom_document_get_namednodemap(struct dom_document *doc,
- struct dom_node_internal *head, dom_node_type type,
- struct dom_namednodemap **map)
+dom_exception _dom_find_element_by_id(dom_node_internal *root,
+ struct lwc_string_s *id, struct dom_element **result)
+{
+ *result = NULL;
+ dom_node_internal *node = root;
+
+ while (node != NULL) {
+ if (root->type == DOM_ELEMENT_NODE) {
+ lwc_string *real_id;
+ _dom_element_get_id((dom_element *) node, &real_id);
+ if (real_id == id) {
+ *result = (dom_element *) node;
+ return DOM_NO_ERR;
+ }
+ }
+
+ if (node->first_child != NULL) {
+ /* Has children */
+ node = node->first_child;
+ } else if (node->next != NULL) {
+ /* No children, but has siblings */
+ node = node->next;
+ } else {
+ /* No children or siblings.
+ * Find first unvisited relation. */
+ struct dom_node_internal *parent = node->parent;
+
+ while (parent != root &&
+ node == parent->last_child) {
+ node = parent;
+ parent = parent->parent;
+ }
+
+ node = node->next;
+ }
+ }
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Duplicate a Node
+ *
+ * \param doc The documen
+ * \param node The node to duplicate
+ * \param deep Whether to make a deep copy
+ * \param result The returned node
+ * \param opt Whether this is adopt or import operation
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception dom_document_dup_node(dom_document *doc, struct dom_node *node,
+ bool deep, struct dom_node **result, dom_node_operation opt)
{
- struct dom_doc_nnm *m;
dom_exception err;
+ dom_node_internal *n = (dom_node_internal *) node;
- for (m = doc->maps; m; m = m->next) {
- if (dom_namednodemap_match(m->map, head, type))
- break;
+ if (opt == DOM_NODE_ADOPTED && _dom_node_readonly(n))
+ return DOM_NO_MODIFICATION_ALLOWED_ERR;
+
+ if (n->type == DOM_DOCUMENT_NODE ||
+ n->type == DOM_DOCUMENT_TYPE_NODE)
+ return DOM_NOT_SUPPORTED_ERR;
+
+ err = dom_node_alloc(doc, node, result);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = dom_node_copy(*result, node);
+ if (err != DOM_NO_ERR) {
+ _dom_document_alloc(doc, *result, 0);
+ return err;
}
- if (m != NULL) {
- /* Found an existing map, so use it */
- dom_namednodemap_ref(m->map);
- } else {
- /* No existing map */
+ if (n->type == DOM_ATTRIBUTE_NODE) {
+ _dom_attr_set_specified((dom_attr *) node, true);
+ deep = true;
+ }
- /* Create active map entry */
- m = doc->alloc(NULL, sizeof(struct dom_doc_nnm), doc->pw);
- if (m == NULL)
- return DOM_NO_MEM_ERR;
+ if (n->type == DOM_ENTITY_REFERENCE_NODE) {
+ deep = false;
+ }
- /* Create namednodemap */
- err = dom_namednodemap_create(doc, head, type, &m->map);
- if (err != DOM_NO_ERR) {
- doc->alloc(m, 0, doc->pw);
- return err;
- }
+ if (n->type == DOM_ELEMENT_NODE) {
+ /* Specified attributes are copyied but not default attributes,
+ * if the document object hold all the default attributes, we
+ * have nothing to do here */
+ }
- /* Add to document's list of active namednodemaps */
- m->prev = NULL;
- m->next = doc->maps;
- if (doc->maps)
- doc->maps->prev = m;
- doc->maps = m;
+ if (opt == DOM_NODE_ADOPTED && (n->type == DOM_ENTITY_NODE ||
+ n->type == DOM_NOTATION_NODE)) {
+ /* We did not support XML now */
+ return DOM_NOT_SUPPORTED_ERR;
}
- /* Note: the document does not claim a reference on the namednodemap
- * If it did, the map's reference count would never reach zero,
- * and the list would remain indefinitely. This is not a problem as
- * the map notifies the document of its destruction via
- * dom_document_remove_namednodempa. */
+ dom_node_internal *child, *r;
+ if (deep == true) {
+ child = ((dom_node_internal *) node)->first_child;
+ while (child != NULL) {
+ err = dom_document_import_node(doc, child, deep,
+ (void *) &r);
+ if (err != DOM_NO_ERR) {
+ _dom_document_alloc(doc, *result, 0);
+ return err;
+ }
- *map = m->map;
+ err = dom_node_append_child(*result, r, (void *) &r);
+ if (err != DOM_NO_ERR) {
+ _dom_document_alloc(doc, *result, 0);
+ dom_node_unref(r);
+ return err;
+ }
+ dom_node_unref(r);
+
+ child = child->next;
+ }
+ }
+
+ /* Call the dom_user_data_handlers */
+ dom_user_data *ud;
+ ud = n->user_data;
+ while (ud != NULL) {
+ if (ud->handler != NULL)
+ ud->handler(opt, ud->key, ud->data,
+ node, *result);
+ ud = ud->next;
+ }
return DOM_NO_ERR;
}
/**
- * Remove a namednodemap
+ * Try to destory the document.
+ *
+ * \param doc The instance of Document
+ *
+ * Delete the document if:
+ * 1. The refcnt reach zero
+ * 2. The pending list is empty
*
- * \param doc The document to remove the map from
- * \param map The map to remove
+ * else, do nothing.
*/
-void dom_document_remove_namednodemap(struct dom_document *doc,
- struct dom_namednodemap *map)
+void _dom_document_try_destroy(struct dom_document *doc)
{
- struct dom_doc_nnm *m;
-
- for (m = doc->maps; m; m = m->next) {
- if (m->map == map)
- break;
- }
-
- if (m == NULL) {
- /* This should never happen; we should probably abort here */
+ if (doc->base.refcnt != 0 || doc->base.parent != NULL)
return;
- }
-
- /* Remove from list */
- if (m->prev != NULL)
- m->prev->next = m->next;
- else
- doc->maps = m->next;
- if (m->next != NULL)
- m->next->prev = m->prev;
+ _dom_document_destroy((dom_node_internal *) doc);
+}
- /* And free item */
- doc->alloc(m, 0, doc->pw);
+/**
+ * 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)
+{
+ if (doc->id_name != NULL)
+ lwc_context_string_unref(doc->context, doc->id_name);
+ doc->id_name = lwc_context_string_ref(doc->context, name);
}
+
diff --git a/src/core/document.h b/src/core/document.h
index f05b9e0..145eddf 100644
--- a/src/core/document.h
+++ b/src/core/document.h
@@ -12,9 +12,14 @@
#include <stddef.h>
#include <dom/core/node.h>
-#include <dom/core/string.h>
+#include "core/string.h"
#include "core/node.h"
+#include "core/nodelist.h"
+
+#include "utils/hashtable.h"
+#include "utils/resource_mgr.h"
+#include "utils/list.h"
struct dom_document;
struct dom_namednodemap;
@@ -32,7 +37,6 @@ struct dom_entity_reference;
struct dom_configuration;
struct dom_doc_nl;
-struct dom_doc_nnm;
/**
* DOM document
@@ -46,14 +50,40 @@ struct dom_document {
struct dom_doc_nl *nodelists; /**< List of active nodelists */
- struct dom_doc_nnm *maps; /**< List of active namednodemaps */
+ struct dom_string *uri; /**< The uri of this document */
- struct dom_string **nodenames; /**< Interned nodenames */
+ struct lwc_context_s *context; /**< The internment context */
dom_alloc alloc; /**< Memory (de)allocation function */
void *pw; /**< Pointer to client data */
+
+ struct list_entry pending_nodes;
+ /**< The deletion pending list */
+
+ struct lwc_string_s *id_name; /**< The ID attribute's name */
};
+/* Initialise the document */
+dom_exception _dom_document_initialise(struct dom_document *doc,
+ struct dom_implementation *impl, dom_alloc alloc, void *pw,
+ struct lwc_context_s *ctx);
+
+/* Finalise the document */
+bool _dom_document_finalise(struct dom_document *doc);
+
+/* Create a dom_string from C string */
+dom_exception _dom_document_create_string(struct dom_document *doc,
+ const uint8_t *data, size_t len, struct dom_string **result);
+/* Create a lwc_string from C string */
+dom_exception _dom_document_create_lwcstring(struct dom_document *doc,
+ const uint8_t *data, size_t len, struct lwc_string_s **result);
+/* Create a dom_string from a lwc_string */
+dom_exception _dom_document_create_string_from_lwcstring(
+ struct dom_document *doc, struct lwc_string_s *str,
+ struct dom_string **result);
+
+
+/* Begin the virtual functions */
dom_exception _dom_document_get_doctype(struct dom_document *doc,
struct dom_document_type **result);
dom_exception _dom_document_get_implementation(struct dom_document *doc,
@@ -156,34 +186,66 @@ dom_exception _dom_document_rename_node(struct dom_document *doc,
_dom_document_get_dom_config, \
_dom_document_normalize, \
_dom_document_rename_node
+/* End of vtable */
+
+/* Following comes the protected vtable */
+void _dom_document_destroy(struct dom_node_internal *node);
+dom_exception __dom_document_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret);
+dom_exception _dom_document_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old);
-/* Initialise the document module */
-dom_exception _dom_document_initialise(dom_alloc alloc, void *pw);
-/* Finalise the document module */
-dom_exception _dom_document_finalise(void);
+#define DOM_DOCUMENT_PROTECT_VTABLE \
+ _dom_document_destroy, \
+ __dom_document_alloc, \
+ _dom_document_copy
-/* Destroy a document */
-void dom_document_destroy(struct dom_node_internal *dnode);
+/*---------------------------- Helper functions ---------------------------*/
+
+/* Try to destroy the document:
+ * When the refcnt is zero and the pending list is empty, we can destroy this
+ * document. */
+void _dom_document_try_destroy(struct dom_document *doc);
/* (De)allocate memory */
-void *dom_document_alloc(struct dom_document *doc, void *ptr, size_t size);
+void *_dom_document_alloc(struct dom_document *doc, void *ptr, size_t size);
+
+/* Get the internment context */
+inline struct lwc_context_s *_dom_document_get_intern_context(
+ struct dom_document *doc);
+
+/* Get the resource manager inside this document, a resource manager
+ * is an object which contain the memory allocator/intern string context,
+ * with which we can allocate strings or intern strings */
+void _dom_document_get_resource_mgr(
+ struct dom_document *doc, struct dom_resource_mgr *rm);
+
+/* Get the internal allocator and its pointer */
+inline void _dom_document_get_allocator(struct dom_document *doc,
+ dom_alloc *al, void **pw);
+
+/* Create a hash_table */
+dom_exception _dom_document_create_hashtable(struct dom_document *doc,
+ size_t chains, dom_hash_func f, struct dom_hash_table **ht);
/* Get a nodelist, creating one if necessary */
-dom_exception dom_document_get_nodelist(struct dom_document *doc,
- struct dom_node_internal *root, struct dom_string *tagname,
- struct dom_string *namespace, struct dom_string *localname,
- struct dom_nodelist **list);
+dom_exception _dom_document_get_nodelist(struct dom_document *doc,
+ nodelist_type type, struct dom_node_internal *root,
+ struct lwc_string_s *tagname, struct lwc_string_s *namespace,
+ struct lwc_string_s *localname, struct dom_nodelist **list);
/* Remove a nodelist */
-void dom_document_remove_nodelist(struct dom_document *doc,
+void _dom_document_remove_nodelist(struct dom_document *doc,
struct dom_nodelist *list);
-/* Get a namednodemap, creating one if necessary */
-dom_exception dom_document_get_namednodemap(struct dom_document *doc,
- struct dom_node_internal *head, dom_node_type type,
- struct dom_namednodemap **map);
-/* Remove a namednodemap */
-void dom_document_remove_namednodemap(struct dom_document *doc,
- struct dom_namednodemap *map);
+/* Find element with certain ID in the subtree rooted at root */
+dom_exception _dom_find_element_by_id(dom_node_internal *root,
+ struct lwc_string_s *id, struct dom_element **result);
+
+/* Set the ID attribute name of this document */
+void _dom_document_set_id_name(struct dom_document *doc,
+ struct lwc_string_s *name);
+
+#define _dom_document_get_id_name(d) (d->id_name)
#endif
diff --git a/src/core/document_type.c b/src/core/document_type.c
index fc1a1e9..fd59ef1 100644
--- a/src/core/document_type.c
+++ b/src/core/document_type.c
@@ -4,15 +4,20 @@
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
* Copyright 2007 James Shaw <jshaw@netsurf-browser.org>
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
*/
+#include <assert.h>
+
#include <dom/core/document_type.h>
-#include <dom/core/string.h>
#include <dom/bootstrap/implpriv.h>
+#include "core/string.h"
#include "core/document_type.h"
#include "core/node.h"
#include "utils/utils.h"
+#include "utils/namespace.h"
+#include "utils/resource_mgr.h"
/**
* DOM DocumentType node
@@ -20,12 +25,12 @@
struct dom_document_type {
struct dom_node_internal base; /**< Base node */
- /** \todo other members */
+ struct dom_implementation *impl; /**< Owning implementation */
+
struct dom_string *public_id; /**< Doctype public ID */
struct dom_string *system_id; /**< Doctype system ID */
- dom_alloc alloc; /**< Memory (de)allocation function */
- void *pw; /**< Pointer to private data */
+ struct dom_resource_mgr res; /**< resource_mgr of this node */
};
static struct dom_document_type_vtable document_type_vtable = {
@@ -35,6 +40,15 @@ static struct dom_document_type_vtable document_type_vtable = {
DOM_DOCUMENT_TYPE_VTABLE
};
+static struct dom_node_protect_vtable dt_protect_vtable = {
+ DOM_DT_PROTECT_VTABLE
+};
+
+
+/*----------------------------------------------------------------------*/
+
+/* Constructors and destructors */
+
/**
* Create a document type node
*
@@ -52,7 +66,8 @@ static struct dom_document_type_vtable document_type_vtable = {
*/
dom_exception dom_document_type_create(struct dom_string *qname,
struct dom_string *public_id, struct dom_string *system_id,
- dom_alloc alloc, void *pw, struct dom_document_type **doctype)
+ dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ struct dom_document_type **doctype)
{
struct dom_document_type *result;
dom_exception err;
@@ -62,28 +77,12 @@ dom_exception dom_document_type_create(struct dom_string *qname,
if (result == NULL)
return DOM_NO_MEM_ERR;
- /* Initialise base node */
- err = dom_node_initialise(&result->base, NULL, DOM_DOCUMENT_TYPE_NODE,
- qname, NULL, NULL, NULL);
- if (err != DOM_NO_ERR) {
- alloc(result, 0, pw);
- return err;
- }
-
/* Initialise the vtable */
result->base.base.vtable = &document_type_vtable;
- result->base.destroy = &dom_document_type_destroy;
-
- /* Get public and system IDs */
- dom_string_ref(public_id);
- result->public_id = public_id;
-
- dom_string_ref(system_id);
- result->system_id = system_id;
-
- /* Fill in allocation information */
- result->alloc = alloc;
- result->pw = pw;
+ result->base.vtable = &dt_protect_vtable;
+
+ err = _dom_document_type_initialise(result, qname, public_id, system_id,
+ alloc, pw, ctx);
*doctype = result;
@@ -97,22 +96,108 @@ dom_exception dom_document_type_create(struct dom_string *qname,
*
* The contents of ::doctype will be destroyed and ::doctype will be freed.
*/
-void dom_document_type_destroy(struct dom_node_internal *doctypenode)
+void _dom_document_type_destroy(struct dom_node_internal *doctypenode)
{
struct dom_document_type *doctype =
(struct dom_document_type *)doctypenode;
- /* Finish with public and system IDs */
- dom_string_unref(doctype->system_id);
- dom_string_unref(doctype->public_id);
-
/* Finalise base class */
- dom_node_finalise(doctype->base.owner, &doctype->base);
+ _dom_document_type_finalise(doctype);
/* Free doctype */
- doctype->alloc(doctype, 0, doctype->pw);
+ doctype->res.alloc(doctype, 0, doctype->res.pw);
}
+/* Initialise this document_type */
+dom_exception _dom_document_type_initialise(struct dom_document_type *doctype,
+ struct dom_string *qname, struct dom_string *public_id,
+ struct dom_string *system_id, dom_alloc alloc, void *pw,
+ struct lwc_context_s *ctx)
+{
+ dom_exception err;
+
+ dom_string *prefix, *localname;
+ err = _dom_namespace_split_qname(qname, &prefix, &localname);
+ if (err != DOM_NO_ERR) {
+ alloc(doctype, 0, pw);
+ return err;
+ }
+
+ lwc_string *lprefix = NULL, *lname = NULL;
+ if (prefix != NULL) {
+ err = _dom_string_intern(prefix, ctx, &lprefix);
+ if (err != DOM_NO_ERR) {
+ dom_string_unref(prefix);
+ dom_string_unref(localname);
+ alloc(doctype, 0, pw);
+ return err;
+ }
+ }
+
+ if (localname != NULL) {
+ err = _dom_string_intern(localname, ctx, &lname);
+ if (err != DOM_NO_ERR) {
+ dom_string_unref(prefix);
+ dom_string_unref(localname);
+ if (lprefix != NULL)
+ lwc_context_string_unref(ctx, lprefix);
+ alloc(doctype, 0, pw);
+ return err;
+ }
+ }
+
+ /* TODO: I should figure out how the namespaceURI can be got */
+
+ /* Initialise base node */
+ err = _dom_node_initialise_generic(&doctype->base, NULL, alloc, pw,
+ ctx, DOM_DOCUMENT_TYPE_NODE, lname, NULL, NULL,
+ lprefix);
+ if (err != DOM_NO_ERR) {
+ alloc(doctype, 0, pw);
+ return err;
+ }
+
+ /* Get public and system IDs */
+ if (public_id != NULL)
+ dom_string_ref(public_id);
+ doctype->public_id = public_id;
+
+ if (system_id != NULL)
+ dom_string_ref(system_id);
+ doctype->system_id = system_id;
+
+ if (prefix != NULL)
+ dom_string_unref(prefix);
+ if (localname != NULL)
+ dom_string_unref(localname);
+
+ /* Fill in allocation information */
+ doctype->res.alloc = alloc;
+ doctype->res.pw = pw;
+ doctype->res.ctx = ctx;
+
+ return DOM_NO_ERR;
+}
+
+/* The destructor function of dom_document_type */
+void _dom_document_type_finalise(struct dom_document_type *doctype)
+{
+ if (doctype->public_id != NULL)
+ dom_string_unref(doctype->public_id);
+ if (doctype->system_id != NULL)
+ dom_string_unref(doctype->system_id);
+
+ assert(doctype->base.owner != NULL || doctype->base.user_data == NULL);
+
+ _dom_node_finalise_generic(&doctype->base, doctype->res.alloc,
+ doctype->res.pw, doctype->res.ctx);
+}
+
+
+/*----------------------------------------------------------------------*/
+
+/* Virtual functions */
+
/**
* Retrieve a document type's name
*
@@ -123,6 +208,9 @@ void dom_document_type_destroy(struct dom_node_internal *doctypenode)
* The returned string will have its reference count increased. It is
* the responsibility of the caller to unref the string once it has
* finished with it.
+ *
+ * We don't support this API now, so this function call should always
+ * return DOM_NOT_SUPPORTED_ERR.
*/
dom_exception _dom_document_type_get_name(struct dom_document_type *doc_type,
struct dom_string **result)
@@ -143,6 +231,9 @@ dom_exception _dom_document_type_get_name(struct dom_document_type *doc_type,
* The returned map will have its reference count increased. It is
* the responsibility of the caller to unref the map once it has
* finished with it.
+ *
+ * We don't support this API now, so this function call should always
+ * return DOM_NOT_SUPPORTED_ERR.
*/
dom_exception _dom_document_type_get_entities(
struct dom_document_type *doc_type,
@@ -164,6 +255,9 @@ dom_exception _dom_document_type_get_entities(
* The returned map will have its reference count increased. It is
* the responsibility of the caller to unref the map once it has
* finished with it.
+ *
+ * We don't support this API now, so this function call should always
+ * return DOM_NOT_SUPPORTED_ERR.
*/
dom_exception _dom_document_type_get_notations(
struct dom_document_type *doc_type,
@@ -185,6 +279,9 @@ dom_exception _dom_document_type_get_notations(
* The returned string will have its reference count increased. It is
* the responsibility of the caller to unref the string once it has
* finished with it.
+ *
+ * We don't support this API now, so this function call should always
+ * return DOM_NOT_SUPPORTED_ERR.
*/
dom_exception _dom_document_type_get_public_id(
struct dom_document_type *doc_type,
@@ -206,6 +303,9 @@ dom_exception _dom_document_type_get_public_id(
* The returned string will have its reference count increased. It is
* the responsibility of the caller to unref the string once it has
* finished with it.
+ *
+ * We don't support this API now, so this function call should always
+ * return DOM_NOT_SUPPORTED_ERR.
*/
dom_exception _dom_document_type_get_system_id(
struct dom_document_type *doc_type,
@@ -227,6 +327,9 @@ dom_exception _dom_document_type_get_system_id(
* The returned string will have its reference count increased. It is
* the responsibility of the caller to unref the string once it has
* finished with it.
+ *
+ * We don't support this API now, so this function call should always
+ * return DOM_NOT_SUPPORTED_ERR.
*/
dom_exception _dom_document_type_get_internal_subset(
struct dom_document_type *doc_type,
@@ -238,3 +341,60 @@ dom_exception _dom_document_type_get_internal_subset(
return DOM_NOT_SUPPORTED_ERR;
}
+/*-----------------------------------------------------------------------*/
+
+/* Overload protected virtual functions */
+
+/* The virtual destroy function of this class */
+void _dom_dt_destroy(struct dom_node_internal *node)
+{
+ _dom_document_type_destroy(node);
+}
+
+/* The memory allocator of this class */
+dom_exception _dom_dt_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret)
+{
+ UNUSED(doc);
+ UNUSED(n);
+ UNUSED(ret);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/* The copy constructor of this class */
+dom_exception _dom_dt_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old)
+{
+ UNUSED(new);
+ UNUSED(old);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+
+/*----------------------------------------------------------------------*/
+
+/* Helper functions */
+
+/* Get the resource manager of this object */
+void _dom_document_type_get_resource_mgr(
+ struct dom_document_type *dt, struct dom_resource_mgr *rm)
+{
+ rm->alloc = dt->res.alloc;
+ rm->pw = dt->res.pw;
+ rm->ctx = dt->res.ctx;
+}
+
+/**
+ * Get the implementation which created this dom_document_type
+ *
+ * \param dt The document type object
+ * \return the dom_implementation instance which creates this node.
+ */
+struct dom_implementation *_dom_document_type_get_impl(
+ struct dom_document_type *dt)
+{
+ return dt->impl;
+}
+
diff --git a/src/core/document_type.h b/src/core/document_type.h
index e38cf52..649b027 100644
--- a/src/core/document_type.h
+++ b/src/core/document_type.h
@@ -9,9 +9,16 @@
#define dom_internal_core_document_type_h_
struct dom_document_type;
+struct dom_resource_mgr;
+struct dom_implementation;
/* Destroy a document type */
-void dom_document_type_destroy(struct dom_node_internal *doctypenode);
+void _dom_document_type_destroy(struct dom_node_internal *doctypenode);
+dom_exception _dom_document_type_initialise(struct dom_document_type *doctype,
+ struct dom_string *qname, struct dom_string *public_id,
+ struct dom_string *system_id, dom_alloc alloc, void *pw,
+ struct lwc_context_s *ctx);
+void _dom_document_type_finalise(struct dom_document_type *doctype);
/* The virtual functions of DocumentType */
dom_exception _dom_document_type_get_name(struct dom_document_type *doc_type,
@@ -40,5 +47,22 @@ dom_exception _dom_document_type_get_internal_subset(
_dom_document_type_get_system_id, \
_dom_document_type_get_internal_subset
-#endif
+/* Following comes the protected vtable */
+void _dom_dt_destroy(struct dom_node_internal *node);
+dom_exception _dom_dt_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret);
+dom_exception _dom_dt_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old);
+
+#define DOM_DT_PROTECT_VTABLE \
+ _dom_dt_destroy, \
+ _dom_dt_alloc, \
+ _dom_dt_copy
+/* Helper functions */
+void _dom_document_type_get_resource_mgr(
+ struct dom_document_type *dt, struct dom_resource_mgr *rm);
+struct dom_implementation *_dom_document_type_get_impl(
+ struct dom_document_type *dt);
+
+#endif
diff --git a/src/core/element.c b/src/core/element.c
index 80d547e..11c7f5e 100644
--- a/src/core/element.c
+++ b/src/core/element.c
@@ -3,31 +3,122 @@
* Licensed under the MIT License,
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
*/
#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include <dom/dom.h>
#include <dom/core/attr.h>
#include <dom/core/element.h>
#include <dom/core/node.h>
#include <dom/core/string.h>
+#include <dom/core/document.h>
#include "core/attr.h"
#include "core/document.h"
#include "core/element.h"
#include "core/node.h"
+#include "core/namednodemap.h"
+#include "utils/validate.h"
#include "utils/namespace.h"
#include "utils/utils.h"
+#include "utils/hashtable.h"
+
+/* The three numbers are just random ones, maybe we should change it after some
+ * more consideration */
+#define CHAINS_ATTRIBUTES 31
+#define CHAINS_NAMESPACE 7
+#define CHAINS_NS_ATTRIBUTES 31
static struct dom_element_vtable element_vtable = {
{
- DOM_NODE_VTABLE
+ DOM_NODE_VTABLE_ELEMENT
},
DOM_ELEMENT_VTABLE
};
+static struct dom_node_protect_vtable element_protect_vtable = {
+ DOM_ELEMENT_PROTECT_VTABLE
+};
+
+static dom_exception _dom_element_get_attr(struct dom_element *element,
+ struct dom_hash_table *hs, struct dom_string *name,
+ struct dom_string **value);
+static dom_exception _dom_element_set_attr(struct dom_element *element,
+ struct dom_hash_table *hs, struct dom_string *name,
+ struct dom_string *value);
+static dom_exception _dom_element_remove_attr(struct dom_element *element,
+ struct dom_hash_table *hs, struct dom_string *name);
+static dom_exception _dom_element_get_attr_node(struct dom_element *element,
+ struct dom_hash_table *hs, struct dom_string *name,
+ struct dom_attr **result);
+static dom_exception _dom_element_set_attr_node(struct dom_element *element,
+ struct dom_hash_table *hs, struct dom_attr *attr,
+ struct dom_attr **result);
+static dom_exception _dom_element_remove_attr_node(struct dom_element *element,
+ struct dom_hash_table *hs, struct dom_attr *attr,
+ struct dom_attr **result);
+static dom_exception _dom_element_has_attr(struct dom_element *element,
+ struct dom_hash_table *hs, struct dom_string *name,
+ bool *result);
+static dom_exception _dom_element_set_id_attr(struct dom_element *element,
+ struct dom_hash_table *hs, struct dom_string *name, bool is_id);
+
+static unsigned int _dom_element_hash_lwcstring(void *key);
+
+
+/* The operation set for namednodemap */
+static dom_exception attributes_get_length(void *priv,
+ unsigned long *length);
+static dom_exception attributes_get_named_item(void *priv,
+ struct dom_string *name, struct dom_node **node);
+static dom_exception attributes_set_named_item(void *priv,
+ struct dom_node *arg, struct dom_node **node);
+static dom_exception attributes_remove_named_item(
+ void *priv, struct dom_string *name,
+ struct dom_node **node);
+static dom_exception attributes_item(void *priv,
+ unsigned long index, struct dom_node **node);
+static dom_exception attributes_get_named_item_ns(
+ void *priv, struct dom_string *namespace,
+ struct dom_string *localname, struct dom_node **node);
+static dom_exception attributes_set_named_item_ns(
+ void *priv, struct dom_node *arg,
+ struct dom_node **node);
+static dom_exception attributes_remove_named_item_ns(
+ void *priv, struct dom_string *namespace,
+ struct dom_string *localname, struct dom_node **node);
+static void attributes_destroy(void *priv);
+static bool attributes_equal(void *p1, void *p2);
+
+static struct nnm_operation attributes_opt = {
+ attributes_get_length,
+ attributes_get_named_item,
+ attributes_set_named_item,
+ attributes_remove_named_item,
+ attributes_item,
+ attributes_get_named_item_ns,
+ attributes_set_named_item_ns,
+ attributes_remove_named_item_ns,
+ attributes_destroy,
+ attributes_equal
+};
+
+static void *_key(void *key, void *key_pw, dom_alloc alloc, void *pw,
+ bool clone);
+static void *_value(void *value, void *value_pw, dom_alloc alloc,
+ void *pw, bool clone);
+static void *_nsattributes(void *value, void *value_pw, dom_alloc alloc,
+ void *pw, bool clone);
+
+/*----------------------------------------------------------------------*/
+/* Constructors and Destructors */
+
/**
- * Initialise an element node
+ * Create an element node
*
* \param doc The owning document
* \param name The (local) name of the node to create
@@ -43,41 +134,29 @@ static struct dom_element_vtable element_vtable = {
*
* The returned element will already be referenced.
*/
-dom_exception dom_element_initialise(struct dom_element *el,
- struct dom_string *name, struct dom_string *namespace,
- struct dom_string *prefix, struct dom_element **result)
+dom_exception _dom_element_create(struct dom_document *doc,
+ struct lwc_string_s *name, struct lwc_string_s *namespace,
+ struct lwc_string_s *prefix, struct dom_element **result)
{
- dom_exception err;
- struct dom_document *doc;
-
- dom_node_get_owner_document(el, &doc);
-
- /** \todo Sanity check the tag name */
-
- /* Initialise the base class */
- err = dom_node_initialise(&el->base, doc, DOM_ELEMENT_NODE,
- name, NULL, namespace, prefix);
- if (err != DOM_NO_ERR) {
- dom_document_alloc(doc, el, 0);
- return err;
- }
+ struct dom_element *el;
- /* Perform our type-specific initialisation */
- el->attributes = NULL;
- el->schema_type_info = NULL;
+ /* Allocate the element */
+ el = _dom_document_alloc(doc, NULL, sizeof(struct dom_element));
+ if (el == NULL)
+ return DOM_NO_MEM_ERR;
- /* Init the vtable's destroy function */
+ /* Initialise the vtables */
el->base.base.vtable = &element_vtable;
- el->base.destroy = &_dom_element_destroy;
+ el->base.vtable = &element_protect_vtable;
- *result = el;
-
- return DOM_NO_ERR;
+ return _dom_element_initialise(el, doc, name, namespace, prefix,
+ result);
}
/**
- * Create an element node
+ * Initialise an element node
*
+ * \param el The element
* \param doc The owning document
* \param name The (local) name of the node to create
* \param namespace The namespace URI of the element, or NULL
@@ -87,24 +166,51 @@ dom_exception dom_element_initialise(struct dom_element *el,
* DOM_INVALID_CHARACTER_ERR if ::name is invalid,
* DOM_NO_MEM_ERR on memory exhaustion.
*
+ * The caller should make sure that ::name is a valid NCName.
+ *
* ::doc, ::name, ::namespace and ::prefix will have their
* reference counts increased.
*
* The returned element will already be referenced.
*/
-dom_exception dom_element_create(struct dom_document *doc,
- struct dom_string *name, struct dom_string *namespace,
- struct dom_string *prefix, struct dom_element **result)
+dom_exception _dom_element_initialise(struct dom_element *el,
+ struct dom_document *doc, struct lwc_string_s *name,
+ struct lwc_string_s *namespace, struct lwc_string_s *prefix,
+ struct dom_element **result)
{
- struct dom_element *el;
+ dom_exception err;
- /* Allocate the element */
- el = dom_document_alloc(doc, NULL, sizeof(struct dom_element));
- if (el == NULL)
- return DOM_NO_MEM_ERR;
+ assert(doc != NULL);
+
+ err = _dom_document_create_hashtable(doc, CHAINS_ATTRIBUTES,
+ _dom_element_hash_lwcstring, &el->attributes);
+ if (err != DOM_NO_ERR) {
+ _dom_document_alloc(doc, el, 0);
+ return err;
+ }
+
+ err = _dom_document_create_hashtable(doc, CHAINS_NAMESPACE,
+ _dom_element_hash_lwcstring, &el->ns_attributes);
+ if (err != DOM_NO_ERR) {
+ _dom_document_alloc(doc, el, 0);
+ _dom_document_alloc(doc, el->attributes, 0);
+ return err;
+ }
+ /* Initialise the base class */
+ err = _dom_node_initialise(&el->base, doc, DOM_ELEMENT_NODE,
+ name, NULL, namespace, prefix);
+ if (err != DOM_NO_ERR) {
+ _dom_document_alloc(doc, el, 0);
+ return err;
+ }
+
+ /* Perform our type-specific initialisation */
+ el->id_ns = NULL;
+ el->id_name = NULL;
+ el->schema_type_info = NULL;
+
+ *result = el;
- dom_element_initialise(el, name, namespace, prefix, result);
-
return DOM_NO_ERR;
}
@@ -116,54 +222,22 @@ dom_exception dom_element_create(struct dom_document *doc,
*
* The contents of ::element will be destroyed and ::element will be freed.
*/
-void dom_element_destroy(struct dom_document *doc,
+void _dom_element_destroy(struct dom_document *doc,
struct dom_element *element)
{
- struct dom_node_internal *c, *d;
-
- /* Destroy children of this node */
- for (c = element->base.first_child; c != NULL; c = d) {
- d = c->next;
-
- /* Detach child */
- c->parent = NULL;
-
- if (c->refcnt > 0) {
- /* Something is using this child */
-
- /** \todo add to list of nodes pending deletion */
-
- continue;
- }
-
- /* Detach from sibling list */
- c->previous = NULL;
- c->next = NULL;
-
- dom_node_destroy(c);
- }
+ lwc_context *ctx = _dom_document_get_intern_context(doc);
+ assert (ctx != NULL);
/* Destroy attributes attached to this node */
- for (c = (struct dom_node_internal *) element->attributes;
- c != NULL; c = d) {
- d = c->next;
-
- /* Detach child */
- c->parent = NULL;
-
- if (c->refcnt > 0) {
- /* Something is using this attribute */
-
- /** \todo add to list of nodes pending deletion */
-
- continue;
- }
-
- /* Detach from sibling list */
- c->previous = NULL;
- c->next = NULL;
+ if (element->attributes != NULL) {
+ _dom_hash_destroy(element->attributes, _key, ctx, _value, ctx);
+ element->attributes = NULL;
+ }
- dom_node_destroy(c);
+ if (element->ns_attributes != NULL) {
+ _dom_hash_destroy(element->ns_attributes, _key, ctx,
+ _nsattributes, ctx);
+ element->ns_attributes = NULL;
}
if (element->schema_type_info != NULL) {
@@ -171,24 +245,15 @@ void dom_element_destroy(struct dom_document *doc,
}
/* Finalise base class */
- dom_node_finalise(doc, &element->base);
+ _dom_node_finalise(doc, &element->base);
/* Free the element */
- dom_document_alloc(doc, element, 0);
+ _dom_document_alloc(doc, element, 0);
}
-/**
- * The destroy virtual function of dom_element
- *
- * \param element The element to be destroyed
- **/
-void _dom_element_destroy(struct dom_node_internal *node)
-{
- struct dom_document *doc;
- dom_node_get_owner_document(node, &doc);
+/*----------------------------------------------------------------------*/
- dom_element_destroy(doc, (struct dom_element *) node);
-}
+/* The public virtual functions */
/**
* Retrieve an element's tag name
@@ -224,23 +289,7 @@ dom_exception _dom_element_get_tag_name(struct dom_element *element,
dom_exception _dom_element_get_attribute(struct dom_element *element,
struct dom_string *name, struct dom_string **value)
{
- struct dom_node_internal *a = (struct dom_node_internal *)
- element->attributes;
-
- /* Search attributes, looking for name */
- for (; a != NULL; a = a->next) {
- if (dom_string_cmp(a->name, name) == 0)
- break;
- }
-
- /* Fill in value */
- if (a == NULL) {
- *value = NULL;
- } else {
- dom_attr_get_value(((struct dom_attr *) a), value);
- }
-
- return DOM_NO_ERR;
+ return _dom_element_get_attr(element, element->attributes, name, value);
}
/**
@@ -256,58 +305,7 @@ dom_exception _dom_element_get_attribute(struct dom_element *element,
dom_exception _dom_element_set_attribute(struct dom_element *element,
struct dom_string *name, struct dom_string *value)
{
- struct dom_node_internal *e = (struct dom_node_internal *) element;
- struct dom_node_internal *a = (struct dom_node_internal *)
- element->attributes;
-
- /** \todo validate name */
-
- /* Ensure element can be written to */
- if (_dom_node_readonly(e))
- return DOM_NO_MODIFICATION_ALLOWED_ERR;
-
- /* Search for existing attribute with same name */
- for (; a != NULL; a = a->next) {
- if (dom_string_cmp(a->name, name) == 0)
- break;
- }
-
- if (a != NULL) {
- /* Found an existing attribute, so replace its value */
- dom_exception err;
-
- err = dom_attr_set_value((struct dom_attr *) a, value);
- if (err != DOM_NO_ERR)
- return err;
- } else {
- /* No existing attribute, so create one */
- dom_exception err;
- struct dom_attr *attr;
-
- err = dom_attr_create(e->owner, name, NULL, NULL, &attr);
- if (err != DOM_NO_ERR)
- return err;
-
- /* Set its value */
- err = dom_attr_set_value(attr, value);
- if (err != DOM_NO_ERR) {
- dom_node_unref((struct dom_node *) attr);
- return err;
- }
-
- a = (struct dom_node_internal *) attr;
-
- /* And insert it into the element */
- a->previous = NULL;
- a->next = (struct dom_node_internal *) element->attributes;
-
- if (a->next != NULL)
- a->next->previous = a;
-
- element->attributes = attr;
- }
-
- return DOM_NO_ERR;
+ return _dom_element_set_attr(element, element->attributes, name, value);
}
/**
@@ -321,39 +319,7 @@ dom_exception _dom_element_set_attribute(struct dom_element *element,
dom_exception _dom_element_remove_attribute(struct dom_element *element,
struct dom_string *name)
{
- struct dom_node_internal *e = (struct dom_node_internal *) element;
- struct dom_node_internal *a = (struct dom_node_internal *)
- element->attributes;
-
- /* Ensure element can be written to */
- if (_dom_node_readonly(e))
- return DOM_NO_MODIFICATION_ALLOWED_ERR;
-
- /* Search for existing attribute with same name */
- for (; a != NULL; a = a->next) {
- if (dom_string_cmp(a->name, name) == 0)
- break;
- }
-
- /* Detach attr node from list */
- if (a != NULL) {
- if (a->previous != NULL)
- a->previous->next = a->next;
- else
- element->attributes = (struct dom_attr *) a->next;
-
- if (a->next != NULL)
- a->next->previous = a->previous;
-
- a->previous = a->next = a->parent = NULL;
-
- /* And destroy attr */
- dom_node_unref(a);
- }
-
- /** \todo defaulted attribute handling */
-
- return DOM_NO_ERR;
+ return _dom_element_remove_attr(element, element->attributes, name);
}
/**
@@ -368,23 +334,11 @@ dom_exception _dom_element_remove_attribute(struct dom_element *element,
* the responsibility of the caller to unref the node once it has
* finished with it.
*/
-dom_exception _dom_element_get_attribute_node(struct dom_element *element,
+dom_exception _dom_element_get_attribute_node(struct dom_element *element,
struct dom_string *name, struct dom_attr **result)
{
- struct dom_node_internal *a = (struct dom_node_internal *)
- element->attributes;
-
- /* Search attributes, looking for name */
- for (; a != NULL; a = a->next) {
- if (dom_string_cmp(a->name, name) == 0)
- break;
- }
-
- if (a != NULL)
- dom_node_ref(a);
- *result = (struct dom_attr *) a;
-
- return DOM_NO_ERR;
+ return _dom_element_get_attr_node(element, element->attributes, name,
+ result);
}
/**
@@ -407,78 +361,8 @@ dom_exception _dom_element_get_attribute_node(struct dom_element *element,
dom_exception _dom_element_set_attribute_node(struct dom_element *element,
struct dom_attr *attr, struct dom_attr **result)
{
- struct dom_node_internal *e = (struct dom_node_internal *) element;
- struct dom_node_internal *a = (struct dom_node_internal *) attr;
- struct dom_attr *prev = NULL;
-
- /* Ensure element and attribute belong to the same document */
- if (e->owner != a->owner)
- return DOM_WRONG_DOCUMENT_ERR;
-
- /* Ensure element can be written to */
- if (_dom_node_readonly(e))
- return DOM_NO_MODIFICATION_ALLOWED_ERR;
-
- /* Ensure attribute isn't attached to another element */
- if (a->parent != NULL && a->parent != e)
- return DOM_INUSE_ATTRIBUTE_ERR;
-
- /* Attach attr to element, if not already attached */
- if (a->parent == NULL) {
-
- /* Search for existing attribute with same name */
- prev = element->attributes;
- while (prev != NULL) {
- struct dom_node_internal *p =
- (struct dom_node_internal *) prev;
-
- if (dom_string_cmp(a->name, p->name) == 0)
- break;
-
- prev = (struct dom_attr *) p->next;
- }
-
- a->parent = e;
-
- if (prev != NULL) {
- /* Found an existing attribute, so replace it */
- struct dom_node_internal *p =
- (struct dom_node_internal *) prev;
-
- a->previous = p->previous;
- a->next = p->next;
-
- if (a->previous != NULL)
- a->previous->next = a;
- else
- element->attributes = attr;
-
- if (a->next != NULL)
- a->next->previous = a;
-
- /* Invalidate existing attribute's location info */
- p->next = NULL;
- p->previous = NULL;
- p->parent = NULL;
- } else {
- /* No existing attribute, so insert at front of list */
- a->previous = NULL;
- a->next = (struct dom_node_internal *)
- element->attributes;
-
- if (a->next != NULL)
- a->next->previous = a;
-
- element->attributes = attr;
- }
- }
-
- if (prev != NULL)
- dom_node_ref((struct dom_node *) prev);
-
- *result = prev;
-
- return DOM_NO_ERR;
+ return _dom_element_set_attr_node(element, element->attributes, attr,
+ result);
}
/**
@@ -499,35 +383,8 @@ dom_exception _dom_element_set_attribute_node(struct dom_element *element,
dom_exception _dom_element_remove_attribute_node(struct dom_element *element,
struct dom_attr *attr, struct dom_attr **result)
{
- struct dom_node_internal *e = (struct dom_node_internal *) element;
- struct dom_node_internal *a = (struct dom_node_internal *) attr;
-
- /* Ensure element can be written to */
- if (_dom_node_readonly(e))
- return DOM_NO_MODIFICATION_ALLOWED_ERR;
-
- /* Ensure attr is an attribute of element */
- if (a->parent != e)
- return DOM_NOT_FOUND_ERR;
-
- /* Detach attr node from list */
- if (a->previous != NULL)
- a->previous->next = a->next;
- else
- element->attributes = (struct dom_attr *) a->next;
-
- if (a->next != NULL)
- a->next->previous = a->previous;
-
- a->previous = a->next = a->parent = NULL;
-
- /** \todo defaulted attribute handling */
-
- /* Return the detached node */
- dom_node_ref(a);
- *result = attr;
-
- return DOM_NO_ERR;
+ return _dom_element_remove_attr_node(element, element->attributes,
+ attr, result);
}
/**
@@ -547,9 +404,25 @@ dom_exception _dom_element_get_elements_by_tag_name(
struct dom_element *element, struct dom_string *name,
struct dom_nodelist **result)
{
- return dom_document_get_nodelist(element->base.owner,
- (struct dom_node_internal *) element, name, NULL,
+ dom_exception err;
+ lwc_string *n;
+ lwc_context *ctx;
+ dom_node_internal *base = (dom_node_internal *) element;
+
+ assert(base->owner != NULL);
+ ctx = _dom_document_get_intern_context(base->owner);
+ assert(ctx != NULL);
+
+ err = _dom_string_intern(name, ctx, &n);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = _dom_document_get_nodelist(base->owner, DOM_NODELIST_BY_NAME,
+ (struct dom_node_internal *) element, n, NULL,
NULL, result);
+
+ lwc_context_string_unref(ctx, n);
+ return err;
}
/**
@@ -573,28 +446,26 @@ dom_exception _dom_element_get_attribute_ns(struct dom_element *element,
struct dom_string *namespace, struct dom_string *localname,
struct dom_string **value)
{
- struct dom_node_internal *a = (struct dom_node_internal *)
- element->attributes;
-
- /** \todo ensure implementation supports XML */
-
- /* Search attributes, looking for namespace/localname pair */
- for (; a != NULL; a = a->next) {
- if (((namespace == NULL && a->namespace == NULL) ||
- (namespace != NULL &&
- dom_string_cmp(a->namespace, namespace) == 0)) &&
- dom_string_cmp(a->name, localname) == 0)
- break;
- }
+ lwc_string *str;
+ dom_exception err;
+ struct dom_hash_table *attrs;
- /* Fill in value */
- if (a == NULL) {
+ if (namespace == NULL)
+ return _dom_element_get_attribute(element, localname, value);
+
+ err = _dom_node_get_intern_string(&element->base, namespace, &str);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ attrs = (struct dom_hash_table *) _dom_hash_get(element->ns_attributes,
+ str);
+ /* The element has no such namespace */
+ if (attrs == NULL) {
*value = NULL;
- } else {
- dom_attr_get_value(((struct dom_attr *) a), value);
+ return DOM_NO_ERR;
}
- return DOM_NO_ERR;
+ return _dom_element_get_attr(element, attrs, localname, value);
}
/**
@@ -630,101 +501,56 @@ dom_exception _dom_element_set_attribute_ns(struct dom_element *element,
struct dom_string *namespace, struct dom_string *qname,
struct dom_string *value)
{
- struct dom_node_internal *e = (struct dom_node_internal *) element;
- struct dom_node_internal *a = (struct dom_node_internal *)
- element->attributes;
- struct dom_string *prefix, *localname;
+ lwc_string *str;
dom_exception err;
+ struct dom_hash_table *attrs;
+ bool added;
- /** \todo ensure XML feature is supported */
+ if (_dom_validate_name(qname) == false)
+ return DOM_INVALID_CHARACTER_ERR;
- /* Validate name */
err = _dom_namespace_validate_qname(qname, namespace);
- if (err != DOM_NO_ERR) {
- return err;
- }
+ if (err != DOM_NO_ERR)
+ return DOM_NAMESPACE_ERR;
- /* Ensure element can be written to */
- if (_dom_node_readonly(e)) {
- return DOM_NO_MODIFICATION_ALLOWED_ERR;
- }
-
- /* Decompose QName */
+ dom_string *localname;
+ dom_string *prefix;
err = _dom_namespace_split_qname(qname, &prefix, &localname);
- if (err != DOM_NO_ERR) {
+ if (err != DOM_NO_ERR)
return err;
- }
- /* Search for existing attribute with same namespace/localname */
- for (; a != NULL; a = a->next) {
- if (((namespace == NULL && a->namespace == NULL) ||
- (namespace != NULL &&
- dom_string_cmp(a->namespace, namespace) == 0)) &&
- dom_string_cmp(a->name, localname) == 0)
- break;
+ /* If there is no namespace, redirect to set_attribute */
+ if (namespace == NULL) {
+ if (prefix != NULL)
+ return DOM_NAMESPACE_ERR;
+ err = _dom_element_set_attribute(element, localname, value);
+ dom_string_unref(localname);
+ return err;
}
- if (a != NULL) {
- /* Found an existing attribute, so replace its prefix & value */
- dom_exception err;
-
- err = dom_node_set_prefix(a, prefix);
- if (err != DOM_NO_ERR) {
- if (prefix != NULL) {
- dom_string_unref(prefix);
- }
- dom_string_unref(localname);
- return err;
- }
-
- err = dom_attr_set_value((struct dom_attr *) a, value);
- if (err != DOM_NO_ERR) {
- if (prefix != NULL) {
- dom_string_unref(prefix);
- }
- dom_string_unref(localname);
- return err;
- }
- } else {
- /* No existing attribute, so create one */
- dom_exception err;
- struct dom_attr *attr;
-
- err = dom_attr_create(e->owner, localname,
- namespace, prefix, &attr);
- if (err != DOM_NO_ERR) {
- if (prefix != NULL) {
- dom_string_unref(prefix);
- }
- dom_string_unref(localname);
- return err;
- }
-
- /* Set its value */
- err = dom_attr_set_value(attr, value);
- if (err != DOM_NO_ERR) {
- dom_node_unref((struct dom_node *) attr);
-
- if (prefix != NULL) {
- dom_string_unref(prefix);
- }
- dom_string_unref(localname);
+ err = _dom_node_get_intern_string(&element->base, namespace, &str);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ attrs = (struct dom_hash_table *) _dom_hash_get(element->ns_attributes,
+ str);
+ /* The element has no such namespace */
+ if (attrs == NULL) {
+ dom_document *doc;
+ doc = dom_node_get_owner(element);
+ assert(doc != NULL);
+ err = _dom_document_create_hashtable(doc, CHAINS_NS_ATTRIBUTES,
+ _dom_element_hash_lwcstring, &attrs);
+ if (err != DOM_NO_ERR)
return err;
- }
- a = (struct dom_node_internal *) attr;
-
- /* And insert it into the element */
- a->previous = NULL;
- a->next = (struct dom_node_internal *) element->attributes;
-
- if (a->next != NULL)
- a->next->previous = a;
-
- element->attributes = attr;
+ added = _dom_hash_add(element->ns_attributes, str, attrs,
+ false);
+ if (added == false)
+ return DOM_NO_MEM_ERR;
}
- return DOM_NO_ERR;
+ return _dom_element_set_attr(element, attrs, localname, value);
}
/**
@@ -744,44 +570,25 @@ dom_exception _dom_element_set_attribute_ns(struct dom_element *element,
dom_exception _dom_element_remove_attribute_ns(struct dom_element *element,
struct dom_string *namespace, struct dom_string *localname)
{
- struct dom_node_internal *e = (struct dom_node_internal *) element;
- struct dom_node_internal *a = (struct dom_node_internal *)
- element->attributes;
-
- /** \todo ensure XML feature is supported */
-
- /* Ensure element can be written to */
- if (_dom_node_readonly(e))
- return DOM_NO_MODIFICATION_ALLOWED_ERR;
-
- /* Search for existing attribute with same namespace/localname */
- for (; a != NULL; a = a->next) {
- if (((namespace == NULL && a->namespace == NULL) ||
- (namespace != NULL &&
- dom_string_cmp(a->namespace, namespace) == 0)) &&
- dom_string_cmp(a->name, localname) == 0)
- break;
- }
-
- /* Detach attr node from list */
- if (a != NULL) {
- if (a->previous != NULL)
- a->previous->next = a->next;
- else
- element->attributes = (struct dom_attr *) a->next;
-
- if (a->next != NULL)
- a->next->previous = a->previous;
+ lwc_string *str;
+ dom_exception err;
+ struct dom_hash_table *attrs;
- a->previous = a->next = a->parent = NULL;
+ if (namespace != NULL)
+ return _dom_element_remove_attribute(element, localname);
- /* And destroy attr */
- dom_node_unref(a);
+ err = _dom_node_get_intern_string(&element->base, namespace, &str);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ attrs = (struct dom_hash_table *) _dom_hash_get(element->ns_attributes,
+ str);
+ /* The element has no such namespace */
+ if (attrs == NULL) {
+ return DOM_NO_ERR;
}
- /** \todo defaulted attribute handling */
-
- return DOM_NO_ERR;
+ return _dom_element_remove_attr(element, attrs, localname);
}
/**
@@ -805,25 +612,28 @@ dom_exception _dom_element_get_attribute_node_ns(struct dom_element *element,
struct dom_string *namespace, struct dom_string *localname,
struct dom_attr **result)
{
- struct dom_node_internal *a = (struct dom_node_internal *)
- element->attributes;
-
- /** \todo ensure XML feature is supported */
+ lwc_string *str;
+ dom_exception err;
+ struct dom_hash_table *attrs;
- /* Search attributes, looking for namespace/localname */
- for (; a != NULL; a = a->next) {
- if (((namespace == NULL && a->namespace == NULL) ||
- (namespace != NULL &&
- dom_string_cmp(a->namespace, namespace) == 0)) &&
- dom_string_cmp(a->name, localname) == 0)
- break;
+ if (namespace == NULL) {
+ return _dom_element_get_attribute_node(element, localname,
+ result);
}
- if (a != NULL)
- dom_node_ref(a);
- *result = (struct dom_attr *) a;
+ err = _dom_node_get_intern_string(&element->base, namespace, &str);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ attrs = (struct dom_hash_table *) _dom_hash_get(element->ns_attributes,
+ str);
+ /* The element has no such namespace */
+ if (attrs == NULL) {
+ *result = NULL;
+ return DOM_NO_ERR;
+ }
- return DOM_NO_ERR;
+ return _dom_element_get_attr_node(element, attrs, localname, result);
}
/**
@@ -851,84 +661,47 @@ dom_exception _dom_element_get_attribute_node_ns(struct dom_element *element,
dom_exception _dom_element_set_attribute_node_ns(struct dom_element *element,
struct dom_attr *attr, struct dom_attr **result)
{
- struct dom_node_internal *e = (struct dom_node_internal *) element;
- struct dom_node_internal *a = (struct dom_node_internal *) attr;
- struct dom_attr *prev = NULL;
-
- /** \todo ensure XML feature is supported */
-
- /* Ensure element and attribute belong to the same document */
- if (e->owner != a->owner)
- return DOM_WRONG_DOCUMENT_ERR;
-
- /* Ensure element can be written to */
- if (_dom_node_readonly(e))
- return DOM_NO_MODIFICATION_ALLOWED_ERR;
-
- /* Ensure attribute isn't attached to another element */
- if (a->parent != NULL && a->parent != e)
- return DOM_INUSE_ATTRIBUTE_ERR;
-
- /* Attach attr to element, if not already attached */
- if (a->parent == NULL) {
-
- /* Search for existing attribute with same namespace/localname */
- prev = element->attributes;
- while (prev != NULL) {
- struct dom_node_internal *p =
- (struct dom_node_internal *) prev;
-
- if (((a->namespace == NULL && p->namespace == NULL) ||
- (a->namespace != NULL &&
- dom_string_cmp(a->namespace,
- p->namespace) == 0)) &&
- dom_string_cmp(a->name, p->name) == 0)
- break;
-
- prev = (struct dom_attr *) p->next;
- }
-
- a->parent = e;
-
- if (prev != NULL) {
- /* Found an existing attribute, so replace it */
- struct dom_node_internal *p =
- (struct dom_node_internal *) prev;
-
- a->previous = p->previous;
- a->next = p->next;
-
- if (a->previous != NULL)
- a->previous->next = a;
- else
- element->attributes = attr;
+ lwc_string *str;
+ dom_exception err;
+ struct dom_hash_table *attrs;
+ bool added;
+ dom_string *namespace;
- if (a->next != NULL)
- a->next->previous = a;
+ err = dom_node_get_namespace(attr, (void *) &namespace);
+ if (err != DOM_NO_ERR)
+ return err;
- /* Invalidate existing attribute's location info */
- p->next = NULL;
- p->previous = NULL;
- p->parent = NULL;
- } else {
- /* No existing attribute, so insert at front of list */
- a->previous = NULL;
- a->next = (struct dom_node_internal *)
- element->attributes;
+ if (namespace == NULL)
+ return _dom_element_set_attribute_node(element, attr, result);
- if (a->next != NULL)
- a->next->previous = a;
+ err = _dom_node_get_intern_string(&element->base, namespace, &str);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ attrs = (struct dom_hash_table *) _dom_hash_get(element->ns_attributes,
+ str);
+ /* The element has no such namespace */
+ if (attrs == NULL) {
+ dom_document *doc;
+ doc = dom_node_get_owner(element);
+ assert(doc != NULL);
+ err = _dom_document_create_hashtable(doc, CHAINS_NS_ATTRIBUTES,
+ _dom_element_hash_lwcstring, &attrs);
+ if (err != DOM_NO_ERR)
+ return err;
- element->attributes = attr;
- }
+ added = _dom_hash_add(element->ns_attributes, str, attrs,
+ false);
+ if (added == false)
+ return DOM_NO_MEM_ERR;
}
- if (prev != NULL)
- dom_node_ref((struct dom_node *) prev);
-
- *result = prev;
+ dom_string *localname;
+ err = dom_node_get_local_name(attr, (void *) &localname);
+ if (err != DOM_NO_ERR)
+ return err;
- return DOM_NO_ERR;
+ return _dom_element_set_attr_node(element, attrs, attr, result);
}
/**
@@ -953,11 +726,40 @@ dom_exception _dom_element_get_elements_by_tag_name_ns(
struct dom_element *element, struct dom_string *namespace,
struct dom_string *localname, struct dom_nodelist **result)
{
+ dom_document *doc;
+ dom_exception err;
+ doc = element->base.owner;
+
/** \todo ensure XML feature is supported */
- return dom_document_get_nodelist(element->base.owner,
- (struct dom_node_internal *) element, NULL,
- namespace, localname, result);
+ /* Get the interned string from the dom_string */
+ assert(doc->context != NULL);
+ lwc_string *l = NULL, *n = NULL;
+ if (localname != NULL) {
+ err = _dom_string_intern(localname, doc->context, &l);
+ if (err != DOM_NO_ERR)
+ return err;
+ }
+ if (namespace != NULL) {
+ err = _dom_string_intern(namespace, doc->context, &n);
+ if (err != DOM_NO_ERR) {
+ lwc_context_string_unref(doc->context, l);
+
+ return err;
+ }
+ }
+
+ err = _dom_document_get_nodelist(element->base.owner,
+ DOM_NODELIST_BY_NAMESPACE,
+ (struct dom_node_internal *) element, NULL, n, l,
+ result);
+
+ if (localname != NULL)
+ lwc_context_string_unref(doc->context, l);
+ if (namespace != NULL)
+ lwc_context_string_unref(doc->context, n);
+
+ return err;
}
/**
@@ -971,18 +773,8 @@ dom_exception _dom_element_get_elements_by_tag_name_ns(
dom_exception _dom_element_has_attribute(struct dom_element *element,
struct dom_string *name, bool *result)
{
- struct dom_node_internal *a = (struct dom_node_internal *)
- element->attributes;
-
- /* Search attributes, looking for name */
- for (; a != NULL; a = a->next) {
- if (dom_string_cmp(a->name, name) == 0)
- break;
- }
-
- *result = (a != NULL);
-
- return DOM_NO_ERR;
+ return _dom_element_has_attr(element, element->attributes, name,
+ result);
}
/**
@@ -1003,23 +795,26 @@ dom_exception _dom_element_has_attribute_ns(struct dom_element *element,
struct dom_string *namespace, struct dom_string *localname,
bool *result)
{
- struct dom_node_internal *a = (struct dom_node_internal *)
- element->attributes;
+ lwc_string *str;
+ dom_exception err;
+ struct dom_hash_table *attrs;
- /** \todo ensure XML feature is supported */
+ if (namespace == NULL)
+ return _dom_element_has_attribute(element, localname, result);
- /* Search attributes, looking for namespace/localname */
- for (; a != NULL; a = a->next) {
- if (((namespace == NULL && a->namespace == NULL) ||
- (namespace != NULL &&
- dom_string_cmp(a->namespace, namespace) == 0)) &&
- dom_string_cmp(a->name, localname) == 0)
- break;
+ err = _dom_node_get_intern_string(&element->base, namespace, &str);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ attrs = (struct dom_hash_table *) _dom_hash_get(element->ns_attributes,
+ str);
+ /* The element has no such namespace */
+ if (attrs == NULL) {
+ *result = false;
+ return DOM_NO_ERR;
}
- *result = (a != NULL);
-
- return DOM_NO_ERR;
+ return _dom_element_has_attr(element, attrs, localname, result);
}
/**
@@ -1052,15 +847,16 @@ dom_exception _dom_element_get_schema_type_info(struct dom_element *element,
* DOM_NO_MODIFICATION_ALLOWED_ERR if ::element is readonly,
* DOM_NOT_FOUND_ERR if the specified node is not an
* attribute of ::element.
+ *
+ * @note: The DOM spec does not say: how to deal with when there are two or
+ * more isId attribute nodes. Here, the implementation just maintain only
+ * one such attribute node.
*/
dom_exception _dom_element_set_id_attribute(struct dom_element *element,
struct dom_string *name, bool is_id)
{
- UNUSED(element);
- UNUSED(name);
- UNUSED(is_id);
-
- return DOM_NOT_SUPPORTED_ERR;
+ return _dom_element_set_id_attr(element, element->attributes, name,
+ is_id);
}
/**
@@ -1079,12 +875,28 @@ dom_exception _dom_element_set_id_attribute_ns(struct dom_element *element,
struct dom_string *namespace, struct dom_string *localname,
bool is_id)
{
- UNUSED(element);
- UNUSED(namespace);
- UNUSED(localname);
- UNUSED(is_id);
+ struct dom_hash_table *hs;
+ dom_exception err;
+ lwc_string *ns;
- return DOM_NOT_SUPPORTED_ERR;
+ if (namespace == NULL)
+ return _dom_element_set_id_attribute(element, localname, is_id);
+
+ err = _dom_node_get_intern_string(&element->base, namespace, &ns);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ hs = (struct dom_hash_table *) _dom_hash_get(element->ns_attributes,
+ ns);
+ assert(hs != NULL);
+
+ err = _dom_element_set_id_attr(element, hs, localname, is_id);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ element->id_ns = ns;
+
+ return DOM_NO_ERR;
}
/**
@@ -1101,59 +913,1078 @@ dom_exception _dom_element_set_id_attribute_ns(struct dom_element *element,
dom_exception _dom_element_set_id_attribute_node(struct dom_element *element,
struct dom_attr *id_attr, bool is_id)
{
- UNUSED(element);
- UNUSED(id_attr);
- UNUSED(is_id);
+ struct dom_hash_table *hs;
+ dom_exception err;
+ lwc_string *ns;
+ dom_string *namespace;
+ dom_string *localname;
- return DOM_NOT_SUPPORTED_ERR;
+ err = dom_node_get_namespace(id_attr, &namespace);
+ if (err != DOM_NO_ERR)
+ return err;
+ err = dom_node_get_local_name(id_attr, &localname);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = _dom_node_get_intern_string(&element->base, namespace, &ns);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ hs = (struct dom_hash_table *) _dom_hash_get(element->ns_attributes,
+ ns);
+ assert(hs != NULL);
+
+ err = _dom_element_set_id_attr(element, hs, localname, is_id);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ element->id_ns = ns;
+
+ return DOM_NO_ERR;
+
+}
+
+/*------------- The overload virtual functions ------------------------*/
+
+/* Overload function of Node, please refer src/core/node.c for detail */
+dom_exception _dom_element_get_attributes(dom_node_internal *node,
+ struct dom_namednodemap **result)
+{
+ dom_exception err;
+ dom_document *doc;
+
+ doc = dom_node_get_owner(node);
+ assert(doc != NULL);
+
+ err = _dom_namednodemap_create(doc, node, &attributes_opt, result);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ dom_node_ref(node);
+
+ return DOM_NO_ERR;
}
-/* */
-/*----------------------------------------------------------------------------*/
-/* */
+/* Overload function of Node, please refer src/core/node.c for detail */
+dom_exception _dom_element_has_attributes(dom_node_internal *node, bool *result)
+{
+ UNUSED(node);
+ *result = true;
+
+ return DOM_NO_ERR;
+}
+
+/* For the following namespace related algorithm take a look at:
+ * http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/namespaces-algorithms.html
+ */
/**
- * Retrieve a map of attributes associated with an Element
+ * Look up the prefix which matches the namespace.
*
- * \param element The element to retrieve the attributes of
- * \param result Pointer to location to receive attribute map
- * \return DOM_NO_ERR.
+ * \param node The current Node in which we search for
+ * \param namespace The namespace for which we search a prefix
+ * \param result The returned prefix
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_element_lookup_prefix(dom_node_internal *node,
+ struct dom_string *namespace, struct dom_string **result)
+{
+ struct dom_element *owner;
+ dom_exception err;
+
+ err = dom_attr_get_owner_element(node, &owner);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ if (owner == NULL) {
+ *result = NULL;
+ return DOM_NO_ERR;
+ }
+
+ return dom_node_lookup_prefix(owner, namespace, result);
+}
+
+/**
+ * Test whether certain namespace is the default namespace of some node.
*
- * The returned NamedNodeMap will be referenced. It is the responsibility
- * of the caller to unref the map once it has finished with it.
+ * \param node The Node to test
+ * \param namespace The namespace to test
+ * \param result true is the namespace is default namespace
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
*/
-dom_exception dom_element_get_attributes(struct dom_element *element,
- struct dom_namednodemap **result)
+dom_exception _dom_element_is_default_namespace(dom_node_internal *node,
+ struct dom_string *namespace, bool *result)
{
- return dom_document_get_namednodemap(element->base.owner,
- (struct dom_node_internal *) element,
- DOM_ATTRIBUTE_NODE, result);
+ struct dom_element *ele = (struct dom_element *) node;
+ lwc_string *ns;
+ dom_string *value;
+ dom_document *doc = node->owner;
+ lwc_context *ctx;
+ dom_exception err;
+
+ assert(doc != NULL);
+ err = _dom_node_get_intern_string(node, namespace, &ns);
+ if (err != DOM_NO_ERR) {
+ return err;
+ }
+ ctx = _dom_document_get_intern_context(doc);
+ assert(ctx != NULL);
+ if (node->prefix == NULL) {
+ lwc_context_string_isequal(ctx, node->namespace, ns, result);
+ lwc_context_string_unref(ctx, ns);
+ return DOM_NO_ERR;
+ }
+
+ bool has;
+ dom_string *xmlns = _dom_namespace_get_xmlns_prefix();
+ err = dom_element_has_attribute(ele, xmlns, &has);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ if (has == true) {
+ return dom_element_get_attribute(ele, xmlns, &value);
+ }
+
+ lwc_string *ns2;
+ err = _dom_node_get_intern_string(node, value, &ns2);
+ if (err != DOM_NO_ERR) {
+ return err;
+ }
+
+ if (ns2 != NULL) {
+ lwc_context_string_isequal(ctx, ns2, ns, result);
+ lwc_context_string_unref(ctx, ns);
+ lwc_context_string_unref(ctx, ns2);
+ dom_string_unref(value);
+ return DOM_NO_ERR;
+ }
+
+
+ return dom_node_is_default_namespace(node->parent, namespace, result);
}
/**
- * Determine if an element has any attributes
+ * Look up the namespace with certain prefix.
*
- * \param element Element to inspect
- * \param result Pointer to location to receive result
+ * \param node The current node in which we search for the prefix
+ * \param prefix The prefix to search
+ * \param result The result namespace if found
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_element_lookup_namespace(dom_node_internal *node,
+ struct dom_string *prefix, struct dom_string **result)
+{
+ lwc_string *pf;
+ dom_exception err;
+
+ err = _dom_node_get_intern_string(node, prefix, &pf);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ /* To some extent, directly compare the two lwc_string pointer
+ * is better */
+ if (node->namespace != NULL && node->prefix == pf) {
+ assert(node->owner != NULL);
+ return _dom_document_create_string_from_lwcstring(node->owner,
+ pf, result);
+ }
+
+ bool has;
+ dom_string *xmlns = _dom_namespace_get_xmlns_prefix();
+ err = dom_element_has_attribute_ns(node,
+ dom_namespaces[DOM_NAMESPACE_XMLNS], prefix, &has);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ if (has == true)
+ return dom_element_get_attribute_ns(node,
+ dom_namespaces[DOM_NAMESPACE_XMLNS], prefix,
+ result);
+
+ err = dom_element_has_attribute(node, xmlns, &has);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ if (has == true) {
+ return dom_element_get_attribute(node, xmlns, result);
+ }
+
+ return dom_node_lookup_namespace(node->parent, prefix, result);
+}
+
+
+/*----------------------------------------------------------------------*/
+/* The protected virtual functions */
+
+/* The destroy virtual function of dom_element */
+void __dom_element_destroy(struct dom_node_internal *node)
+{
+ struct dom_document *doc = dom_node_get_owner(node);
+
+ _dom_element_destroy(doc, (struct dom_element *) node);
+}
+
+/* The memory allocator of this class */
+dom_exception _dom_element_alloc(dom_document *doc, struct dom_node_internal *n,
+ struct dom_node_internal **ret)
+{
+ dom_element *e;
+ UNUSED(n);
+
+ e = _dom_document_alloc(doc, NULL, sizeof(struct dom_element));
+ if (e == NULL)
+ return DOM_NO_MEM_ERR;
+
+ *ret = (dom_node_internal *) e;
+ dom_node_set_owner(*ret, doc);
+
+ return DOM_NO_ERR;
+}
+
+/* TODO: How to deal with default attribue:
+ *
+ * Ask a language binding for default attributes.
+ *
+ * So, when we copy a element we copy all its attributes because they
+ * are all specified. For the methods like importNode and adoptNode,
+ * this will make _dom_element_copy can be used in them.
+ */
+dom_exception _dom_element_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old)
+{
+ dom_element *ne = (dom_element *) new;
+ dom_element *oe = (dom_element *) old;
+ dom_document *od, *nd;
+ struct dom_hash_table *ht;
+ lwc_context *oc, *nc;
+ dom_exception err;
+
+ err = _dom_node_copy(new, old);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ od = dom_node_get_owner(old);
+ nd = dom_node_get_owner(new);
+ assert(od != NULL);
+ assert(nd != NULL);
+
+ oc = _dom_document_get_intern_context(od);
+ nc = _dom_document_get_intern_context(nd);
+ assert(oc != NULL);
+ assert(nc != NULL);
+
+ dom_alloc alloc;
+ void *pw;
+ _dom_document_get_allocator(nd, &alloc, &pw);
+
+ /* Copy the hash tables */
+ ht = _dom_hash_clone(oe->attributes, alloc, pw, _key, nc,
+ _value, nd);
+ if (ht == NULL)
+ return DOM_NO_MEM_ERR;
+ ne->attributes = ht;
+
+ ht = _dom_hash_clone(oe->ns_attributes, alloc, pw, _key, nc,
+ _nsattributes, nd);
+ if (ht == NULL)
+ return DOM_NO_MEM_ERR;
+ ne->ns_attributes = ht;
+
+ /* TODO: deal with dom_type_info, it get no definition ! */
+
+ return DOM_NO_ERR;
+}
+
+
+
+/*--------------------------------------------------------------------------*/
+
+/* Helper functions */
+
+/**
+ * The internal helper function for getAttribute/getAttributeNS.
+ *
+ * \param element The element
+ * \param hs The hash table contains the attributes
+ * \param name The name of the attribute
+ * \param value The value of the attribute
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_element_get_attr(struct dom_element *element,
+ struct dom_hash_table *hs, struct dom_string *name,
+ struct dom_string **value)
+{
+ void *a;
+ dom_exception err;
+ lwc_string *str;
+
+ /* Looking for name */
+ err = _dom_node_get_intern_string(&element->base, name, &str);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ a = _dom_hash_get(hs, str);
+
+ /* Fill in value */
+ if (a == NULL) {
+ *value = NULL;
+ } else {
+ dom_attr_get_value(((struct dom_attr *) a), value);
+ }
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * The internal helper function for setAttribute and setAttributeNS.
+ *
+ * \param element The element
+ * \param hs The attributes' hash table
+ * \param name The name of the new attribute
+ * \param value The value of the new attribute
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_element_set_attr(struct dom_element *element,
+ struct dom_hash_table *hs, struct dom_string *name,
+ struct dom_string *value)
+{
+ void *a;
+ dom_exception err;
+ lwc_string *str;
+ bool added;
+ dom_node_internal *e = (dom_node_internal *) element;
+
+ if (_dom_validate_name(name) == false)
+ return DOM_INVALID_CHARACTER_ERR;
+
+ /* Ensure element can be written */
+ if (_dom_node_readonly(e))
+ return DOM_NO_MODIFICATION_ALLOWED_ERR;
+
+ /* Looking for name */
+ err = _dom_node_get_intern_string(&element->base, name, &str);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ a = _dom_hash_get(hs, str);
+
+ if (a != NULL) {
+ /* Found an existing attribute, so replace its value */
+ dom_exception err;
+
+ err = dom_attr_set_value((struct dom_attr *) a, value);
+ if (err != DOM_NO_ERR)
+ return err;
+ } else {
+ /* No existing attribute, so create one */
+ dom_exception err;
+ struct dom_attr *attr;
+
+ err = _dom_attr_create(e->owner, str, NULL, NULL, true, &attr);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ /* Set its value */
+ err = dom_attr_set_value(attr, value);
+ if (err != DOM_NO_ERR) {
+ dom_node_unref(attr);
+ return err;
+ }
+
+ added = _dom_hash_add(hs, str, attr, false);
+ if (added == false) {
+ /* If we failed at this step, there must be no memory */
+ dom_node_unref(attr);
+ return DOM_NO_MEM_ERR;
+ }
+
+ dom_node_set_parent(attr, element);
+ dom_node_unref(attr);
+ dom_node_remove_pending(attr);
+ }
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Remove an attribute from an element by name
+ *
+ * \param element The element to remove attribute from
+ * \param name The name of the attribute to remove
+ * \return DOM_NO_ERR on success,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if ::element is readonly.
+ */
+dom_exception _dom_element_remove_attr(struct dom_element *element,
+ struct dom_hash_table *hs, struct dom_string *name)
+{
+ void *a;
+ dom_exception err;
+ lwc_string *str;
+ dom_node_internal *e = (dom_node_internal *) element;
+
+ /* Ensure element can be written to */
+ if (_dom_node_readonly(e))
+ return DOM_NO_MODIFICATION_ALLOWED_ERR;
+
+ /* Looking for name */
+ err = _dom_node_get_intern_string(&element->base, name, &str);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ a = (dom_node_internal *) _dom_hash_del(hs, str);
+
+ /* Detach attr node from list */
+ if (a != NULL) {
+ /* And destroy attr */
+ dom_node_set_parent(a, NULL);
+ dom_node_try_destroy(a);
+ }
+
+ /** \todo defaulted attribute handling */
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Retrieve an attribute node from an element by name
+ *
+ * \param element The element to retrieve attribute node from
+ * \param name The attribute's name
+ * \param result Pointer to location to receive attribute node
* \return DOM_NO_ERR.
+ *
+ * The returned node will have its reference count increased. It is
+ * the responsibility of the caller to unref the node once it has
+ * finished with it.
+ */
+dom_exception _dom_element_get_attr_node(struct dom_element *element,
+ struct dom_hash_table *hs, struct dom_string *name,
+ struct dom_attr **result)
+{
+ void *a;
+ dom_exception err;
+ lwc_string *str;
+
+ /* Looking for name */
+ err = _dom_node_get_intern_string(&element->base, name, &str);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ a = _dom_hash_get(hs, str);
+
+ /* Fill in value */
+ if (a == NULL) {
+ *result = NULL;
+ } else {
+ *result = (dom_attr *) a;
+ dom_node_ref(*result);
+ }
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Set an attribute node on an element, replacing existing node, if present
+ *
+ * \param element The element to add a node to
+ * \param attr The attribute node to add
+ * \param result Pointer to location to receive previous node
+ * \return DOM_NO_ERR on success,
+ * DOM_WRONG_DOCUMENT_ERR if ::attr does not belong to the
+ * same document as ::element,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if ::element is readonly,
+ * DOM_INUSE_ATTRIBUTE_ERR if ::attr is already an attribute
+ * of another Element node.
+ *
+ * The returned node will have its reference count increased. It is
+ * the responsibility of the caller to unref the node once it has
+ * finished with it.
*/
-dom_exception dom_element_has_attributes(struct dom_element *element,
+dom_exception _dom_element_set_attr_node(struct dom_element *element,
+ struct dom_hash_table *hs, struct dom_attr *attr,
+ struct dom_attr **result)
+{
+ dom_exception err;
+ lwc_string *str = NULL;
+ dom_string *name = NULL;
+ bool added;
+ dom_node_internal *e = (dom_node_internal *) element;
+ dom_node_internal *a = (dom_node_internal *) attr;
+
+ /** \todo validate name */
+
+ /* Ensure element and attribute belong to the same document */
+ if (e->owner != a->owner)
+ return DOM_WRONG_DOCUMENT_ERR;
+
+ /* Ensure element can be written to */
+ if (_dom_node_readonly(e))
+ return DOM_NO_MODIFICATION_ALLOWED_ERR;
+
+ /* Ensure attribute isn't attached to another element */
+ if (a->parent != NULL && a->parent != e)
+ return DOM_INUSE_ATTRIBUTE_ERR;
+
+ err = dom_node_get_local_name(attr, &name);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ /* Looking for name */
+ err = _dom_node_get_intern_string(&element->base, name, &str);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ a = _dom_hash_del(hs, str);
+
+ *result = NULL;
+ if (a != NULL) {
+ dom_node_ref(a);
+ *result = (dom_attr *) a;
+ dom_node_set_parent(a, NULL);
+ dom_node_mark_pending(a);
+ }
+
+ added = _dom_hash_add(hs, str, attr, false);
+ if (added == false) {
+ /* If we failed at this step, there must be no memory */
+ return DOM_NO_MEM_ERR;
+ }
+ dom_node_set_parent(attr, element);
+ dom_node_remove_pending(attr);
+
+ /* Cleanup */
+ if (name != NULL)
+ dom_string_unref(name);
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Remove an attribute node from an element
+ *
+ * \param element The element to remove attribute node from
+ * \param attr The attribute node to remove
+ * \param result Pointer to location to receive attribute node
+ * \return DOM_NO_ERR on success,
+ * DOM_NO_MODIFICATION_ALLOWED_ERR if ::element is readonly,
+ * DOM_NOT_FOUND_ERR if ::attr is not an attribute of
+ * ::element.
+ *
+ * The returned node will have its reference count increased. It is
+ * the responsibility of the caller to unref the node once it has
+ * finished with it.
+ */
+dom_exception _dom_element_remove_attr_node(struct dom_element *element,
+ struct dom_hash_table *hs, struct dom_attr *attr,
+ struct dom_attr **result)
+{
+ void *a;
+ dom_exception err;
+ lwc_string *str;
+ dom_string *name;
+ dom_node_internal *e = (dom_node_internal *) element;
+
+ /* Ensure element can be written to */
+ if (_dom_node_readonly(e))
+ return DOM_NO_MODIFICATION_ALLOWED_ERR;
+
+ err = dom_node_get_node_name(attr, &name);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ /* Looking for name */
+ err = _dom_node_get_intern_string(&element->base, name, &str);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ a = _dom_hash_del(hs, str);
+
+ /* Now, cleaup the dom_string and lwc_string */
+ dom_string_unref(name);
+ _dom_node_unref_intern_string(&element->base, str);
+
+ /** \todo defaulted attribute handling */
+
+ if (a == NULL || a != (void *) attr) {
+ return DOM_NOT_FOUND_ERR;
+ }
+
+ /* When a Node is removed, it should be destroy. When its refcnt is not
+ * zero, it will be added to the document's deletion pending list.
+ * When a Node is removed, its parent should be NULL, but its owner
+ * should remain to be the document.
+ */
+ dom_node_ref(a);
+ *result = (dom_attr *) a;
+ dom_node_set_parent(a, NULL);
+ dom_node_mark_pending(a);
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Test whether certain attribute is inside the hash table
+ *
+ * \param element The element
+ * \param hs The hash table contains the attributes
+ * \param name The attribute's name
+ * \param result The return value
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_element_has_attr(struct dom_element *element,
+ struct dom_hash_table *hs, struct dom_string *name,
bool *result)
{
- *result = (element->attributes != NULL);
+ void *a;
+ dom_exception err;
+ lwc_string *str;
+
+ /* Looking for name */
+ err = _dom_node_get_intern_string(&element->base, name, &str);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ a = _dom_hash_get(hs, str);
+
+ /* Fill in value */
+ if (a == NULL) {
+ *result = false;
+ } else {
+ *result = true;
+ }
return DOM_NO_ERR;
}
/**
- * Retrieve a pointer to the first attribute attached to an element
+ * (Un)set an attribute Node as a ID.
*
- * \param element The element to retrieve the first attribute from
- * \return Pointer to first attribute, or NULL if none.
+ * \param element The element contains the attribute
+ * \param hs The hash table which contains the attribute node
+ * \param name The name of the attribute
+ * \param is_id true for set the node as a ID attribute, false unset it
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
*/
-struct dom_node_internal *dom_element_get_first_attribute(
- struct dom_element *element)
+dom_exception _dom_element_set_id_attr(struct dom_element *element,
+ struct dom_hash_table *hs, struct dom_string *name, bool is_id)
+{
+ dom_attr *attr;
+ lwc_string *str;
+ dom_exception err;
+ struct dom_hash_table *oh;
+
+ /* Looking for name */
+ err = _dom_node_get_intern_string(&element->base, name, &str);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ attr = (dom_attr *) _dom_hash_get(hs, str);
+ if (attr == NULL)
+ return DOM_NOT_FOUND_ERR;
+
+ if (is_id == true) {
+ /* Firstly, clear the previous id attribute if there is one */
+ if (element->id_ns != NULL) {
+ assert(element->id_name != NULL);
+ oh = (struct dom_hash_table *) _dom_hash_get(
+ element->ns_attributes, element->id_ns);
+ } else {
+ oh = element->attributes;
+ }
+ assert(oh != NULL);
+
+ if (element->id_name != NULL) {
+ attr = (dom_attr *) _dom_hash_get(oh, element->id_name);
+ assert(attr != NULL);
+ _dom_attr_set_isid(attr, false);
+ }
+ }
+
+ _dom_attr_set_isid(attr, is_id);
+
+ element->id_name = str;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Get the ID string of the element
+ *
+ * \param ele The element
+ * \param id The ID of this element
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_element_get_id(struct dom_element *ele, lwc_string **id)
{
- return (struct dom_node_internal *) element->attributes;
+ dom_exception err;
+ dom_string *ret = NULL;
+
+ *id = NULL;
+
+ if (ele->id_ns != NULL && ele->id_name != NULL) {
+ /* There is user specific ID attribute */
+ dom_document *doc;
+ doc = dom_node_get_owner(ele);
+ assert(doc != NULL);
+
+ dom_string *namespace, *name;
+ err = _dom_document_create_string_from_lwcstring(doc,
+ ele->id_ns, &namespace);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = _dom_document_create_string_from_lwcstring(doc,
+ ele->id_name, &name);
+ if (err != DOM_NO_ERR) {
+ dom_string_unref(namespace);
+ return err;
+ }
+
+ err = _dom_element_get_attribute_ns(ele, namespace, name, &ret);
+ if (err != DOM_NO_ERR) {
+ dom_string_unref(namespace);
+ dom_string_unref(name);
+ return err;
+ }
+
+ dom_string_unref(namespace);
+ dom_string_unref(name);
+
+ err = _dom_node_get_intern_string((dom_node_internal *) ele,
+ ret, id);
+ dom_string_unref(ret);
+ return err;
+ }
+
+ dom_document *doc;
+ doc = dom_node_get_owner(ele);
+ assert(doc != NULL);
+ dom_string *name;
+
+ if (ele->id_name != NULL) {
+ err = _dom_document_create_string_from_lwcstring(doc,
+ ele->id_name, &name);
+ if (err != DOM_NO_ERR) {
+ return err;
+ }
+ } else {
+ lwc_string *id_name = _dom_document_get_id_name(doc);
+ if (id_name == NULL) {
+ /* No ID attribute at all, just return NULL */
+ *id = NULL;
+ return DOM_NO_ERR;
+ }
+ err = _dom_document_create_string_from_lwcstring(doc, id_name,
+ &name);
+ if (err != DOM_NO_ERR) {
+ return err;
+ }
+ }
+
+ err = _dom_element_get_attribute(ele, name, &ret);
+ if (err != DOM_NO_ERR) {
+ dom_string_unref(name);
+ return err;
+ }
+
+ dom_string_unref(name);
+
+ if (ret != NULL) {
+ err = _dom_node_get_intern_string((dom_node_internal *) ele,
+ ret, id);
+ dom_string_unref(ret);
+ } else {
+ *id = NULL;
+ }
+
+ return err;
+}
+
+
+/* The hash function for attributes and id tables */
+unsigned int _dom_element_hash_lwcstring(void *key)
+{
+ lwc_string *lstr = (lwc_string *) key;
+
+ return lwc_string_hash_value(lstr);
+}
+
+/*-------------- The dom_namednodemap functions -------------------------*/
+
+/* Implementation function for NamedNodeMap, see core/namednodemap.h for
+ * details */
+dom_exception attributes_get_length(void *priv,
+ unsigned long *length)
+{
+ unsigned int ret = 0;
+ unsigned int c1, *c2 = NULL;
+ void *key, *value;
+ dom_element *e = (dom_element *) priv;
+
+ ret += _dom_hash_get_length(e->attributes);
+ while( (key = _dom_hash_iterate(e->ns_attributes, &c1, &c2)) != NULL) {
+ value = _dom_hash_get(e->ns_attributes, key);
+ if (value != NULL) {
+ ret += _dom_hash_get_length(
+ (struct dom_hash_table *) value);
+ }
+ }
+
+ *length = ret;
+ return DOM_NO_ERR;
+}
+
+/* Implementation function for NamedNodeMap, see core/namednodemap.h for
+ * details */
+dom_exception attributes_get_named_item(void *priv,
+ struct dom_string *name, struct dom_node **node)
+{
+ dom_element *e = (dom_element *) priv;
+
+ return _dom_element_get_attribute_node(e, name, (dom_attr **) node);
+}
+
+/* Implementation function for NamedNodeMap, see core/namednodemap.h for
+ * details */
+dom_exception attributes_set_named_item(void *priv,
+ struct dom_node *arg, struct dom_node **node)
+{
+ dom_element *e = (dom_element *) priv;
+ dom_node_internal *n = (dom_node_internal *) arg;
+
+ if (n->type != DOM_ATTRIBUTE_NODE)
+ return DOM_HIERARCHY_REQUEST_ERR;
+
+ return _dom_element_set_attribute_node(e, (dom_attr *) arg,
+ (dom_attr **) node);
+}
+
+/* Implementation function for NamedNodeMap, see core/namednodemap.h for
+ * details */
+dom_exception attributes_remove_named_item(
+ void *priv, struct dom_string *name,
+ struct dom_node **node)
+{
+ dom_element *e = (dom_element *) priv;
+ dom_exception err;
+
+ err = _dom_element_get_attribute_node(e, name, (dom_attr **) node);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ if (*node == NULL) {
+ return DOM_NOT_FOUND_ERR;
+ }
+
+ return _dom_element_remove_attribute(e, name);
+}
+
+/* Implementation function for NamedNodeMap, see core/namednodemap.h for
+ * details */
+dom_exception attributes_item(void *priv,
+ unsigned long index, struct dom_node **node)
+{
+ struct dom_hash_table *ht = NULL;
+ unsigned int num = index + 1;
+ unsigned int len;
+ dom_element *e = (dom_element *) priv;
+ void *key, *value;
+ unsigned int c1, *c2 = NULL;
+
+ len = _dom_hash_get_length(e->attributes);
+ if (num <= len) {
+ ht = e->attributes;
+ } else {
+ num -= len;
+ }
+
+ while( (key = _dom_hash_iterate(e->ns_attributes, &c1, &c2)) != NULL) {
+ value = _dom_hash_get(e->ns_attributes, key);
+ if (value != NULL) {
+ len = _dom_hash_get_length(
+ (struct dom_hash_table *) value);
+ if (num <= len) {
+ ht = (struct dom_hash_table *) value;
+ break;
+ } else {
+ num -= len;
+ }
+ }
+ }
+
+ *node = NULL;
+ c2 = NULL;
+ if (ht != NULL)
+ {
+ while( (key = _dom_hash_iterate(ht, &c1, &c2)) != NULL) {
+ value = _dom_hash_get(ht, key);
+ if (--num == 0) {
+ *node = (dom_node *) value;
+ break;
+ }
+ }
+ }
+
+ if (*node != NULL)
+ dom_node_ref(*node);
+
+ return DOM_NO_ERR;
+}
+
+/* Implementation function for NamedNodeMap, see core/namednodemap.h for
+ * details */
+dom_exception attributes_get_named_item_ns(
+ void *priv, struct dom_string *namespace,
+ struct dom_string *localname, struct dom_node **node)
+{
+ dom_element *e = (dom_element *) priv;
+
+ return _dom_element_get_attribute_node_ns(e, namespace, localname,
+ (dom_attr **) node);
+}
+
+/* Implementation function for NamedNodeMap, see core/namednodemap.h for
+ * details */
+dom_exception attributes_set_named_item_ns(
+ void *priv, struct dom_node *arg,
+ struct dom_node **node)
+{
+ dom_element *e = (dom_element *) priv;
+ dom_node_internal *n = (dom_node_internal *) arg;
+
+ if (n->type != DOM_ATTRIBUTE_NODE)
+ return DOM_HIERARCHY_REQUEST_ERR;
+
+ return _dom_element_set_attribute_node_ns(e, (dom_attr *) arg,
+ (dom_attr **) node);
+}
+
+/* Implementation function for NamedNodeMap, see core/namednodemap.h for
+ * details */
+dom_exception attributes_remove_named_item_ns(
+ void *priv, struct dom_string *namespace,
+ struct dom_string *localname, struct dom_node **node)
+{
+ dom_element *e = (dom_element *) priv;
+ dom_exception err;
+
+ err = _dom_element_get_attribute_node_ns(e, namespace, localname,
+ (dom_attr **) node);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ if (*node == NULL) {
+ return DOM_NOT_FOUND_ERR;
+ }
+
+ return _dom_element_remove_attribute_ns(e, namespace, localname);
+}
+
+/* Implementation function for NamedNodeMap, see core/namednodemap.h for
+ * details */
+void attributes_destroy(void *priv)
+{
+ dom_element *e = (dom_element *) priv;
+
+ dom_node_unref(e);
+}
+
+/* Implementation function for NamedNodeMap, see core/namednodemap.h for
+ * details */
+bool attributes_equal(void *p1, void *p2)
+{
+ /* We have passed the pointer to this element as the private data,
+ * and here we just need to compare whether the two elements are
+ * equal
+ */
+ return p1 == p2;
+}
+/*------------------ End of namednodemap functions -----------------------*/
+
+/* The key_func of the hash table, see utils/hashtable.h for details */
+void *_key(void *key, void *key_pw, dom_alloc alloc, void *pw,
+ bool clone)
+{
+ assert(key != NULL);
+ assert(key_pw != NULL);
+
+ UNUSED(alloc);
+ UNUSED(pw);
+
+ if (clone == false) {
+ lwc_context_string_unref((lwc_context *) key_pw,
+ (lwc_string *) key);
+ return NULL;
+ } else {
+ lwc_error err;
+ lwc_string *ret;
+ const char *data = lwc_string_data((lwc_string *) key);
+ size_t len = lwc_string_length((lwc_string *) key);
+ err = lwc_context_intern((lwc_context *) key_pw, data, len,
+ &ret);
+ if (err != lwc_error_ok)
+ return NULL;
+
+ return ret;
+ }
+}
+
+/* The value_func of the hash table, see utils/hashtable.h for details */
+void *_value(void *value, void *value_pw, dom_alloc alloc,
+ void *pw, bool clone)
+{
+ assert(value != NULL);
+ assert(value_pw != NULL);
+
+ UNUSED(alloc);
+ UNUSED(pw);
+ UNUSED(value_pw);
+
+ if (clone == false) {
+ dom_node_internal *a = (dom_node_internal *) value;
+ a->parent = NULL;
+ dom_node_try_destroy(a);
+ return NULL;
+ } else {
+ dom_exception err;
+ dom_node *node;
+
+ err = dom_document_import_node((dom_document *) value_pw, value,
+ true, &node);
+ if (err != DOM_NO_ERR)
+ return NULL;
+
+ return node;
+ }
+}
+
+/* The value_func of the hash table, see utils/hashtable.h for details */
+void *_nsattributes(void *value, void *value_pw, dom_alloc alloc,
+ void *pw, bool clone)
+{
+ assert(value != NULL);
+ assert(value_pw != NULL);
+
+ UNUSED(alloc);
+ UNUSED(pw);
+
+ if (clone == false) {
+ _dom_hash_destroy((struct dom_hash_table *) value, _key,
+ value_pw, _value, value_pw);
+ return NULL;
+ } else {
+ dom_document *doc = (dom_document *) value_pw;
+ lwc_context *ctx = _dom_document_get_intern_context(doc);
+ assert(ctx != NULL);
+ dom_alloc alloc;
+ void *pw;
+ struct dom_hash_table *ret = NULL;
+ _dom_document_get_allocator(doc, &alloc, &pw);
+
+ ret = _dom_hash_clone((struct dom_hash_table *) value, alloc,
+ pw, _key, ctx, _value, doc);
+
+ return ret;
+ }
}
diff --git a/src/core/element.h b/src/core/element.h
index a05b8c0..f987fcd 100644
--- a/src/core/element.h
+++ b/src/core/element.h
@@ -19,6 +19,7 @@ struct dom_node;
struct dom_string;
struct dom_attr;
struct dom_type_info;
+struct dom_hash_table;
/**
* DOM element node
@@ -26,33 +27,31 @@ struct dom_type_info;
struct dom_element {
struct dom_node_internal base; /**< Base node */
- struct dom_attr *attributes; /**< Element attributes */
+ struct dom_hash_table *attributes; /**< Element attributes */
- struct dom_type_info *schema_type_info; /**< Type information */
-};
-
-dom_exception dom_element_create(struct dom_document *doc,
- struct dom_string *name, struct dom_string *namespace,
- struct dom_string *prefix, struct dom_element **result);
+ struct dom_hash_table *ns_attributes;
+ /**< Attributes with prefix */
-dom_exception dom_element_initialise(struct dom_element *el,
- struct dom_string *name, struct dom_string *namespace,
- struct dom_string *prefix, struct dom_element **result);
+ struct lwc_string_s *id_ns; /**< The id attribute's namespace */
-void dom_element_destroy(struct dom_document *doc,
- struct dom_element *element);
+ struct lwc_string_s *id_name; /**< The id attribute's name */
-void _dom_element_destroy(struct dom_node_internal *node);
+ struct dom_type_info *schema_type_info; /**< Type information */
+};
-dom_exception dom_element_get_attributes(struct dom_element *element,
- struct dom_namednodemap **result);
+dom_exception _dom_element_create(struct dom_document *doc,
+ struct lwc_string_s *name, struct lwc_string_s *namespace,
+ struct lwc_string_s *prefix, struct dom_element **result);
-dom_exception dom_element_has_attributes(struct dom_element *element,
- bool *result);
+dom_exception _dom_element_initialise(struct dom_element *el,
+ struct dom_document *doc, struct lwc_string_s *name,
+ struct lwc_string_s *namespace, struct lwc_string_s *prefix,
+ struct dom_element **result);
-struct dom_node_internal *dom_element_get_first_attribute(
+void _dom_element_destroy(struct dom_document *doc,
struct dom_element *element);
+
/* The virtual functions of dom_element */
dom_exception _dom_element_get_tag_name(struct dom_element *element,
struct dom_string **name);
@@ -68,8 +67,9 @@ dom_exception _dom_element_set_attribute_node(struct dom_element *element,
struct dom_attr *attr, struct dom_attr **result);
dom_exception _dom_element_remove_attribute_node(struct dom_element *element,
struct dom_attr *attr, struct dom_attr **result);
-dom_exception _dom_element_get_elements_by_tag_name(struct dom_element *element,
- struct dom_string *name, struct dom_nodelist **result);
+dom_exception _dom_element_get_elements_by_tag_name(
+ struct dom_element *element, struct dom_string *name,
+ struct dom_nodelist **result);
dom_exception _dom_element_get_attribute_ns(struct dom_element *element,
struct dom_string *namespace, struct dom_string *localname,
struct dom_string **value);
@@ -123,4 +123,72 @@ dom_exception _dom_element_set_id_attribute_node(struct dom_element *element,
_dom_element_set_id_attribute_ns, \
_dom_element_set_id_attribute_node
+/* Overloading dom_node functions */
+dom_exception _dom_element_get_attributes(dom_node_internal *node,
+ struct dom_namednodemap **result);
+dom_exception _dom_element_has_attributes(dom_node_internal *node,
+ bool *result);
+dom_exception _dom_element_normalize(dom_node_internal *node);
+dom_exception _dom_element_lookup_prefix(dom_node_internal *node,
+ struct dom_string *namespace, struct dom_string **result);
+dom_exception _dom_element_is_default_namespace(dom_node_internal *node,
+ struct dom_string *namespace, bool *result);
+dom_exception _dom_element_lookup_namespace(dom_node_internal *node,
+ struct dom_string *prefix, struct dom_string **result);
+#define DOM_NODE_VTABLE_ELEMENT \
+ _dom_node_get_node_name, \
+ _dom_node_get_node_value, \
+ _dom_node_set_node_value, \
+ _dom_node_get_node_type, \
+ _dom_node_get_parent_node, \
+ _dom_node_get_child_nodes, \
+ _dom_node_get_first_child, \
+ _dom_node_get_last_child, \
+ _dom_node_get_previous_sibling, \
+ _dom_node_get_next_sibling, \
+ _dom_element_get_attributes, /*overload*/\
+ _dom_node_get_owner_document, \
+ _dom_node_insert_before, \
+ _dom_node_replace_child, \
+ _dom_node_remove_child, \
+ _dom_node_append_child, \
+ _dom_node_has_child_nodes, \
+ _dom_node_clone_node, \
+ _dom_node_normalize, \
+ _dom_node_is_supported, \
+ _dom_node_get_namespace, \
+ _dom_node_get_prefix, \
+ _dom_node_set_prefix, \
+ _dom_node_get_local_name, \
+ _dom_element_has_attributes, /*overload*/\
+ _dom_node_get_base, \
+ _dom_node_compare_document_position, \
+ _dom_node_get_text_content, \
+ _dom_node_set_text_content, \
+ _dom_node_is_same, \
+ _dom_element_lookup_prefix, /*overload*/\
+ _dom_element_is_default_namespace, /*overload*/\
+ _dom_element_lookup_namespace, /*overload*/\
+ _dom_node_is_equal, \
+ _dom_node_get_feature, \
+ _dom_node_set_user_data, \
+ _dom_node_get_user_data
+
+
+/* The protected virtual function */
+void __dom_element_destroy(dom_node_internal *node);
+dom_exception _dom_element_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret);
+dom_exception _dom_element_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old);
+
+#define DOM_ELEMENT_PROTECT_VTABLE \
+ __dom_element_destroy, \
+ _dom_element_alloc, \
+ _dom_element_copy
+
+/* Helper functions*/
+dom_exception _dom_element_get_id(struct dom_element *ele,
+ struct lwc_string_s **id);
+
#endif
diff --git a/src/core/entity_ref.c b/src/core/entity_ref.c
index 2b90c79..c5b426c 100644
--- a/src/core/entity_ref.c
+++ b/src/core/entity_ref.c
@@ -3,8 +3,11 @@
* Licensed under the MIT License,
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
*/
+#include <libwapcaplet/libwapcaplet.h>
+
#include "core/document.h"
#include "core/entity_ref.h"
#include "core/node.h"
@@ -17,6 +20,14 @@ struct dom_entity_reference {
struct dom_node_internal base; /**< Base node */
};
+static struct dom_node_vtable er_vtable = {
+ DOM_NODE_VTABLE
+};
+
+static struct dom_node_protect_vtable er_protect_vtable = {
+ DOM_ER_PROTECT_VTABLE
+};
+
/**
* Create an entity reference
*
@@ -31,24 +42,27 @@ struct dom_entity_reference {
*
* The returned node will already be referenced.
*/
-dom_exception dom_entity_reference_create(struct dom_document *doc,
- struct dom_string *name, struct dom_string *value,
+dom_exception _dom_entity_reference_create(struct dom_document *doc,
+ struct lwc_string_s *name, struct dom_string *value,
struct dom_entity_reference **result)
{
struct dom_entity_reference *e;
dom_exception err;
/* Allocate the comment node */
- e = dom_document_alloc(doc, NULL,
+ e = _dom_document_alloc(doc, NULL,
sizeof(struct dom_entity_reference));
if (e == NULL)
return DOM_NO_MEM_ERR;
+ e->base.base.vtable = &er_vtable;
+ e->base.vtable = &er_protect_vtable;
+
/* And initialise the node */
- err = dom_node_initialise(&e->base, doc, DOM_ENTITY_REFERENCE_NODE,
- name, value, NULL, NULL);
+ err = _dom_entity_reference_initialise(&e->base, doc,
+ DOM_ENTITY_REFERENCE_NODE, name, value, NULL, NULL);
if (err != DOM_NO_ERR) {
- dom_document_alloc(doc, e, 0);
+ _dom_document_alloc(doc, e, 0);
return err;
}
@@ -65,52 +79,28 @@ dom_exception dom_entity_reference_create(struct dom_document *doc,
*
* The contents of ::entity will be destroyed and ::entity will be freed.
*/
-void dom_entity_reference_destroy(struct dom_document *doc,
+void _dom_entity_reference_destroy(struct dom_document *doc,
struct dom_entity_reference *entity)
{
- struct dom_node_internal *c, *d;
-
- /* Destroy children of this node */
- for (c = entity->base.first_child; c != NULL; c = d) {
- d = c->next;
-
- /* Detach child */
- c->parent = NULL;
-
- if (c->refcnt > 0) {
- /* Something is using this child */
-
- /** \todo add to list of nodes pending deletion */
-
- continue;
- }
-
- /* Detach from sibling list */
- c->previous = NULL;
- c->next = NULL;
-
- dom_node_destroy(c);
- }
-
/* Finalise base class */
- dom_node_finalise(doc, &entity->base);
+ _dom_entity_reference_finalise(doc, &entity->base);
/* Destroy fragment */
- dom_document_alloc(doc, entity, 0);
+ _dom_document_alloc(doc, entity, 0);
}
/**
- * Get the textual representation of an EntityReference
+ * Get the textual representation of an EntityRererence
*
* \param entity The entity reference to get the textual representation of
* \param result Pointer to location to receive result
* \return DOM_NO_ERR on success.
*
* The returned string will have its reference count increased. It is
- * the responsibility of the caller to unref the string once it has
+ * the responsibility of the caller to unrer the string once it has
* finished with it.
*/
-dom_exception dom_entity_reference_get_textual_representation(
+dom_exception _dom_entity_reference_get_textual_representation(
struct dom_entity_reference *entity, struct dom_string **result)
{
UNUSED(entity);
@@ -119,3 +109,39 @@ dom_exception dom_entity_reference_get_textual_representation(
return DOM_NOT_SUPPORTED_ERR;
}
+/*-----------------------------------------------------------------------*/
+
+/* Following comes the protected vtable */
+
+/* The virtual destroy function of this class */
+void _dom_er_destroy(struct dom_node_internal *node)
+{
+ _dom_entity_reference_destroy(node->owner,
+ (struct dom_entity_reference *) node);
+}
+
+/* The memory allocator of this class */
+dom_exception _dom_er_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret)
+{
+ UNUSED(n);
+ dom_entity_reference *a;
+
+ a = _dom_document_alloc(doc, NULL, sizeof(struct dom_entity_reference));
+ if (a == NULL)
+ return DOM_NO_MEM_ERR;
+
+ *ret = (dom_node_internal *) a;
+ dom_node_set_owner(*ret, doc);
+
+ return DOM_NO_ERR;
+
+}
+
+/* The copy constructor of this class */
+dom_exception _dom_er_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old)
+{
+ return _dom_node_copy(new, old);
+}
+
diff --git a/src/core/entity_ref.h b/src/core/entity_ref.h
index fa03737..2b83d07 100644
--- a/src/core/entity_ref.h
+++ b/src/core/entity_ref.h
@@ -5,23 +5,42 @@
* Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
*/
-#ifndef dom_internal_core_entityreference_h_
-#define dom_internal_core_entityreference_h_
+#ifndef dom_internal_core_entityrererence_h_
+#define dom_internal_core_entityrererence_h_
#include <dom/core/exceptions.h>
+#include <dom/core/entity_ref.h>
struct dom_document;
struct dom_entity_reference;
struct dom_string;
+struct lwc_string_s;
-dom_exception dom_entity_reference_create(struct dom_document *doc,
- struct dom_string *name, struct dom_string *value,
+dom_exception _dom_entity_reference_create(struct dom_document *doc,
+ struct lwc_string_s *name, struct dom_string *value,
struct dom_entity_reference **result);
-void dom_entity_reference_destroy(struct dom_document *doc,
+void _dom_entity_reference_destroy(struct dom_document *doc,
struct dom_entity_reference *entity);
-dom_exception dom_entity_reference_get_textual_representation(
+#define _dom_entity_reference_initialise _dom_node_initialise
+#define _dom_entity_reference_finalise _dom_node_finalise
+
+/* Following comes the protected vtable */
+void _dom_er_destroy(struct dom_node_internal *node);
+dom_exception _dom_er_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret);
+dom_exception _dom_er_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old);
+
+#define DOM_ER_PROTECT_VTABLE \
+ _dom_er_destroy, \
+ _dom_er_alloc, \
+ _dom_er_copy
+
+/* Helper functions */
+dom_exception _dom_entity_reference_get_textual_representation(
struct dom_entity_reference *entity,
struct dom_string **result);
+
#endif
diff --git a/src/core/implementation.c b/src/core/implementation.c
index e37b27d..e2b6763 100644
--- a/src/core/implementation.c
+++ b/src/core/implementation.c
@@ -59,8 +59,6 @@ dom_exception dom_implementation_has_feature(
* \param public_id The external subset public identifier
* \param system_id The external subset system identifier
* \param doctype Pointer to location to receive result
- * \param alloc Memory (de)allocation function
- * \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,
@@ -79,11 +77,11 @@ dom_exception dom_implementation_has_feature(
dom_exception dom_implementation_create_document_type(
struct dom_implementation *impl, struct dom_string *qname,
struct dom_string *public_id, struct dom_string *system_id,
- struct dom_document_type **doctype,
- dom_alloc alloc, void *pw)
+ dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ struct dom_document_type **doctype)
{
return impl->create_document_type(impl, qname, public_id, system_id,
- doctype, alloc, pw);
+ alloc, pw, ctx, doctype);
}
/**
@@ -94,8 +92,6 @@ dom_exception dom_implementation_create_document_type(
* \param qname The qualified name of the document element
* \param doctype The type of document to create
* \param doc Pointer to location to receive result
- * \param alloc Memory (de)allocation function
- * \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, or if ::qname
@@ -125,11 +121,11 @@ dom_exception dom_implementation_create_document(
struct dom_implementation *impl,
struct dom_string *namespace, struct dom_string *qname,
struct dom_document_type *doctype,
- struct dom_document **doc,
- dom_alloc alloc, void *pw)
+ dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ struct dom_document **doc)
{
- return impl->create_document(impl, namespace, qname, doctype, doc,
- alloc, pw);
+ return impl->create_document(impl, namespace, qname, doctype, alloc,
+ pw, ctx, doc);
}
/**
@@ -140,8 +136,6 @@ dom_exception dom_implementation_create_document(
* \param feature The requested feature
* \param version The version number of the feature
* \param object Pointer to location to receive object
- * \param alloc Memory (de)allocation function
- * \param pw Pointer to client-specific private data
* \return DOM_NO_ERR.
*
* Any memory allocated by this call should be allocated using
@@ -150,8 +144,7 @@ dom_exception dom_implementation_create_document(
dom_exception dom_implementation_get_feature(
struct dom_implementation *impl,
struct dom_string *feature, struct dom_string *version,
- void **object,
- dom_alloc alloc, void *pw)
+ void **object)
{
- return impl->get_feature(impl, feature, version, object, alloc, pw);
+ return impl->get_feature(impl, feature, version, object);
}
diff --git a/src/core/impllist.c b/src/core/impllist.c
index 522c3f7..2f25926 100644
--- a/src/core/impllist.c
+++ b/src/core/impllist.c
@@ -9,6 +9,9 @@
#include <dom/core/implementation.h>
#include <dom/core/impllist.h>
+extern void dom_implementation_list_destroy(
+ struct dom_implementation_list *list);
+
/**
* Claim a reference on a DOM implementation list
*
@@ -29,22 +32,8 @@ void dom_implementation_list_ref(struct dom_implementation_list *list)
*/
void dom_implementation_list_unref(struct dom_implementation_list *list)
{
- struct dom_implementation_list_item *i, *j;
-
if (--list->refcnt == 0) {
- /* Destroy all list entries */
- for (i = list->head; i; i = j) {
- j = i->next;
-
- /* Unreference the implementation */
- dom_implementation_unref(i->impl);
-
- /* And free the entry */
- list->alloc(i, 0, list->pw);
- }
-
- /* Free the list object */
- list->alloc(list, 0, list->pw);
+ dom_implementation_list_destroy(list);
}
}
diff --git a/src/core/namednodemap.c b/src/core/namednodemap.c
index dab6bbb..ec1e151 100644
--- a/src/core/namednodemap.c
+++ b/src/core/namednodemap.c
@@ -3,8 +3,11 @@
* Licensed under the MIT License,
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
*/
+#include <assert.h>
+
#include <dom/core/element.h>
#include <dom/core/node.h>
#include <dom/core/string.h>
@@ -22,9 +25,10 @@
struct dom_namednodemap {
struct dom_document *owner; /**< Owning document */
- struct dom_node_internal *head; /**< Start of item list */
+ void *priv; /**< Private data */
- dom_node_type type; /**< Type of items in map */
+ struct nnm_operation *opt; /**< The underlaid operation
+ * implementations */
uint32_t refcnt; /**< Reference count */
};
@@ -33,8 +37,8 @@ struct dom_namednodemap {
* Create a namednodemap
*
* \param doc The owning document
- * \param head Start of list containing items in map
- * \param type The type of items in the map
+ * \param priv The private data of this dom_namednodemap
+ * \param opt The operation function pointer
* \param map Pointer to location to receive created map
* \return DOM_NO_ERR on success, DOM_NO_MEM_ERR on memory exhaustion
*
@@ -49,23 +53,20 @@ struct dom_namednodemap {
* explicitly reference it. The client must unref the map once it is
* finished with it.
*/
-dom_exception dom_namednodemap_create(struct dom_document *doc,
- struct dom_node_internal *head, dom_node_type type,
+dom_exception _dom_namednodemap_create(struct dom_document *doc,
+ void *priv, struct nnm_operation *opt,
struct dom_namednodemap **map)
{
struct dom_namednodemap *m;
- m = dom_document_alloc(doc, NULL, sizeof(struct dom_namednodemap));
+ m = _dom_document_alloc(doc, NULL, sizeof(struct dom_namednodemap));
if (m == NULL)
return DOM_NO_MEM_ERR;
- dom_node_ref((struct dom_node *) doc);
m->owner = doc;
- dom_node_ref(head);
- m->head = head;
-
- m->type = type;
+ m->priv = priv;
+ m->opt = opt;
m->refcnt = 1;
@@ -81,6 +82,7 @@ dom_exception dom_namednodemap_create(struct dom_document *doc,
*/
void dom_namednodemap_ref(struct dom_namednodemap *map)
{
+ assert(map != NULL);
map->refcnt++;
}
@@ -94,22 +96,15 @@ void dom_namednodemap_ref(struct dom_namednodemap *map)
*/
void dom_namednodemap_unref(struct dom_namednodemap *map)
{
- if (--map->refcnt == 0) {
- struct dom_node_internal *owner =
- (struct dom_node_internal *) map->owner;
+ if (map == NULL)
+ return;
- dom_node_unref(map->head);
-
- /* Remove map from document */
- dom_document_remove_namednodemap(map->owner, map);
+ if (--map->refcnt == 0) {
+ /* Call the implementation specific destroy */
+ map->opt->namednodemap_destroy(map->priv);
/* Destroy the map object */
- dom_document_alloc(map->owner, map, 0);
-
- /* And release our reference on the owning document
- * This must be last as, otherwise, it's possible that
- * the document is destroyed before we are */
- dom_node_unref(owner);
+ _dom_document_alloc(map->owner, map, 0);
}
}
@@ -123,29 +118,8 @@ void dom_namednodemap_unref(struct dom_namednodemap *map)
dom_exception dom_namednodemap_get_length(struct dom_namednodemap *map,
unsigned long *length)
{
- struct dom_node_internal *cur;
- unsigned long len = 0;
-
- switch (map->type) {
- case DOM_ATTRIBUTE_NODE:
- cur = dom_element_get_first_attribute(
- (struct dom_element *) map->head);
- break;
- case DOM_NOTATION_NODE:
- case DOM_ENTITY_NODE:
- /** \todo handle notation and entity nodes */
- default:
- return DOM_NOT_SUPPORTED_ERR;
- break;
- }
-
- for (; cur != NULL; cur = cur->next) {
- len++;
- }
-
- *length = len;
-
- return DOM_NO_ERR;
+ assert(map->opt != NULL);
+ return map->opt->namednodemap_get_length(map->priv, length);
}
/**
@@ -162,33 +136,8 @@ dom_exception dom_namednodemap_get_length(struct dom_namednodemap *map,
dom_exception _dom_namednodemap_get_named_item(struct dom_namednodemap *map,
struct dom_string *name, struct dom_node **node)
{
- struct dom_node_internal *cur;
-
- switch (map->type) {
- case DOM_ATTRIBUTE_NODE:
- cur = dom_element_get_first_attribute(
- (struct dom_element *) map->head);
- break;
- case DOM_NOTATION_NODE:
- case DOM_ENTITY_NODE:
- /** \todo handle notation and entity nodes */
- default:
- return DOM_NOT_SUPPORTED_ERR;
- break;
- }
-
- for (; cur != NULL; cur = cur->next) {
- if (dom_string_cmp(cur->name, name) == 0) {
- break;
- }
- }
-
- if (cur != NULL) {
- dom_node_ref(cur);
- }
- *node = (struct dom_node *) cur;
-
- return DOM_NO_ERR;
+ assert(map->opt != NULL);
+ return map->opt->namednodemap_get_named_item(map->priv, name, node);
}
/**
@@ -218,46 +167,8 @@ dom_exception _dom_namednodemap_get_named_item(struct dom_namednodemap *map,
dom_exception _dom_namednodemap_set_named_item(struct dom_namednodemap *map,
struct dom_node *arg, struct dom_node **node)
{
- dom_exception err;
- struct dom_node_internal *n = (struct dom_node_internal *) arg;
-
- /* Ensure arg and map belong to the same document */
- if (n->owner != map->owner)
- return DOM_WRONG_DOCUMENT_ERR;
-
- /* Ensure map is writable */
- if (_dom_node_readonly(map->head))
- return DOM_NO_MODIFICATION_ALLOWED_ERR;
-
- /* Ensure arg isn't attached to another element */
- if (n->type == DOM_ATTRIBUTE_NODE && n->parent != NULL &&
- n->parent != map->head)
- return DOM_INUSE_ATTRIBUTE_ERR;
-
- /* Ensure arg is permitted in the map */
- if (n->type != map->type)
- return DOM_HIERARCHY_REQUEST_ERR;
-
- /* Now delegate to the container-specific function.
- * NamedNodeMaps are live, so this is fine. */
- switch (map->type) {
- case DOM_ATTRIBUTE_NODE:
- err = dom_element_set_attribute_node(
- (struct dom_element *) map->head,
- (struct dom_attr *) arg,
- (struct dom_attr **) node);
- break;
- case DOM_NOTATION_NODE:
- case DOM_ENTITY_NODE:
- /** \todo handle notation and entity nodes */
- default:
- err = DOM_NOT_SUPPORTED_ERR;
- break;
- }
-
- /* Reference counting is handled by the container-specific call */
-
- return err;
+ assert(map->opt != NULL);
+ return map->opt->namednodemap_set_named_item(map->priv, arg, node);
}
/**
@@ -278,44 +189,8 @@ dom_exception _dom_namednodemap_remove_named_item(
struct dom_namednodemap *map, struct dom_string *name,
struct dom_node **node)
{
- dom_exception err;
-
- /* Ensure map is writable */
- if (_dom_node_readonly(map->head))
- return DOM_NO_MODIFICATION_ALLOWED_ERR;
-
- /* Now delegate to the container-specific function.
- * NamedNodeMaps are live, so this is fine. */
- switch (map->type) {
- case DOM_ATTRIBUTE_NODE:
- {
- struct dom_attr *attr;
-
- err = dom_element_get_attribute_node(
- (struct dom_element *) map->head,
- name, &attr);
- if (err == DOM_NO_ERR) {
- err = dom_element_remove_attribute_node(
- (struct dom_element *) map->head,
- attr, (struct dom_attr **) node);
- if (err == DOM_NO_ERR) {
- /* No longer want attr */
- dom_node_unref((struct dom_node *) attr);
- }
- }
- }
- break;
- case DOM_NOTATION_NODE:
- case DOM_ENTITY_NODE:
- /** \todo handle notation and entity nodes */
- default:
- err = DOM_NOT_SUPPORTED_ERR;
- break;
- }
-
- /* Reference counting is handled by the container-specific call */
-
- return err;
+ assert(map->opt != NULL);
+ return map->opt->namednodemap_remove_named_item(map->priv, name, node);
}
/**
@@ -335,36 +210,8 @@ dom_exception _dom_namednodemap_remove_named_item(
dom_exception _dom_namednodemap_item(struct dom_namednodemap *map,
unsigned long index, struct dom_node **node)
{
- struct dom_node_internal *cur;
- unsigned long count = 0;
-
- switch (map->type) {
- case DOM_ATTRIBUTE_NODE:
- cur = dom_element_get_first_attribute(
- (struct dom_element *) map->head);
- break;
- case DOM_NOTATION_NODE:
- case DOM_ENTITY_NODE:
- /** \todo handle notation and entity nodes */
- default:
- return DOM_NOT_SUPPORTED_ERR;
- break;
- }
-
- for (; cur != NULL; cur = cur->next) {
- count++;
-
- if ((index + 1) == count) {
- break;
- }
- }
-
- if (cur != NULL) {
- dom_node_ref(cur);
- }
- *node = (struct dom_node *) cur;
-
- return DOM_NO_ERR;
+ assert(map->opt != NULL);
+ return map->opt->namednodemap_item(map->priv, index, node);
}
/**
@@ -387,38 +234,9 @@ dom_exception _dom_namednodemap_get_named_item_ns(
struct dom_namednodemap *map, struct dom_string *namespace,
struct dom_string *localname, struct dom_node **node)
{
- struct dom_node_internal *cur;
-
- /** \todo ensure XML feature is supported */
-
- switch (map->type) {
- case DOM_ATTRIBUTE_NODE:
- cur = dom_element_get_first_attribute(
- (struct dom_element *) map->head);
- break;
- case DOM_NOTATION_NODE:
- case DOM_ENTITY_NODE:
- /** \todo handle notation and entity nodes */
- default:
- return DOM_NOT_SUPPORTED_ERR;
- break;
- }
-
- for (; cur != NULL; cur = cur->next) {
- if (((namespace == NULL && cur->namespace == NULL) ||
- (namespace != NULL &&
- dom_string_cmp(cur->namespace, namespace) == 0)) &&
- dom_string_cmp(cur->name, localname) == 0) {
- break;
- }
- }
-
- if (cur != NULL) {
- dom_node_ref(cur);
- }
- *node = (struct dom_node *) cur;
-
- return DOM_NO_ERR;
+ assert(map->opt != NULL);
+ return map->opt->namednodemap_get_named_item_ns(map->priv, namespace,
+ localname, node);
}
/**
@@ -454,48 +272,8 @@ dom_exception _dom_namednodemap_set_named_item_ns(
struct dom_namednodemap *map, struct dom_node *arg,
struct dom_node **node)
{
- dom_exception err;
- struct dom_node_internal *n = (struct dom_node_internal *) arg;
-
- /** \todo ensure XML feature is supported */
-
- /* Ensure arg and map belong to the same document */
- if (n->owner != map->owner)
- return DOM_WRONG_DOCUMENT_ERR;
-
- /* Ensure map is writable */
- if (_dom_node_readonly(map->head))
- return DOM_NO_MODIFICATION_ALLOWED_ERR;
-
- /* Ensure arg isn't attached to another element */
- if (n->type == DOM_ATTRIBUTE_NODE && n->parent != NULL &&
- n->parent != map->head)
- return DOM_INUSE_ATTRIBUTE_ERR;
-
- /* Ensure arg is permitted in the map */
- if (n->type != map->type)
- return DOM_HIERARCHY_REQUEST_ERR;
-
- /* Now delegate to the container-specific function.
- * NamedNodeMaps are live, so this is fine. */
- switch (map->type) {
- case DOM_ATTRIBUTE_NODE:
- err = dom_element_set_attribute_node_ns(
- (struct dom_element *) map->head,
- (struct dom_attr *) arg,
- (struct dom_attr **) node);
- break;
- case DOM_NOTATION_NODE:
- case DOM_ENTITY_NODE:
- /** \todo handle notation and entity nodes */
- default:
- err = DOM_NOT_SUPPORTED_ERR;
- break;
- }
-
- /* Reference counting is handled by the container-specific call */
-
- return err;
+ assert(map->opt != NULL);
+ return map->opt->namednodemap_set_named_item_ns(map->priv, arg, node);
}
/**
@@ -521,61 +299,30 @@ dom_exception _dom_namednodemap_remove_named_item_ns(
struct dom_namednodemap *map, struct dom_string *namespace,
struct dom_string *localname, struct dom_node **node)
{
- dom_exception err;
-
- /** \todo ensure XML feature is supported */
-
- /* Ensure map is writable */
- if (_dom_node_readonly(map->head))
- return DOM_NO_MODIFICATION_ALLOWED_ERR;
-
- /* Now delegate to the container-specific function.
- * NamedNodeMaps are live, so this is fine. */
- switch (map->type) {
- case DOM_ATTRIBUTE_NODE:
- {
- struct dom_attr *attr;
-
- err = dom_element_get_attribute_node_ns(
- (struct dom_element *) map->head,
- namespace, localname, &attr);
- if (err == DOM_NO_ERR) {
- err = dom_element_remove_attribute_node(
- (struct dom_element *) map->head,
- attr, (struct dom_attr **) node);
- if (err == DOM_NO_ERR) {
- /* No longer want attr */
- dom_node_unref((struct dom_node *) attr);
- }
- }
- }
- break;
-case DOM_NOTATION_NODE:
- case DOM_ENTITY_NODE:
- /** \todo handle notation and entity nodes */
- default:
- err = DOM_NOT_SUPPORTED_ERR;
- break;
- }
-
- /* Reference counting is handled by the container-specific call */
-
- return err;
+ assert(map->opt != NULL);
+ return map->opt->namednodemap_remove_named_item_ns(map->priv, namespace,
+ localname, node);
}
/**
- * Match a namednodemap instance against a set of creation parameters
+ * Compare whether two NamedNodeMap are equal.
*
- * \param map The map to match
- * \param head Start of list containing items in map
- * \param type The type of items in the map
- * \return true if list matches, false otherwise
*/
-bool dom_namednodemap_match(struct dom_namednodemap *map,
- struct dom_node_internal *head, dom_node_type type)
+bool _dom_namednodemap_equal(struct dom_namednodemap *m1,
+ struct dom_namednodemap *m2)
{
- if (map->head == head && map->type == type)
- return true;
+ assert(m1->opt != NULL);
+ return (m1->opt == m2->opt && m1->opt->namednodemap_equal(m1->priv,
+ m2->priv));
+}
- return false;
+/**
+ * Update the dom_namednodemap to make it as a proxy of another object
+ *
+ * \param map The dom_namednodemap
+ * \param priv The private data to change to
+ */
+void _dom_namednodemap_update(struct dom_namednodemap *map, void *priv)
+{
+ map->priv = priv;
}
diff --git a/src/core/namednodemap.h b/src/core/namednodemap.h
index 830ab6d..328e433 100644
--- a/src/core/namednodemap.h
+++ b/src/core/namednodemap.h
@@ -18,14 +18,54 @@ struct dom_node;
struct dom_namednodemap;
struct dom_string;
+struct nnm_operation {
+ dom_exception (*namednodemap_get_length)(void *priv,
+ unsigned long *length);
+
+ dom_exception (*namednodemap_get_named_item)(void *priv,
+ struct dom_string *name, struct dom_node **node);
+
+ dom_exception (*namednodemap_set_named_item)(void *priv,
+ struct dom_node *arg, struct dom_node **node);
+
+ dom_exception (*namednodemap_remove_named_item)(
+ void *priv, struct dom_string *name,
+ struct dom_node **node);
+
+ dom_exception (*namednodemap_item)(void *priv,
+ unsigned long index, struct dom_node **node);
+
+ dom_exception (*namednodemap_get_named_item_ns)(
+ void *priv, struct dom_string *namespace,
+ struct dom_string *localname, struct dom_node **node);
+
+ dom_exception (*namednodemap_set_named_item_ns)(
+ void *priv, struct dom_node *arg,
+ struct dom_node **node);
+
+ dom_exception (*namednodemap_remove_named_item_ns)(
+ void *priv, struct dom_string *namespace,
+ struct dom_string *localname, struct dom_node **node);
+
+ void (*namednodemap_destroy)(void *priv);
+
+ bool (*namednodemap_equal)(void *p1, void *p2);
+};
+
/* Create a namednodemap */
-dom_exception dom_namednodemap_create(struct dom_document *doc,
- struct dom_node_internal *head, dom_node_type type,
+dom_exception _dom_namednodemap_create(struct dom_document *doc,
+ void *priv, struct nnm_operation *opt,
struct dom_namednodemap **map);
+/* Update the private data */
+void _dom_namednodemap_update(struct dom_namednodemap *map, void *priv);
+
+/* Test whether two maps are equal */
+bool _dom_namednodemap_equal(struct dom_namednodemap *m1,
+ struct dom_namednodemap *m2);
-/* Match a namednodemap instance against a set of creation parameters */
-bool dom_namednodemap_match(struct dom_namednodemap *map,
- struct dom_node_internal *head, dom_node_type type);
+#define dom_namednodemap_equal(m1, m2) _dom_namednodemap_equal( \
+ (struct dom_namednodemap *) (m1), \
+ (struct dom_namednodemap *) (m2))
#endif
diff --git a/src/core/node.c b/src/core/node.c
index 518d88c..0645769 100644
--- a/src/core/node.c
+++ b/src/core/node.c
@@ -3,6 +3,7 @@
* Licensed under the MIT License,
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
*/
#include <assert.h>
@@ -10,9 +11,15 @@
#include <stdio.h>
#include <dom/core/attr.h>
+#include <dom/core/text.h>
#include <dom/core/document.h>
-#include <dom/core/string.h>
+#include <dom/core/namednodemap.h>
+#include <dom/core/nodelist.h>
+#include <dom/core/implementation.h>
+#include <dom/core/document_type.h>
+#include "core/string.h"
+#include "core/namednodemap.h"
#include "core/attr.h"
#include "core/cdatasection.h"
#include "core/comment.h"
@@ -25,6 +32,7 @@
#include "core/pi.h"
#include "core/text.h"
#include "utils/utils.h"
+#include "utils/resource_mgr.h"
static bool _dom_node_permitted_child(const dom_node_internal *parent,
const dom_node_internal *child);
@@ -48,21 +56,27 @@ static struct dom_node_vtable node_vtable = {
DOM_NODE_VTABLE
};
-/**
- * Create a DOM node and compose the vtable
- *
- * Return The new constructed DOM node or NULL if fail.
- */
-dom_node_internal * dom_node_create(struct dom_document *doc)
+static struct dom_node_protect_vtable node_protect_vtable = {
+ DOM_NODE_PROTECT_VTABLE
+};
+
+
+
+/*----------------------------------------------------------------------*/
+
+/* The constructor and destructor of this object */
+
+/* Create a DOM node and compose the vtable */
+dom_node_internal * _dom_node_create(struct dom_document *doc)
{
- dom_node_internal *node = dom_document_alloc(doc, NULL,
+ dom_node_internal *node = _dom_document_alloc(doc, NULL,
sizeof(struct dom_node_internal));
if (node == NULL)
return NULL;
node->base.vtable = &node_vtable;
- node->destroy = _dom_node_destroy;
+ node->vtable = &node_protect_vtable;
return node;
}
@@ -86,9 +100,6 @@ void _dom_node_destroy(struct dom_node_internal *node)
bool null_owner_permitted = (node->type == DOM_DOCUMENT_NODE ||
node->type == DOM_DOCUMENT_TYPE_NODE);
- /* This function simply acts as a central despatcher
- * for type-specific destructors. */
-
assert(null_owner_permitted || owner != NULL);
if (!null_owner_permitted) {
@@ -98,56 +109,19 @@ void _dom_node_destroy(struct dom_node_internal *node)
dom_node_ref(owner);
}
-/* This type dependent switch is not necessary from now.
- But I still keep them for a while untill all the functions works well.
- switch (node->type) {
- case DOM_ELEMENT_NODE:
- dom_element_destroy(owner, (struct dom_element *) node);
- break;
- case DOM_ATTRIBUTE_NODE:
- dom_attr_destroy(owner, (struct dom_attr *) node);
- break;
- case DOM_TEXT_NODE:
- dom_text_destroy(owner, (struct dom_text *) node);
- break;
- case DOM_CDATA_SECTION_NODE:
- dom_cdata_section_destroy(owner,
- (struct dom_cdata_section *) node);
- break;
- case DOM_ENTITY_REFERENCE_NODE:
- dom_entity_reference_destroy(owner,
- (struct dom_entity_reference *) node);
- break;
- case DOM_ENTITY_NODE:
- break;
- case DOM_PROCESSING_INSTRUCTION_NODE:
- dom_processing_instruction_destroy(owner,
- (struct dom_processing_instruction *) node);
- break;
- case DOM_COMMENT_NODE:
- dom_comment_destroy(owner, (struct dom_comment *) node);
- break;
- case DOM_DOCUMENT_NODE:
- dom_document_destroy((struct dom_document *) node);
- break;
- case DOM_DOCUMENT_TYPE_NODE:
- dom_document_type_destroy((struct dom_document_type *) node);
- break;
- case DOM_DOCUMENT_FRAGMENT_NODE:
- dom_document_fragment_destroy(owner,
- (struct dom_document_fragment *) node);
- break;
- case DOM_NOTATION_NODE:
- break;
- }
-*/
+ /* Finalise this node, this should also destroy all the child nodes. */
+ _dom_node_finalise(owner, node);
+
if (!null_owner_permitted) {
- /* Release the reference we claimed on the document. If this
- * is the last reference held on the document and the list
- * of nodes pending deletion is empty, then the document will
+ /* Release the reference we claimed on the document. If this
+ * is the last reference held on the document and the list
+ * of nodes pending deletion is empty, then the document will
* be destroyed. */
dom_node_unref(owner);
}
+
+ /* Release our memory */
+ _dom_document_alloc(owner, node, 0);
}
/**
@@ -165,13 +139,63 @@ void _dom_node_destroy(struct dom_node_internal *node)
* ::name, ::value, ::namespace, and ::prefix will have their reference
* counts increased.
*/
-dom_exception dom_node_initialise(dom_node_internal *node,
+dom_exception _dom_node_initialise(dom_node_internal *node,
struct dom_document *doc, dom_node_type type,
- struct dom_string *name, struct dom_string *value,
- struct dom_string *namespace, struct dom_string *prefix)
+ struct lwc_string_s *name, struct dom_string *value,
+ struct lwc_string_s *namespace, struct lwc_string_s *prefix)
+{
+ lwc_context *ctx;
+ dom_alloc alloc;
+ void *pw;
+ dom_exception err;
+
+ ctx = _dom_document_get_intern_context(doc);
+ /* The lwc_context for a document never can be NULL */
+ assert(ctx != NULL);
+
+ _dom_document_get_allocator(doc, &alloc, &pw);
+
+ err = _dom_node_initialise_generic(node, doc, alloc, pw, ctx, type,
+ name, value, namespace, prefix);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Initialise a DOM node
+ *
+ * \param node The node to initialise
+ * \param doc The document object
+ * \param alloc The memory allocator
+ * \param pw The allocator private pointer data
+ * \param ctx The intern context
+ * \param type The node type required
+ * \param name The node (local) name, or NULL
+ * \param value The node value, or NULL
+ * \param namespace Namespace URI to use for node, or NULL
+ * \param prefix Namespace prefix to use for node, or NULL
+ * \return DOM_NO_ERR on success.
+ *
+ * ::name, ::value, ::namespace, and ::prefix will have their reference
+ * counts increased.
+ */
+dom_exception _dom_node_initialise_generic(
+ struct dom_node_internal *node, struct dom_document *doc,
+ dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ dom_node_type type, struct lwc_string_s *name,
+ struct dom_string *value, struct lwc_string_s *namespace,
+ struct lwc_string_s *prefix)
{
+ UNUSED(alloc);
+ UNUSED(pw);
+
+ assert(ctx != NULL);
+ node->owner = doc;
+
if (name != NULL)
- dom_string_ref(name);
+ lwc_context_string_ref(ctx, name);
node->name = name;
if (value != NULL)
@@ -204,15 +228,14 @@ dom_exception dom_node_initialise(dom_node_internal *node,
* deletion. This list will not be forcibly emptied, as it contains
* those nodes (and their sub-trees) in use by client code.
*/
- node->owner = doc;
if (namespace != NULL) {
- dom_string_ref(namespace);
+ lwc_context_string_ref(ctx, namespace);
}
node->namespace = namespace;
if (prefix != NULL) {
- dom_string_ref(prefix);
+ lwc_context_string_ref(ctx, prefix);
}
node->prefix = prefix;
@@ -220,6 +243,12 @@ dom_exception dom_node_initialise(dom_node_internal *node,
node->refcnt = 1;
+ list_init(&node->pending_list);
+ if (node->type != DOM_DOCUMENT_NODE) {
+ /* A Node should be in the pending list when it is created */
+ dom_node_mark_pending(node);
+ }
+
return DOM_NO_ERR;
}
@@ -232,33 +261,62 @@ dom_exception dom_node_initialise(dom_node_internal *node,
* The contents of ::node will be cleaned up. ::node will not be freed.
* All children of ::node should have been removed prior to finalisation.
*/
-void dom_node_finalise(struct dom_document *doc, dom_node_internal *node)
+void _dom_node_finalise(struct dom_document *doc, dom_node_internal *node)
+{
+ lwc_context *ctx;
+ dom_alloc alloc;
+ void *pw;
+
+ ctx = _dom_document_get_intern_context(doc);
+ /* The lwc_context for a document never can be NULL */
+ assert(ctx != NULL);
+
+ _dom_document_get_allocator(doc, &alloc, &pw);
+
+ _dom_node_finalise_generic(node, alloc, pw, ctx);
+}
+
+/**
+ * Finalise a DOM node
+ *
+ * \param node The node to finalise
+ * \param alloc The allocator
+ * \param pw The allocator private data
+ * \param ctx The intern string context
+ */
+void _dom_node_finalise_generic(dom_node_internal *node, dom_alloc alloc,
+ void *pw, struct lwc_context_s *ctx)
{
struct dom_user_data *u, *v;
- /* Standalone DocumentType nodes may not have user data attached */
- assert(node->type != DOM_DOCUMENT_TYPE_NODE ||
- node->user_data == NULL);
+ UNUSED(alloc);
+ UNUSED(pw);
+
+ assert(ctx != NULL);
/* Destroy user data */
for (u = node->user_data; u != NULL; u = v) {
v = u->next;
-
dom_string_unref(u->key);
-
- dom_document_alloc(doc, u, 0);
+ alloc(u, 0, pw);
}
+ node->user_data = NULL;
if (node->prefix != NULL)
- dom_string_unref(node->prefix);
+ lwc_context_string_unref(ctx, node->prefix);
if (node->namespace != NULL)
- dom_string_unref(node->namespace);
-
- /** \todo check if this node is in list of nodes pending deletion.
- * If so, it must be removed from the list, so the document gets
- * destroyed once the list is empty (and no longer referenced) */
- node->owner = NULL;
+ lwc_context_string_unref(ctx, node->namespace);
+
+ /* Destroy all the child nodes of this node */
+ struct dom_node_internal *p = node->first_child;
+ struct dom_node_internal *n = NULL;
+ while (p != NULL) {
+ n = p->next;
+ p->parent = NULL;
+ dom_node_try_destroy(p);
+ p = n;
+ }
/* Paranoia */
node->next = NULL;
@@ -271,7 +329,19 @@ void dom_node_finalise(struct dom_document *doc, dom_node_internal *node)
dom_string_unref(node->value);
if (node->name != NULL)
- dom_string_unref(node->name);
+ lwc_context_string_unref(ctx, node->name);
+
+ /* Detach from the pending list, if we are in it */
+ if (node->pending_list.prev != &node->pending_list) {
+ assert (node->pending_list.next != &node->pending_list);
+ list_del(&node->pending_list);
+ if (node->owner != NULL && node->type != DOM_DOCUMENT_NODE) {
+ /* Deleting this node from the pending list may cause
+ * the list to be null and we should try to destroy
+ * the document. */
+ _dom_document_try_destroy(node->owner);
+ }
+ }
}
/**
@@ -284,6 +354,11 @@ void _dom_node_ref(dom_node_internal *node)
node->refcnt++;
}
+
+/* ---------------------------------------------------------------------*/
+
+/* The public virtual function of this interface Node */
+
/**
* Release a reference on a DOM node
*
@@ -291,15 +366,20 @@ void _dom_node_ref(dom_node_internal *node)
*
* If the reference count reaches zero and the node is not part of any
* document, any memory claimed by the node will be released.
+ *
+ * If the parent of the node is NULL but the reference count does not reach
+ * zero, this means we should put this node to the document's deletion pending
+ * list. When the refcnt reach zero, we delete it.
*/
void _dom_node_unref(dom_node_internal *node)
{
+ if (node == NULL)
+ return;
+
if (node->refcnt > 0)
node->refcnt--;
- if (node->refcnt == 0 && node->parent == NULL) {
- dom_node_destroy(node);
- }
+ dom_node_try_destroy(node);
}
/**
@@ -316,50 +396,85 @@ void _dom_node_unref(dom_node_internal *node)
dom_exception _dom_node_get_node_name(dom_node_internal *node,
struct dom_string **result)
{
- struct dom_string *node_name;
+ struct dom_string *node_name, *temp;
+ dom_document *doc;
+ dom_exception err;
+ struct dom_resource_mgr rm;
+
+ doc = node->owner;
+ /* Document Node and DocumentType Node can have no owner */
+ assert(node->type == DOM_DOCUMENT_TYPE_NODE ||
+ node->type == DOM_DOCUMENT_NODE ||
+ doc != NULL);
assert(node->name != NULL);
+ if (doc != NULL) {
+ _dom_document_get_resource_mgr(doc, &rm);
+ } else if (node->type == DOM_DOCUMENT_TYPE_NODE) {
+ _dom_document_type_get_resource_mgr(
+ (dom_document_type *) node, &rm);
+ }
+
/* If this node was created using a namespace-aware method and
* has a defined prefix, then nodeName is a QName comprised
* of prefix:name. */
- if ((node->type == DOM_ELEMENT_NODE ||
- node->type == DOM_ATTRIBUTE_NODE) &&
- node->prefix != NULL) {
+ if(node->prefix != NULL) {
struct dom_string *colon;
- dom_exception err;
- err = dom_document_create_string(node->owner,
+ err = _dom_resource_mgr_create_string(&rm,
(const uint8_t *) ":", SLEN(":"), &colon);
if (err != DOM_NO_ERR) {
return err;
}
+ /* Make a temp prefix dom_string */
+ err = _dom_resource_mgr_create_string_from_lwcstring(&rm,
+ node->prefix, &temp);
+ if (err != DOM_NO_ERR) {
+ dom_string_unref(colon);
+ return err;
+ }
+
/* Prefix + : */
- err = dom_string_concat(node->prefix, colon, &node_name);
+ err = dom_string_concat(temp, colon, &node_name);
if (err != DOM_NO_ERR) {
+ dom_string_unref(temp);
dom_string_unref(colon);
return err;
}
+ /*Finished with temp*/
+ dom_string_unref(temp);
/* Finished with colon */
dom_string_unref(colon);
+ /* Make a temp name dom_string */
+ err = _dom_resource_mgr_create_string_from_lwcstring(&rm,
+ node->name, &temp);
+ if (err != DOM_NO_ERR) {
+ return err;
+ }
/* Prefix + : + Localname */
- err = dom_string_concat(node_name, node->name, &colon);
+ err = dom_string_concat(node_name, temp, &colon);
if (err != DOM_NO_ERR) {
+ dom_string_unref(temp);
dom_string_unref(node_name);
return err;
}
+ /* Finished with temp */
+ dom_string_unref(temp);
/* Finished with intermediate node name */
dom_string_unref(node_name);
node_name = colon;
} else {
- dom_string_ref(node->name);
-
- node_name = node->name;
+ err = _dom_resource_mgr_create_string_from_lwcstring(&rm,
+ node->name, &node_name);
+ if (err != DOM_NO_ERR) {
+ return err;
+ }
}
*result = node_name;
@@ -384,10 +499,6 @@ dom_exception _dom_node_get_node_name(dom_node_internal *node,
dom_exception _dom_node_get_node_value(dom_node_internal *node,
struct dom_string **result)
{
- if (node->type == DOM_ATTRIBUTE_NODE) {
- return dom_attr_get_value((struct dom_attr *) node, result);
- }
-
if (node->value != NULL)
dom_string_ref(node->value);
@@ -412,6 +523,9 @@ dom_exception _dom_node_get_node_value(dom_node_internal *node,
dom_exception _dom_node_set_node_value(dom_node_internal *node,
struct dom_string *value)
{
+ /* TODO
+ * Whether we should change this to a virtual function?
+ */
/* This is a NOP if the value is defined to be null. */
if (node->type == DOM_DOCUMENT_NODE ||
node->type == DOM_DOCUMENT_FRAGMENT_NODE ||
@@ -507,8 +621,8 @@ dom_exception _dom_node_get_child_nodes(dom_node_internal *node,
if (node->owner == NULL)
return DOM_NOT_SUPPORTED_ERR;
- return dom_document_get_nodelist(node->owner, node,
- NULL, NULL, NULL, result);
+ return _dom_document_get_nodelist(node->owner, DOM_NODELIST_CHILDREN,
+ node, NULL, NULL, NULL, result);
}
/**
@@ -630,13 +744,10 @@ dom_exception _dom_node_get_next_sibling(dom_node_internal *node,
dom_exception _dom_node_get_attributes(dom_node_internal *node,
struct dom_namednodemap **result)
{
- if (node->type != DOM_ELEMENT_NODE) {
- *result = NULL;
-
- return DOM_NO_ERR;
- }
+ UNUSED(node);
+ *result = NULL;
- return dom_element_get_attributes((struct dom_element *) node, result);
+ return DOM_NO_ERR;
}
/**
@@ -654,8 +765,7 @@ dom_exception _dom_node_get_owner_document(dom_node_internal *node,
struct dom_document **result)
{
/* Document nodes have no owner, as far as clients are concerned
- * In reality, they own themselves as this simplifies code elsewhere
- */
+ * In reality, they own themselves as this simplifies code elsewhere */
if (node->type == DOM_DOCUMENT_NODE) {
*result = NULL;
@@ -664,7 +774,7 @@ dom_exception _dom_node_get_owner_document(dom_node_internal *node,
/* If there is an owner, increase its reference count */
if (node->owner != NULL)
- dom_node_ref((dom_node_internal *) node->owner);
+ dom_node_ref(node->owner);
*result = node->owner;
@@ -729,19 +839,10 @@ dom_exception _dom_node_insert_before(dom_node_internal *node,
}
/* Ensure that new_child is permitted as a child of node */
- if (!_dom_node_permitted_child(node, new_child))
+ if (new_child->type != DOM_DOCUMENT_FRAGMENT_NODE &&
+ !_dom_node_permitted_child(node, new_child))
return DOM_HIERARCHY_REQUEST_ERR;
- /* DocumentType nodes are created outside the Document so,
- * if we're trying to attach a DocumentType node, then we
- * also need to set its owner. */
- if (node->type == DOM_DOCUMENT_NODE &&
- new_child->type == DOM_DOCUMENT_TYPE_NODE) {
- /* See long comment in dom_node_initialise as to why
- * we don't ref the document here */
- new_child->owner = (struct dom_document *) node;
- }
-
/* Attempting to insert a node before itself is a NOP */
if (new_child == ref_child) {
dom_node_ref(new_child);
@@ -759,9 +860,19 @@ dom_exception _dom_node_insert_before(dom_node_internal *node,
_dom_node_detach(new_child);
}
- /* If new_child is a DocumentFragment, insert its children
+ /* When a Node is attached, it should be removed from the pending
+ * list */
+ dom_node_remove_pending(new_child);
+
+ /* If new_child is a DocumentFragment, insert its children.
* Otherwise, insert new_child */
if (new_child->type == DOM_DOCUMENT_FRAGMENT_NODE) {
+ /* Test the children of the docment fragment can be appended */
+ dom_node_internal *c = new_child->first_child;
+ for (; c != NULL; c = c->next)
+ if (!_dom_node_permitted_child(node, c))
+ return DOM_HIERARCHY_REQUEST_ERR;
+
if (new_child->first_child != NULL) {
_dom_node_attach_range(new_child->first_child,
new_child->last_child,
@@ -783,6 +894,16 @@ dom_exception _dom_node_insert_before(dom_node_internal *node,
: ref_child);
}
+ /* DocumentType nodes are created outside the Document so,
+ * if we're trying to attach a DocumentType node, then we
+ * also need to set its owner. */
+ if (node->type == DOM_DOCUMENT_NODE &&
+ new_child->type == DOM_DOCUMENT_TYPE_NODE) {
+ /* See long comment in _dom_node_initialise as to why
+ * we don't ref the document here */
+ new_child->owner = (struct dom_document *) node;
+ }
+
/** \todo Is it correct to return DocumentFragments? */
dom_node_ref(new_child);
@@ -853,8 +974,21 @@ dom_exception _dom_node_replace_child(dom_node_internal *node,
}
/* Ensure that new_child is permitted as a child of node */
- if (!_dom_node_permitted_child(node, new_child))
- return DOM_HIERARCHY_REQUEST_ERR;
+ if (new_child->type == DOM_DOCUMENT_FRAGMENT_NODE) {
+ /* If this node is a doc fragment, we should test all its
+ * children nodes */
+ dom_node_internal *c;
+ c = new_child->first_child;
+ while (c != NULL) {
+ if (!_dom_node_permitted_child(node, c))
+ return DOM_HIERARCHY_REQUEST_ERR;
+
+ c = c->next;
+ }
+ } else {
+ if (!_dom_node_permitted_child(node, new_child))
+ return DOM_HIERARCHY_REQUEST_ERR;
+ }
/* Attempting to replace a node with itself is a NOP */
if (new_child == old_child) {
@@ -878,6 +1012,8 @@ dom_exception _dom_node_replace_child(dom_node_internal *node,
/* Sort out the return value */
dom_node_ref(old_child);
+ /* The replaced node should be marded pending */
+ dom_node_mark_pending(old_child);
*result = old_child;
return DOM_NO_ERR;
@@ -922,8 +1058,12 @@ dom_exception _dom_node_remove_child(dom_node_internal *node,
/* Detach the node */
_dom_node_detach(old_child);
- /* Sort out the return value */
+ /* When a Node is removed, it should be destroy. When its refcnt is not
+ * zero, it will be added to the document's deletion pending list.
+ * When a Node is removed, its parent should be NULL, but its owner
+ * should remain to be the document. */
dom_node_ref(old_child);
+ dom_node_try_destroy(old_child);
*result = old_child;
return DOM_NO_ERR;
@@ -1015,15 +1155,67 @@ dom_exception _dom_node_has_child_nodes(dom_node_internal *node, bool *result)
*
* \todo work out what happens when cloning Document, DocumentType, Entity
* and Notation nodes.
+ *
+ * Note: we adopt a OO paradigm, this clone_node just provide a basic operation
+ * of clone. Special clones like Attr/EntitiReference stated above should
+ * provide their overload of this interface in their implementation file.
*/
dom_exception _dom_node_clone_node(dom_node_internal *node, bool deep,
dom_node_internal **result)
{
- UNUSED(node);
- UNUSED(deep);
- UNUSED(result);
+ dom_node_internal *n, *child, *r;
+ dom_exception err;
+ dom_document *doc;
+ dom_user_data *ud;
+
+ doc = node->owner;
+ assert(doc != NULL);
+
+ err = dom_node_alloc(doc, node, &n);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = dom_node_copy(n, node);
+ if (err != DOM_NO_ERR) {
+ _dom_document_alloc(doc, n, 0);
+ return err;
+ }
- return DOM_NOT_SUPPORTED_ERR;
+ if (deep) {
+ child = node->first_child;
+ while (child != NULL) {
+ err = dom_node_clone_node(child, deep, (void *) &r);
+ if (err != DOM_NO_ERR) {
+ dom_node_unref(n);
+ return err;
+ }
+
+ err = dom_node_append_child(n, r, (void *) &r);
+ if (err != DOM_NO_ERR) {
+ dom_node_unref(n);
+ return err;
+ }
+
+ /* Clean up the new node, we have reference it two
+ * times */
+ dom_node_unref(r);
+ dom_node_unref(r);
+ child = child->next;
+ }
+ }
+
+ *result = n;
+
+ /* Call the dom_user_data_handlers */
+ ud = node->user_data;
+ while (ud != NULL) {
+ if (ud->handler != NULL)
+ ud->handler(DOM_NODE_CLONED, ud->key, ud->data,
+ (dom_node *) node, (dom_node *) n);
+ ud = ud->next;
+ }
+
+ return DOM_NO_ERR;
}
/**
@@ -1038,9 +1230,36 @@ dom_exception _dom_node_clone_node(dom_node_internal *node, bool deep,
*/
dom_exception _dom_node_normalize(dom_node_internal *node)
{
- UNUSED(node);
+ dom_node_internal *n, *p;
+ dom_exception err;
- return DOM_NOT_SUPPORTED_ERR;
+ p = node->first_child;
+ if (p == NULL)
+ return DOM_NO_ERR;
+
+ n = p->next;
+
+ while (n != NULL) {
+ if (n->type == DOM_TEXT_NODE && p->type == DOM_TEXT_NODE) {
+ err = _dom_merge_adjacent_text(p, n);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ _dom_node_detach(n);
+ dom_node_unref(n);
+ n = p->next;
+ continue;
+ }
+ if (n->type != DOM_TEXT_NODE) {
+ err = dom_node_normalize(n);
+ if (err != DOM_NO_ERR)
+ return err;
+ }
+ p = n;
+ n = n->next;
+ }
+
+ return DOM_NO_ERR;
}
/**
@@ -1054,15 +1273,22 @@ dom_exception _dom_node_normalize(dom_node_internal *node)
* \return DOM_NO_ERR.
*/
dom_exception _dom_node_is_supported(dom_node_internal *node,
- struct dom_string *feature, dom_node_internal *version,
+ struct dom_string *feature, struct dom_string *version,
bool *result)
{
- UNUSED(node);
- UNUSED(feature);
- UNUSED(version);
- UNUSED(result);
+ dom_document *doc;
+ dom_implementation *impl;
+ bool has;
- return DOM_NOT_SUPPORTED_ERR;
+ doc = node->owner;
+ assert(doc != NULL);
+ dom_document_get_implementation(doc, &impl);
+ assert(impl != NULL);
+ dom_implementation_has_feature(impl, feature, version, &has);
+
+ *result = has;
+
+ return DOM_NO_ERR;
}
/**
@@ -1079,13 +1305,18 @@ dom_exception _dom_node_is_supported(dom_node_internal *node,
dom_exception _dom_node_get_namespace(dom_node_internal *node,
struct dom_string **result)
{
+ lwc_context *ctx;
+
+ assert(node->owner != NULL);
+ ctx = _dom_document_get_intern_context(node->owner);
+ assert(ctx != NULL);
+
/* If there is a namespace, increase its reference count */
if (node->namespace != NULL)
- dom_string_ref(node->namespace);
+ lwc_context_string_ref(ctx, node->namespace);
- *result = node->namespace;
-
- return DOM_NO_ERR;
+ return _dom_document_create_string_from_lwcstring(node->owner,
+ node->namespace, result);
}
/**
@@ -1102,13 +1333,19 @@ dom_exception _dom_node_get_namespace(dom_node_internal *node,
dom_exception _dom_node_get_prefix(dom_node_internal *node,
struct dom_string **result)
{
+ lwc_context *ctx;
+
+ assert(node->owner != NULL);
+ ctx = _dom_document_get_intern_context(node->owner);
+ assert(ctx != NULL);
+
/* If there is a prefix, increase its reference count */
if (node->prefix != NULL)
- dom_string_ref(node->prefix);
+ lwc_context_string_ref(ctx, node->prefix);
- *result = node->prefix;
-
- return DOM_NO_ERR;
+ return _dom_document_create_string_from_lwcstring(node->owner,
+ node->prefix,
+ result);
}
/**
@@ -1137,6 +1374,13 @@ dom_exception _dom_node_get_prefix(dom_node_internal *node,
dom_exception _dom_node_set_prefix(dom_node_internal *node,
struct dom_string *prefix)
{
+ dom_exception err;
+ lwc_string *str;
+ lwc_context *docctx;
+
+ docctx = _dom_document_get_intern_context(node->owner);
+ assert(docctx != NULL);
+
/* Only Element and Attribute nodes created using
* namespace-aware methods may have a prefix */
if ((node->type != DOM_ELEMENT_NODE &&
@@ -1154,7 +1398,7 @@ dom_exception _dom_node_set_prefix(dom_node_internal *node,
/* No longer want existing prefix */
if (node->prefix != NULL) {
- dom_string_unref(node->prefix);
+ lwc_context_string_unref(docctx, node->prefix);
}
/* Set the prefix */
@@ -1163,8 +1407,11 @@ dom_exception _dom_node_set_prefix(dom_node_internal *node,
if (dom_string_length(prefix) == 0) {
node->prefix = NULL;
} else {
- dom_string_ref(prefix);
- node->prefix = prefix;
+ err = _dom_node_get_intern_string(node, prefix, &str);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ node->prefix = str;
}
} else {
node->prefix = NULL;
@@ -1186,7 +1433,13 @@ dom_exception _dom_node_set_prefix(dom_node_internal *node,
*/
dom_exception _dom_node_get_local_name(dom_node_internal *node,
struct dom_string **result)
-{
+{
+ lwc_context *ctx;
+
+ assert(node->owner != NULL);
+ ctx = _dom_document_get_intern_context(node->owner);
+ assert(ctx != NULL);
+
/* Only Element and Attribute nodes may have a local name */
if (node->type != DOM_ELEMENT_NODE &&
node->type != DOM_ATTRIBUTE_NODE) {
@@ -1194,19 +1447,13 @@ dom_exception _dom_node_get_local_name(dom_node_internal *node,
return DOM_NO_ERR;
}
- /* Node must have been created using a namespace-aware method */
- if (node->namespace == NULL) {
- *result = NULL;
- return DOM_NO_ERR;
- }
-
/* The node may have a local name, reference it if so */
if (node->name != NULL) {
- dom_string_ref(node->name);
+ lwc_context_string_ref(ctx, node->name);
}
- *result = node->name;
- return DOM_NO_ERR;
+ return _dom_document_create_string_from_lwcstring(node->owner,
+ node->name, result);
}
/**
@@ -1218,13 +1465,10 @@ dom_exception _dom_node_get_local_name(dom_node_internal *node,
*/
dom_exception _dom_node_has_attributes(dom_node_internal *node, bool *result)
{
- if (node->type != DOM_ELEMENT_NODE) {
- *result = false;
-
- return DOM_NO_ERR;
- }
+ UNUSED(node);
+ *result = false;
- return dom_element_has_attributes((struct dom_element *) node, result);
+ return DOM_NO_ERR;
}
/**
@@ -1237,6 +1481,9 @@ dom_exception _dom_node_has_attributes(dom_node_internal *node, bool *result)
* The returned string will have its reference count increased. It is
* the responsibility of the caller to unref the string once it has
* finished with it.
+ *
+ * We don't support this API now, so this function call should always
+ * return DOM_NOT_SUPPORTED_ERR.
*/
dom_exception _dom_node_get_base(dom_node_internal *node,
struct dom_string **result)
@@ -1258,6 +1505,9 @@ dom_exception _dom_node_get_base(dom_node_internal *node,
* implementations.
*
* The result is a bitfield of dom_document_position values.
+ *
+ * We don't support this API now, so this function call should always
+ * return DOM_NOT_SUPPORTED_ERR.
*/
dom_exception _dom_node_compare_document_position(dom_node_internal *node,
dom_node_internal *other, uint16_t *result)
@@ -1286,10 +1536,21 @@ dom_exception _dom_node_compare_document_position(dom_node_internal *node,
dom_exception _dom_node_get_text_content(dom_node_internal *node,
struct dom_string **result)
{
- UNUSED(node);
- UNUSED(result);
+ dom_node_internal *n;
+ dom_string *str;
+ dom_string *ret;
- return DOM_NOT_SUPPORTED_ERR;
+ assert(node->owner != NULL);
+
+ for (n = node->first_child; n != NULL; n = n->next) {
+ dom_node_get_text_content(n, &ret);
+ dom_string_concat(str, ret, &str);
+ }
+
+ dom_string_ref(str);
+ *result = str;
+
+ return DOM_NO_ERR;
}
/**
@@ -1306,10 +1567,36 @@ dom_exception _dom_node_get_text_content(dom_node_internal *node,
dom_exception _dom_node_set_text_content(dom_node_internal *node,
struct dom_string *content)
{
- UNUSED(node);
- UNUSED(content);
+ dom_node_internal *n, *p, *r;
+ dom_document *doc;
+ dom_text *text;
+ dom_exception err;
+
+ n = node->first_child;
+
+ while (n != NULL) {
+ p = n;
+ n = n->next;
+ /* Add the (void *) casting to avoid gcc warning:
+ * dereferencing type-punned pointer will break
+ * strict-aliasing rules */
+ err = dom_node_remove_child(node, n, (void *) &r);
+ if (err != DOM_NO_ERR)
+ return err;
+ }
- return DOM_NOT_SUPPORTED_ERR;
+ doc = node->owner;
+ assert(doc != NULL);
+
+ err = dom_document_create_text_node(doc, content, &text);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = dom_node_append_child(node, text, (void *) &r);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ return DOM_NO_ERR;
}
/**
@@ -1322,8 +1609,8 @@ dom_exception _dom_node_set_text_content(dom_node_internal *node,
*
* This tests if the two nodes reference the same object.
*/
-dom_exception _dom_node_is_same(dom_node_internal *node, dom_node_internal *other,
- bool *result)
+dom_exception _dom_node_is_same(dom_node_internal *node,
+ dom_node_internal *other, bool *result)
{
*result = (node == other);
@@ -1345,11 +1632,12 @@ dom_exception _dom_node_is_same(dom_node_internal *node, dom_node_internal *othe
dom_exception _dom_node_lookup_prefix(dom_node_internal *node,
struct dom_string *namespace, struct dom_string **result)
{
- UNUSED(node);
- UNUSED(namespace);
- UNUSED(result);
+ if (node->parent != NULL)
+ return dom_node_lookup_prefix(node, namespace, result);
+ else
+ *result = NULL;
- return DOM_NOT_SUPPORTED_ERR;
+ return DOM_NO_ERR;
}
/**
@@ -1363,11 +1651,11 @@ dom_exception _dom_node_lookup_prefix(dom_node_internal *node,
dom_exception _dom_node_is_default_namespace(dom_node_internal *node,
struct dom_string *namespace, bool *result)
{
- UNUSED(node);
- UNUSED(namespace);
- UNUSED(result);
-
- return DOM_NOT_SUPPORTED_ERR;
+ if (node->parent != NULL)
+ return dom_node_is_default_namespace(node, namespace, result);
+ else
+ *result = false;
+ return DOM_NO_ERR;
}
/**
@@ -1385,11 +1673,12 @@ dom_exception _dom_node_is_default_namespace(dom_node_internal *node,
dom_exception _dom_node_lookup_namespace(dom_node_internal *node,
struct dom_string *prefix, struct dom_string **result)
{
- UNUSED(node);
- UNUSED(prefix);
- UNUSED(result);
+ if (node->parent != NULL)
+ return dom_node_lookup_namespace(node->parent, prefix, result);
+ else
+ *result = NULL;
- return DOM_NOT_SUPPORTED_ERR;
+ return DOM_NO_ERR;
}
/**
@@ -1410,15 +1699,106 @@ dom_exception _dom_node_lookup_namespace(dom_node_internal *node,
* + publicId, systemId, internalSubset are equal
* + The node entities are equal
* + The node notations are equal
+ * TODO: in document_type, we should override this virtual function
*/
dom_exception _dom_node_is_equal(dom_node_internal *node,
dom_node_internal *other, bool *result)
{
- UNUSED(node);
- UNUSED(other);
- UNUSED(result);
+ dom_exception err;
+ dom_string *s1, *s2;
+ lwc_context *c1, *c2;
+ dom_namednodemap *m1, *m2;
+ dom_nodelist *l1, *l2;
- return DOM_NOT_SUPPORTED_ERR;
+ if (node->type != other->type){
+ *result = false;
+ return DOM_NO_ERR;
+ }
+
+ assert(node->owner != NULL);
+ assert(other->owner != NULL);
+
+ err = dom_node_get_node_name(node, &s1);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = dom_node_get_node_name(other, &s2);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ if (dom_string_cmp(s1, s2) != 0) {
+ *result = false;
+ return DOM_NO_ERR;
+ }
+
+ c1 = _dom_document_get_intern_context(node->owner);
+ assert(c1 != NULL);
+
+ c2 = _dom_document_get_intern_context(other->owner);
+ assert(c2 != NULL);
+
+ if (c1 == c2) {
+ if (node->name != other->name ||
+ node->namespace != other->namespace ||
+ node->prefix != other->prefix) {
+ *result = false;
+ return DOM_NO_ERR;
+ }
+ } else {
+ if (_dom_lwc_string_compare_raw(node->name, other->name) != 0){
+ *result = false;
+ return DOM_NO_ERR;
+ }
+
+ if (_dom_lwc_string_compare_raw(node->namespace,
+ other->namespace) != 0){
+ *result = false;
+ return DOM_NO_ERR;
+ }
+
+ if (_dom_lwc_string_compare_raw(node->prefix,
+ other->prefix) != 0){
+ *result = false;
+ return DOM_NO_ERR;
+ }
+ }
+
+ if (dom_string_cmp(node->value, other->value) != 0) {
+ *result = false;
+ return DOM_NO_ERR;
+ }
+
+ // Following comes the attributes
+ err = dom_node_get_attributes(node, &m1);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = dom_node_get_attributes(other, &m2);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ if (dom_namednodemap_equal(m1, m2) != true) {
+ *result = false;
+ return DOM_NO_ERR;
+ }
+
+ // Finally the childNodes
+ err = dom_node_get_child_nodes(node, &l1);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = dom_node_get_child_nodes(other, &l2);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ if (dom_nodelist_equal(l1, l2) != true) {
+ *result = false;
+ return DOM_NO_ERR;
+ }
+
+ *result = true;
+
+ return DOM_NO_ERR;
}
/**
@@ -1435,12 +1815,23 @@ dom_exception _dom_node_get_feature(dom_node_internal *node,
struct dom_string *feature, struct dom_string *version,
void **result)
{
- UNUSED(node);
- UNUSED(feature);
- UNUSED(version);
- UNUSED(result);
+ dom_document *doc;
+ dom_implementation *impl;
+ bool has;
+
+ doc = node->owner;
+ assert(doc != NULL);
+ dom_document_get_implementation(doc, &impl);
+ assert(impl != NULL);
+ dom_implementation_has_feature(impl, feature, version, &has);
+
+ if (has) {
+ *result = node;
+ } else {
+ *result = NULL;
+ }
- return DOM_NOT_SUPPORTED_ERR;
+ return DOM_NO_ERR;
}
/**
@@ -1479,14 +1870,14 @@ dom_exception _dom_node_set_user_data(dom_node_internal *node,
*result = ud->data;
- dom_document_alloc(node->owner, ud, 0);
+ _dom_document_alloc(node->owner, ud, 0);
return DOM_NO_ERR;
}
/* Otherwise, create a new user data object if one wasn't found */
if (ud == NULL) {
- ud = dom_document_alloc(node->owner, NULL,
+ ud = _dom_document_alloc(node->owner, NULL,
sizeof(struct dom_user_data));
if (ud == NULL)
return DOM_NO_MEM_ERR;
@@ -1542,9 +1933,124 @@ dom_exception _dom_node_get_user_data(dom_node_internal *node,
return DOM_NO_ERR;
}
-/* */
-/*----------------------------------------------------------------------------*/
-/* */
+
+/*--------------------------------------------------------------------------*/
+
+/* The protected virtual functions */
+
+/* We should never call this pure-virtual function directly */
+dom_exception _dom_node_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret)
+{
+ UNUSED(doc);
+ UNUSED(n);
+ UNUSED(ret);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+
+/* Copy the internal attributes of a Node from old to new */
+dom_exception _dom_node_copy(dom_node_internal *new, dom_node_internal *old)
+{
+ lwc_context *nctx, *octx;
+ dom_exception err;
+
+ new->vtable = old->vtable;
+ new->base.vtable = old->base.vtable;
+
+ assert(old->owner != NULL);
+ octx = _dom_document_get_intern_context(old->owner);
+ assert(octx != NULL);
+
+ assert(new->owner != NULL);
+ nctx = _dom_document_get_intern_context(old->owner);
+ assert(nctx != NULL);
+
+ new->type = old->type;
+ new->parent = NULL;
+ new->first_child = NULL;
+ new->last_child = NULL;
+ new->previous = NULL;
+ new->next = NULL;
+ new->owner = old->owner;
+
+ if (octx == nctx) {
+ lwc_context_string_ref(octx, old->name);
+ new->name = old->name;
+
+ if (old->namespace != NULL)
+ lwc_context_string_ref(octx, old->namespace);
+ new->namespace = old->namespace;
+
+ if (old->prefix != NULL)
+ lwc_context_string_ref(octx, old->prefix);
+ new->prefix = old->prefix;
+ } else {
+ lwc_string *str;
+ lwc_error lerr;
+
+ lerr = lwc_context_intern(nctx, lwc_string_data(old->name),
+ lwc_string_length(old->name), &str);
+ if (lerr != lwc_error_ok)
+ return _dom_exception_from_lwc_error(lerr);
+
+ new->name = str;
+
+ if (old->namespace != NULL) {
+ lerr = lwc_context_intern(nctx,
+ lwc_string_data(old->namespace),
+ lwc_string_length(old->namespace),
+ &str);
+ if (lerr != lwc_error_ok)
+ return _dom_exception_from_lwc_error(lerr);
+
+ new->namespace = str;
+ } else
+ new->namespace = NULL;
+
+ if (old->prefix != NULL) {
+ lerr = lwc_context_intern(nctx,
+ lwc_string_data(old->prefix),
+ lwc_string_length(old->prefix), &str);
+ if (lerr != lwc_error_ok)
+ return _dom_exception_from_lwc_error(lerr);
+
+ new->prefix = str;
+ } else
+ new->prefix = NULL;
+ }
+
+ dom_alloc al;
+ void *pw;
+
+ if (old->value != NULL) {
+ _dom_document_get_allocator(new->owner, &al, &pw);
+ dom_string *value;
+ err = dom_string_clone(al, pw, old->value, &value);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ new->value = value;
+ } else {
+ new->value = NULL;
+ }
+
+ new->user_data = NULL;
+ new->refcnt = 1;
+
+ list_init(&new->pending_list);
+ /* The new copyed node has no parent,
+ * so it should be put in the pending list. */
+ dom_node_mark_pending(new);
+
+ return DOM_NO_ERR;
+}
+
+
+/*--------------------------------------------------------------------------*/
+
+/* The helper functions */
/**
* Determine if a node is permitted as a child of another node
@@ -1626,20 +2132,18 @@ bool _dom_node_permitted_child(const dom_node_internal *parent,
*/
bool _dom_node_readonly(const dom_node_internal *node)
{
- /* DocumentType and Notation nodes are read only */
- if (node->type == DOM_DOCUMENT_TYPE_NODE ||
- node->type == DOM_NOTATION_NODE)
- return true;
+ const dom_node_internal *n = node;
- /* Entity nodes and their descendants are read only */
- for (; node != NULL; node = node->parent) {
- if (node->type == DOM_ENTITY_NODE)
- return true;
- }
+ /* DocumentType and Notation ns are read only */
+ if (n->type == DOM_DOCUMENT_TYPE_NODE ||
+ n->type == DOM_NOTATION_NODE)
+ return true;
- /* EntityReference nodes and their descendants are read only */
- for (; node != NULL; node = node->parent) {
- if (node->type == DOM_ENTITY_REFERENCE_NODE)
+ /* Entity ns and their descendants are read only
+ * EntityReference ns and their descendants are read only */
+ for (n = node; n != NULL; n = n->parent) {
+ if (n->type == DOM_ENTITY_NODE
+ || n->type == DOM_ENTITY_REFERENCE_NODE)
return true;
}
@@ -1668,6 +2172,10 @@ void _dom_node_attach(dom_node_internal *node, dom_node_internal *parent,
*/
void _dom_node_detach(dom_node_internal *node)
{
+ /* When a Node is not in the document tree, it must be in the
+ pending list */
+ dom_node_mark_pending(node);
+
_dom_node_detach_range(node, node);
}
@@ -1701,8 +2209,9 @@ void _dom_node_attach_range(dom_node_internal *first,
else
parent->last_child = last;
- for (dom_node_internal *n = first; n != last->next; n = n->next)
+ for (dom_node_internal *n = first; n != last->next; n = n->next) {
n->parent = parent;
+ }
}
/**
@@ -1726,8 +2235,9 @@ void _dom_node_detach_range(dom_node_internal *first,
else
last->parent->last_child = first->previous;
- for (dom_node_internal *n = first; n != last->next; n = n->next)
+ for (dom_node_internal *n = first; n != last->next; n = n->next) {
n->parent = NULL;
+ }
first->previous = NULL;
last->next = NULL;
@@ -1771,9 +2281,220 @@ void _dom_node_replace(dom_node_internal *old,
else
old->parent->last_child = last;
- for (dom_node_internal *n = first; n != last->next; n = n->next)
+ for (dom_node_internal *n = first; n != last->next; n = n->next) {
n->parent = old->parent;
+ }
old->previous = old->next = old->parent = NULL;
}
+/**
+ * Migrate one lwc_string from one context to another, this function
+ * may be used when we import/adopt a Node between documents.
+ *
+ * \param old The source context
+ * \param new The new context
+ * \param string The lwc_string to migrate
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _redocument_lwcstring(lwc_context *old, lwc_context *new,
+ lwc_string **string)
+{
+ lwc_string *str;
+ lwc_error lerr;
+
+ lerr = lwc_context_intern(new, lwc_string_data(*string),
+ lwc_string_length(*string), &str);
+ if (lerr != lwc_error_ok)
+ return _dom_exception_from_lwc_error(lerr);
+
+ lwc_context_string_unref(old, *string);
+ *string = str;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Migrate one dom_string from one document to another, this function
+ * may be used when we import/adopt a Node between documents.
+ *
+ * \param old The source document
+ * \param new The new document
+ * \param string The dom_string to migrate
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _redocument_domstring(dom_document *old, dom_document* new,
+ dom_string **string)
+{
+ dom_exception err;
+ dom_string *str;
+
+ UNUSED(old);
+ err = _dom_document_create_string(new, NULL, 0, &str);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = dom_string_dup(*string, &str);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ dom_string_unref(*string);
+ *string = str;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Merge two adjacent text nodes into one text node.
+ *
+ * \param p The first text node
+ * \param n The second text node
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_merge_adjacent_text(dom_node_internal *p,
+ dom_node_internal *n)
+{
+ assert(p->type = DOM_TEXT_NODE);
+ assert(n->type = DOM_TEXT_NODE);
+
+ dom_string *str;
+ dom_exception err;
+
+ err = dom_text_get_whole_text(n, &str);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = dom_characterdata_append_data(p, str);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ dom_string_unref(str);
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Intern a dom_string using the node's owner document's lwc_context
+ *
+ * \param node The node
+ * \param str The dom_string to be interned
+ * \param intern The returned interned string
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_node_get_intern_string(dom_node_internal *node,
+ dom_string *str, lwc_string **intern)
+{
+ dom_exception err;
+ lwc_context *ctx, *docctx;
+ lwc_string *ret;
+
+ assert(str != NULL);
+ assert(node->owner != NULL);
+
+ docctx = _dom_document_get_intern_context(node->owner);
+ assert(docctx != NULL);
+
+ err = dom_string_get_intern(str, &ctx, &ret);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ if (ctx != docctx) {
+ err = _dom_string_intern(str, docctx, &ret);
+ if (err != DOM_NO_ERR)
+ return err;
+ }
+
+ *intern = ret;
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Unref a lwc_string used in this node
+ *
+ * \param node The node
+ * \param intern The lwc_string to unref
+ */
+void _dom_node_unref_intern_string(dom_node_internal *node,
+ struct lwc_string_s *intern)
+{
+ struct dom_resource_mgr rm;
+ struct dom_document *doc = node->owner;
+
+ if (doc != NULL) {
+ _dom_document_get_resource_mgr(doc, &rm);
+ } else if (node->type == DOM_DOCUMENT_TYPE_NODE) {
+ _dom_document_type_get_resource_mgr(
+ (dom_document_type *) node, &rm);
+ }
+
+ lwc_context_string_unref(rm.ctx, intern);
+}
+
+/**
+ * Try to destroy this node.
+ *
+ * \param node The node to destroy
+ *
+ * When some node owns this node, (such as an elment owns its attribute nodes)
+ * when this node being not owned, the owner should call this function to try
+ * to destroy this node.
+ *
+ * @note: Owning a node does not means this node's refcnt is above zero.
+ */
+void _dom_node_try_destroy(dom_node_internal *node)
+{
+ if (node == NULL)
+ return;
+
+ if (node->parent == NULL) {
+ if (node->refcnt == 0) {
+ dom_node_destroy(node);
+ } else if (node->pending_list.prev == &node->pending_list){
+ assert (node->pending_list.next == &node->pending_list);
+ list_append(&node->owner->pending_nodes,
+ &node->pending_list);
+ }
+ }
+}
+
+/**
+ * To add some node to the pending list, when a node is removed from its parent
+ * or an attribute is removed from its element
+ *
+ * \param node The Node instance
+ */
+void _dom_node_mark_pending(dom_node_internal *node)
+{
+ struct dom_document *doc = node->owner;
+
+ /* TODO: the pending_list is located at in dom_document, but some
+ * nodes can be created without a document created, such as a
+ * dom_document_type node. For this reason, we should test whether
+ * the doc is NULL. */
+ if (doc != NULL) {
+ /* The node must not be in the pending list */
+ assert(node->pending_list.prev == &node->pending_list);
+
+ list_append(&doc->pending_nodes, &node->pending_list);
+ }
+}
+
+/**
+ * To remove the node from the pending list, this may happen when
+ * a node is removed and then appended to another parent
+ *
+ * \param node The Node instance
+ */
+void _dom_node_remove_pending(dom_node_internal *node)
+{
+ struct dom_document *doc = node->owner;
+
+ if (doc != NULL) {
+ /* The node must be in the pending list */
+ assert(node->pending_list.prev != &node->pending_list);
+
+ list_del(&node->pending_list);
+ }
+}
+
diff --git a/src/core/node.h b/src/core/node.h
index 27c9f35..68776da 100644
--- a/src/core/node.h
+++ b/src/core/node.h
@@ -10,7 +10,12 @@
#include <stdbool.h>
+#include <libwapcaplet/libwapcaplet.h>
+
#include <dom/core/node.h>
+#include <dom/functypes.h>
+
+#include "utils/list.h"
/**
* User data context attached to a DOM node
@@ -23,6 +28,23 @@ struct dom_user_data {
struct dom_user_data *next; /**< Next in list */
struct dom_user_data *prev; /**< Previous in list */
};
+typedef struct dom_user_data dom_user_data;
+
+/**
+ * The internally used virtual function table.
+ */
+typedef struct dom_node_protect_vtable {
+
+ void (*destroy)(dom_node_internal *n);
+ /**< The destroy virtual function, it
+ * should be private to client */
+ dom_exception (*alloc)(struct dom_document *doc,
+ dom_node_internal *n, dom_node_internal **ret);
+ /**< Allocate the memory of the new Node */
+ dom_exception (*copy)(dom_node_internal *new, dom_node_internal *old);
+ /**< Copy the old to new as well as
+ * all its attributes, but not its children */
+} dom_node_protect_vtable;
/**
* The real DOM node object
@@ -31,13 +53,11 @@ struct dom_user_data {
*/
struct dom_node_internal {
struct dom_node base; /**< The vtable base */
- void (*destroy)(dom_node_internal *n);
- /**< The destroy vitual function, it
- * should be privated to client */
+ void *vtable; /**< The protected vtable */
- struct dom_string *name; /**< Node name (this is the local part
- * of a QName in the cases where a
- * namespace exists) */
+ struct lwc_string_s *name; /**< Node name (this is the local part
+ * of a QName in the cases where a
+ * namespace exists) */
struct dom_string *value; /**< Node value */
dom_node_type type; /**< Node type */
dom_node_internal *parent; /**< Parent node */
@@ -48,27 +68,37 @@ struct dom_node_internal {
struct dom_document *owner; /**< Owning document */
- struct dom_string *namespace; /**< Namespace URI */
- struct dom_string *prefix; /**< Namespace prefix */
+ struct lwc_string_s *namespace; /**< Namespace URI */
+ struct lwc_string_s *prefix; /**< Namespace prefix */
struct dom_user_data *user_data; /**< User data list */
uint32_t refcnt; /**< Reference count */
+
+ struct list_entry pending_list; /**< The document delete pending list */
};
-dom_node_internal * dom_node_create(struct dom_document *doc);
+dom_node_internal * _dom_node_create(struct dom_document *doc);
-dom_exception dom_node_initialise(struct dom_node_internal *node,
+dom_exception _dom_node_initialise(struct dom_node_internal *node,
struct dom_document *doc, dom_node_type type,
- struct dom_string *name, struct dom_string *value,
- struct dom_string *namespace, struct dom_string *prefix);
+ struct lwc_string_s *name, struct dom_string *value,
+ struct lwc_string_s *namespace, struct lwc_string_s *prefix);
-void dom_node_finalise(struct dom_document *doc, dom_node_internal *node);
+dom_exception _dom_node_initialise_generic(
+ struct dom_node_internal *node, struct dom_document *doc,
+ dom_alloc alloc, void *pw, struct lwc_context_s *ctx,
+ dom_node_type type, struct lwc_string_s *name,
+ struct dom_string *value, struct lwc_string_s *namespace,
+ struct lwc_string_s *prefix);
+
+void _dom_node_finalise(struct dom_document *doc, dom_node_internal *node);
+void _dom_node_finalise_generic(dom_node_internal *node, dom_alloc alloc,
+ void *pw, struct lwc_context_s *ctx);
bool _dom_node_readonly(const dom_node_internal *node);
/* The DOM Node's vtable methods */
-void _dom_node_destroy(struct dom_node_internal *node);
dom_exception _dom_node_get_node_name(dom_node_internal *node,
struct dom_string **result);
dom_exception _dom_node_get_node_value(dom_node_internal *node,
@@ -110,7 +140,7 @@ dom_exception _dom_node_clone_node(dom_node_internal *node, bool deep,
dom_node_internal **result);
dom_exception _dom_node_normalize(dom_node_internal *node);
dom_exception _dom_node_is_supported(dom_node_internal *node,
- struct dom_string *feature, dom_node_internal *version,
+ struct dom_string *feature, struct dom_string *version,
bool *result);
dom_exception _dom_node_get_namespace(dom_node_internal *node,
struct dom_string **result);
@@ -129,8 +159,8 @@ dom_exception _dom_node_get_text_content(dom_node_internal *node,
struct dom_string **result);
dom_exception _dom_node_set_text_content(dom_node_internal *node,
struct dom_string *content);
-dom_exception _dom_node_is_same(dom_node_internal *node, dom_node_internal *other,
- bool *result);
+dom_exception _dom_node_is_same(dom_node_internal *node,
+ dom_node_internal *other, bool *result);
dom_exception _dom_node_lookup_prefix(dom_node_internal *node,
struct dom_string *namespace, struct dom_string **result);
dom_exception _dom_node_is_default_namespace(dom_node_internal *node,
@@ -188,11 +218,85 @@ dom_exception _dom_node_get_user_data(dom_node_internal *node,
_dom_node_get_user_data
+/* Following comes the protected vtable */
+void _dom_node_destroy(struct dom_node_internal *node);
+dom_exception _dom_node_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret);
+dom_exception _dom_node_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old);
+
+#define DOM_NODE_PROTECT_VTABLE \
+ _dom_node_destroy, \
+ _dom_node_alloc, \
+ _dom_node_copy
+
+
/* The destroy API should be used inside DOM module */
-static inline void dom_node_destroy(struct dom_node *node)
+static inline void dom_node_destroy(struct dom_node_internal *node)
+{
+ ((dom_node_protect_vtable *) node->vtable)->destroy(node);
+}
+#define dom_node_destroy(n) dom_node_destroy((dom_node_internal *) (n))
+
+/* Allocate the Node */
+static inline dom_exception dom_node_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret)
+{
+ return ((dom_node_protect_vtable *) n->vtable)->alloc(doc, n, ret);
+}
+#define dom_node_alloc(d,n,r) dom_node_alloc((struct dom_document *) (d), \
+ (dom_node_internal *) (n), (dom_node_internal **) (r))
+
+
+/* Copy the Node old to new */
+static inline dom_exception dom_node_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old)
{
- ((dom_node_internal *) node)->destroy((dom_node_internal *) node);
+ return ((dom_node_protect_vtable *) old->vtable)->copy(new, old);
}
-#define dom_node_destroy(n) dom_node_destroy((dom_node *) (n))
+#define dom_node_copy(n,o) dom_node_copy((dom_node_internal *) (n), \
+ (dom_node_internal *) (o))
+
+/* Following are some helper functions */
+#define dom_node_get_owner(n) ((dom_node_internal *) (n))->owner
+
+#define dom_node_set_owner(n, d) ((dom_node_internal *) (n))->owner = \
+ (struct dom_document *) (d)
+
+#define dom_node_get_parent(n) ((dom_node_internal *) (n))->parent
+
+#define dom_node_set_parent(n, p) ((dom_node_internal *) (n))->parent = \
+ (dom_node_internal *) (p)
+
+#define dom_node_get_refcount(n) ((dom_node_internal *) (n))->refcnt
+
+dom_exception _redocument_lwcstring(lwc_context *old, lwc_context *new,
+ lwc_string **string);
+dom_exception _redocument_domstring(struct dom_document *old,
+ struct dom_document* new, struct dom_string **string);
+dom_exception _dom_merge_adjacent_text(dom_node_internal *p,
+ dom_node_internal *n);
+/* Used to extract the lwc_string from dom_string.
+ * If there is no lwc_string inside the param, create one use the node->owner
+ * as document */
+dom_exception _dom_node_get_intern_string(dom_node_internal *node,
+ struct dom_string *str, struct lwc_string_s **intern);
+void _dom_node_unref_intern_string(dom_node_internal *node,
+ struct lwc_string_s *inter);
+
+/* Try to destroy the node, if its refcnt is not zero, then append it to the
+ * owner document's pending list */
+void _dom_node_try_destroy(dom_node_internal *node);
+#define dom_node_try_destroy(n) _dom_node_try_destroy((dom_node_internal *) (n))
+
+/* To add some node to the pending list */
+void _dom_node_mark_pending(dom_node_internal *node);
+#define dom_node_mark_pending(n) _dom_node_mark_pending(\
+ (dom_node_internal *) (n))
+/* To remove the node from the pending list, this may happen when
+ * a node is removed and then appended to another parent */
+void _dom_node_remove_pending(dom_node_internal *node);
+#define dom_node_remove_pending(n) _dom_node_remove_pending(\
+ (dom_node_internal *) (n))
#endif
diff --git a/src/core/nodelist.c b/src/core/nodelist.c
index 16534b6..2497619 100644
--- a/src/core/nodelist.c
+++ b/src/core/nodelist.c
@@ -3,12 +3,17 @@
* Licensed under the MIT License,
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
*/
+#include <assert.h>
#include <dom/core/node.h>
+#include <dom/core/document.h>
#include <dom/core/nodelist.h>
#include <dom/core/string.h>
+#include <libwapcaplet/libwapcaplet.h>
+
#include "core/document.h"
#include "core/node.h"
#include "core/nodelist.h"
@@ -21,18 +26,22 @@
struct dom_nodelist {
struct dom_document *owner; /**< Owning document */
- struct dom_node_internal *root; /**< Root of applicable subtree */
+ struct dom_node_internal *root;
+ /**< Root of applicable subtree */
- enum { DOM_NODELIST_CHILDREN,
- DOM_NODELIST_BY_NAME,
- DOM_NODELIST_BY_NAMESPACE
- } type; /**< List type */
+ nodelist_type type; /**< Type of this list */
union {
- struct dom_string *name; /**< Tag name to match */
struct {
- struct dom_string *namespace; /**< Namespace */
- struct dom_string *localname; /**< Localname */
+ struct lwc_string_s *name;
+ /**< Tag name to match */
+ bool any_name; /**< The name is '*' */
+ } n;
+ struct {
+ bool any_namespace; /**< The namespace is '*' */
+ bool any_localname; /**< The localname is '*' */
+ struct lwc_string_s *namespace; /**< Namespace */
+ struct lwc_string_s *localname; /**< Localname */
} ns; /**< Data for namespace matching */
} data;
@@ -43,6 +52,7 @@ struct dom_nodelist {
* Create a nodelist
*
* \param doc Owning document
+ * \param type The type of the NodeList
* \param root Root node of subtree that list applies to
* \param tagname Name of nodes in list (or NULL)
* \param namespace Namespace part of nodes in list (or NULL)
@@ -52,27 +62,21 @@ struct dom_nodelist {
*
* ::root must be a node owned by ::doc
*
- * If ::tagname is non-NULL, ::namespace and ::localname must be NULL and
- * the created list will match nodes by name
- *
- * If ::namespace is non-NULL, ::localname must be non-NULL and
- * ::tagname must be NULL and the created list will match nodes by namespace
- * and localname
- *
- * If ::tagname, ::namespace and ::localname are NULL, the created list
- * will match the children of ::root.
- *
* The returned list will already be referenced, so the client need not
* do so explicitly. The client must unref the list once finished with it.
*/
-dom_exception dom_nodelist_create(struct dom_document *doc,
- struct dom_node_internal *root, struct dom_string *tagname,
- struct dom_string *namespace, struct dom_string *localname,
+dom_exception _dom_nodelist_create(struct dom_document *doc, nodelist_type type,
+ struct dom_node_internal *root, struct lwc_string_s *tagname,
+ struct lwc_string_s *namespace, struct lwc_string_s *localname,
struct dom_nodelist **list)
{
struct dom_nodelist *l;
+ lwc_context *ctx;
+
+ ctx = _dom_document_get_intern_context(doc);
+ assert(ctx != NULL);
- l = dom_document_alloc(doc, NULL, sizeof(struct dom_nodelist));
+ l = _dom_document_alloc(doc, NULL, sizeof(struct dom_nodelist));
if (l == NULL)
return DOM_NO_MEM_ERR;
@@ -82,20 +86,45 @@ dom_exception dom_nodelist_create(struct dom_document *doc,
dom_node_ref(root);
l->root = root;
- if (tagname != NULL && namespace == NULL && localname == NULL) {
- dom_string_ref(tagname);
- l->type = DOM_NODELIST_BY_NAME;
- l->data.name = tagname;
- } else if (namespace != NULL && localname != NULL &&
- tagname == NULL) {
- dom_string_ref(namespace);
- dom_string_ref(localname);
- l->type = DOM_NODELIST_BY_NAMESPACE;
+ l->type = type;
+
+ if (type == DOM_NODELIST_BY_NAME) {
+ assert(tagname != NULL);
+ l->data.n.any_name = false;
+ if (lwc_string_length(tagname) == 1) {
+ const char *ch = lwc_string_data(tagname);
+ if (*ch == '*') {
+ l->data.n.any_name = true;
+ }
+ }
+
+ lwc_context_string_ref(ctx, tagname);
+ l->data.n.name = tagname;
+ } else if (type == DOM_NODELIST_BY_NAMESPACE) {
+ l->data.ns.any_localname = false;
+ l->data.ns.any_namespace = false;
+ if (localname != NULL) {
+ if (lwc_string_length(localname) == 1) {
+ const char *ch = lwc_string_data(localname);
+ if (*ch == '*') {
+ l->data.ns.any_localname = true;
+ }
+ }
+ lwc_context_string_ref(ctx, localname);
+ }
+ if (namespace != NULL) {
+ if (lwc_string_length(namespace) == 1) {
+ const char *ch = lwc_string_data(namespace);
+ if (*ch == '*') {
+ l->data.ns.any_namespace = true;
+ }
+ }
+ lwc_context_string_ref(ctx, namespace);
+ }
+
l->data.ns.namespace = namespace;
l->data.ns.localname = localname;
- } else {
- l->type = DOM_NODELIST_CHILDREN;
- }
+ }
l->refcnt = 1;
@@ -111,6 +140,7 @@ dom_exception dom_nodelist_create(struct dom_document *doc,
*/
void dom_nodelist_ref(struct dom_nodelist *list)
{
+ assert(list != NULL);
list->refcnt++;
}
@@ -124,30 +154,41 @@ void dom_nodelist_ref(struct dom_nodelist *list)
*/
void dom_nodelist_unref(struct dom_nodelist *list)
{
+ if (list == NULL)
+ return;
+
if (--list->refcnt == 0) {
struct dom_node_internal *owner =
(struct dom_node_internal *) list->owner;
+ lwc_context *ctx;
+ ctx = _dom_document_get_intern_context((dom_document *) owner);
+ assert(ctx != NULL);
switch (list->type) {
case DOM_NODELIST_CHILDREN:
/* Nothing to do */
break;
case DOM_NODELIST_BY_NAMESPACE:
- dom_string_unref(list->data.ns.namespace);
- dom_string_unref(list->data.ns.localname);
+ if (list->data.ns.namespace != NULL)
+ lwc_context_string_unref(ctx,
+ list->data.ns.namespace);
+ if (list->data.ns.localname != NULL)
+ lwc_context_string_unref(ctx,
+ list->data.ns.localname);
break;
case DOM_NODELIST_BY_NAME:
- dom_string_unref(list->data.name);
+ assert(list->data.n.name != NULL);
+ lwc_context_string_unref(ctx, list->data.n.name);
break;
}
dom_node_unref(list->root);
/* Remove list from document */
- dom_document_remove_nodelist(list->owner, list);
+ _dom_document_remove_nodelist(list->owner, list);
/* Destroy the list object */
- dom_document_alloc(list->owner, list, 0);
+ _dom_document_alloc(list->owner, list, 0);
/* And release our reference on the owning document
* This must be last as, otherwise, it's possible that
@@ -175,19 +216,24 @@ dom_exception dom_nodelist_get_length(struct dom_nodelist *list,
if (list->type == DOM_NODELIST_CHILDREN) {
len++;
} else if (list->type == DOM_NODELIST_BY_NAME) {
- if (cur->name != NULL &&
- dom_string_cmp(cur->name,
- list->data.name) == 0) {
- len++;
+ /* Here, we compare two lwc_string pointer directly */
+ if (list->data.n.any_name == true || (
+ cur->name != NULL &&
+ cur->name == list->data.n.name)) {
+ if (cur->type == DOM_ELEMENT_NODE)
+ len++;
}
} else {
- if (cur->namespace != NULL &&
- dom_string_cmp(cur->namespace,
- list->data.ns.namespace) == 0 &&
- cur->name != NULL &&
- dom_string_cmp(cur->name,
- list->data.ns.localname) == 0) {
- len++;
+ if (list->data.ns.any_namespace == true ||
+ cur->namespace ==
+ list->data.ns.namespace) {
+ if (list->data.ns.any_localname == true ||
+ (cur->name != NULL &&
+ cur->name ==
+ list->data.ns.localname)) {
+ if (cur->type == DOM_ELEMENT_NODE)
+ len++;
+ }
}
}
@@ -250,19 +296,24 @@ dom_exception _dom_nodelist_item(struct dom_nodelist *list,
if (list->type == DOM_NODELIST_CHILDREN) {
count++;
} else if (list->type == DOM_NODELIST_BY_NAME) {
- if (cur->name != NULL &&
- dom_string_cmp(cur->name,
- list->data.name) == 0) {
- count++;
+ if (list->data.n.any_name == true || (
+ cur->name != NULL &&
+ cur->name == list->data.n.name)) {
+ if (cur->type == DOM_ELEMENT_NODE)
+ count++;
}
} else {
- if (cur->namespace != NULL &&
- dom_string_cmp(cur->namespace,
- list->data.ns.namespace) == 0 &&
- cur->name != NULL &&
- dom_string_cmp(cur->name,
- list->data.ns.localname) == 0) {
- count++;
+ if (list->data.ns.any_namespace == true ||
+ (cur->namespace != NULL &&
+ cur->namespace ==
+ list->data.ns.namespace)) {
+ if (list->data.ns.any_localname == true ||
+ (cur->name != NULL &&
+ cur->name ==
+ list->data.ns.localname)) {
+ if (cur->type == DOM_ELEMENT_NODE)
+ count++;
+ }
}
}
@@ -311,36 +362,49 @@ dom_exception _dom_nodelist_item(struct dom_nodelist *list,
* Match a nodelist instance against a set of nodelist creation parameters
*
* \param list List to match
+ * \param type The type of the NodeList
* \param root Root node of subtree that list applies to
* \param tagname Name of nodes in list (or NULL)
* \param namespace Namespace part of nodes in list (or NULL)
* \param localname Local part of nodes in list (or NULL)
* \return true if list matches, false otherwise
*/
-bool dom_nodelist_match(struct dom_nodelist *list,
- struct dom_node_internal *root, struct dom_string *tagname,
- struct dom_string *namespace, struct dom_string *localname)
+bool _dom_nodelist_match(struct dom_nodelist *list, nodelist_type type,
+ struct dom_node_internal *root, struct lwc_string_s *tagname,
+ struct lwc_string_s *namespace, struct lwc_string_s *localname)
{
if (list->root != root)
return false;
- if (list->type == DOM_NODELIST_CHILDREN && tagname == NULL &&
- namespace == NULL && localname == NULL) {
+ if (list->type != type)
+ return false;
+
+ if (list->type == DOM_NODELIST_CHILDREN) {
return true;
}
- if (list->type == DOM_NODELIST_BY_NAME && tagname != NULL &&
- namespace == NULL && localname == NULL) {
- return (dom_string_cmp(list->data.name, tagname) == 0);
+ if (list->type == DOM_NODELIST_BY_NAME) {
+ return (list->data.n.name == tagname);
}
- if (list->type == DOM_NODELIST_BY_NAMESPACE && tagname == NULL &&
- namespace != NULL && localname != NULL) {
- return (dom_string_cmp(list->data.ns.namespace,
- namespace) == 0) &&
- (dom_string_cmp(list->data.ns.localname,
- localname) == 0);
+ if (list->type == DOM_NODELIST_BY_NAMESPACE) {
+ return (list->data.ns.namespace == namespace) &&
+ (list->data.ns.localname == localname);
}
return false;
}
+
+/**
+ * Test whether the two NodeList are equal
+ *
+ * \param l1 One list
+ * \param l2 The other list
+ * \reutrn true for equal, false otherwise.
+ */
+bool _dom_nodelist_equal(struct dom_nodelist *l1, struct dom_nodelist *l2)
+{
+ return _dom_nodelist_match(l1, l1->type, l2->root, l2->data.n.name,
+ l2->data.ns.namespace, l2->data.ns.localname);
+}
+
diff --git a/src/core/nodelist.h b/src/core/nodelist.h
index 9629d03..e467aa6 100644
--- a/src/core/nodelist.h
+++ b/src/core/nodelist.h
@@ -16,16 +16,30 @@ struct dom_document;
struct dom_node;
struct dom_nodelist;
struct dom_string;
+struct lwc_string_s;
+
+/**
+ * The NodeList type
+ */
+typedef enum {
+ DOM_NODELIST_CHILDREN,
+ DOM_NODELIST_BY_NAME,
+ DOM_NODELIST_BY_NAMESPACE
+} nodelist_type;
/* Create a nodelist */
-dom_exception dom_nodelist_create(struct dom_document *doc,
- struct dom_node_internal *root, struct dom_string *tagname,
- struct dom_string *namespace, struct dom_string *localname,
+dom_exception _dom_nodelist_create(struct dom_document *doc, nodelist_type type,
+ struct dom_node_internal *root, struct lwc_string_s *tagname,
+ struct lwc_string_s *namespace, struct lwc_string_s *localname,
struct dom_nodelist **list);
/* Match a nodelist instance against a set of nodelist creation parameters */
-bool dom_nodelist_match(struct dom_nodelist *list,
- struct dom_node_internal *root, struct dom_string *tagname,
- struct dom_string *namespace, struct dom_string *localname);
+bool _dom_nodelist_match(struct dom_nodelist *list, nodelist_type type,
+ struct dom_node_internal *root, struct lwc_string_s *tagname,
+ struct lwc_string_s *namespace, struct lwc_string_s *localname);
+
+bool _dom_nodelist_equal(struct dom_nodelist *l1, struct dom_nodelist *l2);
+#define dom_nodelist_equal(l1, l2) _dom_nodelist_equal( \
+ (struct dom_nodelist *) (l1), (struct dom_nodelist *) (l2))
#endif
diff --git a/src/core/pi.c b/src/core/pi.c
index 754b362..634dc05 100644
--- a/src/core/pi.c
+++ b/src/core/pi.c
@@ -9,6 +9,8 @@
#include "core/node.h"
#include "core/pi.h"
+#include "utils/utils.h"
+
/**
* A DOM processing instruction
*/
@@ -16,6 +18,13 @@ struct dom_processing_instruction {
struct dom_node_internal base; /**< Base node */
};
+static struct dom_node_vtable pi_vtable = {
+ DOM_NODE_VTABLE
+};
+
+static struct dom_node_protect_vtable pi_protect_vtable = {
+ DOM_PI_PROTECT_VTABLE
+};
/**
* Create a processing instruction
*
@@ -30,25 +39,28 @@ struct dom_processing_instruction {
*
* The returned node will already be referenced.
*/
-dom_exception dom_processing_instruction_create(struct dom_document *doc,
- struct dom_string *name, struct dom_string *value,
+dom_exception _dom_processing_instruction_create(struct dom_document *doc,
+ struct lwc_string_s *name, struct dom_string *value,
struct dom_processing_instruction **result)
{
struct dom_processing_instruction *p;
dom_exception err;
/* Allocate the comment node */
- p = dom_document_alloc(doc, NULL,
+ p = _dom_document_alloc(doc, NULL,
sizeof(struct dom_processing_instruction));
if (p == NULL)
return DOM_NO_MEM_ERR;
+
+ p->base.base.vtable = &pi_vtable;
+ p->base.vtable = &pi_protect_vtable;
/* And initialise the node */
- err = dom_node_initialise(&p->base, doc,
+ err = _dom_processing_instruction_initialise(&p->base, doc,
DOM_PROCESSING_INSTRUCTION_NODE,
name, value, NULL, NULL);
if (err != DOM_NO_ERR) {
- dom_document_alloc(doc, p, 0);
+ _dom_document_alloc(doc, p, 0);
return err;
}
@@ -65,12 +77,49 @@ dom_exception dom_processing_instruction_create(struct dom_document *doc,
*
* The contents of ::pi will be destroyed and ::pi will be freed.
*/
-void dom_processing_instruction_destroy(struct dom_document *doc,
+void _dom_processing_instruction_destroy(struct dom_document *doc,
struct dom_processing_instruction *pi)
{
/* Finalise base class */
- dom_node_finalise(doc, &pi->base);
+ _dom_processing_instruction_finalise(doc, &pi->base);
/* Free processing instruction */
- dom_document_alloc(doc, pi, 0);
+ _dom_document_alloc(doc, pi, 0);
+}
+
+/*-----------------------------------------------------------------------*/
+
+/* Following comes the protected vtable */
+
+/* The virtual destroy function of this class */
+void _dom_pi_destroy(struct dom_node_internal *node)
+{
+ _dom_processing_instruction_destroy(node->owner,
+ (struct dom_processing_instruction *) node);
+}
+
+/* The memory allocator of this class */
+dom_exception _dom_pi_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret)
+{
+ UNUSED(n);
+ struct dom_processing_instruction *a;
+
+ a = _dom_document_alloc(doc, NULL,
+ sizeof(struct dom_processing_instruction));
+ if (a == NULL)
+ return DOM_NO_MEM_ERR;
+
+ *ret = (dom_node_internal *) a;
+ dom_node_set_owner(*ret, doc);
+
+ return DOM_NO_ERR;
}
+
+/* The copy constructor of this class */
+dom_exception _dom_pi_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old)
+{
+ return _dom_node_copy(new, old);
+}
+
diff --git a/src/core/pi.h b/src/core/pi.h
index 4dca989..3f6d46c 100644
--- a/src/core/pi.h
+++ b/src/core/pi.h
@@ -13,12 +13,28 @@
struct dom_document;
struct dom_processing_instruction;
struct dom_string;
+struct lwc_string_s;
-dom_exception dom_processing_instruction_create(struct dom_document *doc,
- struct dom_string *name, struct dom_string *value,
+dom_exception _dom_processing_instruction_create(struct dom_document *doc,
+ struct lwc_string_s *name, struct dom_string *value,
struct dom_processing_instruction **result);
-void dom_processing_instruction_destroy(struct dom_document *doc,
+void _dom_processing_instruction_destroy(struct dom_document *doc,
struct dom_processing_instruction *pi);
+#define _dom_processing_instruction_initialise _dom_node_initialise
+#define _dom_processing_instruction_finalise _dom_node_finalise
+
+/* Following comes the protected vtable */
+void _dom_pi_destroy(struct dom_node_internal *node);
+dom_exception _dom_pi_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret);
+dom_exception _dom_pi_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old);
+
+#define DOM_PI_PROTECT_VTABLE \
+ _dom_pi_destroy, \
+ _dom_pi_alloc, \
+ _dom_pi_copy
+
#endif
diff --git a/src/core/string.c b/src/core/string.c
index 806531a..e35f416 100644
--- a/src/core/string.c
+++ b/src/core/string.c
@@ -3,16 +3,17 @@
* Licensed under the MIT License,
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
*/
+#include <assert.h>
#include <ctype.h>
#include <inttypes.h>
#include <string.h>
#include <parserutils/charset/utf8.h>
-#include <dom/core/string.h>
-
+#include "core/string.h"
#include "core/document.h"
#include "utils/utils.h"
@@ -26,6 +27,10 @@ struct dom_string {
size_t len; /**< Byte length of string */
+ lwc_string *intern; /**< The lwc_string of this string */
+
+ lwc_context *context; /**< The lwc_context for the lwc_string */
+
dom_alloc alloc; /**< Memory (de)allocation function */
void *pw; /**< Client-specific data */
@@ -40,6 +45,8 @@ static struct dom_string empty_string = {
.refcnt = 1
};
+
+
/**
* Claim a reference on a DOM string
*
@@ -60,8 +67,15 @@ void dom_string_ref(struct dom_string *str)
*/
void dom_string_unref(struct dom_string *str)
{
+ if (str == NULL)
+ return;
+
if (--str->refcnt == 0) {
- if (str->alloc != NULL) {
+ if (str->intern != NULL) {
+ lwc_context_unref(str->context);
+ lwc_context_string_unref(str->context, str->intern);
+ str->alloc(str, 0, str->pw);
+ } else if (str->alloc != NULL) {
str->alloc(str->ptr, 0, str->pw);
str->alloc(str, 0, str->pw);
}
@@ -71,11 +85,11 @@ void dom_string_unref(struct dom_string *str)
/**
* Create a DOM string from a string of characters
*
- * \param alloc Memory (de)allocation function
- * \param pw Pointer to client-specific private data
- * \param ptr Pointer to string of characters
- * \param len Length, in bytes, of string of characters
- * \param str Pointer to location to receive result
+ * \param alloc Memory (de)allocation function
+ * \param pw Pointer to client-specific private data
+ * \param ptr Pointer to string of characters
+ * \param len Length, in bytes, of string of characters
+ * \param str Pointer to location to receive result
* \return DOM_NO_ERR on success, DOM_NO_MEM_ERR on memory exhaustion
*
* The returned string will already be referenced, so there is no need
@@ -89,7 +103,7 @@ dom_exception dom_string_create(dom_alloc alloc, void *pw,
{
struct dom_string *ret;
- if (ptr == NULL && len == 0) {
+ if (ptr == NULL || len == 0) {
dom_string_ref(&empty_string);
*str = &empty_string;
@@ -114,6 +128,9 @@ dom_exception dom_string_create(dom_alloc alloc, void *pw,
ret->alloc = alloc;
ret->pw = pw;
+ ret->intern = NULL;
+ ret->context = NULL;
+
ret->refcnt = 1;
*str = ret;
@@ -122,6 +139,152 @@ dom_exception dom_string_create(dom_alloc alloc, void *pw,
}
/**
+ * Clone a dom_string if necessary. This method is used to create a new string
+ * with a new allocator, but if the allocator is the same with the paramter
+ * str, just ref the string.
+ *
+ * \param alloc The new allocator for this string
+ * \param pw The new pw for this string
+ * \param str The source dom_string
+ * \param ret The cloned dom_string
+ * \return DOM_NO_ERR on success, DOM_NO_MEM_ERR on memory exhaustion
+ *
+ * @note: When both the alloc and pw are the same as the str's, we need no
+ * real clone, just ref the source string is ok.
+ */
+dom_exception dom_string_clone(dom_alloc alloc, void *pw,
+ struct dom_string *str, struct dom_string **ret)
+{
+ if (alloc == str->alloc && pw == str->pw) {
+ *ret = str;
+ dom_string_ref(str);
+ return DOM_NO_ERR;
+ }
+
+ if (str->intern != NULL) {
+ return _dom_string_create_from_lwcstring(alloc, pw,
+ str->context, str->intern, ret);
+ } else {
+ return dom_string_create(alloc, pw, str->ptr, str->len, ret);
+ }
+}
+
+/**
+ * Create a dom_string from a lwc_string
+ *
+ * \param ctx The lwc_context
+ * \param str The lwc_string
+ * \param ret The new dom_string
+ * \return DOM_NO_ERR on success, DOM_NO_MEM_ERR on memory exhaustion
+ */
+dom_exception _dom_string_create_from_lwcstring(dom_alloc alloc, void *pw,
+ lwc_context *ctx, lwc_string *str, struct dom_string **ret)
+{
+ dom_string *r;
+
+ if (str == NULL) {
+ *ret = NULL;
+ return DOM_NO_ERR;
+ }
+
+ r = alloc(NULL, sizeof(struct dom_string), pw);
+ if (r == NULL)
+ return DOM_NO_MEM_ERR;
+
+ if (str == NULL) {
+ *ret = &empty_string;
+ dom_string_ref(*ret);
+ return DOM_NO_ERR;
+ }
+
+ r->context = ctx;
+ r->intern = str;
+ r->ptr = (uint8_t *)lwc_string_data(str);
+ r->len = lwc_string_length(str);
+
+ r->alloc = alloc;
+ r->pw = pw;
+
+ r->refcnt = 1;
+
+ /* Ref the lwc_string */
+ lwc_context_ref(ctx);
+ lwc_context_string_ref(ctx, str);
+
+ *ret = r;
+ return DOM_NO_ERR;
+
+}
+
+/**
+ * Make the dom_string be interned in the lwc_context
+ *
+ * \param str The dom_string to be interned
+ * \param ctx The lwc_context to intern this dom_string
+ * \param lwcstr The result lwc_string
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_string_intern(struct dom_string *str,
+ struct lwc_context_s *ctx, struct lwc_string_s **lwcstr)
+{
+ lwc_string *ret;
+ lwc_error lerr;
+
+ /* If this string is interned with the same context, do nothing */
+ if (str->context != NULL && str->context == ctx) {
+ *lwcstr = str->intern;
+ return DOM_NO_ERR;
+ }
+
+ lerr = lwc_context_intern(ctx, (const char *)str->ptr, str->len, &ret);
+ if (lerr != lwc_error_ok) {
+ return _dom_exception_from_lwc_error(lerr);
+ }
+
+ if (str->context != NULL) {
+ lwc_context_unref(str->context);
+ lwc_context_string_unref(str->context, str->intern);
+ str->ptr = NULL;
+ }
+
+ str->context = ctx;
+ str->intern = ret;
+ lwc_context_ref(ctx);
+ lwc_context_string_ref(ctx, ret);
+
+ if (str->ptr != NULL) {
+ str->alloc(str->ptr, 0, str->pw);
+ }
+
+ str->ptr = (uint8_t *) lwc_string_data(ret);
+
+ *lwcstr = ret;
+ return DOM_NO_ERR;
+}
+
+/**
+ * Get the internal lwc_string
+ *
+ * \param str The dom_string object
+ * \param ctx The lwc_context which intern this dom_string
+ * \param lwcstr The lwc_string of this dom-string
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception dom_string_get_intern(struct dom_string *str,
+ struct lwc_context_s **ctx, struct lwc_string_s **lwcstr)
+{
+ *ctx = str->context;
+ *lwcstr = str->intern;
+
+ if (*ctx != NULL)
+ lwc_context_ref(*ctx);
+ if (*lwcstr != NULL)
+ lwc_context_string_ref(*ctx, *lwcstr);
+
+ return DOM_NO_ERR;
+}
+
+/**
* Case sensitively compare two DOM strings
*
* \param s1 The first string to compare
@@ -132,12 +295,26 @@ dom_exception dom_string_create(dom_alloc alloc, void *pw,
*/
int dom_string_cmp(struct dom_string *s1, struct dom_string *s2)
{
+ bool ret;
+
if (s1 == NULL)
s1 = &empty_string;
if (s2 == NULL)
s2 = &empty_string;
+ if (s1->context == s2->context && s1->context != NULL) {
+ assert(s1->intern != NULL);
+ assert(s2->intern != NULL);
+ lwc_context_string_isequal(s1->context, s1->intern,
+ s2->intern, &ret);
+ if (ret == true) {
+ return 0;
+ } else {
+ return -1;
+ }
+ }
+
if (s1->len != s2->len)
return 1;
@@ -164,6 +341,19 @@ int dom_string_icmp(struct dom_string *s1, struct dom_string *s2)
if (s2 == NULL)
s2 = &empty_string;
+ bool ret;
+ if (s1->context == s2->context && s1->context != NULL) {
+ assert(s1->intern != NULL);
+ assert(s2->intern != NULL);
+ lwc_context_string_caseless_isequal(s1->context, s1->intern,
+ s2->intern, &ret);
+ if (ret == true) {
+ return 0;
+ } else {
+ return -1;
+ }
+ }
+
d1 = s1->ptr;
d2 = s2->ptr;
l1 = s1->len;
@@ -304,6 +494,56 @@ uint32_t dom_string_length(struct dom_string *str)
return clen;
}
+/**
+ * Get the UCS4 character at position index
+ *
+ * \param index The position of the charater
+ * \param ch The UCS4 character
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception dom_string_at(struct dom_string *str, uint32_t index,
+ uint32_t *ch)
+{
+ const uint8_t *s;
+ size_t clen, slen;
+ uint32_t c, i;
+ parserutils_error err;
+
+ if (str == NULL)
+ str = &empty_string;
+
+ s = str->ptr;
+ slen = str->len;
+
+ i = 0;
+
+ while (slen > 0) {
+ err = parserutils_charset_utf8_char_byte_length(s, &clen);
+ if (err != PARSERUTILS_OK) {
+ return (uint32_t) -1;
+ }
+
+ i++;
+ if (i == index + 1)
+ break;
+
+ s += clen;
+ slen -= clen;
+ }
+
+ if (i == index + 1) {
+ err = parserutils_charset_utf8_to_ucs4(s, slen, &c, &clen);
+ if (err != PARSERUTILS_OK) {
+ return (uint32_t) -1;
+ }
+
+ *ch = c;
+ return DOM_NO_ERR;
+ } else {
+ return DOM_DOMSTRING_SIZE_ERR;
+ }
+}
+
/**
* Concatenate two dom strings
*
@@ -322,16 +562,33 @@ dom_exception dom_string_concat(struct dom_string *s1, struct dom_string *s2,
struct dom_string **result)
{
struct dom_string *concat;
+ dom_alloc alloc;
+ void *pw;
+
+ assert(s1 != NULL);
+ assert(s2 != NULL);
+
+ if (s1->alloc != NULL) {
+ alloc = s1->alloc;
+ pw = s1->pw;
+ } else if (s2->alloc != NULL) {
+ alloc = s2->alloc;
+ pw = s2->pw;
+ } else {
+ /* s1 == s2 == empty_string */
+ *result = &empty_string;
+ return DOM_NO_ERR;
+ }
- concat = s1->alloc(NULL, sizeof(struct dom_string), s1->pw);
+ concat = alloc(NULL, sizeof(struct dom_string), pw);
if (concat == NULL) {
return DOM_NO_MEM_ERR;
}
- concat->ptr = s1->alloc(NULL, s1->len + s2->len, s1->pw);
+ concat->ptr = alloc(NULL, s1->len + s2->len, pw);
if (concat->ptr == NULL) {
- s1->alloc(concat, 0, s1->pw);
+ alloc(concat, 0, pw);
return DOM_NO_MEM_ERR;
}
@@ -342,8 +599,10 @@ dom_exception dom_string_concat(struct dom_string *s1, struct dom_string *s2,
concat->len = s1->len + s2->len;
- concat->alloc = s1->alloc;
- concat->pw = s1->pw;
+ concat->alloc = alloc;
+ concat->pw = pw;
+ concat->context = NULL;
+ concat->intern = NULL;
concat->refcnt = 1;
@@ -382,7 +641,7 @@ dom_exception dom_string_substr(struct dom_string *str,
/* Calculate the byte index of the start */
while (i1 > 0) {
- err = parserutils_charset_utf8_next(s, slen - b1, b1, &b1);
+ err = parserutils_charset_utf8_next(s, slen, b1, &b1);
if (err != PARSERUTILS_OK) {
return DOM_NO_MEM_ERR;
}
@@ -395,7 +654,7 @@ dom_exception dom_string_substr(struct dom_string *str,
/* Calculate the byte index of the end */
while (i2 > 0) {
- err = parserutils_charset_utf8_next(s, slen - b2, b2, &b2);
+ err = parserutils_charset_utf8_next(s, slen, b2, &b2);
if (err != PARSERUTILS_OK) {
return DOM_NO_MEM_ERR;
}
@@ -451,7 +710,7 @@ dom_exception dom_string_insert(struct dom_string *target,
ins = tlen;
} else {
while (offset > 0) {
- err = parserutils_charset_utf8_next(t, tlen - ins,
+ err = parserutils_charset_utf8_next(t, tlen,
ins, &ins);
if (err != PARSERUTILS_OK) {
@@ -492,6 +751,8 @@ dom_exception dom_string_insert(struct dom_string *target,
res->alloc = target->alloc;
res->pw = target->pw;
+ res->intern = NULL;
+ res->context = NULL;
res->refcnt = 1;
@@ -526,6 +787,9 @@ dom_exception dom_string_replace(struct dom_string *target,
uint32_t b1, b2;
parserutils_error err;
+ if (source == NULL)
+ source = &empty_string;
+
t = target->ptr;
tlen = target->len;
s = source->ptr;
@@ -538,7 +802,7 @@ dom_exception dom_string_replace(struct dom_string *target,
/* Calculate the byte index of the start */
while (i1 > 0) {
- err = parserutils_charset_utf8_next(s, slen - b1, b1, &b1);
+ err = parserutils_charset_utf8_next(s, slen, b1, &b1);
if (err != PARSERUTILS_OK) {
return DOM_NO_MEM_ERR;
@@ -552,7 +816,7 @@ dom_exception dom_string_replace(struct dom_string *target,
/* Calculate the byte index of the end */
while (i2 > 0) {
- err = parserutils_charset_utf8_next(s, slen - b2, b2, &b2);
+ err = parserutils_charset_utf8_next(s, slen, b2, &b2);
if (err != PARSERUTILS_OK) {
return DOM_NO_MEM_ERR;
@@ -594,6 +858,8 @@ dom_exception dom_string_replace(struct dom_string *target,
res->alloc = target->alloc;
res->pw = target->pw;
+ res->intern = NULL;
+ res->context = NULL;
res->refcnt = 1;
@@ -618,8 +884,13 @@ dom_exception dom_string_replace(struct dom_string *target,
dom_exception dom_string_dup(struct dom_string *str,
struct dom_string **result)
{
- return dom_string_create(str->alloc, str->pw, str->ptr, str->len,
- result);
+ if (str->intern != NULL) {
+ return _dom_string_create_from_lwcstring(str->alloc, str->pw,
+ str->context, str->intern, result);
+ } else {
+ return dom_string_create(str->alloc, str->pw, str->ptr,
+ str->len, result);
+ }
}
/**
@@ -645,3 +916,48 @@ uint32_t dom_string_hash(struct dom_string *str)
return hash;
}
+/**
+ * Convert a lwc_error to a dom_exception
+ *
+ * \param err The input lwc_error
+ * \return the dom_exception
+ */
+dom_exception _dom_exception_from_lwc_error(lwc_error err)
+{
+ switch (err) {
+ case lwc_error_ok:
+ return DOM_NO_ERR;
+ case lwc_error_oom:
+ return DOM_NO_MEM_ERR;
+ case lwc_error_range:
+ return DOM_INDEX_SIZE_ERR;
+ }
+ assert ("Unknow lwc_error, can't convert to dom_exception");
+ /* Suppress compile errors */
+ return DOM_NO_ERR;
+}
+
+/**
+ * Compare the raw data of two lwc_strings for equality when the two strings
+ * belong to different lwc_context
+ *
+ * \param s1 The first lwc_string
+ * \param s2 The second lwc_string
+ * \return 0 for equal, non-zero otherwise
+ */
+int _dom_lwc_string_compare_raw(struct lwc_string_s *s1,
+ struct lwc_string_s *s2)
+{
+ const char *rs1, *rs2;
+ size_t len;
+
+ if (lwc_string_length(s1) != lwc_string_length(s2))
+ return -1;
+
+ len = lwc_string_length(s1);
+ rs1 = lwc_string_data(s1);
+ rs2 = lwc_string_data(s2);
+
+ return memcmp(rs1, rs2, len);
+}
+
diff --git a/src/core/string.h b/src/core/string.h
new file mode 100644
index 0000000..8372688
--- /dev/null
+++ b/src/core/string.h
@@ -0,0 +1,32 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+ */
+
+#ifndef dom_internal_core_string_h_
+#define dom_internal_core_string_h_
+
+#include <dom/core/string.h>
+
+/* Create a DOM string from a lwc_string
+ * This function call mainly used for create a string from lwc_string */
+dom_exception _dom_string_create_from_lwcstring(dom_alloc alloc, void *pw,
+ struct lwc_context_s *ctx, struct lwc_string_s *str,
+ struct dom_string **ret);
+
+/* Make the dom_string be interned in the lwc_context */
+dom_exception _dom_string_intern(struct dom_string *str,
+ struct lwc_context_s *ctx, struct lwc_string_s **lwcstr);
+
+/* Compare the raw data of two lwc_strings for equality when the two strings
+ * belong to different lwc_context */
+int _dom_lwc_string_compare_raw(struct lwc_string_s *s1,
+ struct lwc_string_s *s2);
+
+/* Map the lwc_error to dom_exception */
+dom_exception _dom_exception_from_lwc_error(lwc_error err);
+
+#endif
+
diff --git a/src/core/text.c b/src/core/text.c
index bad20bf..6cb9e1f 100644
--- a/src/core/text.c
+++ b/src/core/text.c
@@ -3,18 +3,23 @@
* Licensed under the MIT License,
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
*/
+#include <assert.h>
+
#include <dom/core/string.h>
#include <dom/core/text.h>
+#include <libwapcaplet/libwapcaplet.h>
+
#include "core/characterdata.h"
#include "core/document.h"
#include "core/text.h"
#include "utils/utils.h"
/* The virtual table for dom_text */
-static struct dom_text_vtable text_vtable = {
+struct dom_text_vtable text_vtable = {
{
{
DOM_NODE_VTABLE
@@ -24,15 +29,30 @@ static struct dom_text_vtable text_vtable = {
DOM_TEXT_VTABLE
};
-/* The destroy virtual function */
-void _dom_text_destroy(struct dom_node_internal *node);
-void _dom_text_destroy(struct dom_node_internal *node)
-{
- struct dom_document *doc;
- dom_node_get_owner_document(node, &doc);
+static struct dom_node_protect_vtable text_protect_vtable = {
+ DOM_TEXT_PROTECT_VTABLE
+};
- dom_text_destroy(doc, (struct dom_text *) node);
-}
+/* Following comes helper functions */
+typedef enum walk_operation {
+ COLLECT,
+ DELETE
+} walk_operation;
+typedef enum walk_order {
+ LEFT,
+ RIGHT
+} walk_order;
+
+/* Walk the logic-adjacent text in document order */
+static dom_exception walk_logic_adjacent_text_in_order(
+ dom_node_internal *node, walk_operation opt,
+ walk_order order, dom_string **ret, bool *cont);
+/* Walk the logic-adjacent text */
+static dom_exception walk_logic_adjacent_text(dom_text *text,
+ walk_operation opt, dom_string **ret);
+
+/*----------------------------------------------------------------------*/
+/* Constructor and Destructor */
/**
* Create a text node
@@ -48,25 +68,29 @@ void _dom_text_destroy(struct dom_node_internal *node)
*
* The returned node will already be referenced.
*/
-dom_exception dom_text_create(struct dom_document *doc,
- struct dom_string *name, struct dom_string *value,
+dom_exception _dom_text_create(struct dom_document *doc,
+ struct lwc_string_s *name, struct dom_string *value,
struct dom_text **result)
{
struct dom_text *t;
dom_exception err;
/* Allocate the text node */
- t = dom_document_alloc(doc, NULL, sizeof(struct dom_text));
+ t = _dom_document_alloc(doc, NULL, sizeof(struct dom_text));
if (t == NULL)
return DOM_NO_MEM_ERR;
/* And initialise the node */
- err = dom_text_initialise(t, doc, DOM_TEXT_NODE, name, value);
+ err = _dom_text_initialise(t, doc, DOM_TEXT_NODE, name, value);
if (err != DOM_NO_ERR) {
- dom_document_alloc(doc, t, 0);
+ _dom_document_alloc(doc, t, 0);
return err;
}
+ /* Compose the vtable */
+ ((struct dom_node *) t)->vtable = &text_vtable;
+ ((struct dom_node_internal *) t)->vtable = &text_protect_vtable;
+
*result = t;
return DOM_NO_ERR;
@@ -80,13 +104,13 @@ dom_exception dom_text_create(struct dom_document *doc,
*
* The contents of ::text will be destroyed and ::text will be freed.
*/
-void dom_text_destroy(struct dom_document *doc, struct dom_text *text)
+void _dom_text_destroy(struct dom_document *doc, struct dom_text *text)
{
/* Finalise node */
- dom_text_finalise(doc, text);
+ _dom_text_finalise(doc, text);
/* Free node */
- dom_document_alloc(doc, text, 0);
+ _dom_document_alloc(doc, text, 0);
}
/**
@@ -101,22 +125,18 @@ void dom_text_destroy(struct dom_document *doc, struct dom_text *text)
*
* ::doc, ::name and ::value will have their reference counts increased.
*/
-dom_exception dom_text_initialise(struct dom_text *text,
+dom_exception _dom_text_initialise(struct dom_text *text,
struct dom_document *doc, dom_node_type type,
- struct dom_string *name, struct dom_string *value)
+ struct lwc_string_s *name, struct dom_string *value)
{
dom_exception err;
/* Initialise the base class */
- err = dom_characterdata_initialise(&text->base, doc, type,
+ err = _dom_characterdata_initialise(&text->base, doc, type,
name, value);
if (err != DOM_NO_ERR)
return err;
- /* Compose the vtable */
- ((struct dom_node *) text)->vtable = &text_vtable;
- text->base.base.destroy = &_dom_text_destroy;
-
/* Perform our type-specific initialisation */
text->element_content_whitespace = false;
@@ -131,11 +151,14 @@ dom_exception dom_text_initialise(struct dom_text *text,
*
* The contents of ::text will be cleaned up. ::text will not be freed.
*/
-void dom_text_finalise(struct dom_document *doc, struct dom_text *text)
+void _dom_text_finalise(struct dom_document *doc, struct dom_text *text)
{
- dom_characterdata_finalise(doc, &text->base);
+ _dom_characterdata_finalise(doc, &text->base);
}
+/*----------------------------------------------------------------------*/
+/* The public virtual functions */
+
/**
* Split a text node at a given character offset
*
@@ -181,7 +204,7 @@ dom_exception _dom_text_split_text(struct dom_text *text,
}
/* Create new node */
- err = dom_text_create(t->owner, t->name, value, &res);
+ err = _dom_text_create(t->owner, t->name, value, &res);
if (err != DOM_NO_ERR) {
dom_string_unref(value);
return err;
@@ -227,10 +250,7 @@ dom_exception _dom_text_get_is_element_content_whitespace(
dom_exception _dom_text_get_whole_text(struct dom_text *text,
struct dom_string **result)
{
- UNUSED(text);
- UNUSED(result);
-
- return DOM_NOT_SUPPORTED_ERR;
+ return walk_logic_adjacent_text(text, COLLECT, result);
}
/**
@@ -249,10 +269,240 @@ dom_exception _dom_text_get_whole_text(struct dom_text *text,
dom_exception _dom_text_replace_whole_text(struct dom_text *text,
struct dom_string *content, struct dom_text **result)
{
- UNUSED(text);
- UNUSED(content);
- UNUSED(result);
+ dom_exception err;
+ dom_string *ret;
+
+ err = walk_logic_adjacent_text(text, DELETE, &ret);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ err = dom_characterdata_set_data(text, content);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ *result = text;
+ dom_node_ref(text);
+
+ return DOM_NO_ERR;
+}
+
+/*-----------------------------------------------------------------------*/
+/* The protected virtual functions */
+
+/* The destroy function of this class */
+void __dom_text_destroy(struct dom_node_internal *node)
+{
+ struct dom_document *doc;
+ doc = dom_node_get_owner(node);
+
+ _dom_text_destroy(doc, (struct dom_text *) node);
+}
+
+/* The memory allocator for this class */
+dom_exception _dom_text_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret)
+{
+ UNUSED(n);
+ dom_text *a;
+
+ a = _dom_document_alloc(doc, NULL, sizeof(struct dom_text));
+ if (a == NULL)
+ return DOM_NO_MEM_ERR;
+
+ *ret = (dom_node_internal *) a;
+ dom_node_set_owner(*ret, doc);
+
+ return DOM_NO_ERR;
+}
+
+/* The copy constructor of this class */
+dom_exception _dom_text_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old)
+{
+ dom_text *ot = (dom_text *) old;
+ dom_text *nt = (dom_text *) new;
- return DOM_NOT_SUPPORTED_ERR;
+ nt->element_content_whitespace = ot->element_content_whitespace;
+
+ return _dom_characterdata_copy(new, old);
+}
+
+/*----------------------------------------------------------------------*/
+/* Helper functions */
+
+/**
+ * Walk the logic adjacent text in certain order
+ *
+ * \param node The start Text node
+ * \param opt The operation on each Text Node
+ * \param order The order
+ * \param ret The string of the logic adjacent text
+ * \param cont Whether the logic adjacent text is interrupt here
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception walk_logic_adjacent_text_in_order(
+ dom_node_internal *node, walk_operation opt,
+ walk_order order, dom_string **ret, bool *cont)
+{
+ dom_exception err;
+ dom_string *data, *tmp;
+ dom_node_internal *parent = dom_node_get_parent(node);
+
+ /* If we reach the leaf of the DOM tree, just return to continue
+ * to next sibling of our parent */
+ if (node == NULL) {
+ *cont = true;
+ return DOM_NO_ERR;
+ }
+
+ while (node != NULL) {
+ /* If we reach the boundary of logical-adjacent text, we stop */
+ if (node->type == DOM_ELEMENT_NODE ||
+ node->type == DOM_COMMENT_NODE ||
+ node->type ==
+ DOM_PROCESSING_INSTRUCTION_NODE) {
+ *cont = false;
+ return DOM_NO_ERR;
+ }
+
+ if (node->type == DOM_TEXT_NODE) {
+ /* According the DOM spec, text node never have child */
+ assert(node->first_child == NULL);
+ assert(node->last_child == NULL);
+ if (opt == COLLECT) {
+ err = dom_characterdata_get_data(node, &data);
+ if (err == DOM_NO_ERR)
+ return err;
+
+ tmp = *ret;
+ if (order == LEFT) {
+ err = dom_string_concat(data, tmp, ret);
+ if (err == DOM_NO_ERR)
+ return err;
+ } else if (order == RIGHT) {
+ err = dom_string_concat(tmp, data, ret);
+ if (err == DOM_NO_ERR)
+ return err;
+ }
+
+ dom_string_unref(tmp);
+ dom_string_unref(data);
+
+ *cont = true;
+ return DOM_NO_ERR;
+ }
+
+ if (opt == DELETE) {
+ dom_node_internal *tn;
+ err = dom_node_remove_child(node->parent,
+ node, (void *) &tn);
+ if (err != DOM_NO_ERR)
+ return err;
+
+ *cont = true;
+ dom_node_unref(tn);
+ return DOM_NO_ERR;
+ }
+ }
+
+ dom_node_internal *p = dom_node_get_parent(node);
+ if (order == LEFT) {
+ if (node->last_child != NULL) {
+ node = node->last_child;
+ } else if (node->previous != NULL) {
+ node = node->previous;
+ } else {
+ while (p != parent && node == p->last_child) {
+ node = p;
+ p = dom_node_get_parent(p);
+ }
+
+ node = node->previous;
+ }
+ } else {
+ if (node->first_child != NULL) {
+ node = node->first_child;
+ } else if (node->next != NULL) {
+ node = node->next;
+ } else {
+ while (p != parent && node == p->first_child) {
+ node = p;
+ p = dom_node_get_parent(p);
+ }
+
+ node = node->next;
+ }
+ }
+ }
+
+ return DOM_NO_ERR;
+}
+
+/**
+ * Traverse the logic adjacent text.
+ *
+ * \param text The Text Node from which we start traversal
+ * \param opt The operation code
+ * \param ret The returned string if the opt is COLLECT
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception walk_logic_adjacent_text(dom_text *text,
+ walk_operation opt, dom_string **ret)
+{
+ dom_node_internal *node = (dom_node_internal *) text;
+ dom_node_internal *parent = node->parent;
+ dom_node_internal *left = node->previous;
+ dom_node_internal *right = node->next;
+ dom_exception err;
+ bool cont;
+
+ if (parent->type == DOM_ENTITY_NODE) {
+ return DOM_NOT_SUPPORTED_ERR;
+ }
+
+ /* Firstly, we look our left */
+ err = walk_logic_adjacent_text_in_order(left, opt, LEFT, ret, &cont);
+ if (err != DOM_NO_ERR) {
+ dom_string_unref(*ret);
+ *ret = NULL;
+ return err;
+ }
+
+ /* Ourself */
+ if (opt == COLLECT) {
+ dom_string *data = NULL, *tmp = NULL;
+ err = dom_characterdata_get_data(text, &data);
+ if (err == DOM_NO_ERR) {
+ dom_string_unref(*ret);
+ return err;
+ }
+
+ err = dom_string_concat(*ret, data, &tmp);
+ if (err == DOM_NO_ERR) {
+ dom_string_unref(*ret);
+ return err;
+ }
+
+ dom_string_unref(*ret);
+ dom_string_unref(data);
+ *ret = tmp;
+ } else {
+ dom_node_internal *tn;
+ err = dom_node_remove_child(node->parent, node,
+ (void *) &tn);
+ if (err != DOM_NO_ERR)
+ return err;
+ dom_node_unref(tn);
+ }
+
+ /* Now, look right */
+ err = walk_logic_adjacent_text_in_order(right, opt, RIGHT, ret, &cont);
+ if (err != DOM_NO_ERR) {
+ dom_string_unref(*ret);
+ *ret = NULL;
+ return err;
+ }
+
+ return DOM_NO_ERR;
}
diff --git a/src/core/text.h b/src/core/text.h
index faf88cc..e5de56c 100644
--- a/src/core/text.h
+++ b/src/core/text.h
@@ -16,6 +16,8 @@
struct dom_document;
struct dom_string;
+struct lwc_context_s;
+struct lwc_string_s;
/**
* A DOM text node
@@ -27,7 +29,21 @@ struct dom_text {
* content whitespace */
};
-/* Vitual functions for dom_text */
+/* Constructor and Destructor */
+dom_exception _dom_text_create(struct dom_document *doc,
+ struct lwc_string_s *name, struct dom_string *value,
+ struct dom_text **result);
+
+void _dom_text_destroy(struct dom_document *doc, struct dom_text *text);
+
+dom_exception _dom_text_initialise(struct dom_text *text,
+ struct dom_document *doc, dom_node_type type,
+ struct lwc_string_s *name, struct dom_string *value);
+
+void _dom_text_finalise(struct dom_document *doc, struct dom_text *text);
+
+
+/* Virtual functions for dom_text */
dom_exception _dom_text_split_text(struct dom_text *text,
unsigned long offset, struct dom_text **result);
dom_exception _dom_text_get_is_element_content_whitespace(
@@ -37,22 +53,26 @@ dom_exception _dom_text_get_whole_text(struct dom_text *text,
dom_exception _dom_text_replace_whole_text(struct dom_text *text,
struct dom_string *content, struct dom_text **result);
-dom_exception dom_text_create(struct dom_document *doc,
- struct dom_string *name, struct dom_string *value,
- struct dom_text **result);
-
-void dom_text_destroy(struct dom_document *doc, struct dom_text *text);
-
-dom_exception dom_text_initialise(struct dom_text *text,
- struct dom_document *doc, dom_node_type type,
- struct dom_string *name, struct dom_string *value);
-
-void dom_text_finalise(struct dom_document *doc, struct dom_text *text);
-
#define DOM_TEXT_VTABLE \
_dom_text_split_text, \
_dom_text_get_is_element_content_whitespace, \
_dom_text_get_whole_text, \
_dom_text_replace_whole_text
+
+/* Following comes the protected vtable */
+void __dom_text_destroy(struct dom_node_internal *node);
+dom_exception _dom_text_alloc(struct dom_document *doc,
+ struct dom_node_internal *n, struct dom_node_internal **ret);
+dom_exception _dom_text_copy(struct dom_node_internal *new,
+ struct dom_node_internal *old);
+
+#define DOM_TEXT_PROTECT_VTABLE \
+ __dom_text_destroy, \
+ _dom_text_alloc, \
+ _dom_text_copy
+
+
+extern struct dom_text_vtable text_vtable;
+
#endif
diff --git a/src/core/typeinfo.c b/src/core/typeinfo.c
new file mode 100644
index 0000000..4ebefcd
--- /dev/null
+++ b/src/core/typeinfo.c
@@ -0,0 +1,80 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+ */
+
+#include <dom/core/typeinfo.h>
+#include <dom/core/string.h>
+
+#include "utils/utils.h"
+
+/* TypeInfo object */
+struct dom_type_info {
+ struct lwc_string_s *type; /**< Type name */
+ struct lwc_string_s *namespace; /**< Type namespace */
+};
+
+/**
+ * Get the type name of this dom_type_info
+ *
+ * \param ti The dom_type_info
+ * \param ret The name
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ *
+ * We don't support this API now, so this function call always
+ * return DOM_NOT_SUPPORTED_ERR.
+ */
+dom_exception _dom_type_info_get_type_name(dom_type_info *ti,
+ struct dom_string **ret)
+{
+ UNUSED(ti);
+ UNUSED(ret);
+
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Get the namespace of this type info
+ *
+ * \param ti The dom_type_info
+ * \param ret The namespace
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ *
+ * We don't support this API now, so this function call always
+ * return DOM_NOT_SUPPORTED_ERR.
+ */
+dom_exception _dom_type_info_get_type_namespace(dom_type_info *ti,
+ struct dom_string **ret)
+{
+ UNUSED(ti);
+ UNUSED(ret);
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
+/**
+ * Whether this type info is derived from another one
+ *
+ * \param ti The dom_type_info
+ * \param namespace The namespace of name
+ * \param name The name of the base typeinfo
+ * \param method The deriving method
+ * \param ret The return value
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ *
+ * We don't support this API now, so this function call always
+ * return DOM_NOT_SUPPORTED_ERR.
+ */
+dom_exception _dom_type_info_is_derived(dom_type_info *ti,
+ struct dom_string *namespace, struct dom_string *name,
+ dom_type_info_derivation_method method, bool *ret)
+{
+ UNUSED(ti);
+ UNUSED(namespace);
+ UNUSED(name);
+ UNUSED(method);
+ UNUSED(ret);
+ return DOM_NOT_SUPPORTED_ERR;
+}
+
diff --git a/src/utils/Makefile b/src/utils/Makefile
index c80f261..428a9cf 100644
--- a/src/utils/Makefile
+++ b/src/utils/Makefile
@@ -1,4 +1,5 @@
# Sources
-DIR_SOURCES := namespace.c
+DIR_SOURCES := namespace.c hashtable.c resource_mgr.c character_valid.c \
+ validate.c
include build/makefiles/Makefile.subdir
diff --git a/src/utils/character_valid.c b/src/utils/character_valid.c
new file mode 100644
index 0000000..2251075
--- /dev/null
+++ b/src/utils/character_valid.c
@@ -0,0 +1,217 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+ */
+
+#include "utils/character_valid.h"
+
+#include <assert.h>
+
+static const struct xml_char_range base_char_range[] = { {0x41, 0x5a},
+ {0x61, 0x7a}, {0xc0, 0xd6}, {0xd8, 0xf6}, {0x00f8, 0x00ff},
+ {0x100, 0x131}, {0x134, 0x13e}, {0x141, 0x148}, {0x14a, 0x17e},
+ {0x180, 0x1c3}, {0x1cd, 0x1f0}, {0x1f4, 0x1f5}, {0x1fa, 0x217},
+ {0x250, 0x2a8}, {0x2bb, 0x2c1}, {0x386, 0x386}, {0x388, 0x38a},
+ {0x38c, 0x38c}, {0x38e, 0x3a1}, {0x3a3, 0x3ce}, {0x3d0, 0x3d6},
+ {0x3da, 0x3da}, {0x3dc, 0x3dc}, {0x3de, 0x3de}, {0x3e0, 0x3e0},
+ {0x3e2, 0x3f3}, {0x401, 0x40c}, {0x40e, 0x44f}, {0x451, 0x45c},
+ {0x45e, 0x481}, {0x490, 0x4c4}, {0x4c7, 0x4c8}, {0x4cb, 0x4cc},
+ {0x4d0, 0x4eb}, {0x4ee, 0x4f5}, {0x4f8, 0x4f9}, {0x531, 0x556},
+ {0x559, 0x559}, {0x561, 0x586}, {0x5d0, 0x5ea}, {0x5f0, 0x5f2},
+ {0x621, 0x63a}, {0x641, 0x64a}, {0x671, 0x6b7}, {0x6ba, 0x6be},
+ {0x6c0, 0x6ce}, {0x6d0, 0x6d3}, {0x6d5, 0x6d5}, {0x6e5, 0x6e6},
+ {0x905, 0x939}, {0x93d, 0x93d}, {0x958, 0x961}, {0x985, 0x98c},
+ {0x98f, 0x990}, {0x993, 0x9a8}, {0x9aa, 0x9b0}, {0x9b2, 0x9b2},
+ {0x9b6, 0x9b9}, {0x9dc, 0x9dd}, {0x9df, 0x9e1}, {0x9f0, 0x9f1},
+ {0xa05, 0xa0a}, {0xa0f, 0xa10}, {0xa13, 0xa28}, {0xa2a, 0xa30},
+ {0xa32, 0xa33}, {0xa35, 0xa36}, {0xa38, 0xa39}, {0xa59, 0xa5c},
+ {0xa5e, 0xa5e}, {0xa72, 0xa74}, {0xa85, 0xa8b}, {0xa8d, 0xa8d},
+ {0xa8f, 0xa91}, {0xa93, 0xaa8}, {0xaaa, 0xab0}, {0xab2, 0xab3},
+ {0xab5, 0xab9}, {0xabd, 0xabd}, {0xae0, 0xae0}, {0xb05, 0xb0c},
+ {0xb0f, 0xb10}, {0xb13, 0xb28}, {0xb2a, 0xb30}, {0xb32, 0xb33},
+ {0xb36, 0xb39}, {0xb3d, 0xb3d}, {0xb5c, 0xb5d}, {0xb5f, 0xb61},
+ {0xb85, 0xb8a}, {0xb8e, 0xb90}, {0xb92, 0xb95}, {0xb99, 0xb9a},
+ {0xb9c, 0xb9c}, {0xb9e, 0xb9f}, {0xba3, 0xba4}, {0xba8, 0xbaa},
+ {0xbae, 0xbb5}, {0xbb7, 0xbb9}, {0xc05, 0xc0c}, {0xc0e, 0xc10},
+ {0xc12, 0xc28}, {0xc2a, 0xc33}, {0xc35, 0xc39}, {0xc60, 0xc61},
+ {0xc85, 0xc8c}, {0xc8e, 0xc90}, {0xc92, 0xca8}, {0xcaa, 0xcb3},
+ {0xcb5, 0xcb9}, {0xcde, 0xcde}, {0xce0, 0xce1}, {0xd05, 0xd0c},
+ {0xd0e, 0xd10}, {0xd12, 0xd28}, {0xd2a, 0xd39}, {0xd60, 0xd61},
+ {0xe01, 0xe2e}, {0xe30, 0xe30}, {0xe32, 0xe33}, {0xe40, 0xe45},
+ {0xe81, 0xe82}, {0xe84, 0xe84}, {0xe87, 0xe88}, {0xe8a, 0xe8a},
+ {0xe8d, 0xe8d}, {0xe94, 0xe97}, {0xe99, 0xe9f}, {0xea1, 0xea3},
+ {0xea5, 0xea5}, {0xea7, 0xea7}, {0xeaa, 0xeab}, {0xead, 0xeae},
+ {0xeb0, 0xeb0}, {0xeb2, 0xeb3}, {0xebd, 0xebd}, {0xec0, 0xec4},
+ {0xf40, 0xf47}, {0xf49, 0xf69}, {0x10a0, 0x10c5}, {0x10d0, 0x10f6},
+ {0x1100, 0x1100}, {0x1102, 0x1103}, {0x1105, 0x1107}, {0x1109, 0x1109},
+ {0x110b, 0x110c}, {0x110e, 0x1112}, {0x113c, 0x113c}, {0x113e, 0x113e},
+ {0x1140, 0x1140}, {0x114c, 0x114c}, {0x114e, 0x114e}, {0x1150, 0x1150},
+ {0x1154, 0x1155}, {0x1159, 0x1159}, {0x115f, 0x1161}, {0x1163, 0x1163},
+ {0x1165, 0x1165}, {0x1167, 0x1167}, {0x1169, 0x1169}, {0x116d, 0x116e},
+ {0x1172, 0x1173}, {0x1175, 0x1175}, {0x119e, 0x119e}, {0x11a8, 0x11a8},
+ {0x11ab, 0x11ab}, {0x11ae, 0x11af}, {0x11b7, 0x11b8}, {0x11ba, 0x11ba},
+ {0x11bc, 0x11c2}, {0x11eb, 0x11eb}, {0x11f0, 0x11f0}, {0x11f9, 0x11f9},
+ {0x1e00, 0x1e9b}, {0x1ea0, 0x1ef9}, {0x1f00, 0x1f15}, {0x1f18, 0x1f1d},
+ {0x1f20, 0x1f45}, {0x1f48, 0x1f4d}, {0x1f50, 0x1f57}, {0x1f59, 0x1f59},
+ {0x1f5b, 0x1f5b}, {0x1f5d, 0x1f5d}, {0x1f5f, 0x1f7d}, {0x1f80, 0x1fb4},
+ {0x1fb6, 0x1fbc}, {0x1fbe, 0x1fbe}, {0x1fc2, 0x1fc4}, {0x1fc6, 0x1fcc},
+ {0x1fd0, 0x1fd3}, {0x1fd6, 0x1fdb}, {0x1fe0, 0x1fec}, {0x1ff2, 0x1ff4},
+ {0x1ff6, 0x1ffc}, {0x2126, 0x2126}, {0x212a, 0x212b}, {0x212e, 0x212e},
+ {0x2180, 0x2182}, {0x3041, 0x3094}, {0x30a1, 0x30fa}, {0x3105, 0x312c},
+ {0xac00, 0xd7a3}
+};
+
+const struct xml_char_group base_char_group = {
+ sizeof(base_char_range) / sizeof(base_char_range[0]),
+ base_char_range};
+
+static const struct xml_char_range char_range[] = { {0x100, 0xd7ff},
+ {0xe000, 0xfffd}, {0x10000, 0x10ffff}
+};
+
+const struct xml_char_group char_group = {
+ sizeof(char_range) / sizeof(char_range[0]), char_range};
+
+static const struct xml_char_range combining_char_range[] = { {0x300, 0x345},
+ {0x360, 0x361}, {0x483, 0x486}, {0x591, 0x5a1}, {0x5a3, 0x5b9},
+ {0x5bb, 0x5bd}, {0x5bf, 0x5bf}, {0x5c1, 0x5c2}, {0x5c4, 0x5c4},
+ {0x64b, 0x652}, {0x670, 0x670}, {0x6d6, 0x6dc}, {0x6dd, 0x6df},
+ {0x6e0, 0x6e4}, {0x6e7, 0x6e8}, {0x6ea, 0x6ed}, {0x901, 0x903},
+ {0x93c, 0x93c}, {0x93e, 0x94c}, {0x94d, 0x94d}, {0x951, 0x954},
+ {0x962, 0x963}, {0x981, 0x983}, {0x9bc, 0x9bc}, {0x9be, 0x9be},
+ {0x9bf, 0x9bf}, {0x9c0, 0x9c4}, {0x9c7, 0x9c8}, {0x9cb, 0x9cd},
+ {0x9d7, 0x9d7}, {0x9e2, 0x9e3}, {0xa02, 0xa02}, {0xa3c, 0xa3c},
+ {0xa3e, 0xa3e}, {0xa3f, 0xa3f}, {0xa40, 0xa42}, {0xa47, 0xa48},
+ {0xa4b, 0xa4d}, {0xa70, 0xa71}, {0xa81, 0xa83}, {0xabc, 0xabc},
+ {0xabe, 0xac5}, {0xac7, 0xac9}, {0xacb, 0xacd}, {0xb01, 0xb03},
+ {0xb3c, 0xb3c}, {0xb3e, 0xb43}, {0xb47, 0xb48}, {0xb4b, 0xb4d},
+ {0xb56, 0xb57}, {0xb82, 0xb83}, {0xbbe, 0xbc2}, {0xbc6, 0xbc8},
+ {0xbca, 0xbcd}, {0xbd7, 0xbd7}, {0xc01, 0xc03}, {0xc3e, 0xc44},
+ {0xc46, 0xc48}, {0xc4a, 0xc4d}, {0xc55, 0xc56}, {0xc82, 0xc83},
+ {0xcbe, 0xcc4}, {0xcc6, 0xcc8}, {0xcca, 0xccd}, {0xcd5, 0xcd6},
+ {0xd02, 0xd03}, {0xd3e, 0xd43}, {0xd46, 0xd48}, {0xd4a, 0xd4d},
+ {0xd57, 0xd57}, {0xe31, 0xe31}, {0xe34, 0xe3a}, {0xe47, 0xe4e},
+ {0xeb1, 0xeb1}, {0xeb4, 0xeb9}, {0xebb, 0xebc}, {0xec8, 0xecd},
+ {0xf18, 0xf19}, {0xf35, 0xf35}, {0xf37, 0xf37}, {0xf39, 0xf39},
+ {0xf3e, 0xf3e}, {0xf3f, 0xf3f}, {0xf71, 0xf84}, {0xf86, 0xf8b},
+ {0xf90, 0xf95}, {0xf97, 0xf97}, {0xf99, 0xfad}, {0xfb1, 0xfb7},
+ {0xfb9, 0xfb9}, {0x20d0, 0x20dc}, {0x20e1, 0x20e1}, {0x302a, 0x302f},
+ {0x3099, 0x3099}, {0x309a, 0x309a}
+};
+
+const struct xml_char_group combining_char_group = {
+ sizeof(combining_char_range) / sizeof(combining_char_range[0]),
+ combining_char_range };
+
+static const struct xml_char_range digit_char_range[] = { {0x30, 0x39},
+ {0x660, 0x669}, {0x6f0, 0x6f9}, {0x966, 0x96f}, {0x9e6, 0x9ef},
+ {0xa66, 0xa6f}, {0xae6, 0xaef}, {0xb66, 0xb6f}, {0xbe7, 0xbef},
+ {0xc66, 0xc6f}, {0xce6, 0xcef}, {0xd66, 0xd6f}, {0xe50, 0xe59},
+ {0xed0, 0xed9}, {0xf20, 0xf29}
+};
+
+const struct xml_char_group digit_char_group = {
+ sizeof(digit_char_range) / sizeof(digit_char_range[0]),
+ digit_char_range };
+
+static const struct xml_char_range extender_range[] = { {0xb7, 0xb7},
+ {0x2d0, 0x2d0}, {0x2d1, 0x2d1}, {0x387, 0x387}, {0x640, 0x640},
+ {0xe46, 0xe46}, {0xec6, 0xec6}, {0x3005, 0x3005}, {0x3031, 0x3035},
+ {0x309d, 0x309e}, {0x30fc, 0x30fe}
+};
+
+const struct xml_char_group extender_group = {
+ sizeof(extender_range) / sizeof(extender_range[0]),
+ extender_range };
+
+static const struct xml_char_range ideographic_range[] = { {0x3007, 0x3007},
+ {0x3021, 0x3029}, {0x4e00, 0x9fa5}
+};
+
+const struct xml_char_group ideographic_group = {
+ sizeof(ideographic_range) / sizeof(ideographic_range[0]),
+ ideographic_range };
+
+/* The binary search helper function */
+static bool binary_search(unsigned int ch, int left, int right,
+ const struct xml_char_range *range);
+
+/* Search for ch in range[left, right] */
+bool binary_search(unsigned int ch, int left, int right,
+ const struct xml_char_range *range)
+{
+ if (left > right)
+ return false;
+
+ int mid = (left + right) / 2;
+ if (ch >= range[mid].start && ch <= range[mid].end)
+ return true;
+
+ if (ch < range[mid].start)
+ return binary_search(ch, left, mid - 1, range);
+
+ if (ch > range[mid].end)
+ return binary_search(ch, mid + 1, right, range);
+
+ return false;
+}
+
+/**
+ * Test whether certain character belongs to some XML character group
+ *
+ * \param ch The character being tested
+ * \param group The character group
+ * \return true if the character belongs to the group, false otherwise.
+ *
+ * Generally, we use an algorithm like binary search to find the desired
+ * character in the group. The time complexity is about lg(n) and here n is
+ * at most 180, so, I think the algorithm is fast enough for name validation.
+ */
+bool _dom_is_character_in_group(unsigned int ch,
+ const struct xml_char_group *group)
+{
+ int len = group->len;
+ const struct xml_char_range *range = group->range;
+
+ if (ch < range[0].start || ch > range[len-1].end)
+ return false;
+
+ return binary_search(ch, 0, len - 1, range);
+}
+
+#ifdef CHVALID_DEBUG
+/* The following is the testcases for this file.
+ * Compile this file :
+ *
+ * gcc -o test -DCHVALID_DEBUG character_valid.c
+ *
+ */
+#include <stdio.h>
+
+int main(int argc, char **argv)
+{
+ unsigned int ch = 0x666;
+
+ assert(is_digit(ch) == true);
+ assert(is_base_char(ch) == false);
+ assert(is_char(ch) == true);
+ assert(is_extender(ch) == false);
+ assert(is_combining_char(ch) == false);
+ assert(is_ideographic(ch) == false);
+
+ ch = 0xf40;
+
+ assert(is_digit(ch) == false);
+ assert(is_base_char(ch) == true);
+ assert(is_char(ch) == true);
+ assert(is_extender(ch) == false);
+ assert(is_combining_char(ch) == false);
+ assert(is_ideographic(ch) == false);
+
+ printf("The test pass.\n");
+ return 0;
+}
+
+#endif
diff --git a/src/utils/character_valid.h b/src/utils/character_valid.h
new file mode 100644
index 0000000..5094e7c
--- /dev/null
+++ b/src/utils/character_valid.h
@@ -0,0 +1,54 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+ *
+ * This file contains the API used to validate whether certain character in
+ * name/value is legal according the XML 1.0 standard. See
+ *
+ * http://www.w3.org/TR/2004/REC-xml-20040204/
+ * http://www.w3.org/TR/REC-xml/
+ *
+ * for detail.
+ */
+
+#ifndef dom_utils_character_valid_h_
+#define dom_utils_character_valid_h_
+
+#include <stdbool.h>
+#include <stdlib.h>
+
+struct xml_char_range {
+ unsigned int start;
+ unsigned int end;
+};
+
+struct xml_char_group {
+ size_t len;
+ const struct xml_char_range *range;
+};
+
+/* The groups */
+extern const struct xml_char_group base_char_group;
+extern const struct xml_char_group char_group;
+extern const struct xml_char_group combining_char_group;
+extern const struct xml_char_group digit_char_group;
+extern const struct xml_char_group extender_group;
+extern const struct xml_char_group ideographic_group;
+
+bool _dom_is_character_in_group(unsigned int ch,
+ const struct xml_char_group *group);
+
+#define is_base_char(ch) _dom_is_character_in_group((ch), &base_char_group)
+#define is_char(ch) _dom_is_character_in_group((ch), &char_group)
+#define is_combining_char(ch) _dom_is_character_in_group((ch), \
+ &combining_char_group)
+#define is_digit(ch) _dom_is_character_in_group((ch), &digit_char_group)
+#define is_extender(ch) _dom_is_character_in_group((ch), &extender_group)
+#define is_ideographic(ch) _dom_is_character_in_group((ch), &ideographic_group)
+
+#define is_letter(ch) (is_base_char(ch) || is_ideographic(ch))
+
+#endif
+
diff --git a/src/utils/hashtable.c b/src/utils/hashtable.c
new file mode 100644
index 0000000..c2ff8ce
--- /dev/null
+++ b/src/utils/hashtable.c
@@ -0,0 +1,492 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2006 Rob Kendrick <rjek@rjek.com>
+ * Copyright 2006 Richard Wilson <info@tinct.net>
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include <stdbool.h>
+#include <assert.h>
+#ifdef TEST_RIG
+#include <stdio.h>
+#endif
+#include "utils/hashtable.h"
+
+/* The hash table entry */
+struct _dom_hash_entry {
+ void *key; /**< The key pointer */
+ void *value; /**< The value pointer */
+ struct _dom_hash_entry *next; /**< Next entry */
+};
+
+/* The hash table */
+struct dom_hash_table {
+ unsigned int nchains; /**< The chains number */
+ dom_hash_func hash; /**< The hash function */
+ struct _dom_hash_entry **chain; /**< The chain head */
+ unsigned int number; /**< The enries in this table */
+
+ dom_alloc alloc; /**< Memory allocation function */
+ void *ptr; /**< The private data for the memory allocator */
+};
+
+
+/**
+ * Create a new hash table, and return a context for it. The memory consumption
+ * of a hash table is approximately 8 + (nchains * 12) bytes if it is empty.
+ *
+ * \param chains Number of chains/buckets this hash table will have. This
+ * should be a prime number, and ideally a prime number just
+ * over a power of two, for best performance and distribution
+ * \param hash The hash function
+ * \param alloc The memory allocator
+ * \param ptr The private pointer for the allocator
+ * \return struct dom_hash_table containing the context of this hash table or
+ * NULL if there is insufficent memory to create it and its chains.
+ */
+struct dom_hash_table *_dom_hash_create(unsigned int chains, dom_hash_func hash,
+ dom_alloc alloc, void *ptr)
+{
+ struct dom_hash_table *r = alloc(NULL, sizeof(struct dom_hash_table),
+ ptr);
+
+ if (r == NULL) {
+ return NULL;
+ }
+
+ r->nchains = chains;
+ r->hash = hash;
+ r->alloc = alloc;
+ r->ptr = ptr;
+ r->chain = (struct _dom_hash_entry **)alloc(NULL,
+ chains*sizeof(struct _dom_hash_entry *), ptr);
+ r->number = 0;
+
+ unsigned int i;
+ for (i = 0; i < chains; i++)
+ r->chain[i] = NULL;
+
+ if (r->chain == NULL) {
+ alloc(r, 0, ptr);
+ return NULL;
+ }
+
+ return r;
+}
+
+/**
+ * Clone a hash table.
+ *
+ * \param ht Hash table to clone.
+ * \param alloc The allocator.
+ * \param pw The private data for the allocator.
+ * \param kf The function pointer used to copy the key.
+ * \param key_pw The private data for the key cloner.
+ * \param vf The function pointer used to copy the value.
+ * \param value_pw The private data for the value cloner.
+ *
+ * \return The cloned hash table.
+ */
+struct dom_hash_table *_dom_hash_clone(struct dom_hash_table *ht,
+ dom_alloc alloc, void *pw, dom_key_func kf, void *key_pw,
+ dom_value_func vf, void *value_pw)
+{
+ struct dom_hash_table *ret;
+
+ ret = _dom_hash_create(ht->nchains, ht->hash, alloc, pw);
+ if (ret == NULL)
+ return NULL;
+
+ void *key = NULL, *nkey = NULL;
+ void *value = NULL, *nvalue = NULL;
+ unsigned int c1, *c2 = NULL;
+ while ( (key = _dom_hash_iterate(ht, &c1, &c2)) != NULL) {
+ nkey = kf(key, key_pw, alloc, pw, true);
+ if (nkey == NULL) {
+ _dom_hash_destroy(ret, kf, key_pw, vf, value_pw);
+ return NULL;
+ }
+
+ value = _dom_hash_get(ht, key);
+ nvalue = vf(value, value_pw, alloc, pw, true);
+ if (nvalue == NULL) {
+ kf(nkey, key_pw, alloc, pw, false);
+ _dom_hash_destroy(ret, kf, key_pw, vf, value_pw);
+ return NULL;
+ }
+
+ if (_dom_hash_add(ret, nkey, nvalue, false) == false) {
+ _dom_hash_destroy(ret, kf, key_pw, vf, value_pw);
+ return NULL;
+ }
+ }
+
+ return ret;
+}
+
+/**
+ * Destroys a hash table, freeing all memory associated with it.
+ *
+ * \param ht Hash table to destroy. After the function returns, this
+ * will nolonger be valid
+ * \param kf The key destroy function
+ * \param key_pw The key destroy function private data
+ * \param vf The value destroy function
+ * \param value_pw The value destroy function private data
+ */
+void _dom_hash_destroy(struct dom_hash_table *ht, dom_key_func kf,
+ void *key_pw, dom_value_func vf, void *value_pw)
+{
+ unsigned int i;
+
+ if (ht == NULL)
+ return;
+
+ assert(ht->alloc != NULL);
+
+ for (i = 0; i < ht->nchains; i++) {
+ if (ht->chain[i] != NULL) {
+ struct _dom_hash_entry *e = ht->chain[i];
+ while (e) {
+ struct _dom_hash_entry *n = e->next;
+ if (kf != NULL) {
+ kf(e->key, key_pw, ht->alloc,
+ ht->ptr, false);
+ }
+ if (vf != NULL) {
+ vf(e->value, value_pw, ht->alloc,
+ ht->ptr, false);
+ }
+ ht->alloc(e, 0, ht->ptr);
+ e = n;
+ }
+ }
+ }
+
+ ht->alloc(ht->chain, 0, ht->ptr);
+ ht->alloc(ht, 0, ht->ptr);
+}
+
+/**
+ * Adds a key/value pair to a hash table
+ *
+ * \param ht The hash table context to add the key/value pair to.
+ * \param key The key to associate the value with.
+ * \param value The value to associate the key with.
+ * \return true if the add succeeded, false otherwise. (Failure most likely
+ * indicates insufficent memory to make copies of the key and value.
+ */
+bool _dom_hash_add(struct dom_hash_table *ht, void *key, void *value,
+ bool replace)
+{
+ unsigned int h, c;
+ struct _dom_hash_entry *e;
+
+ if (ht == NULL || key == NULL || value == NULL)
+ return false;
+
+ h = ht->hash(key);
+ c = h % ht->nchains;
+
+ for (e = ht->chain[c]; e; e = e->next)
+ if (key == e->key) {
+ if (replace == true) {
+ e->value = value;
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ assert(ht->alloc != NULL);
+
+ e = ht->alloc(NULL, sizeof(struct _dom_hash_entry), ht->ptr);
+ if (e == NULL) {
+ return false;
+ }
+
+ e->key = key;
+ e->value = value;
+
+ e->next = ht->chain[c];
+ ht->chain[c] = e;
+ ht->number ++;
+
+ return true;
+}
+
+/**
+ * Looks up a the value associated with with a key from a specific hash table.
+ *
+ * \param ht The hash table context to look up
+ * \param key The key to search for
+ * \return The value associated with the key, or NULL if it was not found.
+ */
+void *_dom_hash_get(struct dom_hash_table *ht, void *key)
+{
+ unsigned int h, c;
+ struct _dom_hash_entry *e;
+
+ if (ht == NULL || key == NULL)
+ return NULL;
+
+ h = ht->hash(key);
+ c = h % ht->nchains;
+
+ for (e = ht->chain[c]; e; e = e->next)
+ if (key == e->key)
+ return e->value;
+
+ return NULL;
+}
+
+/**
+ * Delete the key from the hashtable.
+ *
+ * \param ht The hashtable object
+ * \param key The key to delete
+ * \return The deleted value
+ */
+void *_dom_hash_del(struct dom_hash_table *ht, void *key)
+{
+ unsigned int h, c;
+ struct _dom_hash_entry *e, *p;
+ void *ret;
+
+ if (ht == NULL || key == NULL)
+ return NULL;
+
+ h = ht->hash(key);
+ c = h % ht->nchains;
+
+ assert(ht->alloc != NULL);
+
+ p = ht->chain[c];
+ for (e = p; e; p = e, e = e->next)
+ if (key == e->key) {
+ if (p != e) {
+ p->next = e->next;
+ } else {
+ /* The first item in this chain is target*/
+ ht->chain[c] = e->next;
+ }
+
+ ret = e->value;
+ ht->alloc(e, 0, ht->ptr);
+ ht->number --;
+ return ret;
+ }
+
+ return NULL;
+}
+
+/**
+ * Iterate through all available hash keys.
+ *
+ * \param ht The hash table context to iterate.
+ * \param c1 Pointer to first context
+ * \param c2 Pointer to second context (set to 0 on first call)
+ * \return The next hash key, or NULL for no more keys
+ */
+void *_dom_hash_iterate(struct dom_hash_table *ht, unsigned int *c1,
+ unsigned int **c2)
+{
+ struct _dom_hash_entry **he = (struct _dom_hash_entry **)c2;
+
+ if (ht == NULL)
+ return NULL;
+
+ if (!*he)
+ *c1 = -1;
+ else
+ *he = (*he)->next;
+
+ if (*he)
+ return (*he)->key;
+
+ while (!*he) {
+ (*c1)++;
+ if (*c1 >= ht->nchains)
+ return NULL;
+ *he = ht->chain[*c1];
+ }
+ return (*he)->key;
+}
+
+/**
+ * Get the number of elements in this hash table
+ *
+ * \param ht The hash table
+ *
+ * \return the number of elements
+ */
+unsigned int _dom_hash_get_length(struct dom_hash_table *ht)
+{
+ return ht->number;
+}
+
+/**
+ * Get the chain number of this hash table
+ *
+ * \param ht The hash table
+ *
+ * \return the number of chains
+ */
+unsigned int _dom_hash_get_chains(struct dom_hash_table *ht)
+{
+ return ht->nchains;
+}
+
+/**
+ * Get the hash function of this hash table
+ *
+ * \param ht The hash table
+ *
+ * \return the hash function
+ */
+dom_hash_func _dom_hash_get_func(struct dom_hash_table *ht)
+{
+ return ht->hash;
+}
+
+/* A simple test rig. To compile, use:
+ * gcc -g -o hashtest -I../ -I../../include -DTEST_RIG hashtable.c
+ *
+ * If you make changes to this hash table implementation, please rerun this
+ * test, and if possible, through valgrind to make sure there are no memory
+ * leaks or invalid memory accesses. If you add new functionality, please
+ * include a test for it that has good coverage along side the other tests.
+ */
+
+#ifdef TEST_RIG
+
+
+/**
+ * Hash a pointer, returning a 32bit value.
+ *
+ * \param ptr The pointer to hash.
+ * \return the calculated hash value for the pointer.
+ */
+
+static inline unsigned int _dom_hash_pointer_fnv(void *ptr)
+{
+ return (unsigned int) ptr;
+}
+
+static void *test_alloc(void *p, size_t size, void *ptr)
+{
+ if (p != NULL) {
+ free(p);
+ return NULL;
+ }
+
+ if (p == NULL) {
+ return malloc(size);
+ }
+}
+
+int main(int argc, char *argv[])
+{
+ struct dom_hash_table *a, *b;
+ FILE *dict;
+ char keybuf[BUFSIZ], valbuf[BUFSIZ];
+ int i;
+ char *cow="cow", *moo="moo", *pig="pig", *oink="oink",
+ *chicken="chikcken", *cluck="cluck",
+ *dog="dog", *woof="woof", *cat="cat",
+ *meow="meow";
+ void *ret;
+
+ a = _dom_hash_create(79, _dom_hash_pointer_fnv, test_alloc, NULL);
+ assert(a != NULL);
+
+ b = _dom_hash_create(103, _dom_hash_pointer_fnv, test_alloc, NULL);
+ assert(b != NULL);
+
+ _dom_hash_add(a, cow, moo ,true);
+ _dom_hash_add(b, moo, cow ,true);
+
+ _dom_hash_add(a, pig, oink ,true);
+ _dom_hash_add(b, oink, pig ,true);
+
+ _dom_hash_add(a, chicken, cluck ,true);
+ _dom_hash_add(b, cluck, chicken ,true);
+
+ _dom_hash_add(a, dog, woof ,true);
+ _dom_hash_add(b, woof, dog ,true);
+
+ _dom_hash_add(a, cat, meow ,true);
+ _dom_hash_add(b, meow, cat ,true);
+
+#define MATCH(x,y) assert(!strcmp((char *)hash_get(a, x), (char *)y)); \
+ assert(!strcmp((char *)hash_get(b, y), (char *)x))
+ MATCH(cow, moo);
+ MATCH(pig, oink);
+ MATCH(chicken, cluck);
+ MATCH(dog, woof);
+ MATCH(cat, meow);
+
+ assert(hash_get_length(a) == 5);
+ assert(hash_get_length(b) == 5);
+
+ _dom_hash_del(a, cat);
+ _dom_hash_del(b, meow);
+ assert(hash_get(a, cat) == NULL);
+ assert(hash_get(b, meow) == NULL);
+
+ assert(hash_get_length(a) == 4);
+ assert(hash_get_length(b) == 4);
+
+ _dom_hash_destroy(a, NULL, NULL);
+ _dom_hash_destroy(b, NULL, NULL);
+
+ /* This test requires /usr/share/dict/words - a large list of English
+ * words. We load the entire file - odd lines are used as keys, and
+ * even lines are used as the values for the previous line. we then
+ * work through it again making sure everything matches.
+ *
+ * We do this twice - once in a hash table with many chains, and once
+ * with a hash table with fewer chains.
+ */
+
+ a = _dom_hash_create(1031, _dom_hash_pointer_fnv, test_alloc, NULL);
+ b = _dom_hash_create(7919, _dom_hash_pointer_fnv, test_alloc, NULL);
+
+ dict = fopen("/usr/share/dict/words", "r");
+ if (dict == NULL) {
+ fprintf(stderr, "Unable to open /usr/share/dict/words - \
+ extensive testing skipped.\n");
+ exit(0);
+ }
+
+ while (!feof(dict)) {
+ fscanf(dict, "%s", keybuf);
+ fscanf(dict, "%s", valbuf);
+ _dom_hash_add(a, keybuf, valbuf, true);
+ _dom_hash_add(b, keybuf, valbuf, true);
+ }
+
+ for (i = 0; i < 5; i++) {
+ fseek(dict, 0, SEEK_SET);
+
+ while (!feof(dict)) {
+ fscanf(dict, "%s", keybuf);
+ fscanf(dict, "%s", valbuf);
+ assert(strcmp(hash_get(a, keybuf), valbuf) == 0);
+ assert(strcmp(hash_get(b, keybuf), valbuf) == 0);
+ }
+ }
+
+ _dom_hash_destroy(a, NULL, NULL);
+ _dom_hash_destroy(b, NULL, NULL);
+
+ fclose(dict);
+
+ return 0;
+}
+
+#endif
diff --git a/src/utils/hashtable.h b/src/utils/hashtable.h
new file mode 100644
index 0000000..3cfe95d
--- /dev/null
+++ b/src/utils/hashtable.h
@@ -0,0 +1,42 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2006 Rob Kendrick <rjek@rjek.com>
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+ */
+
+#ifndef dom_utils_hashtable_h_
+#define dom_utils_hashtable_h_
+
+#include <stdbool.h>
+#include <dom/functypes.h>
+
+typedef struct dom_hash_table dom_hash_table;
+/* The hash function */
+typedef unsigned int (*dom_hash_func)(void *key);
+/* Function to clone/delete key */
+typedef void *(*dom_key_func)(void *key, void *pw, dom_alloc alloc,
+ void *alloc_pw, bool clone);
+/* Function to clone/delete value */
+typedef void *(*dom_value_func)(void *value, void *pw, dom_alloc alloc,
+ void *alloc_pw, bool clone);
+
+struct dom_hash_table *_dom_hash_create(unsigned int chains, dom_hash_func hash,
+ dom_alloc alloc, void *ptr);
+struct dom_hash_table *_dom_hash_clone(struct dom_hash_table *ht,
+ dom_alloc alloc, void *pw, dom_key_func kf, void *key_pw,
+ dom_value_func vf, void *value_pw);
+void _dom_hash_destroy(struct dom_hash_table *ht, dom_key_func kf, void *key_pw,
+ dom_value_func vf, void *value_pw);
+bool _dom_hash_add(struct dom_hash_table *ht, void *key, void *value,
+ bool replace);
+void *_dom_hash_get(struct dom_hash_table *ht, void *key);
+void *_dom_hash_del(struct dom_hash_table *ht, void *key);
+void *_dom_hash_iterate(struct dom_hash_table *ht, unsigned int *c1,
+ unsigned int **c2);
+unsigned int _dom_hash_get_length(struct dom_hash_table *ht);
+unsigned int _dom_hash_get_chains(struct dom_hash_table *ht);
+dom_hash_func _dom_hash_get_func(struct dom_hash_table *ht);
+
+#endif
diff --git a/src/utils/list.h b/src/utils/list.h
new file mode 100644
index 0000000..6e3ba20
--- /dev/null
+++ b/src/utils/list.h
@@ -0,0 +1,61 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+ *
+ * This file contains the list structure used to compose lists.
+ *
+ * Note: This is a implementation of a doubld-linked cyclar list.
+ */
+
+#ifndef dom_utils_list_h_
+#define dom_utils_list_h_
+
+#include <stddef.h>
+
+struct list_entry {
+ struct list_entry *prev;
+ struct list_entry *next;
+};
+
+/**
+ * Initialise a list_entry structure
+ *
+ * \param ent The entry to initialise
+ */
+static inline void list_init(struct list_entry *ent)
+{
+ ent->prev = ent;
+ ent->next = ent;
+}
+
+/**
+ * Append a new list_entry after the list
+ *
+ * \param head The list header
+ * \param new The new entry
+ */
+static inline void list_append(struct list_entry *head, struct list_entry *new)
+{
+ new->next = head;
+ new->prev = head->prev;
+ head->prev->next = new;
+ head->prev = new;
+}
+
+/**
+ * Delete a list_entry from the list
+ *
+ * \param entry The entry need to be deleted from the list
+ */
+static inline void list_del(struct list_entry *ent)
+{
+ ent->prev->next = ent->next;
+ ent->next->prev = ent->prev;
+
+ ent->prev = ent;
+ ent->next = ent;
+}
+
+#endif
diff --git a/src/utils/namespace.c b/src/utils/namespace.c
index ca5b01d..8d109ae 100644
--- a/src/utils/namespace.c
+++ b/src/utils/namespace.c
@@ -1,8 +1,9 @@
/*
* This file is part of libdom.
* Licensed under the MIT License,
- * http://www.opensource.org/licenses/mit-license.php
+ * http://www.opensource.org/licenses/mit-license.php
* Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
*/
#include <string.h>
@@ -10,6 +11,7 @@
#include <dom/dom.h>
#include "utils/namespace.h"
+#include "utils/validate.h"
#include "utils/utils.h"
@@ -18,7 +20,7 @@ static struct dom_string *xml;
/** XMLNS prefix */
static struct dom_string *xmlns;
-/** The namespace strings */
+/* The namespace strings */
static const char *namespaces[DOM_NAMESPACE_COUNT] = {
NULL,
"http://www.w3.org/1999/xhtml",
@@ -37,7 +39,7 @@ struct dom_string *dom_namespaces[DOM_NAMESPACE_COUNT] = {
* Initialise the namespace component
*
* \param alloc Pointer to memory (de)allocation function
- * \param pw Pointer to client-specific private data
+ * \param pw Pointer to client-specific private data
* \return DOM_NO_ERR on success.
*/
dom_exception _dom_namespace_initialise(dom_alloc alloc, void *pw)
@@ -130,10 +132,19 @@ dom_exception _dom_namespace_finalise(void)
dom_exception _dom_namespace_validate_qname(struct dom_string *qname,
struct dom_string *namespace)
{
- uint32_t colon;
+ uint32_t colon, len;
+
+ if (qname == NULL){
+ if (namespace != NULL)
+ return DOM_NAMESPACE_ERR;
+ if (namespace == NULL)
+ return DOM_NO_ERR;
+ }
+
+ if (_dom_validate_name(qname) == false)
+ return DOM_NAMESPACE_ERR;
- /** \todo search qname for invalid characters */
- /** \todo ensure qname is not malformed */
+ len = dom_string_length(qname);
/* Find colon */
colon = dom_string_index(qname, ':');
@@ -147,9 +158,14 @@ dom_exception _dom_namespace_validate_qname(struct dom_string *qname,
dom_string_cmp(qname, xmlns) != 0) {
return DOM_NAMESPACE_ERR;
}
+ } else if (colon == 0) {
+ /* Some name like ":name" */
+ if (namespace != NULL)
+ return DOM_NAMESPACE_ERR;
} else {
/* Prefix */
struct dom_string *prefix;
+ struct dom_string *lname;
dom_exception err;
/* Ensure there is a namespace URI */
@@ -157,11 +173,21 @@ dom_exception _dom_namespace_validate_qname(struct dom_string *qname,
return DOM_NAMESPACE_ERR;
}
- err = dom_string_substr(qname, 0, colon - 1, &prefix);
+ err = dom_string_substr(qname, 0, colon, &prefix);
if (err != DOM_NO_ERR) {
return err;
}
+ err = dom_string_substr(qname, colon + 1, len, &lname);
+ if (err != DOM_NO_ERR) {
+ return err;
+ }
+
+ if (_dom_validate_ncname(prefix) == false ||
+ _dom_validate_ncname(lname) == false) {
+ return DOM_NAMESPACE_ERR;
+ }
+
/* Test for invalid XML namespace */
if (dom_string_cmp(prefix, xml) == 0 &&
dom_string_cmp(namespace,
@@ -223,7 +249,7 @@ dom_exception _dom_namespace_split_qname(struct dom_string *qname,
}
} else {
/* Found one => prefix */
- err = dom_string_substr(qname, 0, colon - 1, prefix);
+ err = dom_string_substr(qname, 0, colon, prefix);
if (err != DOM_NO_ERR) {
return err;
}
@@ -240,3 +266,32 @@ dom_exception _dom_namespace_split_qname(struct dom_string *qname,
return DOM_NO_ERR;
}
+/**
+ * Get the XML prefix dom_string
+ *
+ * \return the xml prefix dom_string.
+ *
+ * Note: The client of this function may or may not call the dom_string_ref
+ * on the returned dom_string, because this string will only be destroyed when
+ * the dom_finalise is called. But if the client call dom_string_ref, it must
+ * call dom_string_unref to maintain a correct ref count of the dom_string.
+ */
+dom_string *_dom_namespace_get_xml_prefix(void)
+{
+ return xml;
+}
+
+/**
+ * Get the XMLNS prefix dom_string.
+ *
+ * \return the xmlns prefix dom_string
+ *
+ * Note: The client of this function may or may not call the dom_string_ref
+ * on the returned dom_string, because this string will only be destroyed when
+ * the dom_finalise is called. But if the client call dom_string_ref, it must
+ * call dom_string_unref to maintain a correct ref count of the dom_string.
+ */
+dom_string *_dom_namespace_get_xmlns_prefix(void)
+{
+ return xmlns;
+}
diff --git a/src/utils/namespace.h b/src/utils/namespace.h
index ec69035..900c9ee 100644
--- a/src/utils/namespace.h
+++ b/src/utils/namespace.h
@@ -14,6 +14,7 @@
struct dom_document;
struct dom_string;
+
/* Initialise the namespace component */
dom_exception _dom_namespace_initialise(dom_alloc alloc, void *pw);
@@ -28,5 +29,11 @@ dom_exception _dom_namespace_validate_qname(struct dom_string *qname,
dom_exception _dom_namespace_split_qname(struct dom_string *qname,
struct dom_string **prefix, struct dom_string **localname);
+/* Get the XML prefix dom_string */
+struct dom_string *_dom_namespace_get_xml_prefix(void);
+
+/* Get the XMLNS prefix dom_string */
+struct dom_string *_dom_namespace_get_xmlns_prefix(void);
+
#endif
diff --git a/src/utils/resource_mgr.c b/src/utils/resource_mgr.c
new file mode 100644
index 0000000..c9c86d3
--- /dev/null
+++ b/src/utils/resource_mgr.c
@@ -0,0 +1,105 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+ */
+
+#include "resource_mgr.h"
+
+#include <string.h>
+#include <assert.h>
+
+#include <libwapcaplet/libwapcaplet.h>
+#include "core/string.h"
+
+/**
+ * Allocate some memory with this allocator
+ *
+ * \param res The resource manager
+ * \param size The size of memory to allocate
+ * \return the allocated memory pointer.
+ */
+void *_dom_resource_mgr_alloc(struct dom_resource_mgr *res, void *ptr,
+ size_t size)
+{
+ return res->alloc(ptr, size, res->pw);
+}
+
+/**
+ * Create a dom_string using this resource manager
+ *
+ * \param res The resource manager
+ * \param data The data pointer
+ * \param len The length of data
+ * \param result The returned dom_string
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_resource_mgr_create_string(struct dom_resource_mgr *res,
+ const uint8_t *data, size_t len, struct dom_string **result)
+{
+ return dom_string_create(res->alloc, res->pw, data, len, result);
+}
+
+/**
+ * Create a lwc_string using this resource manager
+ *
+ * \param res The resource manager
+ * \param data The data pointer
+ * \param len The length of the data
+ * \param result The returned lwc_string
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_resource_mgr_create_lwcstring(struct dom_resource_mgr *res,
+ const uint8_t *data, size_t len, struct lwc_string_s **result)
+{
+ lwc_error lerr;
+
+ assert(res->ctx != NULL);
+
+ lerr = lwc_context_intern(res->ctx, (const char *) data, len,
+ result);
+
+ return _dom_exception_from_lwc_error(lerr);
+}
+
+/**
+ * Create a dom_string from a lwc_string using this resource manager
+ *
+ * \param res The resource manager
+ * \param str The dom_string to intern
+ * \param result The returned lwc_string
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_resource_mgr_create_string_from_lwcstring(
+ struct dom_resource_mgr *res, struct lwc_string_s *str,
+ struct dom_string **result)
+{
+ assert(res->ctx != NULL);
+
+ return _dom_string_create_from_lwcstring(res->alloc, res->pw, res->ctx,
+ str, result);
+}
+
+/**
+ * Create a hash table using this resource manager
+ *
+ * \param res The resource manager
+ * \param chains The number of buckets of the hash table
+ * \param f The hash function
+ * \param ht The returned hash table
+ * \return DOM_NO_ERR on success, appropriate dom_exception on failure.
+ */
+dom_exception _dom_resource_mgr_create_hashtable(struct dom_resource_mgr *res,
+ size_t chains, dom_hash_func f, struct dom_hash_table **ht)
+{
+ struct dom_hash_table *ret;
+
+ ret = _dom_hash_create(chains, f, res->alloc, res->pw);
+ if (ret == NULL)
+ return DOM_NO_MEM_ERR;
+
+ *ht = ret;
+ return DOM_NO_ERR;
+}
+
diff --git a/src/utils/resource_mgr.h b/src/utils/resource_mgr.h
new file mode 100644
index 0000000..b58f665
--- /dev/null
+++ b/src/utils/resource_mgr.h
@@ -0,0 +1,45 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+ */
+
+#ifndef dom_utils_resource_mgr_h_
+#define dom_utils_resource_mgr_h_
+
+#include <dom/functypes.h>
+#include <dom/core/exceptions.h>
+
+#include "hashtable.h"
+
+struct lwc_context_s;
+struct lwc_string_s;
+struct dom_string;
+
+/**
+ * Resource manager
+ */
+typedef struct dom_resource_mgr {
+ dom_alloc alloc;
+ void *pw;
+ struct lwc_context_s *ctx;
+} dom_resource_mgr;
+
+void *_dom_resource_mgr_alloc(struct dom_resource_mgr *res, void *ptr,
+ size_t size);
+
+dom_exception _dom_resource_mgr_create_string(struct dom_resource_mgr *res,
+ const uint8_t *data, size_t len, struct dom_string **result);
+
+dom_exception _dom_resource_mgr_create_lwcstring(struct dom_resource_mgr *res,
+ const uint8_t *data, size_t len, struct lwc_string_s **result);
+
+dom_exception _dom_resource_mgr_create_string_from_lwcstring(
+ struct dom_resource_mgr *res, struct lwc_string_s *str,
+ struct dom_string **result);
+
+dom_exception _dom_resource_mgr_create_hashtable(struct dom_resource_mgr *res,
+ size_t chains, dom_hash_func f, struct dom_hash_table **ht);
+
+#endif
diff --git a/src/utils/validate.c b/src/utils/validate.c
new file mode 100644
index 0000000..eb6cb22
--- /dev/null
+++ b/src/utils/validate.c
@@ -0,0 +1,177 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+ */
+
+#include <inttypes.h>
+#include <stddef.h>
+
+#include "utils/validate.h"
+
+#include <dom/core/string.h>
+
+#include "utils/character_valid.h"
+#include "utils/namespace.h"
+#include "utils/utils.h"
+
+/* An combination of various tests */
+static bool is_first_char(uint32_t ch);
+static bool is_name_char(uint32_t ch);
+
+/* Test whether the character can be the first character of
+ * a NCName. */
+static bool is_first_char(uint32_t ch)
+{
+ /* Refer http://www.w3.org/TR/REC-xml/ for detail */
+ if (((ch >= 'a') && (ch <= 'z')) ||
+ ((ch >= 'A') && (ch <= 'Z')) ||
+ (ch == '_') || (ch == ':') ||
+ ((ch >= 0xC0) && (ch <= 0xD6)) ||
+ ((ch >= 0xD8) && (ch <= 0xF6)) ||
+ ((ch >= 0xF8) && (ch <= 0x2FF)) ||
+ ((ch >= 0x370) && (ch <= 0x37D)) ||
+ ((ch >= 0x37F) && (ch <= 0x1FFF)) ||
+ ((ch >= 0x200C) && (ch <= 0x200D)) ||
+ ((ch >= 0x2070) && (ch <= 0x218F)) ||
+ ((ch >= 0x2C00) && (ch <= 0x2FEF)) ||
+ ((ch >= 0x3001) && (ch <= 0xD7FF)) ||
+ ((ch >= 0xF900) && (ch <= 0xFDCF)) ||
+ ((ch >= 0xFDF0) && (ch <= 0xFFFD)) ||
+ ((ch >= 0x10000) && (ch <= 0xEFFFF)))
+ return true;
+
+ if (is_letter(ch) || ch == (uint32_t) '_' || ch == (uint32_t) ':') {
+ return true;
+ }
+
+ return false;
+}
+
+/* Test whether the character can be a part of a NCName */
+static bool is_name_char(uint32_t ch)
+{
+ /* Refer http://www.w3.org/TR/REC-xml/ for detail */
+ if (((ch >= 'a') && (ch <= 'z')) ||
+ ((ch >= 'A') && (ch <= 'Z')) ||
+ ((ch >= '0') && (ch <= '9')) || /* !start */
+ (ch == '_') || (ch == ':') ||
+ (ch == '-') || (ch == '.') || (ch == 0xB7) || /* !start */
+ ((ch >= 0xC0) && (ch <= 0xD6)) ||
+ ((ch >= 0xD8) && (ch <= 0xF6)) ||
+ ((ch >= 0xF8) && (ch <= 0x2FF)) ||
+ ((ch >= 0x300) && (ch <= 0x36F)) || /* !start */
+ ((ch >= 0x370) && (ch <= 0x37D)) ||
+ ((ch >= 0x37F) && (ch <= 0x1FFF)) ||
+ ((ch >= 0x200C) && (ch <= 0x200D)) ||
+ ((ch >= 0x203F) && (ch <= 0x2040)) || /* !start */
+ ((ch >= 0x2070) && (ch <= 0x218F)) ||
+ ((ch >= 0x2C00) && (ch <= 0x2FEF)) ||
+ ((ch >= 0x3001) && (ch <= 0xD7FF)) ||
+ ((ch >= 0xF900) && (ch <= 0xFDCF)) ||
+ ((ch >= 0xFDF0) && (ch <= 0xFFFD)) ||
+ ((ch >= 0x10000) && (ch <= 0xEFFFF)))
+ return true;
+
+ if (is_letter(ch) == true)
+ return true;
+ if (is_digit(ch) == true)
+ return true;
+ if (is_combining_char(ch) == true)
+ return true;
+ if (is_extender(ch) == true)
+ return true;
+
+ if (ch == (uint32_t) '.' || ch == (uint32_t) '-' ||
+ ch == (uint32_t) '_' || ch == (uint32_t) ':')
+ return true;
+
+ return false;
+}
+
+/**
+ * Test whether the name is a valid one according XML 1.0 standard.
+ * For the standard please refer:
+ *
+ * http://www.w3.org/TR/2004/REC-xml-20040204/
+ *
+ * \param name The name need to be tested
+ * \return true if ::name is valid, false otherwise.
+ */
+bool _dom_validate_name(struct dom_string *name)
+{
+ uint32_t ch, len, i;
+ dom_exception err;
+
+ if (name == NULL)
+ return false;
+
+ len = dom_string_length(name);
+ if (len == 0)
+ return false;
+
+ /* Test the first character of this string */
+ err = dom_string_at(name, 0, &ch);
+ if (err != DOM_NO_ERR)
+ return false;
+
+ if (is_first_char(ch) == false)
+ return false;
+
+ /* Test all remain characters in this string */
+ for(i = 1; i < len; i++) {
+ err = dom_string_at(name, i, &ch);
+ if (err != DOM_NO_ERR)
+ return false;
+
+ if (is_name_char(ch) != true)
+ return false;
+ }
+
+ return true;
+}
+
+/**
+ * Validate whether the string is a legal NCName.
+ * Refer http://www.w3.org/TR/REC-xml-names/ for detail.
+ *
+ * \param str The name to validate
+ * \return true if ::name is valid, false otherwise.
+ */
+bool _dom_validate_ncname(struct dom_string *name)
+{
+ uint32_t ch, len, i;
+ dom_exception err;
+
+ if (name == NULL)
+ return false;
+
+ len = dom_string_length(name);
+ if (len == 0)
+ return false;
+
+ /* Test the first character of this string */
+ err = dom_string_at(name, 0, &ch);
+ if (err != DOM_NO_ERR)
+ return false;
+
+ if (is_letter(ch) == false && ch != (uint32_t) '_')
+ return false;
+
+ /* Test all remain characters in this string */
+ for(i = 1; i < len; i++) {
+ err = dom_string_at(name, i, &ch);
+ if (err != DOM_NO_ERR)
+ return false;
+
+ if (is_name_char(ch) == false)
+ return false;
+
+ if (ch == (uint32_t) ':')
+ return false;
+ }
+
+ return true;
+}
+
diff --git a/src/utils/validate.h b/src/utils/validate.h
new file mode 100644
index 0000000..5d375e7
--- /dev/null
+++ b/src/utils/validate.h
@@ -0,0 +1,26 @@
+/*
+ * This file is part of libdom.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+ *
+ * This file contains the API used to validate whether certain element's
+ * name/namespace are legal according the XML 1.0 standard. See
+ *
+ * http://www.w3.org/TR/2004/REC-xml-20040204/
+ *
+ * for detail.
+ */
+
+#ifndef dom_utils_valid_h_
+#define dom_utils_valid_h_
+
+#include <stdbool.h>
+
+struct dom_string;
+
+bool _dom_validate_name(struct dom_string *name);
+bool _dom_validate_ncname(struct dom_string *name);
+
+#endif
+
diff --git a/test/DOMTSHandler.pm b/test/DOMTSHandler.pm
new file mode 100644
index 0000000..c7dd61d
--- /dev/null
+++ b/test/DOMTSHandler.pm
@@ -0,0 +1,1541 @@
+# This is the PerSAX Handlers Package
+
+package DOMTSHandler;
+
+use Switch;
+
+use XML::XPath;
+use XML::XPath::XMLParser;
+
+our $description = 0;
+our $string_index = 0;
+our $ret_index = 0;
+our $condition_index = 0;
+our $test_index = 0;
+our $iterator_index = 0;
+our $temp_index = 0;
+# Sometimes, we need temp nodes
+our $tnode_index = 0;
+our $dom_feature = "\"XML\"";
+our %bootstrap_api = (
+ dom_implementation_create_document_type => "",
+ dom_implementation_create_document => "",
+);
+our %native_interface = (
+ DOMString => \&generate_domstring_interface,
+ DOMTimeStamp => "",
+ DOMUserData => "",
+ DOMObject =>"",
+);
+our %special_type = (
+ # Some of the type are not defined now!
+ boolean => "bool ",
+ int => "unsigned long ",
+ "unsigned long" => "unsigned long ",
+ DOMString => "dom_string *",
+ List => "list *",
+ Collection => "list *",
+ DOMImplementation => "dom_implementation *",
+ NamedNodeMap => "dom_namednodemap *",
+ NodeList => "dom_nodelist *",
+ CharacterData => "dom_characterdata *",
+ CDATASection => "dom_cdata_section *",
+);
+our %special_prefix = (
+ DOMString => "dom_string",
+ DOMImplementation => "dom_implementation",
+ NamedNodeMap => "dom_namednodemap",
+ NodeList => "dom_nodelist",
+ CharacterData => "dom_characterdata",
+ CDATASection => "dom_cdata_section *",
+);
+
+our %unref_prefix = (
+ DOMString => "dom_string",
+ NamedNodeMap => "dom_namednodemap",
+ NodeList => "dom_nodelist",
+);
+
+our %special_method = (
+);
+
+our %special_attribute = (
+ namespaceURI => "namespace",
+);
+
+our %no_unref = (
+ "boolean" => 1,
+ "int" => 1,
+ "unsigned int" => 1,
+ "List" => 1,
+ "Collection" => 1,
+);
+
+our %override_suffix = (
+ boolean => "bool",
+ int => "int",
+ "unsigned long" => "unsigned_long",
+ DOMString => "domstring",
+ DOMImplementation => "domimplementation",
+ NamedNodeMap => "domnamednodemap",
+ NodeList => "domnodelist",
+ Collection => "list",
+ List => "list",
+);
+
+our %exceptions = (
+
+ DOM_NO_ERR => 0,
+ DOM_INDEX_SIZE_ERR => 1,
+ DOM_DOMSTRING_SIZE_ERR => 2,
+ DOM_HIERARCHY_REQUEST_ERR => 3,
+ DOM_WRONG_DOCUMENT_ERR => 4,
+ DOM_INVALID_CHARACTER_ERR => 5,
+ DOM_NO_DATA_ALLOWED_ERR => 6,
+ DOM_NO_MODIFICATION_ALLOWED_ERR => 7,
+ DOM_NOT_FOUND_ERR => 8,
+ DOM_NOT_SUPPORTED_ERR => 9,
+ DOM_INUSE_ATTRIBUTE_ERR => 10,
+ DOM_INVALID_STATE_ERR => 11,
+ DOM_SYNTAX_ERR => 12,
+ DOM_INVALID_MODIFICATION_ERR => 13,
+ DOM_NAMESPACE_ERR => 14,
+ DOM_INVALID_ACCESS_ERR => 15,
+ DOM_VALIDATION_ERR => 16,
+ DOM_TYPE_MISMATCH_ERR => 17,
+ DOM_NO_MEM_ERR => (1<<16)
+);
+
+our @condition = qw(same equals notEquals less lessOrEquals greater greaterOrEquals isNull notNull and or xor not instanceOf isTrue isFalse hasSize contentType hasFeature implementationAttribute);
+
+our @exception = qw(INDEX_SIZE_ERR DOMSTRING_SIZE_ERR HIERARCHY_REQUEST_ERR WRONG_DOCUMENT_ERR INVALID_CHARACTER_ERR NO_DATA_ALLOWED_ERR NO_MODIFICATION_ALLOWED_ERR NOT_FOUND_ERR NOT_SUPPORTED_ERR INUSE_ATTRIBUTE_ERR NAMESPACE_ERR);
+
+our @assertion = qw(assertTrue assertFalse assertNull assertNotNull assertEquals assertNotEquals assertSame assertInstanceOf assertSize assertEventCount assertURIEquals);
+
+our @control = qw(if while for-each else);
+
+our @framework_statement = qw(assign increment decrement append plus subtract mult divide load implementation comment hasFeature implementationAttribute EventMonitor.setUserObj EventMonitor.getAtEvents EventMonitor.getCaptureEvents EventMonitor.getBubbleEvents EventMonitor.getAllEvents wait);
+
+sub new {
+ my $type = shift;
+ my $dtd = shift;
+ my $dd = XML::XPath->new(filename => $dtd);
+ my $self = {
+ # The DTD file of the xml files
+ dd => $dd,
+ # To indicate whether we are in comments
+ comment => 0,
+ # To indicate that whether we are in <comment> element
+ inline_comment => 0,
+ # The stack of elements encountered utill now
+ context => [],
+ # The map for <var> name => type
+ var => {},
+ # See the comment on generate_condition2 for this member
+ condition_stack => [],
+ # The list for UNREF
+ unref => [],
+ string_unref => [],
+ # The indent of current statement
+ indent => "",
+ # The variables for List/Collection
+ # We now, declare an array for a list and then add them into a list
+ # The map for all the List/Collection in one test
+ # "List Name" => "Member type"
+ list_map => {},
+ # The name of the current List/Collection
+ list_name => "",
+ # The number of items of the current List/Collection
+ list_num => 0,
+ # Whether List/Collection has members
+ list_hasmem => 0,
+ # The type of the current List/Collection
+ list_type => "",
+ # Whether we are in exception assertion
+ exception => 0,
+
+ };
+
+ return bless $self, $type;
+}
+
+sub start_element {
+ my ($self, $element) = @_;
+
+ my $en = $element->{Name};
+
+ my $dd = $self->{dd};
+ my $ct = $self->{context};
+ push(@$ct, $en);
+
+ switch ($en) {
+ case "test" {
+ ;
+ }
+ case "metadata" {
+ # start comments here
+ print "/*\n";
+ $self->{comment} = 1;
+ }
+
+ # Print the var definition
+ case "var" {
+ $self->generate_var($element->{Attributes});
+ }
+
+ case "member" {
+ if ($self->{context}->[-2] eq "var") {
+ if ($self->{"list_hasmem"} eq 1) {
+ print ", ";
+ }
+ $self->{"list_hasmem"} = 1;
+ $self->{"list_num"} ++;
+ }
+ }
+
+
+ # The framework statements
+ case [@framework_statement] {
+ # Because the implementationAttribute & hasFeature belongs to both
+ # framework-statement and condition, we should distinct the two
+ # situation here. Let the generate_condtion to do the work.
+ if ($en eq "hasFeature" || $en eq "implementationAttribute") {
+ next;
+ }
+
+ $self->generate_framework_statement($en, $element->{Attributes});
+ }
+
+ case [@control] {
+ $self->generate_control_statement($en, $element->{Attributes});
+ }
+
+ # Test condition
+ case [@condition] {
+ $self->generate_condition($en, $element->{Attributes});
+ }
+
+ # The assertsions
+ case [@assertion] {
+ $self->generate_assertion($en, $element->{Attributes});
+ }
+
+ case "assertDOMException" {
+ # Indeed, nothing to do here!
+ }
+
+ # Deal with exception
+ case [@exception] {
+ # Just see end_element
+ $self->{'exception'} = 1;
+ }
+
+ # Then catch other case
+ else {
+ # we don't care the comment nodes
+ if ($self->{comment} eq 0) {
+ $self->generate_interface($en, $element->{Attributes});
+ }
+ }
+ }
+}
+
+sub end_element {
+ my ($self, $element) = @_;
+
+ my @ct = @{$self->{context}};
+ my $name = pop(@{$self->{context}});
+
+ switch ($name) {
+ case "metadata" {
+ print "*/\n";
+ $self->{comment} = 0;
+ $self->generate_main();
+ }
+ case "test" {
+ $self->cleanup();
+ }
+
+ case "var" {
+ $self->generate_list();
+ }
+
+ # End of condition
+ case [@condition] {
+ $self->complete_condition($name);
+ }
+
+ # The assertion
+ case [@assertion] {
+ $self->complete_assertion($name);
+ }
+
+ case [@control] {
+ $self->complete_control_statement($name);
+ }
+
+ case [@exception] {
+ $name = "DOM_".$name;
+ print "assert(exp == $exceptions{$name});\n";
+ $self->{'exception'} = 0;
+ }
+
+ }
+}
+
+sub characters {
+ my ($self, $data) = @_;
+ our $description;
+
+ my $ct = $self->{context};
+
+ if ($self->{"inline_comment"} eq 1) {
+ print "$data->{Data}";
+ return ;
+ }
+
+ # We print the comments here
+ if ($self->{comment} eq 1) {
+ # So, we are in comments state
+ my $top = $ct->[$#{$ct}];
+ if ($top eq "metadata") {
+ return;
+ }
+
+ if ($top eq "description") {
+ if ($description eq 0) {
+ print "description: \n";
+ $description = 1;
+ }
+ print "$data->{Data}";
+ } else {
+ print "$top: $data->{Data}\n";
+ }
+ return;
+ }
+
+ if ($self->{context}->[-1] eq "member") {
+ # We should mark that the List/Collection has members
+ $self->{"list_hasmem"} = 1;
+
+ # Here, we should detect the characters type
+ # whether it is a integer or string (now, we only take care
+ # of the two types, because I did not find any other type).
+ if ($self->{"list_type"} eq "") {
+ if ($data->{Data} =~ /^\"/) {
+ $self->{"list_type"} = "char *";
+ print "char *".$self->{"list_name"}."Array[] = \{ $data->{Data}";
+ } else {
+ if ($data->{Data} =~ /^[0-9]+/) {
+ $self->{"list_type"} = "int *";
+ print "int ".$self->{"list_name"}."Array[] = \{ $data->{Data}";
+ } else {
+ die "Some data in the <member> we can't process: \"$data->{Data}\"";
+ }
+ }
+ } else {
+ # So, we must have known the type, just output the member
+ print "$data->{Data}";
+ }
+ }
+}
+
+sub generate_main {
+ my $self = shift;
+ # Firstly, push a new "b" to the string_unref list
+ push(@{$self->{"string_unref"}}, "b");
+
+ print << "__EOF__"
+
+#include <stdio.h>
+#include <string.h>
+#include <stdbool.h>
+
+#include <dom/dom.h>
+#include <dom/functypes.h>
+
+#include <domts.h>
+
+dom_implementation *doc_impl;
+lwc_context *ctx;
+
+int main(int argc, char **argv)
+{
+ dom_exception exp;
+ lwc_error lerr;
+
+ /* Firstly, initialise dom and dom implementations */
+ exp = dom_initialise(myrealloc, NULL);
+ if (exp != DOM_NO_ERR)
+ return exp;
+
+ lerr = lwc_create_context(myrealloc, NULL, &ctx);
+ if (lerr != lwc_error_ok)
+ return -1;
+
+__EOF__
+}
+
+# Note that, we have not just declare variables here
+# we should also define EventListener here!
+# I think this should be done after the EventListener design
+# is complete
+sub generate_var {
+ my ($self, $ats) = @_;
+
+ my $type = "";
+ my $dstring = "";
+
+ # For the case like <var name="v" type="DOMString" value="some some"
+ if ($ats->{"type"} eq "DOMString" and exists $ats->{"value"}) {
+ $dstring = $self->generate_domstring($ats->{"value"});
+ $ats->{"value"} = $dstring;
+ }
+
+ $type = type_to_ctype($ats->{"type"});
+ if ($type eq "") {
+ print "Not implement this type now\n";
+ return;
+ }
+
+ print "\t$type$ats->{'name'}";
+ if (exists $ats->{"value"}) {
+ print " = $ats->{'value'};\n";
+ } else {
+ if ($type =~ m/\*/) {
+ print " = NULL;";
+ } else {
+ print ";\n";
+ }
+ }
+
+ my $var = $self->{"var"};
+ $var->{$ats->{"name"}} = $ats->{"type"};
+
+ # If the type is List/Collection, we should take care of it
+ if ($ats->{"type"} =~ /^(List|Collection)$/) {
+ $self->{"list_name"} = $ats->{"name"};
+ }
+}
+
+sub generate_list {
+ my $self = shift;
+
+ # We should deal with the end of <var> when the <var> is declaring a List/Collection
+ if ($self->{"list_hasmem"} eq 1) {
+ # Yes, we are in List/Collection declaration
+ # Firstly, enclose the Array declaration
+ print "};\n";
+
+ # Now, we should create the list * for the List/Collection
+ # Note, we should deal with "int" or "string" type with different params.
+ if ($self->{"list_type"} eq "char *") {
+ print $self->{"list_name"}." = list_new(STRING);\n";
+ }
+ if ($self->{"list_type"} eq "int *") {
+ print $self->{"list_name"}." = list_new(INT);\n";
+ }
+ if ($self->{"list_type"} eq "") {
+ die "A List/Collection has children member but no type is impossible!";
+ }
+ for (my $i = 0; $i < $self->{"list_num"}; $i++) {
+ # Use *(char **) to convert char *[] to char *
+ print "list_add(".$self->{"list_name"}.", *(char **)(".$self->{"list_name"}."Array + $i));\n";
+ }
+ } else {
+ if ($self->{"list_name"} ne "") {
+ #TODO: generally, we set the list type as dom_string, but it may be dom_node
+ print $self->{"list_name"}." = list_new(DOM_STRING);\n";
+ $self->{"list_type"} = "DOMString";
+ }
+ }
+
+ # Add the List/Collection to map
+ $self->{"list_map"}->{$self->{"list_name"}} = $self->{"list_type"};
+
+ # Reset the List/Collection member state
+ $self->{"list_hasmem"} = 0;
+ $self->{"list_name"} = "";
+ $self->{"list_type"} = "";
+ $self->{"list_num"} = 0;
+}
+
+sub generate_load {
+ my ($self, $a) = @_;
+ my %ats = %$a;
+ my $doc = $ats{"var"};
+
+ $test_index ++;
+ # define the test file path, use HTML if there is, otherwise using XML
+ # Attention: I intend to copy the test files to the program excuting dir
+ print "\tchar *test$test_index = \"$ats{'href'}.html\";\n\n";
+ print "$doc = load_html(test$test_index, $ats{'willBeModified'});";
+ print "if ($doc == NULL) {";
+ $test_index ++;
+ print " char *test$test_index = \"$ats{'href'}.xml\";\n\n";
+ print " $doc = load_xml(test$test_index, $ats{'willBeModified'});";
+ print " if ($doc == NULL)";
+ print " return 1;";
+ print "}";
+ print << "__EOF__";
+exp = dom_document_get_implementation($doc, &doc_impl);
+if (exp != DOM_NO_ERR)
+ return exp;
+__EOF__
+
+ $self->addto_cleanup($doc);
+}
+
+sub generate_framework_statement {
+ my ($self, $name, $ats) = @_;
+
+ switch($name) {
+ case "load" {
+ $self->generate_load($ats);
+ }
+
+ case "assign" {
+ my $var = $ats->{"var"};
+ my $value = "0";
+ if (exists $ats->{"value"}) {
+ $value = $ats->{"value"};
+ }
+
+ # Assign with strong-type-conversion, this is necessary in C.
+ # And we may need to do deep-copy in the future. FIXME
+ my $type = type_to_ctype($self->{"var"}->{$var});
+ print "$var = \($type\) $value;\n";
+ }
+
+ case "increment" {
+ my $var = $ats->{"var"};
+ my $value = $ats->{"value"};
+
+ print "$var += $value;\n";
+ }
+
+ case "decrement" {
+ my $var = $ats->{"var"};
+ my $value = $ats->{"value"};
+
+ print "$var -= $value;\n";
+ }
+
+ case "append" {
+ my $col = $ats->{"collection"};
+ my $obj = "";
+
+ # God, the DTD said, there should be a "OBJ" attribute, but there may not!
+ if (exists $ats->{"obj"}) {
+ $obj = $ats->{"obj"};
+ } else {
+ $obj = $ats->{"item"}
+ }
+
+ if (not $self->{"var"}->{$col} =~ /^(List|Collection)/) {
+ die "Append data to some non-list type!";
+ }
+
+ print "list_add($col, $obj);\n";
+ }
+
+ case [qw(plus subtract mult divide)] {
+ my $var = $ats->{"var"};
+ my $op1 = $ats->{"op1"};
+ my $op2 = $ats->{"op2"};
+
+ my %table = ("plus", "+", "subtract", "-", "mult", "*", "divide", "/");
+ print "$var = $op1 $table{$name} $op2;\n";
+ }
+
+ case "comment" {
+ print "\*";
+ $self->{"inline_comment"} = 1;
+ }
+
+ case "implementation" {
+ if (not exists $ats->{"obj"}) {
+ my $var = $ats->{"var"};
+ my $dstring = generate_domstring($self, $dom_feature);
+ print "exp = dom_implregistry_get_dom_implementation($dstring, \&$var);";
+ print "if (exp != DOM_NO_ERR) {";
+ $self->cleanup_fail("\t\t");
+ print "return exp;}";
+ last;
+ }
+
+ my $obj = $ats->{"obj"};
+ my $var = $ats->{"var"};
+ # Here we directly output the libDOM's get_implementation API
+ print "exp = dom_document_get_implementation($obj, \&$var);";
+ print "if (exp != DOM_NO_ERR) {";
+ $self->cleanup_fail("\t\t");
+ print "return exp;}";
+ }
+
+ # We deal with hasFeaturn and implementationAttribute in the generate_condition
+ case "hasFeature" {
+ die "No, never can be here!";
+ }
+ case "implementaionAttribute" {
+ die "No, never can be here!";
+ }
+
+ # Here, we die because we did not implement other statements
+ # We did not implement these statements, because there are no use of them in the W3C DOMTS now
+ case [@framework_statement] {
+ die "The statement \"$name\" is not implemented yet!";
+ }
+
+ }
+}
+
+sub complete_framework_statement {
+ my ($self, $name) = @_;
+
+ switch($name) {
+ case "comment" {
+ print "*/\n";
+ $self->{"inline_comment"} = 0;
+ }
+ }
+}
+
+sub generate_interface {
+ my ($self, $en, $a) = @_;
+ my %ats = %$a;
+ my $dd = $self->{dd};
+
+ if (exists $ats{'interface'}) {
+ # Firstly, test whether it is a DOM native interface
+ if (exists $native_interface{$ats{'interface'}}) {
+ if ($native_interface{$ats{'interface'}} eq "") {
+ die "Unkown how to deal with $en of $ats{'interface'}";
+ }
+
+ return $native_interface{$ats{'interface'}}($self, $en, $a);
+ }
+
+ my $ns = $dd->find("/library/interface[\@name=\"$ats{'interface'}\"]/method[\@name=\"$en\"]");
+ if ($ns->size() != 0) {
+ my $node = $ns->get_node(1);
+ $self->generate_method($en, $node, %ats);
+ } else {
+ my $ns = $dd->find("/library/interface[\@name=\"$ats{'interface'}\"]/attribute[\@name=\"$en\"]");
+ if ($ns->size() != 0) {
+ my $node = $ns->get_node(1);
+ $self->generate_attribute_accessor($en, $node, %ats);
+ }
+ }
+ } else {
+ my $ns = $dd->find("/library/interface/method[\@name=\"$en\"]");
+ if ($ns->size() != 0) {
+ my $node = $ns->get_node(1);
+ $self->generate_method($en, $node, %ats);
+ } else {
+ my $ns = $dd->find("/library/interface/attribute[\@name=\"$en\"]");
+ if ($ns->size() != 0) {
+ my $node = $ns->get_node(1);
+ $self->generate_attribute_accessor($en, $node, %ats);
+ } else {
+ die "Oh, Can't find how to deal with the element $en\n";
+ }
+ }
+ }
+}
+
+sub generate_method {
+ my ($self, $en, $node, %ats) = @_;
+ my $dd = $self->{dd};
+ if (! exists $ats{'interface'}) {
+ my $n = $node;
+ while($n->getLocalName() ne "interface") {
+ $n = $n->getParentNode();
+ }
+ $ats{'interface'} = $n->getAttribute("name");
+ }
+
+ $method = to_cmethod($ats{'interface'}, $en);
+
+ my $ns = $dd->find("parameters/param", $node);
+ my $params = "$ats{'obj'}";
+ for ($count = 1; $count <= $ns->size; $count++) {
+ my $n = $ns->get_node($count);
+ my $p = $n->getAttribute("name");
+ my $t = $n->getAttribute("type");
+
+ # Change the raw string and the char * to dom_string
+ if ($t eq "DOMString") {
+ if ($ats{$p} =~ /^"/ or $self->{"var"}->{$ats{$p}} eq "char *") {
+ $self->generate_domstring($ats{$p});
+ $params = $params.", dstring$string_index";
+ next;
+ }
+ }
+
+ # For the case that the testcase did not provide the param, we just pass a NULL
+ # Because we are in C, not like C++ which can overriden functions
+ if (not exists $ats{$p}) {
+ $params = $params.", NULL";
+ next;
+ }
+
+ $params = $params.", $ats{$p}";
+ }
+
+ #$ns = $dd->find("returns", $node);
+ #my $n = $ns->get_node(1);
+ #my $t = $n->getAttribute("type");
+ # declare the return value
+ #my $tp = type_to_ctype($t);
+ #print "\t$tp ret$ret_index;\n";
+ my $unref = 0;
+ my $temp_node = 0;
+ if (exists $ats{'var'}) {
+ # Add the bootstrap params
+ if (exists $bootstrap_api{$method}) {
+ $params = $params.", myrealloc, NULL, ctx";
+ }
+ # Deal with the situation like
+ #
+ # dom_node_append_child(node, new_node, &node);
+ #
+ # Here, we should import a tempNode, and change this expression to
+ #
+ # dom_node *tnode1 = NULL;
+ # dom_node_append_child(node, new_node, &tnode1);
+ # dom_node_unref(node);
+ # node = tnode1;
+ #
+ # Over.
+ if ($ats{'obj'} eq $ats{'var'}) {
+ my $t = type_to_ctype($self->{'var'}->{$ats{'var'}});
+ $tnode_index ++;
+ print "$t tnode$tnode_index = NULL;";
+ $params = $params.", \&tnode$tnode_index";
+ # The ats{'obj'} must have been added to cleanup stack
+ $unref = 1;
+ # Indicate that we have created a temp node
+ $temp_node = 1;
+ } else {
+ $params = $params.", (void *) \&$ats{'var'}";
+ $unref = $self->param_unref($ats{'var'});
+ }
+ }
+
+ print "exp = $method($params);";
+
+ if ($self->{'exception'} eq 0) {
+ print << "__EOF__";
+ if (exp != DOM_NO_ERR) {
+ fprintf(stderr, "Exception raised from %s\\n", "$method");
+__EOF__
+
+ $self->cleanup_fail("\t\t");
+ print << "__EOF__";
+ return exp;
+ }
+__EOF__
+ }
+
+ if (exists $ats{'var'} and $unref eq 0) {
+ $self->addto_cleanup($ats{'var'});
+ }
+
+ if ($temp_node eq 1) {
+ my $t = $self->{'var'}->{$ats{'var'}};
+ if (not exists $no_unref{$t}) {
+ my $prefix = "dom_node";
+ if (exists $unref_prefix{$t}) {
+ $prefix = $unref_prefix{$t};
+ }
+ print $prefix."_unref(".$ats{'obj'}.");\n";
+ }
+ print "$ats{'var'} = tnode$tnode_index;";
+ }
+}
+
+sub generate_attribute_accessor {
+ my ($self, $en, $node, %ats) = @_;
+
+ if (defined($ats{'var'})) {
+ generate_attribute_fetcher(@_);
+ } else {
+ if (defined($ats{'value'})) {
+ generate_attribute_setter(@_);
+ }
+ }
+}
+
+sub generate_attribute_fetcher {
+ my ($self, $en, $node, %ats) = @_;
+ my $dd = $self->{dd};
+ if (! exists $ats{'interface'}) {
+ my $n = $node;
+ while($n->getLocalName() ne "interface") {
+ $n = $n->getParentNode();
+ }
+ $ats{'interface'} = $n->getAttribute("name");
+ }
+
+ my $fetcher = to_attribute_fetcher($ats{'interface'}, "$en");
+
+ my $unref = 0;
+ my $temp_node = 0;
+ # Deal with the situation like
+ #
+ # dom_node_get_next_sibling(child, &child);
+ #
+ # Here, we should import a tempNode, and change this expression to
+ #
+ # dom_node *tnode1 = NULL;
+ # dom_node_get_next_sibling(child, &tnode1);
+ # dom_node_unref(child);
+ # child = tnode1;
+ #
+ # Over.
+ if ($ats{'obj'} eq $ats{'var'}) {
+ my $t = type_to_ctype($self->{'var'}->{$ats{'var'}});
+ $tnode_index ++;
+ print "$t tnode$tnode_index = NULL;";
+ print "exp = $fetcher($ats{'obj'}, \&tnode$tnode_index);";
+ # The ats{'obj'} must have been added to cleanup stack
+ $unref = 1;
+ # Indicate that we have created a temp node
+ $temp_node = 1;
+ } else {
+ $unref = $self->param_unref($ats{'var'});
+ print "exp = $fetcher($ats{'obj'}, \&$ats{'var'});";
+ }
+
+
+ if ($self->{'exception'} eq 0) {
+ print << "__EOF__";
+ if (exp != DOM_NO_ERR) {
+ fprintf(stderr, "Exception raised when fetch attribute %s", "$en");
+__EOF__
+ $self->cleanup_fail("\t\t");
+ print << "__EOF__";
+ return exp;
+ }
+__EOF__
+ }
+
+ if ($temp_node eq 1) {
+ my $t = $self->{'var'}->{$ats{'var'}};
+ if (not exists $no_unref{$t}) {
+ my $prefix = "dom_node";
+ if (exists $unref_prefix{$t}) {
+ $prefix = $unref_prefix{$t};
+ }
+ print $prefix."_unref(".$ats{'obj'}.");\n";
+ }
+ print "$ats{'var'} = tnode$tnode_index;";
+ }
+
+ if ($unref eq 0) {
+ $self->addto_cleanup($ats{'var'});
+ }
+}
+
+sub generate_attribute_setter {
+ my ($self, $en, $node, %ats) = @_;
+ my $dd = $self->{dd};
+ if (! exists $ats{'interface'}) {
+ my $n = $node;
+ while($n->getLocalName() ne "interface") {
+ $n = $n->getParentNode();
+ }
+ $ats{'interface'} = $n->getAttribute("name");
+ }
+
+ my $setter = to_attribute_setter($ats{'interface'}, "$en");
+ my $param = "$ats{'obj'}";
+
+ # For DOMString, we should deal specially
+ my $lp = $ats{'value'};
+ if ($node->getAttribute("type") eq "DOMString") {
+ if ($ats{'value'} =~ /^"/ or $self->{"var"}->{$ats{'value'}} eq "char *") {
+ $lp = $self->generate_domstring($ats{'value'});
+ }
+ }
+
+ $param = $param.", $lp";
+
+ print "exp = $setter($param);";
+
+ if ($self->{'exception'} eq 0) {
+ print << "__EOF__";
+ if (exp != DOM_NO_ERR) {
+ fprintf(stderr, "Exception raised when fetch attribute %s", "$en");
+__EOF__
+ $self->cleanup_fail("\t\t");
+ print << "__EOF__";
+ return exp;
+ }
+__EOF__
+ }
+
+}
+
+
+sub generate_condition {
+ my ($self, $name, $ats) = @_;
+
+ # If we are in nested or/and/xor/not, we should put a operator before test
+ my @array = @{$self->{condition_stack}};
+ if ($#array ge 0) {
+ switch ($array[-1]) {
+ case "xor" {
+ print " ^ ";
+ }
+ case "or" {
+ print " || ";
+ }
+ case "and" {
+ print " && ";
+ }
+ # It is the indicator, just pop it.
+ case "new" {
+ pop(@{$self->{condition_stack}});
+ }
+ }
+ }
+
+ switch ($name) {
+ case [qw(less lessOrEquals greater greaterOrEquals)] {
+ my $actual = $ats->{actual};
+ my $expected = $ats->{expected};
+ my $method = $name;
+ $method =~ s/[A-Z]/_$&/g;
+ $method = lc $method;
+ print "$method($expected, $actual)";
+ }
+
+ case "same" {
+ my $actual = $ats->{actual};
+ my $expected = $ats->{expected};
+ my $func = $self->find_override("is_same", $actual, $expected);
+ print "$func($expected, $actual)";
+ }
+
+ case [qw(equals notEquals)]{
+ my $actual = $ats->{actual};
+ my $expected = $ats->{expected};
+ my $ig;
+ if (exists $ats->{ignoreCase}){
+ $ig = $ats->{ignoreCase};
+ } else {
+ $ig = "false";
+ }
+ $ig = adjust_ignore($ig);
+
+ my $func = $self->find_override("is_equals", $actual, $expected);
+ if ($name =~ /not/i){
+ print "(false == $func($expected, $actual, $ig))";
+ } else {
+ print "$func($expected, $actual, $ig)";
+ }
+ }
+
+ case [qw(isNull notNull)]{
+ my $obj = $ats->{obj};
+ if ($name =~ /not/i) {
+ print "(false == is_null($obj))";
+ } else {
+ print "is_null($obj)";
+ }
+ }
+
+ case "isTrue" {
+ my $value = $ats->{value};
+ print "is_true($value)";
+ }
+
+ case "isFalse" {
+ my $value = $ats->{value};
+ print "(false == is_true($value))";
+ }
+
+ case "hasSize" {
+ my $obj = $ats->{obj};
+ my $size = $ats->{expected};
+ my $func = $self->find_override("is_size", $obj, $size);
+ print "$func($size, $obj)";
+ }
+
+ case "contentType" {
+ my $type = $ats->{type};
+ print "is_contenttype(\"$type\")";
+ }
+
+ case "instanceOf" {
+ my $obj = $ats->{obj};
+ my $type = $ats->{type};
+ print "instanceOf(\"$type\", $obj)";
+ }
+
+ case "hasFeature" {
+ if (exists $ats->{var}) {
+ $self->generate_interface($name, $ats);
+ } else {
+ my $feature = $ats->{feature};
+ if (not ($feature =~ /^"/)) {
+ $feature = '"'.$feature.'"';
+ }
+ my $version = "NULL";
+ if (exists $ats->{version}) {
+ $version = $ats->{version};
+ if (not ($version =~ /^"/)) {
+ $version = '"'.$version.'"';
+ }
+
+ }
+
+ if ($self->{context}->[-2] ne "condition") {
+ # we are not in a %condition place, so we must be a statement
+ # we change this to assert
+ # print "assert(has_feature($feature, $version));\n"
+ # do nothing if we are not in condition.
+ } else {
+ print "has_feature($feature, $version)";
+ }
+ }
+ }
+
+ case "implementationAttribute" {
+ my $value = $ats->{value};
+ my $name = $ats->{name};
+
+ if ($self->{context}->[-2] ne "condition") {
+ # print "assert(implementation_attribute(\"$name\", $value));";
+ # Do nothing, and the same with hasFeature, this means we will
+ # run all test cases now and try to get a result whether we support
+ # such feature.
+ } else {
+ print "implementation_attribute(\"$name\", $value)";
+ }
+ }
+
+ case [qw(and or xor)] {
+ push(@{$self->{condition_stack}}, $name);
+ push(@{$self->{condition_stack}}, "new");
+ print "(";
+ }
+
+ case "not" {
+ push(@{$self->{condition_stack}}, $name);
+ print "(false == ";
+ }
+ }
+
+}
+
+sub complete_condition {
+ my ($self, $name) = @_;
+
+ if ($name =~ /^(xor|or|and)$/i) {
+ print ")";
+ my $top = pop(@{$self->{condition_stack}});
+ die "Condition stack error! $top != $name" if $top ne $name;
+ }
+
+ if ($name eq "not") {
+ my $top = pop(@{$self->{condition_stack}});
+ die "Condition stack error! $top != $name" if $top ne $name;
+ print ")";
+ }
+
+ # we deal with the situation that the %condition is in a control statement such as
+ # <if> or <while>, and we should start a new '{' block here
+ if ($self->{context}->[-1] eq "condition") {
+ print ") {\n";
+ pop(@{$self->{context}});
+ }
+}
+
+sub generate_assertion {
+ my ($self, $name, $ats) = @_;
+
+ print "\tassert(";
+ switch($name){
+ # Only assertTrue & assertFalse can have nested %conditions
+ case [qw(assertTrue assertFalse assertNull)] {
+ my $n = $name;
+ $n =~ s/assert/is/g;
+ if (exists $ats->{actual}){
+ my $ta = { value => $ats->{actual}, obj => $ats->{actual}};
+ $self->generate_condition($n,$ta);
+ }
+ }
+
+ case [qw(assertNotNull assertEquals assertNotEquals assertSame)] {
+ my $n = $name;
+ $n =~ s/assert//g;
+ $n = lcfirst $n;
+ if (exists $ats->{actual}){
+ my $ta = {
+ actual => $ats->{actual},
+ value => $ats->{actual},
+ obj => $ats->{actual},
+ expected => $ats->{expected},
+ ignoreCase => $ats->{ignoreCase},
+ type => $ats->{type},
+ };
+ $self->generate_condition($n,$ta);
+ }
+ }
+
+ case "assertInstanceOf" {
+ my $obj = $ats->{obj};
+ my $type = $ats->{type};
+ print "is_instanceof(\"$type\", $obj)";
+ }
+
+ case "assertSize" {
+ my $n = $name;
+ $n =~ s/assert/has/;
+ if (exists $ats->{collection}){
+ my $ta = { obj => $ats->{collection}, expected => $ats->{size}};
+ $self->generate_condition($n,$ta);
+ }
+ }
+
+ case "assertEventCount" {
+ #todo
+ }
+
+ case "assertURIEquals" {
+ my $actual = $ats->{actual};
+ my ($scheme, $path, $host, $file, $query, $fragment, $isAbsolute) = qw(NULL NULL NULL NULL NULL NULL NULL);
+ if (exists $ats->{scheme}) {
+ $scheme = $ats->{scheme};
+ }
+ if (exists $ats->{path}) {
+ $path = $ats->{path};
+ }
+ if (exists $ats->{host}) {
+ $host = $ats->{host};
+ }
+ if (exists $ats->{file}) {
+ $file = $ats->{file};
+ }
+ if (exists $ats->{query}) {
+ $query = $ats->{query};
+ }
+ if (exists $ats->{fragment}) {
+ $fragment = $ats->{fragment};
+ }
+ if (exists $ats->{isAbsolute}) {
+ $isAbsolute = $ats->{isAbsolute};
+ }
+
+ print "is_uri_equals($scheme, $path, $host, $file, $query, $fragment, $isAbsolute, $actual)"
+ }
+ }
+
+}
+
+sub complete_assertion {
+ my ($self, $name) = @_;
+
+ print ");\n";
+}
+
+sub generate_control_statement {
+ my ($self, $name, $ats) = @_;
+
+ switch($name) {
+ case "if" {
+ print "\tif(";
+ push(@{$self->{"context"}}, "condition");
+ }
+
+ case "else" {
+ $self->cleanup_block_domstring();
+ print "\t} else {";
+ }
+
+ case "while" {
+ print "\twhile (";
+ push(@{$self->{"context"}}, "condition");
+ }
+
+ case "for-each" {
+ # Detect what is the collection type, if it is "string", we
+ # should also do some conversion work
+ my $coll = $ats->{"collection"};
+ # The default member type is dom_node
+ my $type = "dom_node *";
+ if (exists $self->{"list_map"}->{$coll}) {
+ $type = $self->{"list_map"}->{$coll};
+ }
+
+ # Find the member variable, if it is not declared before, declare it firstly
+ my $member = $ats->{"member"};
+ if (not exists $self->{"var"}->{$member}) {
+ print "$type $member;\n";
+ # Add the new variable to the {var} map
+ $self->{"var"}->{"$member"} = $type;
+ }
+
+ # Now the member is conformed to be declared
+ if ($self->{"var"}->{$coll} =~ /^(List|Collection)$/) {
+ # The element in the list is not equal with the member object
+ # For now, there is only one case for this, it is "char *" <=> "DOMString"
+ my $conversion = 0;
+ if ($self->{"var"}->{"$member"} ne $type) {
+ if ($self->{"var"}->{"$member"} eq "DOMString") {
+ if ($type eq "char *") {
+ $conversion = 1;
+ }
+ }
+ }
+
+ $iterator_index++;
+ print "unsigned int iterator$iterator_index = 0;";
+ if ($conversion eq 1) {
+ print "char *tstring$temp_index = NULL;";
+ }
+ print "foreach_initialise_list($coll, \&iterator$iterator_index);\n";
+ print "while(get_next_list($coll, \&iterator$iterator_index, ";
+ if ($conversion eq 1) {
+ print "\&tstring$temp_index)) {\n";
+ print "exp = dom_string_create(myrealloc, NULL, (const uint8_t *)tstring$temp_index,";
+ print "strlen(tstring$temp_index), &$member);";
+ print "if (exp != DOM_NO_ERR) {";
+ print "fprintf(stderr, \"Can't create DOMString\\n\");";
+ $self->cleanup_fail("\t\t");
+ print "return exp; }";
+ $temp_index ++;
+ } else {
+ print "\&$member)) {\n";
+ }
+ }
+
+ if ($self->{"var"}->{$coll} eq "NodeList") {
+ $iterator_index++;
+ print "unsigned int iterator$iterator_index = 0;";
+ print "foreach_initialise_domnodelist($coll, \&iterator$iterator_index);\n";
+ print "while(get_next_domnodelist($coll, \&iterator$iterator_index, \&$member)) {\n";
+ }
+
+ if ($self->{"var"}->{$coll} eq "NamedNodeMap") {
+ $iterator_index++;
+ print "unsigned int iterator$iterator_index = 0;";
+ print "foreach_initialise_domnamednodemap($coll, \&iterator$iterator_index);\n";
+ print "while(get_next_domnamednodemap($coll, \&iterator$iterator_index, \&$member)) {\n";
+ }
+ }
+ }
+
+ # Firstly, we enter a new block, so push a "b" into the string_unref list
+ push(@{$self->{"string_unref"}}, "b");
+}
+
+sub complete_control_statement {
+ my ($self, $name) = @_;
+
+ # Note: we only print a '}' when <if> element ended but not <else>
+ # The reason is that there may be no <else> element in <if> and
+ # we when there is an <else> element, it must nested in <if>. ^_^
+ switch($name) {
+ case [qw(if while for-each)] {
+ # Firstly, we should cleanup the dom_string in this block
+ $self->cleanup_block_domstring();
+
+ print "}\n";
+ }
+ }
+}
+
+
+###############################################################################
+#
+# The helper functions
+#
+sub generate_domstring {
+ my ($self, $str) = @_;
+ $string_index = $string_index + 1;
+
+ print << "__EOF__";
+ const char *string$string_index = $str;
+ dom_string *dstring$string_index;
+ exp = dom_string_create(myrealloc, NULL, (const uint8_t *)string$string_index,
+ strlen(string$string_index), &dstring$string_index);
+ if (exp != DOM_NO_ERR) {
+ fprintf(stderr, "Can't create DOMString\\n");
+__EOF__
+ $self->cleanup_fail("\t\t");
+ print << "__EOF__";
+ return exp;
+ }
+
+__EOF__
+
+ push(@{$self->{string_unref}}, "$string_index");
+
+ return "dstring$string_index";
+}
+
+sub cleanup_domstring {
+ my ($self, $indent) = @_;
+
+ for (my $i = 0; $i <= $#{$self->{string_unref}}; $i++) {
+ if ($self->{string_unref}->[$i] ne "b") {
+ print $indent."dom_string_unref(dstring$self->{string_unref}->[$i]);\n";
+ }
+ }
+}
+
+sub cleanup_block_domstring {
+ my $self = shift;
+
+ while ((my $num = pop(@{$self->{string_unref}})) ne "b" and $#{$self->{string_unref}} ne -1) {
+ print "dom_string_unref(dstring$num);\n";
+ }
+}
+
+sub type_to_ctype {
+ my $type = shift;
+
+ if (exists $special_type{$type}) {
+ return $special_type{$type};
+ }
+
+ # If the type is not specially treated, we can transform it by rules
+ if ($type =~ m/^HTML/) {
+ # Don't deal with this now
+ return "";
+ }
+
+ # The core module comes here
+ $type =~ s/[A-Z]/_$&/g;
+ $type = lc $type;
+ return "dom".$type." *";
+}
+
+sub to_cmethod {
+ my ($type, $m) = @_;
+ my $prefix = get_prefix($type);
+ my $ret;
+
+ if (exists $special_method{$m}) {
+ $ret = $prefix."_".$special_method{$m};
+ } else {
+ $m =~ s/[A-Z]/_$&/g;
+ $m = lc $m;
+ $ret = $prefix."_".$m;
+ }
+
+ $ret =~ s/h_t_m_l/html/;
+ $ret =~ s/c_d_a_t_a/cdata/;
+ $ret =~ s/_n_s$/_ns/;
+ return $ret;
+}
+
+sub to_attribute_fetcher {
+ return to_attribute_accessor(@_, "get");
+}
+
+sub to_attribute_setter {
+ return to_attribute_accessor(@_, "set");
+}
+
+sub to_attribute_accessor {
+ my ($type, $af, $accessor) = @_;
+ my $prefix = get_prefix($type);
+ my $ret;
+
+ if (exists $special_attribute{$af}) {
+ $ret = $prefix."_".$accessor."_".$special_attribute{$af};
+ } else {
+ $af =~ s/[A-Z]/_$&/g;
+ $af = lc $af;
+ $ret = $prefix."_".$accessor."_".$af;
+ }
+
+ $ret =~ s/h_t_m_l/html/;
+ return $ret;
+}
+
+sub get_prefix {
+ my $type = shift;
+
+ if (exists $special_prefix{$type}) {
+ $prefix = $special_prefix{$type};
+ } else {
+ $type =~ s/[A-Z]/_$&/g;
+ $prefix = lc $type;
+ $prefix = "dom".$prefix;
+ }
+ return $prefix;
+}
+
+# This function remain unsed
+sub get_suffix {
+ my $type = shift;
+ my $suffix = "default";
+
+ if (exists $override_suffix{$type}) {
+ $suffix = $override_suffix{$type};
+ } else {
+ $type =~ s/[A-Z]/_$&/g;
+ $suffix = lc $type;
+ $suffix = "dom".$suffix;
+ }
+ return $suffix;
+}
+
+#asserttions sometimes can contain sub-statements according the DTD. Like
+#<assertEquals ..>
+# <stat1 />
+# <stat2 />
+#</assertEquals>
+#
+# And assertion can contains assertions too! So, I use the assertion_stack
+# to deal:
+#
+# when we encounter an assertion, we push $assertionName, "end", "start" to
+# the stack, and when we encounter a statement, we examine the stack to see
+# the top element, if it is:
+#
+# 1. "start", then we are in sub-statement of that assertion, and this is the
+# the first sub-statement, so we should print a if (condtion==true) {, before
+# print the real statement.
+# 2. "end", then we are in sub-statement of that assertion, and we are not the
+# first one, just print the statement.
+#
+# But after searching the whole testcases, I found no use of sub-statements of assertions.
+# So, this function left unsed!
+
+sub end_half_assertion {
+ my ($self, $name) = @_;
+
+ my $top = pop(@{$self->{assertion_stack}});
+ if ($top eq "end") {
+ print "$self->{indent}"."}\n";
+ } else {
+ if ($top eq "start") {
+ pop(@{$self->{assertion_stack}});
+ pop(@{$self->{assertion_stack}});
+ }
+ }
+
+ pop(@{$self->{assertion_stack}});
+}
+### Enclose an unsed function
+##############################################################################################
+
+
+sub cleanup_domvar {
+ my ($self, $indent) = @_;
+
+ my $str = join($indent, @{$self->{unref}});
+ print $indent.$str."\n";
+}
+
+sub cleanup_fail {
+ my ($self, $indent) = @_;
+
+ $self->cleanup_domstring($indent);
+ $self->cleanup_domvar($indent);
+}
+
+sub cleanup {
+ my $self = shift;
+
+ print "\n\n";
+ $self->cleanup_domstring("\t");
+ $self->cleanup_domvar("\t");
+ print "\n\treturn 0;\n";
+ print "\n\}\n";
+}
+
+sub addto_cleanup {
+ my ($self, $var) = @_;
+
+ my $type = $self->{'var'}->{$var};
+ if (not exists $no_unref{$type}) {
+ my $prefix = "dom_node";
+ if (exists $unref_prefix{$type}) {
+ $prefix = $unref_prefix{$type};
+ }
+ push(@{$self->{unref}}, $prefix."_unref(".$var.");\n");
+ }
+}
+
+sub adjust_ignore {
+ my $ig = shift;
+
+ if ($ig eq "auto"){
+ return "true";
+ }
+ return $ig;
+}
+
+sub find_override {
+ my ($self, $func, $var, $expected) = @_;
+ my $vn = $self->{var}->{$var};
+
+ # Deal with string types
+ if ($expected eq "DOMString") {
+ return $func."_domstring";
+ } else {
+ if ($expected =~ /^\"/ or $self->{"var"}->{$expected} eq "char *") {
+ return $func."_string";
+ }
+ }
+
+ if (exists $override_suffix{$vn}) {
+ $func = $func."_".$override_suffix{$vn}
+ }
+ return $func;
+}
+
+sub param_unref {
+ my ($self, $var) = @_;
+
+ my $type = $self->{'var'}->{$var};
+ if (not exists $no_unref{$type}) {
+ my $prefix = "dom_node";
+ if (exists $unref_prefix{$type}) {
+ $prefix = $unref_prefix{$type};
+ }
+ print "if ($var != NULL) {";
+ print $prefix."_unref(".$var.");\n";
+ print "$var = NULL;";
+ print "}";
+ }
+
+ foreach my $item (@{$self->{unref}}) {
+ $item =~ m/.*\((.*)\).*/;
+ if ($var eq $1) {
+ return 1;
+ }
+ }
+
+ foreach my $item (@{$self->{string_unref}}) {
+ if ($var eq $item) {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+sub generate_domstring_interface {
+ my ($self, $en, $a) = @_;
+
+ switch ($en) {
+ case "length" {
+ print "$a->{'var'} = dom_string_length($a->{'obj'});";
+ }
+
+ else {
+ die "Can't generate method/attribute $en for DOMString";
+ }
+ }
+}
+
+1;
diff --git a/test/INDEX b/test/INDEX
deleted file mode 100644
index a1b7297..0000000
--- a/test/INDEX
+++ /dev/null
@@ -1,4 +0,0 @@
-# Index for libdom testcases
-#
-# Test Description DataDir
-
diff --git a/test/Makefile b/test/Makefile
index 3d50686..2d20d02 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,18 +1,17 @@
-testlib_files := lib/comparators.c;lib/list.c;lib/testassert.c
-testlib_files := $(testlib_files);lib/testobject.c;lib/utils.c
+testutils_files := testutils/comparators.c;testutils/list.c;testutils/domasserts.c
+testutils_files := $(testutils_files);testutils/utils.c;testutils/foreach.c;testutils/load.c
-TESTCFLAGS := $(TESTCFLAGS) -I$(CURDIR) -I$(CURDIR)/$(DIR)
+TESTCFLAGS := $(TESTCFLAGS) -I$(CURDIR) -I$(CURDIR)/testutils
-DIR_TEST_ITEMS := binding:binding.c;$(testlib_files) \
- test-list:test-list.c;$(testlib_files)
+DIR_TEST_ITEMS := $(testutils_files)
define add_xml_test
ifeq ($$(WANT_TEST),yes)
- $(DIR)xml/c/$1.c: $(DIR)xml/tests/$1.xml
+ $(DIR)xml/c/$1.c: $(DIR)xml/tests/$1.xml
$$(Q)$$(XSLTPROC) $$(XSLTPROCFLAGS) -o $$@ \
$(DIR)transform/test-to-c.xsl $$<
- DIR_TEST_ITEMS := $$(DIR_TEST_ITEMS) $1:xml/c/$1.c;$$(testlib_files)
+ DIR_TEST_ITEMS := $$(DIR_TEST_ITEMS) $1:xml/c/$1.c;$$(testlib_files)
endif
DISTCLEAN_ITEMS := $$(DISTCLEAN_ITEMS) $(DIR)xml/c/$1.c
diff --git a/test/binding.c b/test/binding.c
deleted file mode 100644
index e7d824f..0000000
--- a/test/binding.c
+++ /dev/null
@@ -1,35 +0,0 @@
-#include <stdio.h>
-
-#include <dom/dom.h>
-#include "testutils.h"
-
-int main(int argc, char **argv)
-{
- struct dom_document *doc;
- struct dom_element *element;
- struct dom_string *elementName;
- dom_exception err;
- TestObject *staff;
- TestObject *html;
-
- staff = test_object_create(argc, argv, "staff.xml", false);
- assert(staff != NULL);
-
- html = test_object_create(argc, argv, "sample.html", false);
- assert(html != NULL);
-
- doc = test_object_get_doc(staff);
- assert(doc != NULL);
-
- err = dom_document_get_document_element(doc, &element);
- assert(err == DOM_NO_ERR);
- assert(element != NULL);
-
- err = dom_element_get_tag_name(element, &elementName);
- assert(err == DOM_NO_ERR);
- assert(elementName != NULL);
-
- printf("PASS\n");
-
- return 0;
-}
diff --git a/test/build-test.sh b/test/build-test.sh
new file mode 100755
index 0000000..a353298
--- /dev/null
+++ b/test/build-test.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+#
+# This is a simple script to recompile a C test file.
+# Usage:
+# This script is designed to run under test output directory.
+#
+# You should firstly run "run-test.sh", which will genrate a test output directory. In that
+# directory, there are C source files and corresponding executables.
+#
+# ../../../build-test.sh some-test-converted-c-file.c
+#
+# This file is part of libdom test suite.
+# Licensed under the MIT License,
+# http://www.opensource.org/licenses/mit-license.php
+# Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+
+src="testutils/comparators.c testutils/domtsasserts.c testutils/foreach.c testutils/list.c testutils/load.c testutils/utils.c testutils/domtscondition.c"
+domdir="../build-Linux-Linux-debug-lib-static"
+ldflags="-L$domdir -ldom -L/usr/local/lib -lwapcaplet -L/usr/lib -lxml2 -lhubbub -lparserutils"
+#ldflags="-L/usr/lib -lm -lz -L$domdir -ldom -L/usr/local/lib -lwapcaplet -lxml2 -lhubbub -lparserutils"
+cflags="-Itestutils/ -I../bindings/xml -I../include -I../bindings/hubbub -I/usr/local/include"
+
+sf="$1";
+echo $sf;
+cwd=$(pwd);
+cd ../../../
+exe=${sf%%.c};
+cfile="$cwd"/"$sf";
+gcc -g $cflags $src $cfile $ldflags -o $exe;
+mv $exe $cwd;
+cd $cwd;
diff --git a/test/data/binding/Aliases b/test/data/Aliases
index db61ff1..8978ede 100644
--- a/test/data/binding/Aliases
+++ b/test/data/Aliases
@@ -245,7 +245,7 @@ Ventura-Math 2022 csVenturaMath
Microsoft-Publishing 2023 csMicrosoftPublishing
Windows-31J 2024 csWindows31J
GB2312 2025 csGB2312 EUC-CN EUCCN CN-GB
-Big5 2026 csBig5 BIG-FIVE BIG-5 CN-BIG5 BIG_FIVE
+Big5 2026 csBig5 BIG-FIVE BIG-5 CN-BIG5 BIG_FIVE x-x-big5
windows-1250 2250 CP1250 MS-EE
windows-1251 2251 CP1251 MS-CYRL
windows-1252 2252 CP1252 MS-ANSI
@@ -287,6 +287,7 @@ CP874 3004 WINDOWS-874
#MACTHAI 3024 X-MAC-THAI MAC-THAI
#MACTURKISH 3025 X-MAC-TURKISH MAC-TURKISH
#MULELAO-1 3026
+CP949 3027 WINDOWS-949
# From Unicode Lib
ISO-IR-182 4000
diff --git a/test/data/binding/sample.html b/test/data/binding/sample.html
deleted file mode 100644
index a090978..0000000
--- a/test/data/binding/sample.html
+++ /dev/null
@@ -1,11 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-<title>This is a title</title>
-</head>
-<body>
-<p>Here is some text with mismatched <b>bold <i>and italic </b>tags</i>. Here's some more text.</p>
-</body>
-</html>
-
diff --git a/test/data/binding/staff.xml b/test/data/binding/staff.xml
deleted file mode 100644
index f89c510..0000000
--- a/test/data/binding/staff.xml
+++ /dev/null
@@ -1,57 +0,0 @@
-<?xml version="1.0"?><?TEST-STYLE PIDATA?>
-<!DOCTYPE staff SYSTEM "staff.dtd" [
- <!ENTITY ent1 "es">
- <!ENTITY ent2 "1900 Dallas Road">
- <!ENTITY ent3 "Texas">
- <!ENTITY ent4 "<entElement domestic='Yes'>Element data</entElement><?PItarget PIdata?>">
- <!ENTITY ent5 PUBLIC "entityURI" "entityFile" NDATA notation1>
- <!ENTITY ent1 "This entity should be discarded">
- <!NOTATION notation1 PUBLIC "notation1File">
- <!NOTATION notation2 SYSTEM "notation2File">
-]>
-<!-- This is comment number 1.-->
-<staff>
- <employee>
- <employeeId>EMP0001</employeeId>
- <name>Margaret Martin</name>
- <position>Accountant</position>
- <salary>56,000</salary>
- <gender>Female</gender>
- <address domestic="Yes">1230 North Ave. Dallas, Texas 98551</address>
- </employee>
- <employee>
- <employeeId>EMP0002</employeeId>
- <name>Martha Raynolds<![CDATA[This is a CDATASection with EntityReference number 2 &ent2;]]>
-<![CDATA[This is an adjacent CDATASection with a reference to a tab &tab;]]></name>
- <position>Secretary</position>
- <salary>35,000</salary>
- <gender>Female</gender>
- <address domestic="Yes" street="Yes">&ent2; Dallas, &ent3;
- 98554</address>
- </employee>
- <employee>
- <employeeId>EMP0003</employeeId>
- <name>Roger
- Jones</name>
- <position>Department Manager</position>
- <salary>100,000</salary>
- <gender>&ent4;</gender>
- <address domestic="Yes" street="No">PO Box 27 Irving, texas 98553</address>
- </employee>
- <employee>
- <employeeId>EMP0004</employeeId>
- <name>Jeny Oconnor</name>
- <position>Personnel Director</position>
- <salary>95,000</salary>
- <gender>Female</gender>
- <address domestic="Yes" street="Y&ent1;">27 South Road. Dallas, Texas 98556</address>
- </employee>
- <employee>
- <employeeId>EMP0005</employeeId>
- <name>Robert Myers</name>
- <position>Computer Specialist</position>
- <salary>90,000</salary>
- <gender>male</gender>
- <address street="Yes">1821 Nordic. Road, Irving Texas 98558</address>
- </employee>
- </staff>
diff --git a/test/transform/dom1-interfaces.xml b/test/dom1-interfaces.xml
index 0c2488e..0c2488e 100644
--- a/test/transform/dom1-interfaces.xml
+++ b/test/dom1-interfaces.xml
diff --git a/test/dom2-core-interface.xml b/test/dom2-core-interface.xml
new file mode 100644
index 0000000..03d2e17
--- /dev/null
+++ b/test/dom2-core-interface.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0"?>
+<!--
+Copyright (c) 2001-2003 World Wide Web Consortium,
+(Massachusetts Institute of Technology, Institut National de
+Recherche en Informatique et en Automatique, Keio University). All
+Rights Reserved. This program is distributed under the W3C's Document
+Intellectual Property License. This program is distributed in the
+hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+PURPOSE.
+See W3C License http://www.w3.org/Consortium/Legal/ for more details.
+-->
+<!--This file is an extract of interface definitions from Document Object Model (DOM) Level 2 Core Specification-->
+<library>
+ <exception name="DOMException" id="ID-17189187"><descr><p>DOM operations only raise exceptions in "exceptional" circumstances, i.e., when an operation is impossible to perform (either for logical reasons, because data is lost, or because the implementation has become unstable). In general, DOM methods return specific error values in ordinary processing situations, such as out-of-bound errors when using<code>NodeList</code>.</p><p>Implementations should raise other exceptions under other circumstances. For example, implementations should raise an implementation-dependent exception if a<code>null</code>argument is passed.</p><p>Some languages and object systems do not support the concept of exceptions. For such systems, error conditions may be indicated using native error reporting mechanisms. For some bindings, for example, methods may return error codes similar to those listed in the corresponding method descriptions.</p></descr><component id="ID-146F692A" name="code"><typename>unsigned short</typename></component></exception>
+ <group id="ID-258A00AF" name="ExceptionCode"><descr><p>An integer indicating the type of error generated.</p><note><p>Other numeric codes are reserved for W3C for possible future use.</p></note></descr><constant name="INDEX_SIZE_ERR" type="unsigned short" value="1"><descr><p>If index or size is negative, or greater than the allowed value</p></descr></constant><constant name="DOMSTRING_SIZE_ERR" type="unsigned short" value="2"><descr><p>If the specified range of text does not fit into a DOMString</p></descr></constant><constant name="HIERARCHY_REQUEST_ERR" type="unsigned short" value="3"><descr><p>If any node is inserted somewhere it doesn't belong</p></descr></constant><constant name="WRONG_DOCUMENT_ERR" type="unsigned short" value="4"><descr><p>If a node is used in a different document than the one that created it (that doesn't support it)</p></descr></constant><constant name="INVALID_CHARACTER_ERR" type="unsigned short" value="5"><descr><p>If an invalid or illegal character is specified, such as in a name. Seein the XML specification for the definition of a legal character, andfor the definition of a legal name character.</p></descr></constant><constant name="NO_DATA_ALLOWED_ERR" type="unsigned short" value="6"><descr><p>If data is specified for a node which does not support data</p></descr></constant><constant name="NO_MODIFICATION_ALLOWED_ERR" type="unsigned short" value="7"><descr><p>If an attempt is made to modify an object where modifications are not allowed</p></descr></constant><constant name="NOT_FOUND_ERR" type="unsigned short" value="8"><descr><p>If an attempt is made to reference a node in a context where it does not exist</p></descr></constant><constant name="NOT_SUPPORTED_ERR" type="unsigned short" value="9"><descr><p>If the implementation does not support the requested type of object or operation.</p></descr></constant><constant name="INUSE_ATTRIBUTE_ERR" type="unsigned short" value="10"><descr><p>If an attempt is made to add an attribute that is already in use elsewhere</p></descr></constant><constant name="INVALID_STATE_ERR" type="unsigned short" value="11" since="DOM Level 2"><descr><p>If an attempt is made to use an object that is not, or is no longer, usable.</p></descr></constant><constant name="SYNTAX_ERR" type="unsigned short" value="12" since="DOM Level 2"><descr><p>If an invalid or illegal string is specified.</p></descr></constant><constant name="INVALID_MODIFICATION_ERR" type="unsigned short" value="13" since="DOM Level 2"><descr><p>If an attempt is made to modify the type of the underlying object.</p></descr></constant><constant name="NAMESPACE_ERR" type="unsigned short" value="14" since="DOM Level 2"><descr><p>If an attempt is made to create or change an object in a way which is incorrect with regard to namespaces.</p></descr></constant><constant name="INVALID_ACCESS_ERR" type="unsigned short" value="15" since="DOM Level 2"><descr><p>If a parameter or an operation is not supported by the underlying object.</p></descr></constant></group>
+ <interface name="DOMImplementation" id="ID-102161490"><descr><p>The<code>DOMImplementation</code>interface provides a number of methods for performing operations that are independent of any particular instance of the document object model.</p></descr><method name="hasFeature" id="ID-5CED94D7"><descr><p>Test if the DOM implementation implements a specific feature.</p></descr><parameters><param name="feature" type="DOMString" attr="in"><descr><p>The name of the feature to test (case-insensitive). The values used by DOM features are defined throughout the DOM Level 2 specifications and listed in the<specref ref="ID-Conformance"/>section. The name must be an<termref def="dt-XML-name">XML name</termref>. To avoid possible conflicts, as a convention, names referring to features defined outside the DOM specification should be made unique by reversing the name of the Internet domain name of the person (or the organization that the person belongs to) who defines the feature, component by component, and using this as a prefix. For instance, the W3C SVG Working Group defines the feature "org.w3c.dom.svg".</p></descr></param><param name="version" type="DOMString" attr="in"><descr><p>This is the version number of the feature to test. In Level 2, the string can be either "2.0" or "1.0". If the version is not specified, supporting any version of the feature causes the method to return<code>true</code>.</p></descr></param></parameters><returns type="boolean"><descr><p><code>true</code>if the feature is implemented in the specified version,<code>false</code>otherwise.</p></descr></returns><raises></raises></method><method name="createDocumentType" id="Level-2-Core-DOM-createDocType" since="DOM Level 2"><descr><p>Creates an empty<code>DocumentType</code>node. Entity declarations and notations are not made available. Entity reference expansions and default attribute additions do not occur. It is expected that a future version of the DOM will provide a way for populating a<code>DocumentType</code>.</p><p>HTML-only DOM implementations do not need to implement this method.</p></descr><parameters><param name="qualifiedName" type="DOMString" attr="in"><descr><p>The<termref def="dt-qualifiedname">qualified name</termref>of the document type to be created.</p></descr></param><param name="publicId" type="DOMString" attr="in"><descr><p>The external subset public identifier.</p></descr></param><param name="systemId" type="DOMString" attr="in"><descr><p>The external subset system identifier.</p></descr></param></parameters><returns type="DocumentType"><descr><p>A new<code>DocumentType</code>node with<code>Node.ownerDocument</code>set to<code>null</code>.</p></descr></returns><raises><exception name="DOMException"><descr><p>INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character.</p><p>NAMESPACE_ERR: Raised if the<code>qualifiedName</code>is malformed.</p></descr></exception></raises></method><method name="createDocument" id="Level-2-Core-DOM-createDocument" since="DOM Level 2"><descr><p>Creates an XML<code>Document</code>object of the specified type with its document element. HTML-only DOM implementations do not need to implement this method.</p></descr><parameters><param name="namespaceURI" type="DOMString" attr="in"><descr><p>The<termref def="dt-namespaceURI">namespace URI</termref>of the document element to create.</p></descr></param><param name="qualifiedName" type="DOMString" attr="in"><descr><p>The<termref def="dt-qualifiedname">qualified name</termref>of the document element to be created.</p></descr></param><param name="doctype" type="DocumentType" attr="in"><descr><p>The type of document to be created or<code>null</code>.</p><p>When<code>doctype</code>is not<code>null</code>, its<code>Node.ownerDocument</code>attribute is set to the document being created.</p></descr></param></parameters><returns type="Document"><descr><p>A new<code>Document</code>object.</p></descr></returns><raises><exception name="DOMException"><descr><p>INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character.</p><p>NAMESPACE_ERR: Raised if the<code>qualifiedName</code>is malformed, if the<code>qualifiedName</code>has a prefix and the<code>namespaceURI</code>is<code>null</code>, or if the<code>qualifiedName</code>has a prefix that is "xml" and the<code>namespaceURI</code>is different from ""<bibref ref="Namespaces"/>.</p><p>WRONG_DOCUMENT_ERR: Raised if<code>doctype</code>has already been used with a different document or was created from a different implementation.</p><p>NOT_SUPPORTED_ERR: May be raised by DOM implementations which do not support the "XML" feature, if they choose not to support this method. Note: Other features introduced in the future, by the DOM WG or in extensions defined by other groups, may also demand support for this method; please consult the definition of the feature to see if it requires this method.</p></descr></exception></raises></method></interface>
+ <interface name="DocumentFragment" inherits="Node" id="ID-B63ED1A3"><descr><p><code>DocumentFragment</code>is a "lightweight" or "minimal"<code>Document</code>object. It is very common to want to be able to extract a portion of a document's tree or to create a new fragment of a document. Imagine implementing a user command like cut or rearranging a document by moving fragments around. It is desirable to have an object which can hold such fragments and it is quite natural to use a Node for this purpose. While it is true that a<code>Document</code>object could fulfill this role, a<code>Document</code>object can potentially be a heavyweight object, depending on the underlying implementation. What is really needed for this is a very lightweight object.<code>DocumentFragment</code>is such an object.</p><p>Furthermore, various operations -- such as inserting nodes as children of another<code>Node</code>-- may take<code>DocumentFragment</code>objects as arguments; this results in all the child nodes of the<code>DocumentFragment</code>being moved to the child list of this node.</p><p>The children of a<code>DocumentFragment</code>node are zero or more nodes representing the tops of any sub-trees defining the structure of the document.<code>DocumentFragment</code>nodes do not need to be<termref def="dt-well-formed">well-formed XML documents</termref>(although they do need to follow the rules imposed upon well-formed XML parsed entities, which can have multiple top nodes). For example, a<code>DocumentFragment</code>might have only one child and that child node could be a<code>Text</code>node. Such a structure model represents neither an HTML document nor a well-formed XML document.</p><p>When a<code>DocumentFragment</code>is inserted into a<code>Document</code>(or indeed any other<code>Node</code>that may take children) the children of the<code>DocumentFragment</code>and not the<code>DocumentFragment</code>itself are inserted into the<code>Node</code>. This makes the<code>DocumentFragment</code>very useful when the user wishes to create nodes that are<termref def="dt-sibling">siblings</termref>; the<code>DocumentFragment</code>acts as the parent of these nodes so that the user can use the standard methods from the<code>Node</code>interface, such as<code>insertBefore</code>and<code>appendChild</code>.</p></descr></interface>
+ <interface name="Document" inherits="Node" id="i-Document"><descr><p>The<code>Document</code>interface represents the entire HTML or XML document. Conceptually, it is the<termref def="dt-root-node">root</termref>of the document tree, and provides the primary access to the document's data.</p><p>Since elements, text nodes, comments, processing instructions, etc. cannot exist outside the context of a<code>Document</code>, the<code>Document</code>interface also contains the factory methods needed to create these objects. The<code>Node</code>objects created have a<code>ownerDocument</code>attribute which associates them with the<code>Document</code>within whose context they were created.</p></descr><attribute readonly="yes" name="doctype" type="DocumentType" id="ID-B63ED1A31"><descr><p>The Document Type Declaration (see<code>DocumentType</code>) associated with this document. For HTML documents as well as XML documents without a document type declaration this returns<code>null</code>. The DOM Level 2 does not support editing the Document Type Declaration.<code>docType</code>cannot be altered in any way, including through the use of methods inherited from the<code>Node</code>interface, such as<code>insertNode</code>or<code>removeNode</code>.</p></descr></attribute><attribute readonly="yes" name="implementation" type="DOMImplementation" id="ID-1B793EBA"><descr><p>The<code>DOMImplementation</code>object that handles this document. A DOM application may use objects from multiple implementations.</p></descr></attribute><attribute readonly="yes" name="documentElement" type="Element" id="ID-87CD092"><descr><p>This is a<termref def="dt-convenience">convenience</termref>attribute that allows direct access to the child node that is the root element of the document. For HTML documents, this is the element with the tagName "HTML".</p></descr></attribute><method name="createElement" id="ID-2141741547"><descr><p>Creates an element of the type specified. Note that the instance returned implements the<code>Element</code>interface, so attributes can be specified directly on the returned object.</p><p>In addition, if there are known attributes with default values,<code>Attr</code>nodes representing them are automatically created and attached to the element.</p><p>To create an element with a qualified name and namespace URI, use the<code>createElementNS</code>method.</p></descr><parameters><param name="tagName" type="DOMString" attr="in"><descr><p>The name of the element type to instantiate. For XML, this is case-sensitive. For HTML, the<code>tagName</code>parameter may be provided in any case, but it must be mapped to the canonical uppercase form by the DOM implementation.</p></descr></param></parameters><returns type="Element"><descr><p>A new<code>Element</code>object with the<code>nodeName</code>attribute set to<code>tagName</code>, and<code>localName</code>,<code>prefix</code>, and<code>namespaceURI</code>set to<code>null</code>.</p></descr></returns><raises><exception name="DOMException"><descr><p>INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.</p></descr></exception></raises></method><method name="createDocumentFragment" id="ID-35CB04B5"><descr><p>Creates an empty<code>DocumentFragment</code>object.</p></descr><parameters></parameters><returns type="DocumentFragment"><descr><p>A new<code>DocumentFragment</code>.</p></descr></returns><raises></raises></method><method name="createTextNode" id="ID-1975348127"><descr><p>Creates a<code>Text</code>node given the specified string.</p></descr><parameters><param name="data" type="DOMString" attr="in"><descr><p>The data for the node.</p></descr></param></parameters><returns type="Text"><descr><p>The new<code>Text</code>object.</p></descr></returns><raises></raises></method><method name="createComment" id="ID-1334481328"><descr><p>Creates a<code>Comment</code>node given the specified string.</p></descr><parameters><param name="data" type="DOMString" attr="in"><descr><p>The data for the node.</p></descr></param></parameters><returns type="Comment"><descr><p>The new<code>Comment</code>object.</p></descr></returns><raises></raises></method><method name="createCDATASection" id="ID-D26C0AF8"><descr><p>Creates a<code>CDATASection</code>node whose value is the specified string.</p></descr><parameters><param name="data" type="DOMString" attr="in"><descr><p>The data for the<code>CDATASection</code>contents.</p></descr></param></parameters><returns type="CDATASection"><descr><p>The new<code>CDATASection</code>object.</p></descr></returns><raises><exception name="DOMException"><descr><p>NOT_SUPPORTED_ERR: Raised if this document is an HTML document.</p></descr></exception></raises></method><method name="createProcessingInstruction" id="ID-135944439"><descr><p>Creates a<code>ProcessingInstruction</code>node given the specified name and data strings.</p></descr><parameters><param name="target" type="DOMString" attr="in"><descr><p>The target part of the processing instruction.</p></descr></param><param name="data" type="DOMString" attr="in"><descr><p>The data for the node.</p></descr></param></parameters><returns type="ProcessingInstruction"><descr><p>The new<code>ProcessingInstruction</code>object.</p></descr></returns><raises><exception name="DOMException"><descr><p>INVALID_CHARACTER_ERR: Raised if the specified target contains an illegal character.</p><p>NOT_SUPPORTED_ERR: Raised if this document is an HTML document.</p></descr></exception></raises></method><method name="createAttribute" id="ID-1084891198"><descr><p>Creates an<code>Attr</code>of the given name. Note that the<code>Attr</code>instance can then be set on an<code>Element</code>using the<code>setAttributeNode</code>method.</p><p>To create an attribute with a qualified name and namespace URI, use the<code>createAttributeNS</code>method.</p></descr><parameters><param name="name" type="DOMString" attr="in"><descr><p>The name of the attribute.</p></descr></param></parameters><returns type="Attr"><descr><p>A new<code>Attr</code>object with the<code>nodeName</code>attribute set to<code>name</code>, and<code>localName</code>,<code>prefix</code>, and<code>namespaceURI</code>set to<code>null</code>. The value of the attribute is the empty string.</p></descr></returns><raises><exception name="DOMException"><descr><p>INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.</p></descr></exception></raises></method><method name="createEntityReference" id="ID-392B75AE"><descr><p>Creates an<code>EntityReference</code>object. In addition, if the referenced entity is known, the child list of the<code>EntityReference</code>node is made the same as that of the corresponding<code>Entity</code>node.</p><note><p>If any descendant of the<code>Entity</code>node has an unbound<termref def="dt-namespaceprefix">namespace prefix</termref>, the corresponding descendant of the created<code>EntityReference</code>node is also unbound; (its<code>namespaceURI</code>is<code>null</code>). The DOM Level 2 does not support any mechanism to resolve namespace prefixes.</p></note></descr><parameters><param name="name" type="DOMString" attr="in"><descr><p>The name of the entity to reference.</p></descr></param></parameters><returns type="EntityReference"><descr><p>The new<code>EntityReference</code>object.</p></descr></returns><raises><exception name="DOMException"><descr><p>INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.</p><p>NOT_SUPPORTED_ERR: Raised if this document is an HTML document.</p></descr></exception></raises></method><method name="getElementsByTagName" id="ID-A6C9094"><descr><p>Returns a<code>NodeList</code>of all the<code>Elements</code>with a given tag name in the order in which they are encountered in a preorder traversal of the<code>Document</code>tree.</p></descr><parameters><param name="tagname" type="DOMString" attr="in"><descr><p>The name of the tag to match on. The special value "*" matches all tags.</p></descr></param></parameters><returns type="NodeList"><descr><p>A new<code>NodeList</code>object containing all the matched<code>Elements</code>.</p></descr></returns><raises></raises></method><method name="importNode" id="Core-Document-importNode" since="DOM Level 2"><descr><p>Imports a node from another document to this document. The returned node has no parent; (<code>parentNode</code>is<code>null</code>). The source node is not altered or removed from the original document; this method creates a new copy of the source node.</p><p>For all nodes, importing a node creates a node object owned by the importing document, with attribute values identical to the source node's<code>nodeName</code>and<code>nodeType</code>, plus the attributes related to namespaces (<code>prefix</code>,<code>localName</code>, and<code>namespaceURI</code>). As in the<code>cloneNode</code>operation on a<code>Node</code>, the source node is not altered.</p><p>Additional information is copied as appropriate to the<code>nodeType</code>, attempting to mirror the behavior expected if a fragment of XML or HTML source was copied from one document to another, recognizing that the two documents may have different DTDs in the XML case. The following list describes the specifics for each type of node.<glist><gitem><label>ATTRIBUTE_NODE</label><def><p>The<code>ownerElement</code>attribute is set to<code>null</code>and the<code>specified</code>flag is set to<code>true</code>on the generated<code>Attr</code>. The<termref def="dt-descendant">descendants</termref>of the source<code>Attr</code>are recursively imported and the resulting nodes reassembled to form the corresponding subtree.</p><p>Note that the<code>deep</code>parameter has no effect on<code>Attr</code>nodes; they always carry their children with them when imported.</p></def></gitem><gitem><label>DOCUMENT_FRAGMENT_NODE</label><def><p>If the<code>deep</code>option was set to<code>true</code>, the<termref def="dt-descendant">descendants</termref>of the source element are recursively imported and the resulting nodes reassembled to form the corresponding subtree. Otherwise, this simply generates an empty<code>DocumentFragment</code>.</p></def></gitem><gitem><label>DOCUMENT_NODE</label><def><p><code>Document</code>nodes cannot be imported.</p></def></gitem><gitem><label>DOCUMENT_TYPE_NODE</label><def><p><code>DocumentType</code>nodes cannot be imported.</p></def></gitem><gitem><label>ELEMENT_NODE</label><def><p><emph>Specified</emph>attribute nodes of the source element are imported, and the generated<code>Attr</code>nodes are attached to the generated<code>Element</code>. Default attributes are<emph>not</emph>copied, though if the document being imported into defines default attributes for this element name, those are assigned. If the<code>importNode</code><code>deep</code>parameter was set to<code>true</code>, the<termref def="dt-descendant">descendants</termref>of the source element are recursively imported and the resulting nodes reassembled to form the corresponding subtree.</p></def></gitem><gitem><label>ENTITY_NODE</label><def><p><code>Entity</code>nodes can be imported, however in the current release of the DOM the<code>DocumentType</code>is readonly. Ability to add these imported nodes to a<code>DocumentType</code>will be considered for addition to a future release of the DOM.</p><p>On import, the<code>publicId</code>,<code>systemId</code>, and<code>notationName</code>attributes are copied. If a<code>deep</code>import is requested, the<termref def="dt-descendant">descendants</termref>of the the source<code>Entity</code>are recursively imported and the resulting nodes reassembled to form the corresponding subtree.</p></def></gitem><gitem><label>ENTITY_REFERENCE_NODE</label><def><p>Only the<code>EntityReference</code>itself is copied, even if a<code>deep</code>import is requested, since the source and destination documents might have defined the entity differently. If the document being imported into provides a definition for this entity name, its value is assigned.</p></def></gitem><gitem><label>NOTATION_NODE</label><def><p><code>Notation</code>nodes can be imported, however in the current release of the DOM the<code>DocumentType</code>is readonly. Ability to add these imported nodes to a<code>DocumentType</code>will be considered for addition to a future release of the DOM.</p><p>On import, the<code>publicId</code>and<code>systemId</code>attributes are copied.</p><p>Note that the<code>deep</code>parameter has no effect on<code>Notation</code>nodes since they never have any children.</p></def></gitem><gitem><label>PROCESSING_INSTRUCTION_NODE</label><def><p>The imported node copies its<code>target</code>and<code>data</code>values from those of the source node.</p></def></gitem><gitem><label>TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE</label><def><p>These three types of nodes inheriting from<code>CharacterData</code>copy their<code>data</code>and<code>length</code>attributes from those of the source node.</p></def></gitem></glist></p></descr><parameters><param name="importedNode" type="Node" attr="in"><descr><p>The node to import.</p></descr></param><param name="deep" type="boolean" attr="in"><descr><p>If<code>true</code>, recursively import the subtree under the specified node; if<code>false</code>, import only the node itself, as explained above. This has no effect on<code>Attr</code>,<code>EntityReference</code>, and<code>Notation</code>nodes.</p></descr></param></parameters><returns type="Node"><descr><p>The imported node that belongs to this<code>Document</code>.</p></descr></returns><raises><exception name="DOMException"><descr><p>NOT_SUPPORTED_ERR: Raised if the type of node being imported is not supported.</p></descr></exception></raises></method><method name="createElementNS" id="ID-DocCrElNS" since="DOM Level 2"><descr><p>Creates an element of the given qualified name and namespace URI. HTML-only DOM implementations do not need to implement this method.</p></descr><parameters><param name="namespaceURI" type="DOMString" attr="in"><descr><p>The<termref def="dt-namespaceURI">namespace URI</termref>of the element to create.</p></descr></param><param name="qualifiedName" type="DOMString" attr="in"><descr><p>The<termref def="dt-qualifiedname">qualified name</termref>of the element type to instantiate.</p></descr></param></parameters><returns type="Element"><descr><p>A new<code>Element</code>object with the following attributes:</p><table summary="Layout table: the first cell the name property, the second cell contains his initial value"><tbody><tr><th rowspan="1" colspan="1">Attribute</th><th rowspan="1" colspan="1">Value</th></tr><tr><td rowspan="1" colspan="1"><code>Node.nodeName</code></td><td rowspan="1" colspan="1"><code>qualifiedName</code></td></tr><tr><td rowspan="1" colspan="1"><code>Node.namespaceURI</code></td><td rowspan="1" colspan="1"><code>namespaceURI</code></td></tr><tr><td rowspan="1" colspan="1"><code>Node.prefix</code></td><td rowspan="1" colspan="1">prefix, extracted from<code>qualifiedName</code>, or<code>null</code>if there is no prefix</td></tr><tr><td rowspan="1" colspan="1"><code>Node.localName</code></td><td rowspan="1" colspan="1"><termref def="dt-localname">local name</termref>, extracted from<code>qualifiedName</code></td></tr><tr><td rowspan="1" colspan="1"><code>Element.tagName</code></td><td rowspan="1" colspan="1"><code>qualifiedName</code></td></tr></tbody></table></descr></returns><raises><exception name="DOMException"><descr><p>INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character.</p><p>NAMESPACE_ERR: Raised if the<code>qualifiedName</code>is malformed, if the<code>qualifiedName</code>has a prefix and the<code>namespaceURI</code>is<code>null</code>, or if the<code>qualifiedName</code>has a prefix that is "xml" and the<code>namespaceURI</code>is different from ""<bibref ref="Namespaces"/>.</p></descr></exception></raises></method><method name="createAttributeNS" id="ID-DocCrAttrNS" since="DOM Level 2"><descr><p>Creates an attribute of the given qualified name and namespace URI. HTML-only DOM implementations do not need to implement this method.</p></descr><parameters><param name="namespaceURI" type="DOMString" attr="in"><descr><p>The<termref def="dt-namespaceURI">namespace URI</termref>of the attribute to create.</p></descr></param><param name="qualifiedName" type="DOMString" attr="in"><descr><p>The<termref def="dt-qualifiedname">qualified name</termref>of the attribute to instantiate.</p></descr></param></parameters><returns type="Attr"><descr><p>A new<code>Attr</code>object with the following attributes:</p><table summary="Layout table: the first cell the name property, the second cell contains his initial value"><tbody><tr><th rowspan="1" colspan="1">Attribute</th><th rowspan="1" colspan="1">Value</th></tr><tr><td rowspan="1" colspan="1"><code>Node.nodeName</code></td><td rowspan="1" colspan="1">qualifiedName</td></tr><tr><td rowspan="1" colspan="1"><code>Node.namespaceURI</code></td><td rowspan="1" colspan="1"><code>namespaceURI</code></td></tr><tr><td rowspan="1" colspan="1"><code>Node.prefix</code></td><td rowspan="1" colspan="1">prefix, extracted from<code>qualifiedName</code>, or<code>null</code>if there is no prefix</td></tr><tr><td rowspan="1" colspan="1"><code>Node.localName</code></td><td rowspan="1" colspan="1"><termref def="dt-localname">local name</termref>, extracted from<code>qualifiedName</code></td></tr><tr><td rowspan="1" colspan="1"><code>Attr.name</code></td><td rowspan="1" colspan="1"><code>qualifiedName</code></td></tr><tr><td rowspan="1" colspan="1"><code>Node.nodeValue</code></td><td rowspan="1" colspan="1">the empty string</td></tr></tbody></table></descr></returns><raises><exception name="DOMException"><descr><p>INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character.</p><p>NAMESPACE_ERR: Raised if the<code>qualifiedName</code>is malformed, if the<code>qualifiedName</code>has a prefix and the<code>namespaceURI</code>is<code>null</code>, if the<code>qualifiedName</code>has a prefix that is "xml" and the<code>namespaceURI</code>is different from "", or if the<code>qualifiedName</code>is "xmlns" and the<code>namespaceURI</code>is different from "".</p></descr></exception></raises></method><method name="getElementsByTagNameNS" id="ID-getElBTNNS" since="DOM Level 2"><descr><p>Returns a<code>NodeList</code>of all the<code>Elements</code>with a given<termref def="dt-localname">local name</termref>and namespace URI in the order in which they are encountered in a preorder traversal of the<code>Document</code>tree.</p></descr><parameters><param name="namespaceURI" type="DOMString" attr="in"><descr><p>The<termref def="dt-namespaceURI">namespace URI</termref>of the elements to match on. The special value "*" matches all namespaces.</p></descr></param><param name="localName" type="DOMString" attr="in"><descr><p>The<termref def="dt-localname">local name</termref>of the elements to match on. The special value "*" matches all local names.</p></descr></param></parameters><returns type="NodeList"><descr><p>A new<code>NodeList</code>object containing all the matched<code>Elements</code>.</p></descr></returns><raises></raises></method><method name="getElementById" id="ID-getElBId" since="DOM Level 2"><descr><p>Returns the<code>Element</code>whose<code>ID</code>is given by<code>elementId</code>. If no such element exists, returns<code>null</code>. Behavior is not defined if more than one element has this<code>ID</code>.<note><p>The DOM implementation must have information that says which attributes are of type ID. Attributes with the name "ID" are not of type ID unless so defined. Implementations that do not know whether attributes are of type ID or not are expected to return<code>null</code>.</p></note></p></descr><parameters><param name="elementId" type="DOMString" attr="in"><descr><p>The unique<code>id</code>value for an element.</p></descr></param></parameters><returns type="Element"><descr><p>The matching element.</p></descr></returns><raises></raises></method></interface>
+ <interface name="Node" id="ID-1950641247"><descr><p>The<code>Node</code>interface is the primary datatype for the entire Document Object Model. It represents a single node in the document tree. While all objects implementing the<code>Node</code>interface expose methods for dealing with children, not all objects implementing the<code>Node</code>interface may have children. For example,<code>Text</code>nodes may not have children, and adding children to such nodes results in a<code>DOMException</code>being raised.</p><p>The attributes<code>nodeName</code>,<code>nodeValue</code>and<code>attributes</code>are included as a mechanism to get at node information without casting down to the specific derived interface. In cases where there is no obvious mapping of these attributes for a specific<code>nodeType</code>(e.g.,<code>nodeValue</code>for an<code>Element</code>or<code>attributes</code>for a<code>Comment</code>), this returns<code>null</code>. Note that the specialized interfaces may contain additional and more convenient mechanisms to get and set the relevant information.</p></descr><group id="ID-1841493061" name="NodeType"><descr><p>An integer indicating which type of node this is.</p><note><p>Numeric codes up to 200 are reserved to W3C for possible future use.</p></note></descr><constant name="ELEMENT_NODE" type="unsigned short" value="1"><descr><p>The node is an<code>Element</code>.</p></descr></constant><constant name="ATTRIBUTE_NODE" type="unsigned short" value="2"><descr><p>The node is an<code>Attr</code>.</p></descr></constant><constant name="TEXT_NODE" type="unsigned short" value="3"><descr><p>The node is a<code>Text</code>node.</p></descr></constant><constant name="CDATA_SECTION_NODE" type="unsigned short" value="4"><descr><p>The node is a<code>CDATASection</code>.</p></descr></constant><constant name="ENTITY_REFERENCE_NODE" type="unsigned short" value="5"><descr><p>The node is an<code>EntityReference</code>.</p></descr></constant><constant name="ENTITY_NODE" type="unsigned short" value="6"><descr><p>The node is an<code>Entity</code>.</p></descr></constant><constant name="PROCESSING_INSTRUCTION_NODE" type="unsigned short" value="7"><descr><p>The node is a<code>ProcessingInstruction</code>.</p></descr></constant><constant name="COMMENT_NODE" type="unsigned short" value="8"><descr><p>The node is a<code>Comment</code>.</p></descr></constant><constant name="DOCUMENT_NODE" type="unsigned short" value="9"><descr><p>The node is a<code>Document</code>.</p></descr></constant><constant name="DOCUMENT_TYPE_NODE" type="unsigned short" value="10"><descr><p>The node is a<code>DocumentType</code>.</p></descr></constant><constant name="DOCUMENT_FRAGMENT_NODE" type="unsigned short" value="11"><descr><p>The node is a<code>DocumentFragment</code>.</p></descr></constant><constant name="NOTATION_NODE" type="unsigned short" value="12"><descr><p>The node is a<code>Notation</code>.</p></descr></constant></group><p>The values of<code>nodeName</code>,<code>nodeValue</code>, and<code>attributes</code>vary according to the node type as follows:<table summary="Layout table: the first cell contains the name of the interface, the second contains the value of the nodeName attribute for this interface, the third contains the value of the nodeValue attribute for this interface and the fourth contains the value of the attributes attribute for this interface" border="1"><tbody><tr><th rowspan="1" colspan="1">Interface</th><th rowspan="1" colspan="1">nodeName</th><th rowspan="1" colspan="1">nodeValue</th><th rowspan="1" colspan="1">attributes</th></tr><tr><td rowspan="1" colspan="1">Attr</td><td rowspan="1" colspan="1">name of attribute</td><td rowspan="1" colspan="1">value of attribute</td><td rowspan="1" colspan="1">null</td></tr><tr><td rowspan="1" colspan="1">CDATASection</td><td rowspan="1" colspan="1">#cdata-section</td><td rowspan="1" colspan="1">content of the CDATA Section</td><td rowspan="1" colspan="1">null</td></tr><tr><td rowspan="1" colspan="1">Comment</td><td rowspan="1" colspan="1">#comment</td><td rowspan="1" colspan="1">content of the comment</td><td rowspan="1" colspan="1">null</td></tr><tr><td rowspan="1" colspan="1">Document</td><td rowspan="1" colspan="1">#document</td><td rowspan="1" colspan="1">null</td><td rowspan="1" colspan="1">null</td></tr><tr><td rowspan="1" colspan="1">DocumentFragment</td><td rowspan="1" colspan="1">#document-fragment</td><td rowspan="1" colspan="1">null</td><td rowspan="1" colspan="1">null</td></tr><tr><td rowspan="1" colspan="1">DocumentType</td><td rowspan="1" colspan="1">document type name</td><td rowspan="1" colspan="1">null</td><td rowspan="1" colspan="1">null</td></tr><tr><td rowspan="1" colspan="1">Element</td><td rowspan="1" colspan="1">tag name</td><td rowspan="1" colspan="1">null</td><td rowspan="1" colspan="1">NamedNodeMap</td></tr><tr><td rowspan="1" colspan="1">Entity</td><td rowspan="1" colspan="1">entity name</td><td rowspan="1" colspan="1">null</td><td rowspan="1" colspan="1">null</td></tr><tr><td rowspan="1" colspan="1">EntityReference</td><td rowspan="1" colspan="1">name of entity referenced</td><td rowspan="1" colspan="1">null</td><td rowspan="1" colspan="1">null</td></tr><tr><td rowspan="1" colspan="1">Notation</td><td rowspan="1" colspan="1">notation name</td><td rowspan="1" colspan="1">null</td><td rowspan="1" colspan="1">null</td></tr><tr><td rowspan="1" colspan="1">ProcessingInstruction</td><td rowspan="1" colspan="1">target</td><td rowspan="1" colspan="1">entire content excluding the target</td><td rowspan="1" colspan="1">null</td></tr><tr><td rowspan="1" colspan="1">Text</td><td rowspan="1" colspan="1">#text</td><td rowspan="1" colspan="1">content of the text node</td><td rowspan="1" colspan="1">null</td></tr></tbody></table></p><attribute type="DOMString" readonly="yes" name="nodeName" id="ID-F68D095"><descr><p>The name of this node, depending on its type; see the table above.</p></descr></attribute><attribute type="DOMString" name="nodeValue" id="ID-F68D080" readonly="no"><descr><p>The value of this node, depending on its type; see the table above. When it is defined to be<code>null</code>, setting it has no effect.</p></descr><setraises><exception name="DOMException"><descr><p>NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.</p></descr></exception></setraises><getraises><exception name="DOMException"><descr><p>DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in a<code>DOMString</code>variable on the implementation platform.</p></descr></exception></getraises></attribute><attribute type="unsigned short" name="nodeType" readonly="yes" id="ID-111237558"><descr><p>A code representing the type of the underlying object, as defined above.</p></descr></attribute><attribute type="Node" readonly="yes" name="parentNode" id="ID-1060184317"><descr><p>The<termref def="dt-parent">parent</termref>of this node. All nodes, except<code>Attr</code>,<code>Document</code>,<code>DocumentFragment</code>,<code>Entity</code>, and<code>Notation</code>may have a parent. However, if a node has just been created and not yet added to the tree, or if it has been removed from the tree, this is<code>null</code>.</p></descr></attribute><attribute type="NodeList" readonly="yes" name="childNodes" id="ID-1451460987"><descr><p>A<code>NodeList</code>that contains all children of this node. If there are no children, this is a<code>NodeList</code>containing no nodes.</p></descr></attribute><attribute readonly="yes" type="Node" name="firstChild" id="ID-169727388"><descr><p>The first child of this node. If there is no such node, this returns<code>null</code>.</p></descr></attribute><attribute readonly="yes" type="Node" name="lastChild" id="ID-61AD09FB"><descr><p>The last child of this node. If there is no such node, this returns<code>null</code>.</p></descr></attribute><attribute readonly="yes" type="Node" name="previousSibling" id="ID-640FB3C8"><descr><p>The node immediately preceding this node. If there is no such node, this returns<code>null</code>.</p></descr></attribute><attribute readonly="yes" type="Node" name="nextSibling" id="ID-6AC54C2F"><descr><p>The node immediately following this node. If there is no such node, this returns<code>null</code>.</p></descr></attribute><attribute readonly="yes" type="NamedNodeMap" name="attributes" id="ID-84CF096"><descr><p>A<code>NamedNodeMap</code>containing the attributes of this node (if it is an<code>Element</code>) or<code>null</code>otherwise.</p></descr></attribute><attribute readonly="yes" type="Document" name="ownerDocument" id="node-ownerDoc" version="DOM Level 2"><descr><p>The<code>Document</code>object associated with this node. This is also the<code>Document</code>object used to create new nodes. When this node is a<code>Document</code>or a<code>DocumentType</code>which is not used with any<code>Document</code>yet, this is<code>null</code>.</p></descr></attribute><method name="insertBefore" id="ID-952280727"><descr><p>Inserts the node<code>newChild</code>before the existing child node<code>refChild</code>. If<code>refChild</code>is<code>null</code>, insert<code>newChild</code>at the end of the list of children.</p><p>If<code>newChild</code>is a<code>DocumentFragment</code>object, all of its children are inserted, in the same order, before<code>refChild</code>. If the<code>newChild</code>is already in the tree, it is first removed.</p></descr><parameters><param name="newChild" type="Node" attr="in"><descr><p>The node to insert.</p></descr></param><param name="refChild" type="Node" attr="in"><descr><p>The reference node, i.e., the node before which the new node must be inserted.</p></descr></param></parameters><returns type="Node"><descr><p>The node being inserted.</p></descr></returns><raises><exception name="DOMException"><descr><p>HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the<code>newChild</code>node, or if the node to insert is one of this node's<termref def="dt-ancestor">ancestors</termref>.</p><p>WRONG_DOCUMENT_ERR: Raised if<code>newChild</code>was created from a different document than the one that created this node.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or if the parent of the node being inserted is readonly.</p><p>NOT_FOUND_ERR: Raised if<code>refChild</code>is not a child of this node.</p></descr></exception></raises></method><method name="replaceChild" id="ID-785887307"><descr><p>Replaces the child node<code>oldChild</code>with<code>newChild</code>in the list of children, and returns the<code>oldChild</code>node.</p><p>If<code>newChild</code>is a<code>DocumentFragment</code>object,<code>oldChild</code>is replaced by all of the<code>DocumentFragment</code>children, which are inserted in the same order. If the<code>newChild</code>is already in the tree, it is first removed.</p></descr><parameters><param name="newChild" type="Node" attr="in"><descr><p>The new node to put in the child list.</p></descr></param><param name="oldChild" type="Node" attr="in"><descr><p>The node being replaced in the list.</p></descr></param></parameters><returns type="Node"><descr><p>The node replaced.</p></descr></returns><raises><exception name="DOMException"><descr><p>HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the<code>newChild</code>node, or if the node to put in is one of this node's<termref def="dt-ancestor">ancestors</termref>.</p><p>WRONG_DOCUMENT_ERR: Raised if<code>newChild</code>was created from a different document than the one that created this node.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the parent of the new node is readonly.</p><p>NOT_FOUND_ERR: Raised if<code>oldChild</code>is not a child of this node.</p></descr></exception></raises></method><method name="removeChild" id="ID-1734834066"><descr><p>Removes the child node indicated by<code>oldChild</code>from the list of children, and returns it.</p></descr><parameters><param name="oldChild" type="Node" attr="in"><descr><p>The node being removed.</p></descr></param></parameters><returns type="Node"><descr><p>The node removed.</p></descr></returns><raises><exception name="DOMException"><descr><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p><p>NOT_FOUND_ERR: Raised if<code>oldChild</code>is not a child of this node.</p></descr></exception></raises></method><method name="appendChild" id="ID-184E7107"><descr><p>Adds the node<code>newChild</code>to the end of the list of children of this node. If the<code>newChild</code>is already in the tree, it is first removed.</p></descr><parameters><param name="newChild" type="Node" attr="in"><descr><p>The node to add.</p><p>If it is a<code>DocumentFragment</code>object, the entire contents of the document fragment are moved into the child list of this node</p></descr></param></parameters><returns type="Node"><descr><p>The node added.</p></descr></returns><raises><exception name="DOMException"><descr><p>HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the<code>newChild</code>node, or if the node to append is one of this node's<termref def="dt-ancestor">ancestors</termref>.</p><p>WRONG_DOCUMENT_ERR: Raised if<code>newChild</code>was created from a different document than the one that created this node.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p></descr></exception></raises></method><method name="hasChildNodes" id="ID-810594187"><descr><p>Returns whether this node has any children.</p></descr><parameters></parameters><returns type="boolean"><descr><p><code>true</code>if this node has any children,<code>false</code>otherwise.</p></descr></returns><raises></raises></method><method name="cloneNode" id="ID-3A0ED0A4"><descr><p>Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes. The duplicate node has no parent; (<code>parentNode</code>is<code>null</code>.).</p><p>Cloning an<code>Element</code>copies all attributes and their values, including those generated by the XML processor to represent defaulted attributes, but this method does not copy any text it contains unless it is a deep clone, since the text is contained in a child<code>Text</code>node. Cloning an<code>Attribute</code>directly, as opposed to be cloned as part of an<code>Element</code>cloning operation, returns a specified attribute (<code>specified</code>is<code>true</code>). Cloning any other type of node simply returns a copy of this node.</p><p>Note that cloning an immutable subtree results in a mutable copy, but the children of an<code>EntityReference</code>clone are<termref def="dt-readonly-node">readonly</termref>. In addition, clones of unspecified<code>Attr</code>nodes are specified. And, cloning<code>Document</code>,<code>DocumentType</code>,<code>Entity</code>, and<code>Notation</code>nodes is implementation dependent.</p></descr><parameters><param name="deep" type="boolean" attr="in"><descr><p>If<code>true</code>, recursively clone the subtree under the specified node; if<code>false</code>, clone only the node itself (and its attributes, if it is an<code>Element</code>).</p></descr></param></parameters><returns type="Node"><descr><p>The duplicate node.</p></descr></returns><raises></raises></method><method id="ID-normalize" name="normalize" version="DOM Level 2"><descr><p>Puts all<code>Text</code>nodes in the full depth of the sub-tree underneath this<code>Node</code>, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates<code>Text</code>nodes, i.e., there are neither adjacent<code>Text</code>nodes nor empty<code>Text</code>nodes. This can be used to ensure that the DOM view of a document is the same as if it were saved and re-loaded, and is useful when operations (such as XPointer<bibref ref="XPointer"/>lookups) that depend on a particular document tree structure are to be used.</p><note><p>In cases where the document contains<code>CDATASections</code>, the normalize operation alone may not be sufficient, since XPointers do not differentiate between<code>Text</code>nodes and<code>CDATASection</code>nodes.</p></note></descr><parameters></parameters><returns type="void"><descr><p/></descr></returns><raises></raises></method><method name="isSupported" id="Level-2-Core-Node-supports" since="DOM Level 2"><descr><p>Tests whether the DOM implementation implements a specific feature and that feature is supported by this node.</p></descr><parameters><param name="feature" type="DOMString" attr="in"><descr><p>The name of the feature to test. This is the same name which can be passed to the method<code>hasFeature</code>on<code>DOMImplementation</code>.</p></descr></param><param name="version" type="DOMString" attr="in"><descr><p>This is the version number of the feature to test. In Level 2, version 1, this is the string "2.0". If the version is not specified, supporting any version of the feature will cause the method to return<code>true</code>.</p></descr></param></parameters><returns type="boolean"><descr><p>Returns<code>true</code>if the specified feature is supported on this node,<code>false</code>otherwise.</p></descr></returns><raises></raises></method><attribute readonly="yes" type="DOMString" name="namespaceURI" id="ID-NodeNSname" since="DOM Level 2"><descr><p>The<termref def="dt-namespaceURI">namespace URI</termref>of this node, or<code>null</code>if it is unspecified.</p><p>This is not a computed value that is the result of a namespace lookup based on an examination of the namespace declarations in scope. It is merely the namespace URI given at creation time.</p><p>For nodes of any type other than<code>ELEMENT_NODE</code>and<code>ATTRIBUTE_NODE</code>and nodes created with a DOM Level 1 method, such as<code>createElement</code>from the<code>Document</code>interface, this is always<code>null</code>.</p><note><p>Per the<emph>Namespaces in XML</emph>Specification<bibref ref="Namespaces"/>an attribute does not inherit its namespace from the element it is attached to. If an attribute is not explicitly given a namespace, it simply has no namespace.</p></note></descr></attribute><attribute type="DOMString" name="prefix" id="ID-NodeNSPrefix" since="DOM Level 2" readonly="no"><descr><p>The<termref def="dt-namespaceprefix">namespace prefix</termref>of this node, or<code>null</code>if it is unspecified.</p><p>Note that setting this attribute, when permitted, changes the<code>nodeName</code>attribute, which holds the<termref def="dt-qualifiedname">qualified name</termref>, as well as the<code>tagName</code>and<code>name</code>attributes of the<code>Element</code>and<code>Attr</code>interfaces, when applicable.</p><p>Note also that changing the prefix of an attribute that is known to have a default value, does not make a new attribute with the default value and the original prefix appear, since the<code>namespaceURI</code>and<code>localName</code>do not change.</p><p>For nodes of any type other than<code>ELEMENT_NODE</code>and<code>ATTRIBUTE_NODE</code>and nodes created with a DOM Level 1 method, such as<code>createElement</code>from the<code>Document</code>interface, this is always<code>null</code>.</p></descr><setraises><exception name="DOMException"><descr><p>INVALID_CHARACTER_ERR: Raised if the specified prefix contains an illegal character.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p><p>NAMESPACE_ERR: Raised if the specified<code>prefix</code>is malformed, if the<code>namespaceURI</code>of this node is<code>null</code>, if the specified prefix is "xml" and the<code>namespaceURI</code>of this node is different from "", if this node is an attribute and the specified prefix is "xmlns" and the<code>namespaceURI</code>of this node is different from "", or if this node is an attribute and the<code>qualifiedName</code>of this node is "xmlns"<bibref ref="Namespaces"/>.</p></descr></exception></setraises></attribute><attribute readonly="yes" type="DOMString" name="localName" id="ID-NodeNSLocalN" since="DOM Level 2"><descr><p>Returns the local part of the<termref def="dt-qualifiedname">qualified name</termref>of this node.</p><p>For nodes of any type other than<code>ELEMENT_NODE</code>and<code>ATTRIBUTE_NODE</code>and nodes created with a DOM Level 1 method, such as<code>createElement</code>from the<code>Document</code>interface, this is always<code>null</code>.</p></descr></attribute><method name="hasAttributes" id="ID-NodeHasAttrs" since="DOM Level 2"><descr><p>Returns whether this node (if it is an element) has any attributes.</p></descr><parameters></parameters><returns type="boolean"><descr><p><code>true</code>if this node has any attributes,<code>false</code>otherwise.</p></descr></returns><raises></raises></method></interface>
+ <interface name="NodeList" id="ID-536297177"><descr><p>The<code>NodeList</code>interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented.<code>NodeList</code>objects in the DOM are<termref def="td-live">live</termref>.</p><p>The items in the<code>NodeList</code>are accessible via an integral index, starting from 0.</p></descr><method name="item" id="ID-844377136"><descr><p>Returns the<code>index</code>th item in the collection. If<code>index</code>is greater than or equal to the number of nodes in the list, this returns<code>null</code>.</p></descr><parameters><param name="index" type="unsigned long" attr="in"><descr><p>Index into the collection.</p></descr></param></parameters><returns type="Node"><descr><p>The node at the<code>index</code>th position in the<code>NodeList</code>, or<code>null</code>if that is not a valid index.</p></descr></returns><raises></raises></method><attribute type="unsigned long" readonly="yes" name="length" id="ID-203510337"><descr><p>The number of nodes in the list. The range of valid child node indices is 0 to<code>length-1</code>inclusive.</p></descr></attribute></interface>
+ <interface name="NamedNodeMap" id="ID-1780488922"><descr><p>Objects implementing the<code>NamedNodeMap</code>interface are used to represent collections of nodes that can be accessed by name. Note that<code>NamedNodeMap</code>does not inherit from<code>NodeList</code>;<code>NamedNodeMaps</code>are not maintained in any particular order. Objects contained in an object implementing<code>NamedNodeMap</code>may also be accessed by an ordinal index, but this is simply to allow convenient enumeration of the contents of a<code>NamedNodeMap</code>, and does not imply that the DOM specifies an order to these Nodes.</p><p><code>NamedNodeMap</code>objects in the DOM are<termref def="td-live">live</termref>.</p></descr><method name="getNamedItem" id="ID-1074577549"><descr><p>Retrieves a node specified by name.</p></descr><parameters><param name="name" type="DOMString" attr="in"><descr><p>The<code>nodeName</code>of a node to retrieve.</p></descr></param></parameters><returns type="Node"><descr><p>A<code>Node</code>(of any type) with the specified<code>nodeName</code>, or<code>null</code>if it does not identify any node in this map.</p></descr></returns><raises></raises></method><method name="setNamedItem" id="ID-1025163788"><descr><p>Adds a node using its<code>nodeName</code>attribute. If a node with that name is already present in this map, it is replaced by the new one.</p><p>As the<code>nodeName</code>attribute is used to derive the name which the node must be stored under, multiple nodes of certain types (those that have a "special" string value) cannot be stored as the names would clash. This is seen as preferable to allowing nodes to be aliased.</p></descr><parameters><param name="arg" type="Node" attr="in"><descr><p>A node to store in this map. The node will later be accessible using the value of its<code>nodeName</code>attribute.</p></descr></param></parameters><returns type="Node"><descr><p>If the new<code>Node</code>replaces an existing node the replaced<code>Node</code>is returned, otherwise<code>null</code>is returned.</p></descr></returns><raises><exception name="DOMException"><descr><p>WRONG_DOCUMENT_ERR: Raised if<code>arg</code>was created from a different document than the one that created this map.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.</p><p>INUSE_ATTRIBUTE_ERR: Raised if<code>arg</code>is an<code>Attr</code>that is already an attribute of another<code>Element</code>object. The DOM user must explicitly clone<code>Attr</code>nodes to re-use them in other elements.</p><p>HIERARCHY_REQUEST_ERR: Raised if an attempt is made to add a node doesn't belong in this NamedNodeMap. Examples would include trying to insert something other than an Attr node into an Element's map of attributes, or a non-Entity node into the DocumentType's map of Entities</p></descr></exception></raises></method><method name="removeNamedItem" id="ID-D58B193"><descr><p>Removes a node specified by name. When this map contains the attributes attached to an element, if the removed attribute is known to have a default value, an attribute immediately appears containing the default value as well as the corresponding namespace URI, local name, and prefix when applicable.</p></descr><parameters><param name="name" type="DOMString" attr="in"><descr><p>The<code>nodeName</code>of the node to remove.</p></descr></param></parameters><returns type="Node"><descr><p>The node removed from this map if a node with such a name exists.</p></descr></returns><raises><exception name="DOMException"><descr><p>NOT_FOUND_ERR: Raised if there is no node named<code>name</code>in this map.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.</p></descr></exception></raises></method><method name="item" id="ID-349467F9"><descr><p>Returns the<code>index</code>th item in the map. If<code>index</code>is greater than or equal to the number of nodes in this map, this returns<code>null</code>.</p></descr><parameters><param name="index" type="unsigned long" attr="in"><descr><p>Index into this map.</p></descr></param></parameters><returns type="Node"><descr><p>The node at the<code>index</code>th position in the map, or<code>null</code>if that is not a valid index.</p></descr></returns><raises></raises></method><attribute type="unsigned long" readonly="yes" name="length" id="ID-6D0FB19E"><descr><p>The number of nodes in this map. The range of valid child node indices is<code>0</code>to<code>length-1</code>inclusive.</p></descr></attribute><method name="getNamedItemNS" id="ID-getNamedItemNS" since="DOM Level 2"><descr><p>Retrieves a node specified by local name and namespace URI. HTML-only DOM implementations do not need to implement this method.</p></descr><parameters><param name="namespaceURI" type="DOMString" attr="in"><descr><p>The<termref def="dt-namespaceURI">namespace URI</termref>of the node to retrieve.</p></descr></param><param name="localName" type="DOMString" attr="in"><descr><p>The<termref def="dt-localname">local name</termref>of the node to retrieve.</p></descr></param></parameters><returns type="Node"><descr><p>A<code>Node</code>(of any type) with the specified local name and namespace URI, or<code>null</code>if they do not identify any node in this map.</p></descr></returns><raises></raises></method><method name="setNamedItemNS" id="ID-setNamedItemNS" since="DOM Level 2"><descr><p>Adds a node using its<code>namespaceURI</code>and<code>localName</code>. If a node with that namespace URI and that local name is already present in this map, it is replaced by the new one.</p><p>HTML-only DOM implementations do not need to implement this method.</p></descr><parameters><param name="arg" type="Node" attr="in"><descr><p>A node to store in this map. The node will later be accessible using the value of its<code>namespaceURI</code>and<code>localName</code>attributes.</p></descr></param></parameters><returns type="Node"><descr><p>If the new<code>Node</code>replaces an existing node the replaced<code>Node</code>is returned, otherwise<code>null</code>is returned.</p></descr></returns><raises><exception name="DOMException"><descr><p>WRONG_DOCUMENT_ERR: Raised if<code>arg</code>was created from a different document than the one that created this map.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.</p><p>INUSE_ATTRIBUTE_ERR: Raised if<code>arg</code>is an<code>Attr</code>that is already an attribute of another<code>Element</code>object. The DOM user must explicitly clone<code>Attr</code>nodes to re-use them in other elements.</p><p>HIERARCHY_REQUEST_ERR: Raised if an attempt is made to add a node doesn't belong in this NamedNodeMap. Examples would include trying to insert something other than an Attr node into an Element's map of attributes, or a non-Entity node into the DocumentType's map of Entities</p></descr></exception></raises></method><method name="removeNamedItemNS" id="ID-removeNamedItemNS" since="DOM Level 2"><descr><p>Removes a node specified by local name and namespace URI. A removed attribute may be known to have a default value when this map contains the attributes attached to an element, as returned by the attributes attribute of the<code>Node</code>interface. If so, an attribute immediately appears containing the default value as well as the corresponding namespace URI, local name, and prefix when applicable.</p><p>HTML-only DOM implementations do not need to implement this method.</p></descr><parameters><param name="namespaceURI" type="DOMString" attr="in"><descr><p>The<termref def="dt-namespaceURI">namespace URI</termref>of the node to remove.</p></descr></param><param name="localName" type="DOMString" attr="in"><descr><p>The<termref def="dt-localname">local name</termref>of the node to remove.</p></descr></param></parameters><returns type="Node"><descr><p>The node removed from this map if a node with such a local name and namespace URI exists.</p></descr></returns><raises><exception name="DOMException"><descr><p>NOT_FOUND_ERR: Raised if there is no node with the specified<code>namespaceURI</code>and<code>localName</code>in this map.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.</p></descr></exception></raises></method></interface>
+ <interface name="CharacterData" inherits="Node" id="ID-FF21A306"><descr><p>The<code>CharacterData</code>interface extends Node with a set of attributes and methods for accessing character data in the DOM. For clarity this set is defined here rather than on each object that uses these attributes and methods. No DOM objects correspond directly to<code>CharacterData</code>, though<code>Text</code>and others do inherit the interface from it. All<code>offsets</code>in this interface start from<code>0</code>.</p><p>As explained in the<code>DOMString</code>interface, text strings in the DOM are represented in UTF-16, i.e. as a sequence of 16-bit units. In the following, the term<termref def="dt-16-bit-unit">16-bit units</termref>is used whenever necessary to indicate that indexing on CharacterData is done in 16-bit units.</p></descr><attribute type="DOMString" name="data" id="ID-72AB8359" readonly="no"><descr><p>The character data of the node that implements this interface. The DOM implementation may not put arbitrary limits on the amount of data that may be stored in a<code>CharacterData</code>node. However, implementation limits may mean that the entirety of a node's data may not fit into a single<code>DOMString</code>. In such cases, the user may call<code>substringData</code>to retrieve the data in appropriately sized pieces.</p></descr><setraises><exception name="DOMException"><descr><p>NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.</p></descr></exception></setraises><getraises><exception name="DOMException"><descr><p>DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in a<code>DOMString</code>variable on the implementation platform.</p></descr></exception></getraises></attribute><attribute type="unsigned long" name="length" readonly="yes" id="ID-7D61178C"><descr><p>The number of<termref def="dt-16-bit-unit">16-bit units</termref>that are available through<code>data</code>and the<code>substringData</code>method below. This may have the value zero, i.e.,<code>CharacterData</code>nodes may be empty.</p></descr></attribute><method name="substringData" id="ID-6531BCCF"><descr><p>Extracts a range of data from the node.</p></descr><parameters><param name="offset" type="unsigned long" attr="in"><descr><p>Start offset of substring to extract.</p></descr></param><param name="count" type="unsigned long" attr="in"><descr><p>The number of 16-bit units to extract.</p></descr></param></parameters><returns type="DOMString"><descr><p>The specified substring. If the sum of<code>offset</code>and<code>count</code>exceeds the<code>length</code>, then all 16-bit units to the end of the data are returned.</p></descr></returns><raises><exception name="DOMException"><descr><p>INDEX_SIZE_ERR: Raised if the specified<code>offset</code>is negative or greater than the number of 16-bit units in<code>data</code>, or if the specified<code>count</code>is negative.</p><p>DOMSTRING_SIZE_ERR: Raised if the specified range of text does not fit into a<code>DOMString</code>.</p></descr></exception></raises></method><method name="appendData" id="ID-32791A2F"><descr><p>Append the string to the end of the character data of the node. Upon success,<code>data</code>provides access to the concatenation of<code>data</code>and the<code>DOMString</code>specified.</p></descr><parameters><param name="arg" type="DOMString" attr="in"><descr><p>The<code>DOMString</code>to append.</p></descr></param></parameters><returns type="void"><descr><p/></descr></returns><raises><exception name="DOMException"><descr><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p></descr></exception></raises></method><method name="insertData" id="ID-3EDB695F"><descr><p>Insert a string at the specified<termref def="dt-16-bit-unit">16-bit unit</termref>offset.</p></descr><parameters><param name="offset" type="unsigned long" attr="in"><descr><p>The character offset at which to insert.</p></descr></param><param name="arg" type="DOMString" attr="in"><descr><p>The<code>DOMString</code>to insert.</p></descr></param></parameters><returns type="void"><descr><p/></descr></returns><raises><exception name="DOMException"><descr><p>INDEX_SIZE_ERR: Raised if the specified<code>offset</code>is negative or greater than the number of 16-bit units in<code>data</code>.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p></descr></exception></raises></method><method name="deleteData" id="ID-7C603781"><descr><p>Remove a range of<termref def="dt-16-bit-unit">16-bit units</termref>from the node. Upon success,<code>data</code>and<code>length</code>reflect the change.</p></descr><parameters><param name="offset" type="unsigned long" attr="in"><descr><p>The offset from which to start removing.</p></descr></param><param name="count" type="unsigned long" attr="in"><descr><p>The number of 16-bit units to delete. If the sum of<code>offset</code>and<code>count</code>exceeds<code>length</code>then all 16-bit units from<code>offset</code>to the end of the data are deleted.</p></descr></param></parameters><returns type="void"><descr><p/></descr></returns><raises><exception name="DOMException"><descr><p>INDEX_SIZE_ERR: Raised if the specified<code>offset</code>is negative or greater than the number of 16-bit units in<code>data</code>, or if the specified<code>count</code>is negative.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p></descr></exception></raises></method><method name="replaceData" id="ID-E5CBA7FB"><descr><p>Replace the characters starting at the specified<termref def="dt-16-bit-unit">16-bit unit</termref>offset with the specified string.</p></descr><parameters><param name="offset" type="unsigned long" attr="in"><descr><p>The offset from which to start replacing.</p></descr></param><param name="count" type="unsigned long" attr="in"><descr><p>The number of 16-bit units to replace. If the sum of<code>offset</code>and<code>count</code>exceeds<code>length</code>, then all 16-bit units to the end of the data are replaced; (i.e., the effect is the same as a<code>remove</code>method call with the same range, followed by an<code>append</code>method invocation).</p></descr></param><param name="arg" type="DOMString" attr="in"><descr><p>The<code>DOMString</code>with which the range must be replaced.</p></descr></param></parameters><returns type="void"><descr><p/></descr></returns><raises><exception name="DOMException"><descr><p>INDEX_SIZE_ERR: Raised if the specified<code>offset</code>is negative or greater than the number of 16-bit units in<code>data</code>, or if the specified<code>count</code>is negative.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p></descr></exception></raises></method></interface>
+ <interface name="Attr" inherits="Node" id="ID-637646024"><descr><p>The<code>Attr</code>interface represents an attribute in an<code>Element</code>object. Typically the allowable values for the attribute are defined in a document type definition.</p><p><code>Attr</code>objects inherit the<code>Node</code>interface, but since they are not actually child nodes of the element they describe, the DOM does not consider them part of the document tree. Thus, the<code>Node</code>attributes<code>parentNode</code>,<code>previousSibling</code>, and<code>nextSibling</code>have a<code>null</code>value for<code>Attr</code>objects. The DOM takes the view that attributes are properties of elements rather than having a separate identity from the elements they are associated with; this should make it more efficient to implement such features as default attributes associated with all elements of a given type. Furthermore,<code>Attr</code>nodes may not be immediate children of a<code>DocumentFragment</code>. However, they can be associated with<code>Element</code>nodes contained within a<code>DocumentFragment</code>. In short, users and implementors of the DOM need to be aware that<code>Attr</code>nodes have some things in common with other objects inheriting the<code>Node</code>interface, but they also are quite distinct.</p><p>The attribute's effective value is determined as follows: if this attribute has been explicitly assigned any value, that value is the attribute's effective value; otherwise, if there is a declaration for this attribute, and that declaration includes a default value, then that default value is the attribute's effective value; otherwise, the attribute does not exist on this element in the structure model until it has been explicitly added. Note that the<code>nodeValue</code>attribute on the<code>Attr</code>instance can also be used to retrieve the string version of the attribute's value(s).</p><p>In XML, where the value of an attribute can contain entity references, the child nodes of the<code>Attr</code>node may be either<code>Text</code>or<code>EntityReference</code>nodes (when these are in use; see the description of<code>EntityReference</code>for discussion). Because the DOM Core is not aware of attribute types, it treats all attribute values as simple strings, even if the DTD or schema declares them as having<termref def="dt-tokenized">tokenized</termref>types.</p></descr><attribute type="DOMString" readonly="yes" name="name" id="ID-1112119403"><descr><p>Returns the name of this attribute.</p></descr></attribute><attribute type="boolean" readonly="yes" name="specified" id="ID-862529273"><descr><p>If this attribute was explicitly given a value in the original document, this is<code>true</code>; otherwise, it is<code>false</code>. Note that the implementation is in charge of this attribute, not the user. If the user changes the value of the attribute (even if it ends up having the same value as the default value) then the<code>specified</code>flag is automatically flipped to<code>true</code>. To re-specify the attribute as the default value from the DTD, the user must delete the attribute. The implementation will then make a new attribute available with<code>specified</code>set to<code>false</code>and the default value (if one exists).</p><p>In summary:<ulist><item><p>If the attribute has an assigned value in the document then<code>specified</code>is<code>true</code>, and the value is the assigned value.</p></item><item><p>If the attribute has no assigned value in the document and has a default value in the DTD, then<code>specified</code>is<code>false</code>, and the value is the default value in the DTD.</p></item><item><p>If the attribute has no assigned value in the document and has a value of #IMPLIED in the DTD, then the attribute does not appear in the structure model of the document.</p></item><item><p>If the<code>ownerElement</code>attribute is<code>null</code>(i.e. because it was just created or was set to<code>null</code>by the various removal and cloning operations)<code>specified</code>is<code>true</code>.</p></item></ulist></p></descr></attribute><attribute type="DOMString" name="value" id="ID-221662474" readonly="no"><descr><p>On retrieval, the value of the attribute is returned as a string. Character and general entity references are replaced with their values. See also the method<code>getAttribute</code>on the<code>Element</code>interface.</p><p>On setting, this creates a<code>Text</code>node with the unparsed contents of the string. I.e. any characters that an XML processor would recognize as markup are instead treated as literal text. See also the method<code>setAttribute</code>on the<code>Element</code>interface.</p></descr><setraises><exception name="DOMException"><descr><p>NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.</p></descr></exception></setraises></attribute><attribute name="ownerElement" type="Element" readonly="yes" id="Attr-ownerElement" since="DOM Level 2"><descr><p>The<code>Element</code>node this attribute is attached to or<code>null</code>if this attribute is not in use.</p></descr></attribute></interface>
+ <interface name="Element" inherits="Node" id="ID-745549614"><descr><p>The<code>Element</code>interface represents an<termref def="dt-element">element</termref>in an HTML or XML document. Elements may have attributes associated with them; since the<code>Element</code>interface inherits from<code>Node</code>, the generic<code>Node</code>interface attribute<code>attributes</code>may be used to retrieve the set of all attributes for an element. There are methods on the<code>Element</code>interface to retrieve either an<code>Attr</code>object by name or an attribute value by name. In XML, where an attribute value may contain entity references, an<code>Attr</code>object should be retrieved to examine the possibly fairly complex sub-tree representing the attribute value. On the other hand, in HTML, where all attributes have simple string values, methods to directly access an attribute value can safely be used as a<termref def="dt-convenience">convenience</termref>.</p><note><p>In DOM Level 2, the method<code>normalize</code>is inherited from the<code>Node</code>interface where it was moved.</p></note></descr><attribute type="DOMString" name="tagName" readonly="yes" id="ID-104682815"><descr><p>The name of the element. For example, in:<eg role="code" xml:space="preserve">&lt;elementExample id="demo"&gt; ... &lt;/elementExample&gt; ,</eg><code>tagName</code>has the value<code>"elementExample"</code>. Note that this is case-preserving in XML, as are all of the operations of the DOM. The HTML DOM returns the<code>tagName</code>of an HTML element in the canonical uppercase form, regardless of the case in the source HTML document.</p></descr></attribute><method name="getAttribute" id="ID-666EE0F9"><descr><p>Retrieves an attribute value by name.</p></descr><parameters><param name="name" type="DOMString" attr="in"><descr><p>The name of the attribute to retrieve.</p></descr></param></parameters><returns type="DOMString"><descr><p>The<code>Attr</code>value as a string, or the empty string if that attribute does not have a specified or default value.</p></descr></returns><raises></raises></method><method name="setAttribute" id="ID-F68F082"><descr><p>Adds a new attribute. If an attribute with that name is already present in the element, its value is changed to be that of the value parameter. This value is a simple string; it is not parsed as it is being set. So any markup (such as syntax to be recognized as an entity reference) is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out. In order to assign an attribute value that contains entity references, the user must create an<code>Attr</code>node plus any<code>Text</code>and<code>EntityReference</code>nodes, build the appropriate subtree, and use<code>setAttributeNode</code>to assign it as the value of an attribute.</p><p>To set an attribute with a qualified name and namespace URI, use the<code>setAttributeNS</code>method.</p></descr><parameters><param name="name" type="DOMString" attr="in"><descr><p>The name of the attribute to create or alter.</p></descr></param><param name="value" type="DOMString" attr="in"><descr><p>Value to set in string form.</p></descr></param></parameters><returns type="void"><descr><p/></descr></returns><raises><exception name="DOMException"><descr><p>INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p></descr></exception></raises></method><method name="removeAttribute" id="ID-6D6AC0F9"><descr><p>Removes an attribute by name. If the removed attribute is known to have a default value, an attribute immediately appears containing the default value as well as the corresponding namespace URI, local name, and prefix when applicable.</p><p>To remove an attribute by local name and namespace URI, use the<code>removeAttributeNS</code>method.</p></descr><parameters><param name="name" type="DOMString" attr="in"><descr><p>The name of the attribute to remove.</p></descr></param></parameters><returns type="void"><descr><p/></descr></returns><raises><exception name="DOMException"><descr><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p></descr></exception></raises></method><method name="getAttributeNode" id="ID-217A91B8"><descr><p>Retrieves an attribute node by name.</p><p>To retrieve an attribute node by qualified name and namespace URI, use the<code>getAttributeNodeNS</code>method.</p></descr><parameters><param name="name" type="DOMString" attr="in"><descr><p>The name (<code>nodeName</code>) of the attribute to retrieve.</p></descr></param></parameters><returns type="Attr"><descr><p>The<code>Attr</code>node with the specified name (<code>nodeName</code>) or<code>null</code>if there is no such attribute.</p></descr></returns><raises></raises></method><method name="setAttributeNode" id="ID-887236154"><descr><p>Adds a new attribute node. If an attribute with that name (<code>nodeName</code>) is already present in the element, it is replaced by the new one.</p><p>To add a new attribute node with a qualified name and namespace URI, use the<code>setAttributeNodeNS</code>method.</p></descr><parameters><param name="newAttr" type="Attr" attr="in"><descr><p>The<code>Attr</code>node to add to the attribute list.</p></descr></param></parameters><returns type="Attr"><descr><p>If the<code>newAttr</code>attribute replaces an existing attribute, the replaced<code>Attr</code>node is returned, otherwise<code>null</code>is returned.</p></descr></returns><raises><exception name="DOMException"><descr><p>WRONG_DOCUMENT_ERR: Raised if<code>newAttr</code>was created from a different document than the one that created the element.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p><p>INUSE_ATTRIBUTE_ERR: Raised if<code>newAttr</code>is already an attribute of another<code>Element</code>object. The DOM user must explicitly clone<code>Attr</code>nodes to re-use them in other elements.</p></descr></exception></raises></method><method name="removeAttributeNode" id="ID-D589198"><descr><p>Removes the specified attribute node. If the removed<code>Attr</code>has a default value it is immediately replaced. The replacing attribute has the same namespace URI and local name, as well as the original prefix, when applicable.</p></descr><parameters><param name="oldAttr" type="Attr" attr="in"><descr><p>The<code>Attr</code>node to remove from the attribute list.</p></descr></param></parameters><returns type="Attr"><descr><p>The<code>Attr</code>node that was removed.</p></descr></returns><raises><exception name="DOMException"><descr><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p><p>NOT_FOUND_ERR: Raised if<code>oldAttr</code>is not an attribute of the element.</p></descr></exception></raises></method><method name="getElementsByTagName" id="ID-1938918D"><descr><p>Returns a<code>NodeList</code>of all<termref def="dt-descendant">descendant</termref><code>Elements</code>with a given tag name, in the order in which they are encountered in a preorder traversal of this<code>Element</code>tree.</p></descr><parameters><param name="tagname" type="DOMString" attr="in"><descr><p>The name of the tag to match on. The special value "*" matches all tags.</p></descr></param></parameters><returns type="NodeList"><descr><p>A list of matching<code>Element</code>nodes.</p></descr></returns><raises></raises></method><method name="getAttributeNS" id="ID-ElGetAttrNS" since="DOM Level 2"><descr><p>Retrieves an attribute value by local name and namespace URI. HTML-only DOM implementations do not need to implement this method.</p></descr><parameters><param name="namespaceURI" type="DOMString" attr="in"><descr><p>The<termref def="dt-namespaceURI">namespace URI</termref>of the attribute to retrieve.</p></descr></param><param name="localName" type="DOMString" attr="in"><descr><p>The<termref def="dt-localname">local name</termref>of the attribute to retrieve.</p></descr></param></parameters><returns type="DOMString"><descr><p>The<code>Attr</code>value as a string, or the empty string if that attribute does not have a specified or default value.</p></descr></returns><raises></raises></method><method name="setAttributeNS" id="ID-ElSetAttrNS" since="DOM Level 2"><descr><p>Adds a new attribute. If an attribute with the same local name and namespace URI is already present on the element, its prefix is changed to be the prefix part of the<code>qualifiedName</code>, and its value is changed to be the<code>value</code>parameter. This value is a simple string; it is not parsed as it is being set. So any markup (such as syntax to be recognized as an entity reference) is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out. In order to assign an attribute value that contains entity references, the user must create an<code>Attr</code>node plus any<code>Text</code>and<code>EntityReference</code>nodes, build the appropriate subtree, and use<code>setAttributeNodeNS</code>or<code>setAttributeNode</code>to assign it as the value of an attribute.</p><p>HTML-only DOM implementations do not need to implement this method.</p></descr><parameters><param name="namespaceURI" type="DOMString" attr="in"><descr><p>The<termref def="dt-namespaceURI">namespace URI</termref>of the attribute to create or alter.</p></descr></param><param name="qualifiedName" type="DOMString" attr="in"><descr><p>The<termref def="dt-qualifiedname">qualified name</termref>of the attribute to create or alter.</p></descr></param><param name="value" type="DOMString" attr="in"><descr><p>The value to set in string form.</p></descr></param></parameters><returns type="void"><descr><p/></descr></returns><raises><exception name="DOMException"><descr><p>INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p><p>NAMESPACE_ERR: Raised if the<code>qualifiedName</code>is malformed, if the<code>qualifiedName</code>has a prefix and the<code>namespaceURI</code>is<code>null</code>, if the<code>qualifiedName</code>has a prefix that is "xml" and the<code>namespaceURI</code>is different from "", or if the<code>qualifiedName</code>is "xmlns" and the<code>namespaceURI</code>is different from "".</p></descr></exception></raises></method><method name="removeAttributeNS" id="ID-ElRemAtNS" since="DOM Level 2"><descr><p>Removes an attribute by local name and namespace URI. If the removed attribute has a default value it is immediately replaced. The replacing attribute has the same namespace URI and local name, as well as the original prefix.</p><p>HTML-only DOM implementations do not need to implement this method.</p></descr><parameters><param name="namespaceURI" type="DOMString" attr="in"><descr><p>The<termref def="dt-namespaceURI">namespace URI</termref>of the attribute to remove.</p></descr></param><param name="localName" type="DOMString" attr="in"><descr><p>The<termref def="dt-localname">local name</termref>of the attribute to remove.</p></descr></param></parameters><returns type="void"><descr><p/></descr></returns><raises><exception name="DOMException"><descr><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p></descr></exception></raises></method><method name="getAttributeNodeNS" id="ID-ElGetAtNodeNS" since="DOM Level 2"><descr><p>Retrieves an<code>Attr</code>node by local name and namespace URI. HTML-only DOM implementations do not need to implement this method.</p></descr><parameters><param name="namespaceURI" type="DOMString" attr="in"><descr><p>The<termref def="dt-namespaceURI">namespace URI</termref>of the attribute to retrieve.</p></descr></param><param name="localName" type="DOMString" attr="in"><descr><p>The<termref def="dt-localname">local name</termref>of the attribute to retrieve.</p></descr></param></parameters><returns type="Attr"><descr><p>The<code>Attr</code>node with the specified attribute local name and namespace URI or<code>null</code>if there is no such attribute.</p></descr></returns><raises></raises></method><method name="setAttributeNodeNS" id="ID-ElSetAtNodeNS" since="DOM Level 2"><descr><p>Adds a new attribute. If an attribute with that local name and that namespace URI is already present in the element, it is replaced by the new one.</p><p>HTML-only DOM implementations do not need to implement this method.</p></descr><parameters><param name="newAttr" type="Attr" attr="in"><descr><p>The<code>Attr</code>node to add to the attribute list.</p></descr></param></parameters><returns type="Attr"><descr><p>If the<code>newAttr</code>attribute replaces an existing attribute with the same<termref def="dt-localname">local name</termref>and<termref def="dt-namespaceURI">namespace URI</termref>, the replaced<code>Attr</code>node is returned, otherwise<code>null</code>is returned.</p></descr></returns><raises><exception name="DOMException"><descr><p>WRONG_DOCUMENT_ERR: Raised if<code>newAttr</code>was created from a different document than the one that created the element.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p><p>INUSE_ATTRIBUTE_ERR: Raised if<code>newAttr</code>is already an attribute of another<code>Element</code>object. The DOM user must explicitly clone<code>Attr</code>nodes to re-use them in other elements.</p></descr></exception></raises></method><method name="getElementsByTagNameNS" id="ID-A6C90942" since="DOM Level 2"><descr><p>Returns a<code>NodeList</code>of all the<termref def="dt-descendant">descendant</termref><code>Elements</code>with a given local name and namespace URI in the order in which they are encountered in a preorder traversal of this<code>Element</code>tree.</p><p>HTML-only DOM implementations do not need to implement this method.</p></descr><parameters><param name="namespaceURI" type="DOMString" attr="in"><descr><p>The<termref def="dt-namespaceURI">namespace URI</termref>of the elements to match on. The special value "*" matches all namespaces.</p></descr></param><param name="localName" type="DOMString" attr="in"><descr><p>The<termref def="dt-localname">local name</termref>of the elements to match on. The special value "*" matches all local names.</p></descr></param></parameters><returns type="NodeList"><descr><p>A new<code>NodeList</code>object containing all the matched<code>Elements</code>.</p></descr></returns><raises></raises></method><method name="hasAttribute" id="ID-ElHasAttr" since="DOM Level 2"><descr><p>Returns<code>true</code>when an attribute with a given name is specified on this element or has a default value,<code>false</code>otherwise.</p></descr><parameters><param name="name" type="DOMString" attr="in"><descr><p>The name of the attribute to look for.</p></descr></param></parameters><returns type="boolean"><descr><p><code>true</code>if an attribute with the given name is specified on this element or has a default value,<code>false</code>otherwise.</p></descr></returns><raises></raises></method><method name="hasAttributeNS" id="ID-ElHasAttrNS" since="DOM Level 2"><descr><p>Returns<code>true</code>when an attribute with a given local name and namespace URI is specified on this element or has a default value,<code>false</code>otherwise. HTML-only DOM implementations do not need to implement this method.</p></descr><parameters><param name="namespaceURI" type="DOMString" attr="in"><descr><p>The<termref def="dt-namespaceURI">namespace URI</termref>of the attribute to look for.</p></descr></param><param name="localName" type="DOMString" attr="in"><descr><p>The<termref def="dt-localname">local name</termref>of the attribute to look for.</p></descr></param></parameters><returns type="boolean"><descr><p><code>true</code>if an attribute with the given local name and namespace URI is specified or has a default value on this element,<code>false</code>otherwise.</p></descr></returns><raises></raises></method></interface>
+ <interface name="Text" inherits="CharacterData" id="ID-1312295772"><descr><p>The<code>Text</code>interface inherits from<code>CharacterData</code>and represents the textual content (termedin XML) of an<code>Element</code>or<code>Attr</code>. If there is no markup inside an element's content, the text is contained in a single object implementing the<code>Text</code>interface that is the only child of the element. If there is markup, it is parsed into the<termref def="dt-infoitem">information items</termref>(elements, comments, etc.) and<code>Text</code>nodes that form the list of children of the element.</p><p>When a document is first made available via the DOM, there is only one<code>Text</code>node for each block of text. Users may create adjacent<code>Text</code>nodes that represent the contents of a given element without any intervening markup, but should be aware that there is no way to represent the separations between these nodes in XML or HTML, so they will not (in general) persist between DOM editing sessions. The<code>normalize()</code>method on<code>Node</code>merges any such adjacent<code>Text</code>objects into a single node for each block of text.</p></descr><method name="splitText" id="ID-38853C1D"><descr><p>Breaks this node into two nodes at the specified<code>offset</code>, keeping both in the tree as<termref def="dt-sibling">siblings</termref>. After being split, this node will contain all the content up to the<code>offset</code>point. A new node of the same type, which contains all the content at and after the<code>offset</code>point, is returned. If the original node had a parent node, the new node is inserted as the next<termref def="dt-sibling">sibling</termref>of the original node. When the<code>offset</code>is equal to the length of this node, the new node has no data.</p></descr><parameters><param name="offset" type="unsigned long" attr="in"><descr><p>The<termref def="dt-16-bit-unit">16-bit unit</termref>offset at which to split, starting from<code>0</code>.</p></descr></param></parameters><returns type="Text"><descr><p>The new node, of the same type as this node.</p></descr></returns><raises><exception name="DOMException"><descr><p>INDEX_SIZE_ERR: Raised if the specified offset is negative or greater than the number of 16-bit units in<code>data</code>.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p></descr></exception></raises></method></interface>
+ <interface name="Comment" inherits="CharacterData" id="ID-1728279322"><descr><p>This interface inherits from<code>CharacterData</code>and represents the content of a comment, i.e., all the characters between the starting '<code>&lt;!--</code>' and ending '<code>--&gt;</code>'. Note that this is the definition of a comment in XML, and, in practice, HTML, although some HTML tools may implement the full SGML comment structure.</p></descr></interface>
+ <interface name="CDATASection" inherits="Text" id="ID-667469212"><descr><p>CDATA sections are used to escape blocks of text containing characters that would otherwise be regarded as markup. The only delimiter that is recognized in a CDATA section is the "]]&gt;" string that ends the CDATA section. CDATA sections cannot be nested. Their primary purpose is for including material such as XML fragments, without needing to escape all the delimiters.</p><p>The<code>DOMString</code>attribute of the<code>Text</code>node holds the text that is contained by the CDATA section. Note that this<emph>may</emph>contain characters that need to be escaped outside of CDATA sections and that, depending on the character encoding ("charset") chosen for serialization, it may be impossible to write out some characters as part of a CDATA section.</p><p>The<code>CDATASection</code>interface inherits from the<code>CharacterData</code>interface through the<code>Text</code>interface. Adjacent<code>CDATASection</code>nodes are not merged by use of the<code>normalize</code>method of the<code>Node</code>interface.</p><note><p>Because no markup is recognized within a<code>CDATASection</code>, character numeric references cannot be used as an escape mechanism when serializing. Therefore, action needs to be taken when serializing a<code>CDATASection</code>with a character encoding where some of the contained characters cannot be represented. Failure to do so would not produce well-formed XML.</p><p>One potential solution in the serialization process is to end the CDATA section before the character, output the character using a character reference or entity reference, and open a new CDATA section for any further characters in the text node. Note, however, that some code conversion libraries at the time of writing do not return an error or exception when a character is missing from the encoding, making the task of ensuring that data is not corrupted on serialization more difficult.</p></note></descr></interface>
+ <interface name="DocumentType" inherits="Node" id="ID-412266927"><descr><p>Each<code>Document</code>has a<code>doctype</code>attribute whose value is either<code>null</code>or a<code>DocumentType</code>object. The<code>DocumentType</code>interface in the DOM Core provides an interface to the list of entities that are defined for the document, and little else because the effect of namespaces and the various XML schema efforts on DTD representation are not clearly understood as of this writing.</p><p>The DOM Level 2 doesn't support editing<code>DocumentType</code>nodes.</p></descr><attribute readonly="yes" name="name" type="DOMString" id="ID-1844763134"><descr><p>The name of DTD; i.e., the name immediately following the<code>DOCTYPE</code>keyword.</p></descr></attribute><attribute readonly="yes" name="entities" type="NamedNodeMap" id="ID-1788794630"><descr><p>A<code>NamedNodeMap</code>containing the general entities, both external and internal, declared in the DTD. Parameter entities are not contained. Duplicates are discarded. For example in:<eg role="code" xml:space="preserve">&lt;!DOCTYPE ex SYSTEM "ex.dtd" [ &lt;!ENTITY foo "foo"&gt; &lt;!ENTITY bar "bar"&gt; &lt;!ENTITY bar "bar2"&gt; &lt;!ENTITY % baz "baz"&gt; ]&gt; &lt;ex/&gt;</eg>the interface provides access to<code>foo</code>and the first declaration of<code>bar</code>but not the second declaration of<code>bar</code>or<code>baz</code>. Every node in this map also implements the<code>Entity</code>interface.</p><p>The DOM Level 2 does not support editing entities, therefore<code>entities</code>cannot be altered in any way.</p></descr></attribute><attribute readonly="yes" name="notations" type="NamedNodeMap" id="ID-D46829EF"><descr><p>A<code>NamedNodeMap</code>containing the notations declared in the DTD. Duplicates are discarded. Every node in this map also implements the<code>Notation</code>interface.</p><p>The DOM Level 2 does not support editing notations, therefore<code>notations</code>cannot be altered in any way.</p></descr></attribute><attribute readonly="yes" name="publicId" type="DOMString" id="ID-Core-DocType-publicId" since="DOM Level 2"><descr><p>The public identifier of the external subset.</p></descr></attribute><attribute readonly="yes" name="systemId" type="DOMString" id="ID-Core-DocType-systemId" since="DOM Level 2"><descr><p>The system identifier of the external subset.</p></descr></attribute><attribute readonly="yes" name="internalSubset" type="DOMString" id="ID-Core-DocType-internalSubset" since="DOM Level 2"><descr><p>The internal subset as a string.</p><note><p>The actual content returned depends on how much information is available to the implementation. This may vary depending on various parameters, including the XML processor used to build the document.</p></note></descr></attribute></interface>
+ <interface name="Notation" inherits="Node" id="ID-5431D1B9"><descr><p>This interface represents a notation declared in the DTD. A notation either declares, by name, the format of an unparsed entity (seeof the XML 1.0 specification<bibref ref="XML"/>), or is used for formal declaration of processing instruction targets (seeof the XML 1.0 specification<bibref ref="XML"/>). The<code>nodeName</code>attribute inherited from<code>Node</code>is set to the declared name of the notation.</p><p>The DOM Level 1 does not support editing<code>Notation</code>nodes; they are therefore<termref def="dt-readonly-node">readonly</termref>.</p><p>A<code>Notation</code>node does not have any parent.</p></descr><attribute readonly="yes" name="publicId" type="DOMString" id="ID-54F2B4D0"><descr><p>The public identifier of this notation. If the public identifier was not specified, this is<code>null</code>.</p></descr></attribute><attribute readonly="yes" name="systemId" type="DOMString" id="ID-E8AAB1D0"><descr><p>The system identifier of this notation. If the system identifier was not specified, this is<code>null</code>.</p></descr></attribute></interface>
+ <interface name="Entity" inherits="Node" id="ID-527DCFF2"><descr><p>This interface represents an entity, either parsed or unparsed, in an XML document. Note that this models the entity itself<emph>not</emph>the entity declaration.<code>Entity</code>declaration modeling has been left for a later Level of the DOM specification.</p><p>The<code>nodeName</code>attribute that is inherited from<code>Node</code>contains the name of the entity.</p><p>An XML processor may choose to completely expand entities before the structure model is passed to the DOM; in this case there will be no<code>EntityReference</code>nodes in the document tree.</p><p>XML does not mandate that a non-validating XML processor read and process entity declarations made in the external subset or declared in external parameter entities. This means that parsed entities declared in the external subset need not be expanded by some classes of applications, and that the replacement value of the entity may not be available. When the replacement value is available, the corresponding<code>Entity</code>node's child list represents the structure of that replacement text. Otherwise, the child list is empty.</p><p>The DOM Level 2 does not support editing<code>Entity</code>nodes; if a user wants to make changes to the contents of an<code>Entity</code>, every related<code>EntityReference</code>node has to be replaced in the structure model by a clone of the<code>Entity</code>'s contents, and then the desired changes must be made to each of those clones instead.<code>Entity</code>nodes and all their<termref def="dt-descendant">descendants</termref>are<termref def="dt-readonly-node">readonly</termref>.</p><p>An<code>Entity</code>node does not have any parent.</p><note><p>If the entity contains an unbound<termref def="dt-namespaceprefix">namespace prefix</termref>, the<code>namespaceURI</code>of the corresponding node in the<code>Entity</code>node subtree is<code>null</code>. The same is true for<code>EntityReference</code>nodes that refer to this entity, when they are created using the<code>createEntityReference</code>method of the<code>Document</code>interface. The DOM Level 2 does not support any mechanism to resolve namespace prefixes.</p></note></descr><attribute readonly="yes" name="publicId" type="DOMString" id="ID-D7303025"><descr><p>The public identifier associated with the entity, if specified. If the public identifier was not specified, this is<code>null</code>.</p></descr></attribute><attribute readonly="yes" name="systemId" type="DOMString" id="ID-D7C29F3E"><descr><p>The system identifier associated with the entity, if specified. If the system identifier was not specified, this is<code>null</code>.</p></descr></attribute><attribute readonly="yes" name="notationName" type="DOMString" id="ID-6ABAEB38"><descr><p>For unparsed entities, the name of the notation for the entity. For parsed entities, this is<code>null</code>.</p></descr></attribute></interface>
+ <interface name="EntityReference" inherits="Node" id="ID-11C98490"><descr><p><code>EntityReference</code>objects may be inserted into the structure model when an entity reference is in the source document, or when the user wishes to insert an entity reference. Note that character references and references to predefined entities are considered to be expanded by the HTML or XML processor so that characters are represented by their Unicode equivalent rather than by an entity reference. Moreover, the XML processor may completely expand references to entities while building the structure model, instead of providing<code>EntityReference</code>objects. If it does provide such objects, then for a given<code>EntityReference</code>node, it may be that there is no<code>Entity</code>node representing the referenced entity. If such an<code>Entity</code>exists, then the subtree of the<code>EntityReference</code>node is in general a copy of the<code>Entity</code>node subtree. However, this may not be true when an entity contains an unbound<termref def="dt-namespaceprefix">namespace prefix</termref>. In such a case, because the namespace prefix resolution depends on where the entity reference is, the<termref def="dt-descendant">descendants</termref>of the<code>EntityReference</code>node may be bound to different<termref def="dt-namespaceURI">namespace URIs</termref>.</p><p>As for<code>Entity</code>nodes,<code>EntityReference</code>nodes and all their<termref def="dt-descendant">descendants</termref>are<termref def="dt-readonly-node">readonly</termref>.</p></descr></interface>
+ <interface name="ProcessingInstruction" inherits="Node" id="ID-1004215813"><descr><p>The<code>ProcessingInstruction</code>interface represents a "processing instruction", used in XML as a way to keep processor-specific information in the text of the document.</p></descr><attribute readonly="yes" type="DOMString" name="target" id="ID-1478689192"><descr><p>The target of this processing instruction. XML defines this as being the first<termref def="dt-token">token</termref>following the markup that begins the processing instruction.</p></descr></attribute><attribute type="DOMString" name="data" id="ID-837822393" readonly="no"><descr><p>The content of this processing instruction. This is from the first non white space character after the target to the character immediately preceding the<code>?&gt;</code>.</p></descr><setraises><exception name="DOMException"><descr><p>NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.</p></descr></exception></setraises></attribute></interface>
+ <interface id="i18n-methods-StringExtend" name="StringExtend"><descr><p>Extensions to a language's native String class or interface</p></descr><method id="i18n-methods-StringExtend-findOffset16" name="findOffset16"><descr><p>Returns the UTF-16 offset that corresponds to a UTF-32 offset. Used for random access.</p><note><p>You can always round-trip from a UTF-32 offset to a UTF-16 offset and back. You can round-trip from a UTF-16 offset to a UTF-32 offset and back if and only if the offset16 is not in the middle of a surrogate pair. Unmatched surrogates count as a single UTF-16 value.</p></note></descr><parameters><param name="offset32" type="int" attr="in"><descr><p>UTF-32 offset.</p></descr></param></parameters><returns type="int"><descr><p>UTF-16 offset</p></descr></returns><raises><exception name="StringIndexOutOfBoundsException"><descr><p>if<code>offset32</code>is out of bounds.</p></descr></exception></raises></method><method id="i18n-methods-StringExtend-findOffset32" name="findOffset32"><descr><p>Returns the UTF-32 offset corresponding to a UTF-16 offset. Used for random access. To find the UTF-32 length of a string, use:<eg xml:space="preserve">len32 = findOffset32(source, source.length());</eg></p><note><p>If the UTF-16 offset is into the middle of a surrogate pair, then the UTF-32 offset of the<emph>end</emph>of the pair is returned; that is, the index of the char after the end of the pair. You can always round-trip from a UTF-32 offset to a UTF-16 offset and back. You can round-trip from a UTF-16 offset to a UTF-32 offset and back if and only if the offset16 is not in the middle of a surrogate pair. Unmatched surrogates count as a single UTF-16 value.</p></note></descr><parameters><param attr="in" type="int" name="offset16"><descr><p>UTF-16 offset</p></descr></param></parameters><returns type="int"><descr><p>UTF-32 offset</p></descr></returns><raises><exception name="StringIndexOutOfBoundsException"><descr><p>if offset16 is out of bounds.</p></descr></exception></raises></method></interface>
+</library>
diff --git a/test/dom3-core-interface.xml b/test/dom3-core-interface.xml
new file mode 100644
index 0000000..a8373a0
--- /dev/null
+++ b/test/dom3-core-interface.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0"?>
+<!--
+Copyright (c) 2001-2003 World Wide Web Consortium,
+(Massachusetts Institute of Technology, Institut National de
+Recherche en Informatique et en Automatique, Keio University). All
+Rights Reserved. This program is distributed under the W3C's Document
+Intellectual Property License. This program is distributed in the
+hope that it will be useful, but WITHOUT ANY WARRANTY; without even
+the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+PURPOSE.
+See W3C License http://www.w3.org/Consortium/Legal/ for more details.
+-->
+<!--This file is an extract of interface definitions from Document Object Model (DOM) Level 3 Core Specification-->
+<library>
+ <exception name="DOMException" id="ID-17189187"><descr><p>DOM operations only raise exceptions in "exceptional" circumstances, i.e., when an operation is impossible to perform (either for logical reasons, because data is lost, or because the implementation has become unstable). In general, DOM methods return specific error values in ordinary processing situations, such as out-of-bound errors when using<code>NodeList</code>.</p><p>Implementations should raise other exceptions under other circumstances. For example, implementations should raise an implementation-dependent exception if a<code>null</code>argument is passed when<code>null</code>was not expected.</p><p>Some languages and object systems do not support the concept of exceptions. For such systems, error conditions may be indicated using native error reporting mechanisms. For some bindings, for example, methods may return error codes similar to those listed in the corresponding method descriptions.</p></descr><component id="ID-146F692A" name="code"><typename>unsigned short</typename></component></exception>
+ <group id="ID-258A00AF" name="ExceptionCode"><descr><p>An integer indicating the type of error generated.</p><note><p>Other numeric codes are reserved for W3C for possible future use.</p></note></descr><constant id="DOMException-INDEX_SIZE_ERR" name="INDEX_SIZE_ERR" type="unsigned short" value="1"><descr><p>If index or size is negative, or greater than the allowed value.</p></descr></constant><constant id="DOMException-DOMSTRING_SIZE_ERR" name="DOMSTRING_SIZE_ERR" type="unsigned short" value="2"><descr><p>If the specified range of text does not fit into a<code>DOMString</code>.</p></descr></constant><constant id="DOMException-HIERARCHY_REQUEST_ERR" name="HIERARCHY_REQUEST_ERR" type="unsigned short" value="3"><descr><p>If any<code>Node</code>is inserted somewhere it doesn't belong.</p></descr></constant><constant id="DOMException-WRONG_DOCUMENT_ERR" name="WRONG_DOCUMENT_ERR" type="unsigned short" value="4"><descr><p>If a<code>Node</code>is used in a different document than the one that created it (that doesn't support it).</p></descr></constant><constant id="DOMException-INVALID_CHARACTER_ERR" name="INVALID_CHARACTER_ERR" type="unsigned short" value="5"><descr><p>If an invalid or illegal character is specified, such as in an XML name.</p></descr></constant><constant id="DOMException-NO_DATA_ALLOWED_ERR" name="NO_DATA_ALLOWED_ERR" type="unsigned short" value="6"><descr><p>If data is specified for a<code>Node</code>which does not support data.</p></descr></constant><constant id="DOMException-NO_MODIFICATION_ALLOWED_ERR" name="NO_MODIFICATION_ALLOWED_ERR" type="unsigned short" value="7"><descr><p>If an attempt is made to modify an object where modifications are not allowed.</p></descr></constant><constant id="DOMException-NOT_FOUND_ERR" name="NOT_FOUND_ERR" type="unsigned short" value="8"><descr><p>If an attempt is made to reference a<code>Node</code>in a context where it does not exist.</p></descr></constant><constant id="DOMException-NOT_SUPPORTED_ERR" name="NOT_SUPPORTED_ERR" type="unsigned short" value="9"><descr><p>If the implementation does not support the requested type of object or operation.</p></descr></constant><constant id="DOMException-INUSE_ATTRIBUTE_ERR" name="INUSE_ATTRIBUTE_ERR" type="unsigned short" value="10"><descr><p>If an attempt is made to add an attribute that is already in use elsewhere.</p></descr></constant><constant id="DOMException-INVALID_STATE_ERR" name="INVALID_STATE_ERR" type="unsigned short" value="11" since="DOM Level 2"><descr><p>If an attempt is made to use an object that is not, or is no longer, usable.</p></descr></constant><constant id="DOMException-SYNTAX_ERR" name="SYNTAX_ERR" type="unsigned short" value="12" since="DOM Level 2"><descr><p>If an invalid or illegal string is specified.</p></descr></constant><constant id="DOMException-INVALID_MODIFICATION_ERR" name="INVALID_MODIFICATION_ERR" type="unsigned short" value="13" since="DOM Level 2"><descr><p>If an attempt is made to modify the type of the underlying object.</p></descr></constant><constant id="DOMException-NAMESPACE_ERR" name="NAMESPACE_ERR" type="unsigned short" value="14" since="DOM Level 2"><descr><p>If an attempt is made to create or change an object in a way which is incorrect with regard to namespaces.</p></descr></constant><constant id="DOMException-INVALID_ACCESS_ERR" name="INVALID_ACCESS_ERR" type="unsigned short" value="15" since="DOM Level 2"><descr><p>If a parameter or an operation is not supported by the underlying object.</p></descr></constant><constant id="DOMException-VALIDATION_ERR" name="VALIDATION_ERR" type="unsigned short" value="16" since="DOM Level 3"><descr><p>If a call to a method such as<code>insertBefore</code>or<code>removeChild</code>would make the<code>Node</code>invalid with respect to<termref def="dt-partially-valid">"partial validity"</termref>, this exception would be raised and the operation would not be done. This code is used in<bibref role="informative" ref="DOMVal"/>. Refer to this specification for further information.</p></descr></constant><constant id="DOMException-TYPE_MISMATCH_ERR" name="TYPE_MISMATCH_ERR" type="unsigned short" value="17" since="DOM Level 3"><descr><p>If the type of an object is incompatible with the expected type of the parameter associated to the object.</p></descr></constant></group>
+ <interface name="DOMStringList" id="DOMStringList" since="DOM Level 3"><descr><p>The<code>DOMStringList</code>interface provides the abstraction of an ordered collection of<code>DOMString</code>values, without defining or constraining how this collection is implemented. The items in the<code>DOMStringList</code>are accessible via an integral index, starting from 0.</p></descr><method name="item" id="DOMStringList-item"><descr><p>Returns the<code>index</code>th item in the collection. If<code>index</code>is greater than or equal to the number of<code>DOMString</code>s in the list, this returns<code>null</code>.</p></descr><parameters><param name="index" type="unsigned long" attr="in"><descr><p>Index into the collection.</p></descr></param></parameters><returns type="DOMString"><descr><p>The<code>DOMString</code>at the<code>index</code>th position in the<code>DOMStringList</code>, or<code>null</code>if that is not a valid index.</p></descr></returns><raises></raises></method><attribute type="unsigned long" readonly="yes" name="length" id="DOMStringList-length"><descr><p>The number of<code>DOMString</code>s in the list. The range of valid child node indices is 0 to<code>length-1</code>inclusive.</p></descr></attribute><method name="contains" id="DOMStringList-contains"><descr><p>Test if a string is part of this<code>DOMStringList</code>.</p></descr><parameters><param name="str" type="DOMString" attr="in"><descr><p>The string to look for.</p></descr></param></parameters><returns type="boolean"><descr><p><code>true</code>if the string has been found,<code>false</code>otherwise.</p></descr></returns><raises></raises></method></interface>
+ <interface name="NameList" id="NameList" since="DOM Level 3"><descr><p>The<code>NameList</code>interface provides the abstraction of an ordered collection of parallel pairs of name and namespace values (which could be null values), without defining or constraining how this collection is implemented. The items in the<code>NameList</code>are accessible via an integral index, starting from 0.</p></descr><method name="getName" id="NameList-getName"><descr><p>Returns the<code>index</code>th name item in the collection.</p></descr><parameters><param name="index" type="unsigned long" attr="in"><descr><p>Index into the collection.</p></descr></param></parameters><returns type="DOMString"><descr><p>The name at the<code>index</code>th position in the<code>NameList</code>, or<code>null</code>if there is no name for the specified index or if the index is out of range.</p></descr></returns><raises></raises></method><method name="getNamespaceURI" id="NameList-getNamespaceURI"><descr><p>Returns the<code>index</code>th namespaceURI item in the collection.</p></descr><parameters><param name="index" type="unsigned long" attr="in"><descr><p>Index into the collection.</p></descr></param></parameters><returns type="DOMString"><descr><p>The namespace URI at the<code>index</code>th position in the<code>NameList</code>, or<code>null</code>if there is no name for the specified index or if the index is out of range.</p></descr></returns><raises></raises></method><attribute type="unsigned long" readonly="yes" name="length" id="NameList-length"><descr><p>The number of pairs (name and namespaceURI) in the list. The range of valid child node indices is 0 to<code>length-1</code>inclusive.</p></descr></attribute><method name="contains" id="NameList-contains"><descr><p>Test if a name is part of this<code>NameList</code>.</p></descr><parameters><param name="str" type="DOMString" attr="in"><descr><p>The name to look for.</p></descr></param></parameters><returns type="boolean"><descr><p><code>true</code>if the name has been found,<code>false</code>otherwise.</p></descr></returns><raises></raises></method><method name="containsNS" id="NameList-containsNS"><descr><p>Test if the pair namespaceURI/name is part of this<code>NameList</code>.</p></descr><parameters><param name="namespaceURI" type="DOMString" attr="in"><descr><p>The namespace URI to look for.</p></descr></param><param name="name" type="DOMString" attr="in"><descr><p>The name to look for.</p></descr></param></parameters><returns type="boolean"><descr><p><code>true</code>if the pair namespaceURI/name has been found,<code>false</code>otherwise.</p></descr></returns><raises></raises></method></interface>
+ <interface name="DOMImplementationList" id="DOMImplementationList" since="DOM Level 3"><descr><p>The<code>DOMImplementationList</code>interface provides the abstraction of an ordered collection of DOM implementations, without defining or constraining how this collection is implemented. The items in the<code>DOMImplementationList</code>are accessible via an integral index, starting from 0.</p></descr><method name="item" id="DOMImplementationList-item"><descr><p>Returns the<code>index</code>th item in the collection. If<code>index</code>is greater than or equal to the number of<code>DOMImplementation</code>s in the list, this returns<code>null</code>.</p></descr><parameters><param name="index" type="unsigned long" attr="in"><descr><p>Index into the collection.</p></descr></param></parameters><returns type="DOMImplementation"><descr><p>The<code>DOMImplementation</code>at the<code>index</code>th position in the<code>DOMImplementationList</code>, or<code>null</code>if that is not a valid index.</p></descr></returns><raises></raises></method><attribute type="unsigned long" readonly="yes" name="length" id="DOMImplementationList-length"><descr><p>The number of<code>DOMImplementation</code>s in the list. The range of valid child node indices is 0 to<code>length-1</code>inclusive.</p></descr></attribute></interface>
+ <interface name="DOMImplementationSource" id="DOMImplementationSource" since="DOM Level 3"><descr><p>This interface permits a DOM implementer to supply one or more implementations, based upon requested features and versions, as specified in<specref ref="DOMFeatures"/>. Each implemented<code>DOMImplementationSource</code>object is listed in the binding-specific list of available sources so that its<code>DOMImplementation</code>objects are made available.</p></descr><method name="getDOMImplementation" id="ID-getDOMImpl"><descr><p>A method to request the first DOM implementation that supports the specified features.</p></descr><parameters><param name="features" type="DOMString" attr="in"><descr><p>A string that specifies which features and versions are required. This is a space separated list in which each feature is specified by its name optionally followed by a space and a version number.</p><p>This method returns the first item of the list returned by<code>getDOMImplementationList</code>.</p><p>As an example, the string<code>"XML 3.0 Traversal +Events 2.0"</code>will request a DOM implementation that supports the module "XML" for its 3.0 version, a module that support of the "Traversal" module for any version, and the module "Events" for its 2.0 version. The module "Events" must be accessible using the method<code>Node.getFeature()</code>and<code>DOMImplementation.getFeature()</code>.</p></descr></param></parameters><returns type="DOMImplementation"><descr><p>The first DOM implementation that support the desired features, or<code>null</code>if this source has none.</p></descr></returns><raises></raises></method><method name="getDOMImplementationList" id="ID-getDOMImpls"><descr><p>A method to request a list of DOM implementations that support the specified features and versions, as specified in<specref ref="DOMFeatures"/>.</p></descr><parameters><param name="features" type="DOMString" attr="in"><descr><p>A string that specifies which features and versions are required. This is a space separated list in which each feature is specified by its name optionally followed by a space and a version number. This is something like: "XML 3.0 Traversal +Events 2.0"</p></descr></param></parameters><returns type="DOMImplementationList"><descr><p>A list of DOM implementations that support the desired features.</p></descr></returns><raises></raises></method></interface>
+ <interface name="DOMImplementation" id="ID-102161490"><descr><p>The<code>DOMImplementation</code>interface provides a number of methods for performing operations that are independent of any particular instance of the document object model.</p></descr><method name="hasFeature" id="ID-5CED94D7"><descr><p>Test if the DOM implementation implements a specific feature and version, as specified in<specref ref="DOMFeatures"/>.</p></descr><parameters><param name="feature" type="DOMString" attr="in"><descr><p>The name of the feature to test.</p></descr></param><param name="version" type="DOMString" attr="in"><descr><p>This is the version number of the feature to test.</p></descr></param></parameters><returns type="boolean"><descr><p><code>true</code>if the feature is implemented in the specified version,<code>false</code>otherwise.</p></descr></returns><raises></raises></method><method name="createDocumentType" id="Level-2-Core-DOM-createDocType" since="DOM Level 2"><descr><p>Creates an empty<code>DocumentType</code>node. Entity declarations and notations are not made available. Entity reference expansions and default attribute additions do not occur..</p></descr><parameters><param name="qualifiedName" type="DOMString" attr="in"><descr><p>The<termref def="dt-qualifiedname">qualified name</termref>of the document type to be created.</p></descr></param><param name="publicId" type="DOMString" attr="in"><descr><p>The external subset public identifier.</p></descr></param><param name="systemId" type="DOMString" attr="in"><descr><p>The external subset system identifier.</p></descr></param></parameters><returns type="DocumentType"><descr><p>A new<code>DocumentType</code>node with<code>Node.ownerDocument</code>set to<code>null</code>.</p></descr></returns><raises><exception name="DOMException"><descr><p>INVALID_CHARACTER_ERR: Raised if the specified qualified name is not an XML name according to<bibref ref="XML"/>.</p><p>NAMESPACE_ERR: Raised if the<code>qualifiedName</code>is malformed.</p><p>NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature "XML" and the language exposed through the Document does not support XML Namespaces (such as<bibref role="informative" ref="HTML40"/>).</p></descr></exception></raises></method><method name="createDocument" id="Level-2-Core-DOM-createDocument" since="DOM Level 2"><descr><p>Creates a DOM Document object of the specified type with its document element.</p><p>Note that based on the<code>DocumentType</code>given to create the document, the implementation may instantiate specialized<code>Document</code>objects that support additional features than the "Core", such as "HTML"<bibref role="informative" ref="DOM2HTML"/>. On the other hand, setting the<code>DocumentType</code>after the document was created makes this very unlikely to happen. Alternatively, specialized<code>Document</code>creation methods, such as<code>createHTMLDocument</code><bibref role="informative" ref="DOM2HTML"/>, can be used to obtain specific types of<code>Document</code>objects.</p></descr><parameters><param name="namespaceURI" type="DOMString" attr="in"><descr><p>The<termref def="dt-namespaceURI">namespace URI</termref>of the document element to create or<code>null</code>.</p></descr></param><param name="qualifiedName" type="DOMString" attr="in"><descr><p>The<termref def="dt-qualifiedname">qualified name</termref>of the document element to be created or<code>null</code>.</p></descr></param><param name="doctype" type="DocumentType" attr="in"><descr><p>The type of document to be created or<code>null</code>.</p><p>When<code>doctype</code>is not<code>null</code>, its<code>Node.ownerDocument</code>attribute is set to the document being created.</p></descr></param></parameters><returns type="Document"><descr><p>A new<code>Document</code>object with its document element. If the<code>NamespaceURI</code>,<code>qualifiedName</code>, and<code>doctype</code>are<code>null</code>, the returned<code>Document</code>is empty with no document element.</p></descr></returns><raises><exception name="DOMException"><descr><p>INVALID_CHARACTER_ERR: Raised if the specified qualified name is not an XML name according to<bibref ref="XML"/>.</p><p>NAMESPACE_ERR: Raised if the<code>qualifiedName</code>is malformed, if the<code>qualifiedName</code>has a prefix and the<code>namespaceURI</code>is<code>null</code>, or if the<code>qualifiedName</code>is<code>null</code>and the<code>namespaceURI</code>is different from<code>null</code>, or if the<code>qualifiedName</code>has a prefix that is "xml" and the<code>namespaceURI</code>is different from "<loc href="http://www.w3.org/XML/1998/namespace" type="simple" show="replace" actuate="onRequest">http://www.w3.org/XML/1998/namespace</loc>"<bibref ref="Namespaces"/>, or if the DOM implementation does not support the<code>"XML"</code>feature but a non-null namespace URI was provided, since namespaces were defined by XML.</p><p>WRONG_DOCUMENT_ERR: Raised if<code>doctype</code>has already been used with a different document or was created from a different implementation.</p><p>NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature "XML" and the language exposed through the Document does not support XML Namespaces (such as<bibref role="informative" ref="HTML40"/>).</p></descr></exception></raises></method><method name="getFeature" id="DOMImplementation3-getFeature" since="DOM Level 3"><descr><p>This method returns a specialized object which implements the specialized APIs of the specified feature and version, as specified in<specref ref="DOMFeatures"/>. The specialized object may also be obtained by using binding-specific casting methods but is not necessarily expected to, as discussed in<specref ref="Embedded-DOM"/>. This method also allow the implementation to provide specialized objects which do not support the<code>DOMImplementation</code>interface.</p></descr><parameters><param name="feature" type="DOMString" attr="in"><descr><p>The name of the feature requested. Note that any plus sign "+" prepended to the name of the feature will be ignored since it is not significant in the context of this method.</p></descr></param><param name="version" type="DOMString" attr="in"><descr><p>This is the version number of the feature to test.</p></descr></param></parameters><returns type="DOMObject"><descr><p>Returns an object which implements the specialized APIs of the specified feature and version, if any, or<code>null</code>if there is no object which implements interfaces associated with that feature. If the<code>DOMObject</code>returned by this method implements the<code>DOMImplementation</code>interface, it must delegate to the primary core<code>DOMImplementation</code>and not return results inconsistent with the primary core<code>DOMImplementation</code>such as<code>hasFeature</code>,<code>getFeature</code>, etc.</p></descr></returns><raises></raises></method></interface>
+ <interface name="DocumentFragment" inherits="Node" id="ID-B63ED1A3"><descr><p><code>DocumentFragment</code>is a "lightweight" or "minimal"<code>Document</code>object. It is very common to want to be able to extract a portion of a document's tree or to create a new fragment of a document. Imagine implementing a user command like cut or rearranging a document by moving fragments around. It is desirable to have an object which can hold such fragments and it is quite natural to use a Node for this purpose. While it is true that a<code>Document</code>object could fulfill this role, a<code>Document</code>object can potentially be a heavyweight object, depending on the underlying implementation. What is really needed for this is a very lightweight object.<code>DocumentFragment</code>is such an object.</p><p>Furthermore, various operations -- such as inserting nodes as children of another<code>Node</code>-- may take<code>DocumentFragment</code>objects as arguments; this results in all the child nodes of the<code>DocumentFragment</code>being moved to the child list of this node.</p><p>The children of a<code>DocumentFragment</code>node are zero or more nodes representing the tops of any sub-trees defining the structure of the document.<code>DocumentFragment</code>nodes do not need to be<termref def="dt-well-formed">well-formed XML documents</termref>(although they do need to follow the rules imposed upon well-formed XML parsed entities, which can have multiple top nodes). For example, a<code>DocumentFragment</code>might have only one child and that child node could be a<code>Text</code>node. Such a structure model represents neither an HTML document nor a well-formed XML document.</p><p>When a<code>DocumentFragment</code>is inserted into a<code>Document</code>(or indeed any other<code>Node</code>that may take children) the children of the<code>DocumentFragment</code>and not the<code>DocumentFragment</code>itself are inserted into the<code>Node</code>. This makes the<code>DocumentFragment</code>very useful when the user wishes to create nodes that are<termref def="dt-sibling">siblings</termref>; the<code>DocumentFragment</code>acts as the parent of these nodes so that the user can use the standard methods from the<code>Node</code>interface, such as<code>Node.insertBefore</code>and<code>Node.appendChild</code>.</p></descr></interface>
+ <interface name="Document" inherits="Node" id="i-Document"><descr><p>The<code>Document</code>interface represents the entire HTML or XML document. Conceptually, it is the<termref def="dt-root-node">root</termref>of the document tree, and provides the primary access to the document's data.</p><p>Since elements, text nodes, comments, processing instructions, etc. cannot exist outside the context of a<code>Document</code>, the<code>Document</code>interface also contains the factory methods needed to create these objects. The<code>Node</code>objects created have a<code>ownerDocument</code>attribute which associates them with the<code>Document</code>within whose context they were created.</p></descr><attribute id="ID-B63ED1A31" name="doctype" type="DocumentType" readonly="yes" version="DOM Level 3"><descr><p>The Document Type Declaration (see<code>DocumentType</code>) associated with this document. For XML documents without a document type declaration this returns<code>null</code>. For HTML documents, a<code>DocumentType</code>object may be returned, independently of the presence or absence of document type declaration in the HTML document.</p><p>This provides direct access to the<code>DocumentType</code>node, child node of this<code>Document</code>. This node can be set at document creation time and later changed through the use of child nodes manipulation methods, such as<code>Node.insertBefore</code>, or<code>Node.replaceChild</code>. Note, however, that while some implementations may instantiate different types of<code>Document</code>objects supporting additional features than the "Core", such as "HTML"<bibref role="informative" ref="DOM2HTML"/>, based on the<code>DocumentType</code>specified at creation time, changing it afterwards is very unlikely to result in a change of the features supported.</p></descr></attribute><attribute readonly="yes" name="implementation" type="DOMImplementation" id="ID-1B793EBA"><descr><p>The<code>DOMImplementation</code>object that handles this document. A DOM application may use objects from multiple implementations.</p></descr></attribute><attribute readonly="yes" name="documentElement" type="Element" id="ID-87CD092"><descr><p>This is a<termref def="dt-convenience">convenience</termref>attribute that allows direct access to the child node that is the<termref def="dt-document-element">document element</termref>of the document.</p></descr></attribute><method name="createElement" id="ID-2141741547"><descr><p>Creates an element of the type specified. Note that the instance returned implements the<code>Element</code>interface, so attributes can be specified directly on the returned object.</p><p>In addition, if there are known attributes with default values,<code>Attr</code>nodes representing them are automatically created and attached to the element.</p><p>To create an element with a<termref def="dt-qualifiedname">qualified name</termref>and<termref def="dt-namespaceURI">namespace URI</termref>, use the<code>createElementNS</code>method.</p></descr><parameters><param name="tagName" type="DOMString" attr="in"><descr><p>The name of the element type to instantiate. For XML, this is case-sensitive, otherwise it depends on the case-sensitivity of the markup language in use. In that case, the name is mapped to the canonical form of that markup by the DOM implementation.</p></descr></param></parameters><returns type="Element"><descr><p>A new<code>Element</code>object with the<code>nodeName</code>attribute set to<code>tagName</code>, and<code>localName</code>,<code>prefix</code>, and<code>namespaceURI</code>set to<code>null</code>.</p></descr></returns><raises><exception name="DOMException"><descr><p>INVALID_CHARACTER_ERR: Raised if the specified name is not an XML name according to the XML version in use specified in the<code>Document.xmlVersion</code>attribute.</p></descr></exception></raises></method><method name="createDocumentFragment" id="ID-35CB04B5"><descr><p>Creates an empty<code>DocumentFragment</code>object.</p></descr><parameters></parameters><returns type="DocumentFragment"><descr><p>A new<code>DocumentFragment</code>.</p></descr></returns><raises></raises></method><method name="createTextNode" id="ID-1975348127"><descr><p>Creates a<code>Text</code>node given the specified string.</p></descr><parameters><param name="data" type="DOMString" attr="in"><descr><p>The data for the node.</p></descr></param></parameters><returns type="Text"><descr><p>The new<code>Text</code>object.</p></descr></returns><raises></raises></method><method name="createComment" id="ID-1334481328"><descr><p>Creates a<code>Comment</code>node given the specified string.</p></descr><parameters><param name="data" type="DOMString" attr="in"><descr><p>The data for the node.</p></descr></param></parameters><returns type="Comment"><descr><p>The new<code>Comment</code>object.</p></descr></returns><raises></raises></method><method name="createCDATASection" id="ID-D26C0AF8"><descr><p>Creates a<code>CDATASection</code>node whose value is the specified string.</p></descr><parameters><param name="data" type="DOMString" attr="in"><descr><p>The data for the<code>CDATASection</code>contents.</p></descr></param></parameters><returns type="CDATASection"><descr><p>The new<code>CDATASection</code>object.</p></descr></returns><raises><exception name="DOMException"><descr><p>NOT_SUPPORTED_ERR: Raised if this document is an HTML document.</p></descr></exception></raises></method><method name="createProcessingInstruction" id="ID-135944439"><descr><p>Creates a<code>ProcessingInstruction</code>node given the specified name and data strings.</p></descr><parameters><param name="target" type="DOMString" attr="in"><descr><p>The target part of the processing instruction.</p><p>Unlike<code>Document.createElementNS</code>or<code>Document.createAttributeNS</code>, no namespace well-formed checking is done on the target name. Applications should invoke<code>Document.normalizeDocument()</code>with the parameter "<termref def="parameter-namespaces">namespaces</termref>" set to<code>true</code>in order to ensure that the target name is namespace well-formed.</p></descr></param><param name="data" type="DOMString" attr="in"><descr><p>The data for the node.</p></descr></param></parameters><returns type="ProcessingInstruction"><descr><p>The new<code>ProcessingInstruction</code>object.</p></descr></returns><raises><exception name="DOMException"><descr><p>INVALID_CHARACTER_ERR: Raised if the specified target is not an XML name according to the XML version in use specified in the<code>Document.xmlVersion</code>attribute.</p><p>NOT_SUPPORTED_ERR: Raised if this document is an HTML document.</p></descr></exception></raises></method><method name="createAttribute" id="ID-1084891198"><descr><p>Creates an<code>Attr</code>of the given name. Note that the<code>Attr</code>instance can then be set on an<code>Element</code>using the<code>setAttributeNode</code>method.</p><p>To create an attribute with a<termref def="dt-qualifiedname">qualified name</termref>and<termref def="dt-namespaceURI">namespace URI</termref>, use the<code>createAttributeNS</code>method.</p></descr><parameters><param name="name" type="DOMString" attr="in"><descr><p>The name of the attribute.</p></descr></param></parameters><returns type="Attr"><descr><p>A new<code>Attr</code>object with the<code>nodeName</code>attribute set to<code>name</code>, and<code>localName</code>,<code>prefix</code>, and<code>namespaceURI</code>set to<code>null</code>. The value of the attribute is the empty string.</p></descr></returns><raises><exception name="DOMException"><descr><p>INVALID_CHARACTER_ERR: Raised if the specified name is not an XML name according to the XML version in use specified in the<code>Document.xmlVersion</code>attribute.</p></descr></exception></raises></method><method name="createEntityReference" id="ID-392B75AE"><descr><p>Creates an<code>EntityReference</code>object. In addition, if the referenced entity is known, the child list of the<code>EntityReference</code>node is made the same as that of the corresponding<code>Entity</code>node.</p><note><p>If any descendant of the<code>Entity</code>node has an unbound<termref def="dt-namespaceprefix">namespace prefix</termref>, the corresponding descendant of the created<code>EntityReference</code>node is also unbound; (its<code>namespaceURI</code>is<code>null</code>). The DOM Level 2 and 3 do not support any mechanism to resolve namespace prefixes in this case.</p></note></descr><parameters><param name="name" type="DOMString" attr="in"><descr><p>The name of the entity to reference.</p><p>Unlike<code>Document.createElementNS</code>or<code>Document.createAttributeNS</code>, no namespace well-formed checking is done on the entity name. Applications should invoke<code>Document.normalizeDocument()</code>with the parameter "<termref def="parameter-namespaces">namespaces</termref>" set to<code>true</code>in order to ensure that the entity name is namespace well-formed.</p></descr></param></parameters><returns type="EntityReference"><descr><p>The new<code>EntityReference</code>object.</p></descr></returns><raises><exception name="DOMException"><descr><p>INVALID_CHARACTER_ERR: Raised if the specified name is not an XML name according to the XML version in use specified in the<code>Document.xmlVersion</code>attribute.</p><p>NOT_SUPPORTED_ERR: Raised if this document is an HTML document.</p></descr></exception></raises></method><method name="getElementsByTagName" id="ID-A6C9094"><descr><p>Returns a<code>NodeList</code>of all the<code>Elements</code>in<termref def="dt-document-order">document order</termref>with a given tag name and are contained in the document.</p></descr><parameters><param name="tagname" type="DOMString" attr="in"><descr><p>The name of the tag to match on. The special value "*" matches all tags. For XML, the<code>tagname</code>parameter is case-sensitive, otherwise it depends on the case-sensitivity of the markup language in use.</p></descr></param></parameters><returns type="NodeList"><descr><p>A new<code>NodeList</code>object containing all the matched<code>Elements</code>.</p></descr></returns><raises></raises></method><method name="importNode" id="Core-Document-importNode" since="DOM Level 2"><descr><p>Imports a node from another document to this document, without altering or removing the source node from the original document; this method creates a new copy of the source node. The returned node has no parent; (<code>parentNode</code>is<code>null</code>).</p><p>For all nodes, importing a node creates a node object owned by the importing document, with attribute values identical to the source node's<code>nodeName</code>and<code>nodeType</code>, plus the attributes related to namespaces (<code>prefix</code>,<code>localName</code>, and<code>namespaceURI</code>). As in the<code>cloneNode</code>operation, the source node is not altered. User data associated to the imported node is not carried over. However, if any<code>UserDataHandlers</code>has been specified along with the associated data these handlers will be called with the appropriate parameters before this method returns.</p><p>Additional information is copied as appropriate to the<code>nodeType</code>, attempting to mirror the behavior expected if a fragment of XML or HTML source was copied from one document to another, recognizing that the two documents may have different DTDs in the XML case. The following list describes the specifics for each type of node.<glist><gitem><label>ATTRIBUTE_NODE</label><def><p>The<code>ownerElement</code>attribute is set to<code>null</code>and the<code>specified</code>flag is set to<code>true</code>on the generated<code>Attr</code>. The<termref def="dt-descendant">descendants</termref>of the source<code>Attr</code>are recursively imported and the resulting nodes reassembled to form the corresponding subtree.</p><p>Note that the<code>deep</code>parameter has no effect on<code>Attr</code>nodes; they always carry their children with them when imported.</p></def></gitem><gitem><label>DOCUMENT_FRAGMENT_NODE</label><def><p>If the<code>deep</code>option was set to<code>true</code>, the<termref def="dt-descendant">descendants</termref>of the source<code>DocumentFragment</code>are recursively imported and the resulting nodes reassembled under the imported<code>DocumentFragment</code>to form the corresponding subtree. Otherwise, this simply generates an empty<code>DocumentFragment</code>.</p></def></gitem><gitem><label>DOCUMENT_NODE</label><def><p><code>Document</code>nodes cannot be imported.</p></def></gitem><gitem><label>DOCUMENT_TYPE_NODE</label><def><p><code>DocumentType</code>nodes cannot be imported.</p></def></gitem><gitem><label>ELEMENT_NODE</label><def><p><emph>Specified</emph>attribute nodes of the source element are imported, and the generated<code>Attr</code>nodes are attached to the generated<code>Element</code>. Default attributes are<emph>not</emph>copied, though if the document being imported into defines default attributes for this element name, those are assigned. If the<code>importNode</code><code>deep</code>parameter was set to<code>true</code>, the<termref def="dt-descendant">descendants</termref>of the source element are recursively imported and the resulting nodes reassembled to form the corresponding subtree.</p></def></gitem><gitem><label>ENTITY_NODE</label><def><p><code>Entity</code>nodes can be imported, however in the current release of the DOM the<code>DocumentType</code>is readonly. Ability to add these imported nodes to a<code>DocumentType</code>will be considered for addition to a future release of the DOM.</p><p>On import, the<code>publicId</code>,<code>systemId</code>, and<code>notationName</code>attributes are copied. If a<code>deep</code>import is requested, the<termref def="dt-descendant">descendants</termref>of the the source<code>Entity</code>are recursively imported and the resulting nodes reassembled to form the corresponding subtree.</p></def></gitem><gitem><label>ENTITY_REFERENCE_NODE</label><def><p>Only the<code>EntityReference</code>itself is copied, even if a<code>deep</code>import is requested, since the source and destination documents might have defined the entity differently. If the document being imported into provides a definition for this entity name, its value is assigned.</p></def></gitem><gitem><label>NOTATION_NODE</label><def><p><code>Notation</code>nodes can be imported, however in the current release of the DOM the<code>DocumentType</code>is readonly. Ability to add these imported nodes to a<code>DocumentType</code>will be considered for addition to a future release of the DOM.</p><p>On import, the<code>publicId</code>and<code>systemId</code>attributes are copied.</p><p>Note that the<code>deep</code>parameter has no effect on this type of nodes since they cannot have any children.</p></def></gitem><gitem><label>PROCESSING_INSTRUCTION_NODE</label><def><p>The imported node copies its<code>target</code>and<code>data</code>values from those of the source node.</p><p>Note that the<code>deep</code>parameter has no effect on this type of nodes since they cannot have any children.</p></def></gitem><gitem><label>TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE</label><def><p>These three types of nodes inheriting from<code>CharacterData</code>copy their<code>data</code>and<code>length</code>attributes from those of the source node.</p><p>Note that the<code>deep</code>parameter has no effect on these types of nodes since they cannot have any children.</p></def></gitem></glist></p></descr><parameters><param name="importedNode" type="Node" attr="in"><descr><p>The node to import.</p></descr></param><param name="deep" type="boolean" attr="in"><descr><p>If<code>true</code>, recursively import the subtree under the specified node; if<code>false</code>, import only the node itself, as explained above. This has no effect on nodes that cannot have any children, and on<code>Attr</code>, and<code>EntityReference</code>nodes.</p></descr></param></parameters><returns type="Node"><descr><p>The imported node that belongs to this<code>Document</code>.</p></descr></returns><raises><exception name="DOMException" version="DOM Level 3"><descr><p>NOT_SUPPORTED_ERR: Raised if the type of node being imported is not supported.</p><p>INVALID_CHARACTER_ERR: Raised if one of the imported names is not an XML name according to the XML version in use specified in the<code>Document.xmlVersion</code>attribute. This may happen when importing an XML 1.1<bibref role="informative" ref="XML11"/>element into an XML 1.0 document, for instance.</p></descr></exception></raises></method><method name="createElementNS" id="ID-DocCrElNS" since="DOM Level 2"><descr><p>Creates an element of the given<termref def="dt-qualifiedname">qualified name</termref>and<termref def="dt-namespaceURI">namespace URI</termref>.</p><p>Per<bibref ref="Namespaces"/>, applications must use the value<code>null</code>as the namespaceURI parameter for methods if they wish to have no namespace.</p></descr><parameters><param name="namespaceURI" type="DOMString" attr="in"><descr><p>The<termref def="dt-namespaceURI">namespace URI</termref>of the element to create.</p></descr></param><param name="qualifiedName" type="DOMString" attr="in"><descr><p>The<termref def="dt-qualifiedname">qualified name</termref>of the element type to instantiate.</p></descr></param></parameters><returns type="Element"><descr><p>A new<code>Element</code>object with the following attributes:</p><table cellpadding="3" summary="Layout table: the first cell the name property, the second cell contains his initial value"><tbody><tr><th rowspan="1" colspan="1">Attribute</th><th rowspan="1" colspan="1">Value</th></tr><tr><td rowspan="1" colspan="1"><code>Node.nodeName</code></td><td rowspan="1" colspan="1"><code>qualifiedName</code></td></tr><tr><td rowspan="1" colspan="1"><code>Node.namespaceURI</code></td><td rowspan="1" colspan="1"><code>namespaceURI</code></td></tr><tr><td rowspan="1" colspan="1"><code>Node.prefix</code></td><td rowspan="1" colspan="1">prefix, extracted from<code>qualifiedName</code>, or<code>null</code>if there is no prefix</td></tr><tr><td rowspan="1" colspan="1"><code>Node.localName</code></td><td rowspan="1" colspan="1"><termref def="dt-localname">local name</termref>, extracted from<code>qualifiedName</code></td></tr><tr><td rowspan="1" colspan="1"><code>Element.tagName</code></td><td rowspan="1" colspan="1"><code>qualifiedName</code></td></tr></tbody></table></descr></returns><raises><exception name="DOMException"><descr><p>INVALID_CHARACTER_ERR: Raised if the specified<code>qualifiedName</code>is not an XML name according to the XML version in use specified in the<code>Document.xmlVersion</code>attribute.</p><p>NAMESPACE_ERR: Raised if the<code>qualifiedName</code>is a malformed<termref def="dt-qualifiedname">qualified name</termref>, if the<code>qualifiedName</code>has a prefix and the<code>namespaceURI</code>is<code>null</code>, or if the<code>qualifiedName</code>has a prefix that is "xml" and the<code>namespaceURI</code>is different from "<loc href="http://www.w3.org/XML/1998/namespace" type="simple" show="replace" actuate="onRequest">http://www.w3.org/XML/1998/namespace</loc>"<bibref ref="Namespaces"/>, or if the<code>qualifiedName</code>or its prefix is "xmlns" and the<code>namespaceURI</code>is different from "<loc href="http://www.w3.org/2000/xmlns/" type="simple" show="replace" actuate="onRequest">http://www.w3.org/2000/xmlns/</loc>", or if the<code>namespaceURI</code>is "<loc href="http://www.w3.org/2000/xmlns/" type="simple" show="replace" actuate="onRequest">http://www.w3.org/2000/xmlns/</loc>" and neither the<code>qualifiedName</code>nor its prefix is "xmlns".</p><p>NOT_SUPPORTED_ERR: Always thrown if the current document does not support the<code>"XML"</code>feature, since namespaces were defined by XML.</p></descr></exception></raises></method><method name="createAttributeNS" id="ID-DocCrAttrNS" since="DOM Level 2"><descr><p>Creates an attribute of the given<termref def="dt-qualifiedname">qualified name</termref>and<termref def="dt-namespaceURI">namespace URI</termref>.</p><p>Per<bibref ref="Namespaces"/>, applications must use the value<code>null</code>as the<code>namespaceURI</code>parameter for methods if they wish to have no namespace.</p></descr><parameters><param name="namespaceURI" type="DOMString" attr="in"><descr><p>The<termref def="dt-namespaceURI">namespace URI</termref>of the attribute to create.</p></descr></param><param name="qualifiedName" type="DOMString" attr="in"><descr><p>The<termref def="dt-qualifiedname">qualified name</termref>of the attribute to instantiate.</p></descr></param></parameters><returns type="Attr"><descr><p>A new<code>Attr</code>object with the following attributes:</p><table cellpadding="3" summary="Layout table: the first cell the name property, the second cell contains his initial value"><tbody><tr><th rowspan="1" colspan="1">Attribute</th><th rowspan="1" colspan="1">Value</th></tr><tr><td rowspan="1" colspan="1"><code>Node.nodeName</code></td><td rowspan="1" colspan="1">qualifiedName</td></tr><tr><td rowspan="1" colspan="1"><code>Node.namespaceURI</code></td><td rowspan="1" colspan="1"><code>namespaceURI</code></td></tr><tr><td rowspan="1" colspan="1"><code>Node.prefix</code></td><td rowspan="1" colspan="1">prefix, extracted from<code>qualifiedName</code>, or<code>null</code>if there is no prefix</td></tr><tr><td rowspan="1" colspan="1"><code>Node.localName</code></td><td rowspan="1" colspan="1"><termref def="dt-localname">local name</termref>, extracted from<code>qualifiedName</code></td></tr><tr><td rowspan="1" colspan="1"><code>Attr.name</code></td><td rowspan="1" colspan="1"><code>qualifiedName</code></td></tr><tr><td rowspan="1" colspan="1"><code>Node.nodeValue</code></td><td rowspan="1" colspan="1">the empty string</td></tr></tbody></table></descr></returns><raises><exception name="DOMException"><descr><p>INVALID_CHARACTER_ERR: Raised if the specified<code>qualifiedName</code>is not an XML name according to the XML version in use specified in the<code>Document.xmlVersion</code>attribute.</p><p>NAMESPACE_ERR: Raised if the<code>qualifiedName</code>is a malformed<termref def="dt-qualifiedname">qualified name</termref>, if the<code>qualifiedName</code>has a prefix and the<code>namespaceURI</code>is<code>null</code>, if the<code>qualifiedName</code>has a prefix that is "xml" and the<code>namespaceURI</code>is different from "<loc href="http://www.w3.org/XML/1998/namespace" type="simple" show="replace" actuate="onRequest">http://www.w3.org/XML/1998/namespace</loc>", if the<code>qualifiedName</code>or its prefix is "xmlns" and the<code>namespaceURI</code>is different from "<loc href="http://www.w3.org/2000/xmlns/" type="simple" show="replace" actuate="onRequest">http://www.w3.org/2000/xmlns/</loc>", or if the<code>namespaceURI</code>is "<loc href="http://www.w3.org/2000/xmlns/" type="simple" show="replace" actuate="onRequest">http://www.w3.org/2000/xmlns/</loc>" and neither the<code>qualifiedName</code>nor its prefix is "xmlns".</p><p>NOT_SUPPORTED_ERR: Always thrown if the current document does not support the<code>"XML"</code>feature, since namespaces were defined by XML.</p></descr></exception></raises></method><method name="getElementsByTagNameNS" id="ID-getElBTNNS" since="DOM Level 2"><descr><p>Returns a<code>NodeList</code>of all the<code>Elements</code>with a given<termref def="dt-localname">local name</termref>and<termref def="dt-namespaceURI">namespace URI</termref>in<termref def="dt-document-order">document order</termref>.</p></descr><parameters><param name="namespaceURI" type="DOMString" attr="in"><descr><p>The<termref def="dt-namespaceURI">namespace URI</termref>of the elements to match on. The special value<code>"*"</code>matches all namespaces.</p></descr></param><param name="localName" type="DOMString" attr="in"><descr><p>The<termref def="dt-localname">local name</termref>of the elements to match on. The special value "*" matches all local names.</p></descr></param></parameters><returns type="NodeList"><descr><p>A new<code>NodeList</code>object containing all the matched<code>Elements</code>.</p></descr></returns><raises></raises></method><method name="getElementById" id="ID-getElBId" since="DOM Level 2"><descr><p>Returns the<code>Element</code>that has an ID attribute with the given value. If no such element exists, this returns<code>null</code>. If more than one element has an ID attribute with that value, what is returned is undefined.</p><p>The DOM implementation is expected to use the attribute<code>Attr.isId</code>to determine if an attribute is of type ID.</p><note><p>Attributes with the name "ID" or "id" are not of type ID unless so defined.</p></note></descr><parameters><param name="elementId" type="DOMString" attr="in"><descr><p>The unique<code>id</code>value for an element.</p></descr></param></parameters><returns type="Element"><descr><p>The matching element or<code>null</code>if there is none.</p></descr></returns><raises></raises></method><attribute readonly="yes" type="DOMString" name="inputEncoding" id="Document3-inputEncoding" since="DOM Level 3"><descr><p>An attribute specifying the encoding used for this document at the time of the parsing. This is<code>null</code>when it is not known, such as when the<code>Document</code>was created in memory.</p></descr></attribute><attribute readonly="yes" type="DOMString" name="xmlEncoding" id="Document3-encoding" since="DOM Level 3"><descr><p>An attribute specifying, as part of the<xspecref href="http://www.w3.org/TR/2004/REC-xml-20040204#NT-XMLDecl" type="simple" show="new" actuate="onRequest">XML declaration</xspecref>, the encoding of this document. This is<code>null</code>when unspecified or when it is not known, such as when the<code>Document</code>was created in memory.</p></descr></attribute><attribute readonly="no" type="boolean" name="xmlStandalone" id="Document3-standalone" since="DOM Level 3"><descr><p>An attribute specifying, as part of the<xspecref href="http://www.w3.org/TR/2004/REC-xml-20040204#NT-XMLDecl" type="simple" show="new" actuate="onRequest">XML declaration</xspecref>, whether this document is standalone. This is<code>false</code>when unspecified.</p><note><p>No verification is done on the value when setting this attribute. Applications should use<code>Document.normalizeDocument()</code>with the "<termref def="parameter-validate">validate</termref>" parameter to verify if the value matches the<xspecref href="http://www.w3.org/TR/2004/REC-xml-20040204#sec-rmd" type="simple" show="new" actuate="onRequest">validity constraint for standalone document declaration</xspecref>as defined in<bibref ref="XML"/>.</p></note></descr><setraises><exception name="DOMException"><descr><p>NOT_SUPPORTED_ERR: Raised if this document does not support the "XML" feature.</p></descr></exception></setraises></attribute><attribute readonly="no" type="DOMString" name="xmlVersion" id="Document3-version" since="DOM Level 3"><descr><p>An attribute specifying, as part of the<xspecref href="http://www.w3.org/TR/2004/REC-xml-20040204#NT-XMLDecl" type="simple" show="new" actuate="onRequest">XML declaration</xspecref>, the version number of this document. If there is no declaration and if this document supports the "XML" feature, the value is<code>"1.0"</code>. If this document does not support the "XML" feature, the value is always<code>null</code>. Changing this attribute will affect methods that check for invalid characters in XML names. Application should invoke<code>Document.normalizeDocument()</code>in order to check for invalid characters in the<code>Node</code>s that are already part of this<code>Document</code>.</p><p>DOM applications may use the<code>DOMImplementation.hasFeature(feature, version)</code>method with parameter values "XMLVersion" and "1.0" (respectively) to determine if an implementation supports<bibref ref="XML"/>. DOM applications may use the same method with parameter values "XMLVersion" and "1.1" (respectively) to determine if an implementation supports<bibref ref="XML11"/>. In both cases, in order to support XML, an implementation must also support the "XML" feature defined in this specification.<code>Document</code>objects supporting a version of the "XMLVersion" feature must not raise a<code>NOT_SUPPORTED_ERR</code>exception for the same version number when using<code>Document.xmlVersion</code>.</p></descr><setraises><exception name="DOMException"><descr><p>NOT_SUPPORTED_ERR: Raised if the version is set to a value that is not supported by this<code>Document</code>or if this document does not support the "XML" feature.</p></descr></exception></setraises></attribute><attribute readonly="no" type="boolean" name="strictErrorChecking" id="Document3-strictErrorChecking" since="DOM Level 3"><descr><p>An attribute specifying whether error checking is enforced or not. When set to<code>false</code>, the implementation is free to not test every possible error case normally defined on DOM operations, and not raise any<code>DOMException</code>on DOM operations or report errors while using<code>Document.normalizeDocument()</code>. In case of error, the behavior is undefined. This attribute is<code>true</code>by default.</p></descr></attribute><attribute name="documentURI" id="Document3-documentURI" type="DOMString" readonly="no" since="DOM Level 3"><descr><p>The location of the document or<code>null</code>if undefined or if the<code>Document</code>was created using<code>DOMImplementation.createDocument</code>. No lexical checking is performed when setting this attribute; this could result in a<code>null</code>value returned when using<code>Node.baseURI</code>.</p><p>Beware that when the<code>Document</code>supports the feature "HTML"<bibref role="informative" ref="DOM2HTML"/>, the href attribute of the HTML BASE element takes precedence over this attribute when computing<code>Node.baseURI</code>.</p></descr></attribute><method name="adoptNode" id="Document3-adoptNode" since="DOM Level 3"><descr><p>Attempts to adopt a node from another document to this document. If supported, it changes the<code>ownerDocument</code>of the source node, its children, as well as the attached attribute nodes if there are any. If the source node has a parent it is first removed from the child list of its parent. This effectively allows moving a subtree from one document to another (unlike<code>importNode()</code>which create a copy of the source node instead of moving it). When it fails, applications should use<code>Document.importNode()</code>instead. Note that if the adopted node is already part of this document (i.e. the source and target document are the same), this method still has the effect of removing the source node from the child list of its parent, if any. The following list describes the specifics for each type of node.<glist><gitem><label>ATTRIBUTE_NODE</label><def><p>The<code>ownerElement</code>attribute is set to<code>null</code>and the<code>specified</code>flag is set to<code>true</code>on the adopted<code>Attr</code>. The descendants of the source<code>Attr</code>are recursively adopted.</p></def></gitem><gitem><label>DOCUMENT_FRAGMENT_NODE</label><def><p>The descendants of the source node are recursively adopted.</p></def></gitem><gitem><label>DOCUMENT_NODE</label><def><p><code>Document</code>nodes cannot be adopted.</p></def></gitem><gitem><label>DOCUMENT_TYPE_NODE</label><def><p><code>DocumentType</code>nodes cannot be adopted.</p></def></gitem><gitem><label>ELEMENT_NODE</label><def><p><emph>Specified</emph>attribute nodes of the source element are adopted. Default attributes are discarded, though if the document being adopted into defines default attributes for this element name, those are assigned. The descendants of the source element are recursively adopted.</p></def></gitem><gitem><label>ENTITY_NODE</label><def><p><code>Entity</code>nodes cannot be adopted.</p></def></gitem><gitem><label>ENTITY_REFERENCE_NODE</label><def><p>Only the<code>EntityReference</code>node itself is adopted, the descendants are discarded, since the source and destination documents might have defined the entity differently. If the document being imported into provides a definition for this entity name, its value is assigned.</p></def></gitem><gitem><label>NOTATION_NODE</label><def><p><code>Notation</code>nodes cannot be adopted.</p></def></gitem><gitem><label>PROCESSING_INSTRUCTION_NODE, TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE</label><def><p>These nodes can all be adopted. No specifics.</p></def></gitem></glist></p><note><p>Since it does not create new nodes unlike the<code>Document.importNode()</code>method, this method does not raise an<code>INVALID_CHARACTER_ERR</code>exception, and applications should use the<code>Document.normalizeDocument()</code>method to check if an imported name is not an XML name according to the XML version in use.</p></note></descr><parameters><param attr="in" type="Node" name="source"><descr><p>The node to move into this document.</p></descr></param></parameters><returns type="Node"><descr><p>The adopted node, or<code>null</code>if this operation fails, such as when the source node comes from a different implementation.</p></descr></returns><raises><exception name="DOMException"><descr><p>NOT_SUPPORTED_ERR: Raised if the source node is of type<code>DOCUMENT</code>,<code>DOCUMENT_TYPE</code>.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised when the source node is readonly.</p></descr></exception></raises></method><attribute readonly="yes" type="DOMConfiguration" name="domConfig" id="Document3-domConfig" since="DOM Level 3"><descr><p>The configuration used when<code>Document.normalizeDocument()</code>is invoked.</p></descr></attribute><method name="normalizeDocument" id="Document3-normalizeDocument" since="DOM Level 3"><descr><p>This method acts as if the document was going through a save and load cycle, putting the document in a "normal" form. As a consequence, this method updates the replacement tree of<code>EntityReference</code>nodes and normalizes<code>Text</code>nodes, as defined in the method<code>Node.normalize()</code>.</p><p>Otherwise, the actual result depends on the features being set on the<code>Document.domConfig</code>object and governing what operations actually take place. Noticeably this method could also make the document<termref def="dt-namespace-well-formed">namespace well-formed</termref>according to the algorithm described in<specref ref="normalizeDocumentAlgo"/>, check the character normalization, remove the<code>CDATASection</code>nodes, etc. See<code>DOMConfiguration</code>for details.</p><eg role="code" space="preserve">// Keep in the document the information defined // in the XML Information Set (Java example) DOMConfiguration docConfig = myDocument.getDomConfig(); docConfig.setParameter("infoset", Boolean.TRUE); myDocument.normalizeDocument();</eg><p>Mutation events, when supported, are generated to reflect the changes occurring on the document.</p><p>If errors occur during the invocation of this method, such as an attempt to update a<termref def="dt-readonly-node">read-only node</termref>or a<code>Node.nodeName</code>contains an invalid character according to the XML version in use, errors or warnings (<code>DOMError.SEVERITY_ERROR</code>or<code>DOMError.SEVERITY_WARNING</code>) will be reported using the<code>DOMErrorHandler</code>object associated with the "<termref def="parameter-error-handler">error-handler</termref>" parameter. Note this method might also report fatal errors (<code>DOMError.SEVERITY_FATAL_ERROR</code>) if an implementation cannot recover from an error.</p></descr><parameters></parameters><returns type="void"><descr><p/></descr></returns><raises></raises></method><method name="renameNode" id="Document3-renameNode" since="DOM Level 3"><descr><p>Rename an existing node of type<code>ELEMENT_NODE</code>or<code>ATTRIBUTE_NODE</code>.</p><p>When possible this simply changes the name of the given node, otherwise this creates a new node with the specified name and replaces the existing node with the new node as described below.</p><p>If simply changing the name of the given node is not possible, the following operations are performed: a new node is created, any registered event listener is registered on the new node, any user data attached to the old node is removed from that node, the old node is removed from its parent if it has one, the children are moved to the new node, if the renamed node is an<code>Element</code>its attributes are moved to the new node, the new node is inserted at the position the old node used to have in its parent's child nodes list if it has one, the user data that was attached to the old node is attached to the new node.</p><p>When the node being renamed is an<code>Element</code>only the specified attributes are moved, default attributes originated from the DTD are updated according to the new element name. In addition, the implementation may update default attributes from other schemas. Applications should use<code>Document.normalizeDocument()</code>to guarantee these attributes are up-to-date.</p><p>When the node being renamed is an<code>Attr</code>that is attached to an<code>Element</code>, the node is first removed from the<code>Element</code>attributes map. Then, once renamed, either by modifying the existing node or creating a new one as described above, it is put back.</p><p>In addition,</p><ulist><item><p>a user data event<code>NODE_RENAMED</code>is fired,</p></item><item><p>when the implementation supports the feature "MutationNameEvents", each mutation operation involved in this method fires the appropriate event, and in the end the event {<code>http://www.w3.org/2001/xml-events</code>,<code>DOMElementNameChanged</code>} or {<code>http://www.w3.org/2001/xml-events</code>,<code>DOMAttributeNameChanged</code>} is fired.</p></item></ulist></descr><parameters><param name="n" type="Node" attr="in"><descr><p>The node to rename.</p></descr></param><param name="namespaceURI" type="DOMString" attr="in"><descr><p>The new<termref def="dt-namespaceURI">namespace URI</termref>.</p></descr></param><param name="qualifiedName" type="DOMString" attr="in"><descr><p>The new<termref def="dt-qualifiedname">qualified name</termref>.</p></descr></param></parameters><returns type="Node"><descr><p>The renamed node. This is either the specified node or the new node that was created to replace the specified node.</p></descr></returns><raises><exception name="DOMException"><descr><p>NOT_SUPPORTED_ERR: Raised when the type of the specified node is neither<code>ELEMENT_NODE</code>nor<code>ATTRIBUTE_NODE</code>, or if the implementation does not support the renaming of the<termref def="dt-document-element">document element</termref>.</p><p>INVALID_CHARACTER_ERR: Raised if the new qualified name is not an XML name according to the XML version in use specified in the<code>Document.xmlVersion</code>attribute.</p><p>WRONG_DOCUMENT_ERR: Raised when the specified node was created from a different document than this document.</p><p>NAMESPACE_ERR: Raised if the<code>qualifiedName</code>is a malformed<termref def="dt-qualifiedname">qualified name</termref>, if the<code>qualifiedName</code>has a prefix and the<code>namespaceURI</code>is<code>null</code>, or if the<code>qualifiedName</code>has a prefix that is "xml" and the<code>namespaceURI</code>is different from "<loc href="http://www.w3.org/XML/1998/namespace" type="simple" show="replace" actuate="onRequest">http://www.w3.org/XML/1998/namespace</loc>"<bibref ref="Namespaces"/>. Also raised, when the node being renamed is an attribute, if the<code>qualifiedName</code>, or its prefix, is "xmlns" and the<code>namespaceURI</code>is different from "<loc href="http://www.w3.org/2000/xmlns/" type="simple" show="replace" actuate="onRequest">http://www.w3.org/2000/xmlns/</loc>".</p></descr></exception></raises></method></interface>
+ <interface name="Node" id="ID-1950641247"><descr><p>The<code>Node</code>interface is the primary datatype for the entire Document Object Model. It represents a single node in the document tree. While all objects implementing the<code>Node</code>interface expose methods for dealing with children, not all objects implementing the<code>Node</code>interface may have children. For example,<code>Text</code>nodes may not have children, and adding children to such nodes results in a<code>DOMException</code>being raised.</p><p>The attributes<code>nodeName</code>,<code>nodeValue</code>and<code>attributes</code>are included as a mechanism to get at node information without casting down to the specific derived interface. In cases where there is no obvious mapping of these attributes for a specific<code>nodeType</code>(e.g.,<code>nodeValue</code>for an<code>Element</code>or<code>attributes</code>for a<code>Comment</code>), this returns<code>null</code>. Note that the specialized interfaces may contain additional and more convenient mechanisms to get and set the relevant information.</p></descr><group id="ID-1841493061" name="NodeType"><descr><p>An integer indicating which type of node this is.</p><note><p>Numeric codes up to 200 are reserved to W3C for possible future use.</p></note></descr><constant id="Node-ELEMENT_NODE" name="ELEMENT_NODE" type="unsigned short" value="1"><descr><p>The node is an<code>Element</code>.</p></descr></constant><constant id="Node-ATTRIBUTE_NODE" name="ATTRIBUTE_NODE" type="unsigned short" value="2"><descr><p>The node is an<code>Attr</code>.</p></descr></constant><constant id="Node-TEXT_NODE" name="TEXT_NODE" type="unsigned short" value="3"><descr><p>The node is a<code>Text</code>node.</p></descr></constant><constant id="Node-CDATA_SECTION_NODE" name="CDATA_SECTION_NODE" type="unsigned short" value="4"><descr><p>The node is a<code>CDATASection</code>.</p></descr></constant><constant id="Node-ENTITY_REFERENCE_NODE" name="ENTITY_REFERENCE_NODE" type="unsigned short" value="5"><descr><p>The node is an<code>EntityReference</code>.</p></descr></constant><constant id="Node-ENTITY_NODE" name="ENTITY_NODE" type="unsigned short" value="6"><descr><p>The node is an<code>Entity</code>.</p></descr></constant><constant id="Node-PROCESSING_INSTRUCTION_NODE" name="PROCESSING_INSTRUCTION_NODE" type="unsigned short" value="7"><descr><p>The node is a<code>ProcessingInstruction</code>.</p></descr></constant><constant id="Node-COMMENT_NODE" name="COMMENT_NODE" type="unsigned short" value="8"><descr><p>The node is a<code>Comment</code>.</p></descr></constant><constant id="Node-DOCUMENT_NODE" name="DOCUMENT_NODE" type="unsigned short" value="9"><descr><p>The node is a<code>Document</code>.</p></descr></constant><constant id="Node-DOCUMENT_TYPE_NODE" name="DOCUMENT_TYPE_NODE" type="unsigned short" value="10"><descr><p>The node is a<code>DocumentType</code>.</p></descr></constant><constant id="Node-DOCUMENT_FRAGMENT_NODE" name="DOCUMENT_FRAGMENT_NODE" type="unsigned short" value="11"><descr><p>The node is a<code>DocumentFragment</code>.</p></descr></constant><constant id="Node-NOTATION_NODE" name="NOTATION_NODE" type="unsigned short" value="12"><descr><p>The node is a<code>Notation</code>.</p></descr></constant></group><p>The values of<code>nodeName</code>,<code>nodeValue</code>, and<code>attributes</code>vary according to the node type as follows:<table cellpadding="3" summary="Layout table: the first cell contains the name of the interface, the second contains the value of the nodeName attribute for this interface, the third contains the value of the nodeValue attribute for this interface and the fourth contains the value of the attributes attribute for this interface" border="1"><tbody><tr><th rowspan="1" colspan="1">Interface</th><th rowspan="1" colspan="1">nodeName</th><th rowspan="1" colspan="1">nodeValue</th><th rowspan="1" colspan="1">attributes</th></tr><tr><td rowspan="1" colspan="1"><code>Attr</code></td><td rowspan="1" colspan="1">same as<code>Attr.name</code></td><td rowspan="1" colspan="1">same as<code>Attr.value</code></td><td rowspan="1" colspan="1"><code>null</code></td></tr><tr><td rowspan="1" colspan="1"><code>CDATASection</code></td><td rowspan="1" colspan="1"><code>"#cdata-section"</code></td><td rowspan="1" colspan="1">same as<code>CharacterData.data</code>, the content of the CDATA Section</td><td rowspan="1" colspan="1"><code>null</code></td></tr><tr><td rowspan="1" colspan="1"><code>Comment</code></td><td rowspan="1" colspan="1"><code>"#comment"</code></td><td rowspan="1" colspan="1">same as<code>CharacterData.data</code>, the content of the comment</td><td rowspan="1" colspan="1"><code>null</code></td></tr><tr><td rowspan="1" colspan="1"><code>Document</code></td><td rowspan="1" colspan="1"><code>"#document"</code></td><td rowspan="1" colspan="1"><code>null</code></td><td rowspan="1" colspan="1"><code>null</code></td></tr><tr><td rowspan="1" colspan="1"><code>DocumentFragment</code></td><td rowspan="1" colspan="1"><code>"#document-fragment"</code></td><td rowspan="1" colspan="1"><code>null</code></td><td rowspan="1" colspan="1"><code>null</code></td></tr><tr><td rowspan="1" colspan="1"><code>DocumentType</code></td><td rowspan="1" colspan="1">same as<code>DocumentType.name</code></td><td rowspan="1" colspan="1"><code>null</code></td><td rowspan="1" colspan="1"><code>null</code></td></tr><tr><td rowspan="1" colspan="1"><code>Element</code></td><td rowspan="1" colspan="1">same as<code>Element.tagName</code></td><td rowspan="1" colspan="1"><code>null</code></td><td rowspan="1" colspan="1"><code>NamedNodeMap</code></td></tr><tr><td rowspan="1" colspan="1"><code>Entity</code></td><td rowspan="1" colspan="1">entity name</td><td rowspan="1" colspan="1"><code>null</code></td><td rowspan="1" colspan="1"><code>null</code></td></tr><tr><td rowspan="1" colspan="1"><code>EntityReference</code></td><td rowspan="1" colspan="1">name of entity referenced</td><td rowspan="1" colspan="1"><code>null</code></td><td rowspan="1" colspan="1"><code>null</code></td></tr><tr><td rowspan="1" colspan="1"><code>Notation</code></td><td rowspan="1" colspan="1">notation name</td><td rowspan="1" colspan="1"><code>null</code></td><td rowspan="1" colspan="1"><code>null</code></td></tr><tr><td rowspan="1" colspan="1"><code>ProcessingInstruction</code></td><td rowspan="1" colspan="1">same as<code>ProcessingInstruction.target</code></td><td rowspan="1" colspan="1">same as<code>ProcessingInstruction.data</code></td><td rowspan="1" colspan="1"><code>null</code></td></tr><tr><td rowspan="1" colspan="1"><code>Text</code></td><td rowspan="1" colspan="1"><code>"#text"</code></td><td rowspan="1" colspan="1">same as<code>CharacterData.data</code>, the content of the text node</td><td rowspan="1" colspan="1"><code>null</code></td></tr></tbody></table></p><attribute type="DOMString" readonly="yes" name="nodeName" id="ID-F68D095"><descr><p>The name of this node, depending on its type; see the table above.</p></descr></attribute><attribute type="DOMString" name="nodeValue" id="ID-F68D080" readonly="no"><descr><p>The value of this node, depending on its type; see the table above. When it is defined to be<code>null</code>, setting it has no effect, including if the node is<termref def="dt-readonly-node">read-only</termref>.</p></descr><setraises><exception name="DOMException"><descr><p>NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly and if it is not defined to be<code>null</code>.</p></descr></exception></setraises><getraises><exception name="DOMException"><descr><p>DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in a<code>DOMString</code>variable on the implementation platform.</p></descr></exception></getraises></attribute><attribute type="unsigned short" name="nodeType" readonly="yes" id="ID-111237558"><descr><p>A code representing the type of the underlying object, as defined above.</p></descr></attribute><attribute type="Node" readonly="yes" name="parentNode" id="ID-1060184317"><descr><p>The<termref def="dt-parent">parent</termref>of this node. All nodes, except<code>Attr</code>,<code>Document</code>,<code>DocumentFragment</code>,<code>Entity</code>, and<code>Notation</code>may have a parent. However, if a node has just been created and not yet added to the tree, or if it has been removed from the tree, this is<code>null</code>.</p></descr></attribute><attribute type="NodeList" readonly="yes" name="childNodes" id="ID-1451460987"><descr><p>A<code>NodeList</code>that contains all children of this node. If there are no children, this is a<code>NodeList</code>containing no nodes.</p></descr></attribute><attribute readonly="yes" type="Node" name="firstChild" id="ID-169727388"><descr><p>The first child of this node. If there is no such node, this returns<code>null</code>.</p></descr></attribute><attribute readonly="yes" type="Node" name="lastChild" id="ID-61AD09FB"><descr><p>The last child of this node. If there is no such node, this returns<code>null</code>.</p></descr></attribute><attribute readonly="yes" type="Node" name="previousSibling" id="ID-640FB3C8"><descr><p>The node immediately preceding this node. If there is no such node, this returns<code>null</code>.</p></descr></attribute><attribute readonly="yes" type="Node" name="nextSibling" id="ID-6AC54C2F"><descr><p>The node immediately following this node. If there is no such node, this returns<code>null</code>.</p></descr></attribute><attribute readonly="yes" type="NamedNodeMap" name="attributes" id="ID-84CF096"><descr><p>A<code>NamedNodeMap</code>containing the attributes of this node (if it is an<code>Element</code>) or<code>null</code>otherwise.</p></descr></attribute><attribute readonly="yes" type="Document" name="ownerDocument" id="node-ownerDoc" version="DOM Level 2"><descr><p>The<code>Document</code>object associated with this node. This is also the<code>Document</code>object used to create new nodes. When this node is a<code>Document</code>or a<code>DocumentType</code>which is not used with any<code>Document</code>yet, this is<code>null</code>.</p></descr></attribute><method name="insertBefore" id="ID-952280727" version="DOM Level 3"><descr><p>Inserts the node<code>newChild</code>before the existing child node<code>refChild</code>. If<code>refChild</code>is<code>null</code>, insert<code>newChild</code>at the end of the list of children.</p><p>If<code>newChild</code>is a<code>DocumentFragment</code>object, all of its children are inserted, in the same order, before<code>refChild</code>. If the<code>newChild</code>is already in the tree, it is first removed.</p><note><p>Inserting a node before itself is implementation dependent.</p></note></descr><parameters><param name="newChild" type="Node" attr="in"><descr><p>The node to insert.</p></descr></param><param name="refChild" type="Node" attr="in"><descr><p>The reference node, i.e., the node before which the new node must be inserted.</p></descr></param></parameters><returns type="Node"><descr><p>The node being inserted.</p></descr></returns><raises><exception name="DOMException"><descr><p>HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the<code>newChild</code>node, or if the node to insert is one of this node's<termref def="dt-ancestor">ancestors</termref>or this node itself, or if this node is of type<code>Document</code>and the DOM application attempts to insert a second<code>DocumentType</code>or<code>Element</code>node.</p><p>WRONG_DOCUMENT_ERR: Raised if<code>newChild</code>was created from a different document than the one that created this node.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or if the parent of the node being inserted is readonly.</p><p>NOT_FOUND_ERR: Raised if<code>refChild</code>is not a child of this node.</p><p>NOT_SUPPORTED_ERR: if this node is of type<code>Document</code>, this exception might be raised if the DOM implementation doesn't support the insertion of a<code>DocumentType</code>or<code>Element</code>node.</p></descr></exception></raises></method><method name="replaceChild" id="ID-785887307" version="DOM Level 3"><descr><p>Replaces the child node<code>oldChild</code>with<code>newChild</code>in the list of children, and returns the<code>oldChild</code>node.</p><p>If<code>newChild</code>is a<code>DocumentFragment</code>object,<code>oldChild</code>is replaced by all of the<code>DocumentFragment</code>children, which are inserted in the same order. If the<code>newChild</code>is already in the tree, it is first removed.</p><note><p>Replacing a node with itself is implementation dependent.</p></note></descr><parameters><param name="newChild" type="Node" attr="in"><descr><p>The new node to put in the child list.</p></descr></param><param name="oldChild" type="Node" attr="in"><descr><p>The node being replaced in the list.</p></descr></param></parameters><returns type="Node"><descr><p>The node replaced.</p></descr></returns><raises><exception name="DOMException"><descr><p>HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the<code>newChild</code>node, or if the node to put in is one of this node's<termref def="dt-ancestor">ancestors</termref>or this node itself, or if this node is of type<code>Document</code>and the result of the replacement operation would add a second<code>DocumentType</code>or<code>Element</code>on the<code>Document</code>node.</p><p>WRONG_DOCUMENT_ERR: Raised if<code>newChild</code>was created from a different document than the one that created this node.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the parent of the new node is readonly.</p><p>NOT_FOUND_ERR: Raised if<code>oldChild</code>is not a child of this node.</p><p>NOT_SUPPORTED_ERR: if this node is of type<code>Document</code>, this exception might be raised if the DOM implementation doesn't support the replacement of the<code>DocumentType</code>child or<code>Element</code>child.</p></descr></exception></raises></method><method name="removeChild" id="ID-1734834066" version="DOM Level 3"><descr><p>Removes the child node indicated by<code>oldChild</code>from the list of children, and returns it.</p></descr><parameters><param name="oldChild" type="Node" attr="in"><descr><p>The node being removed.</p></descr></param></parameters><returns type="Node"><descr><p>The node removed.</p></descr></returns><raises><exception name="DOMException"><descr><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p><p>NOT_FOUND_ERR: Raised if<code>oldChild</code>is not a child of this node.</p><p>NOT_SUPPORTED_ERR: if this node is of type<code>Document</code>, this exception might be raised if the DOM implementation doesn't support the removal of the<code>DocumentType</code>child or the<code>Element</code>child.</p></descr></exception></raises></method><method name="appendChild" id="ID-184E7107" version="DOM Level 3"><descr><p>Adds the node<code>newChild</code>to the end of the list of children of this node. If the<code>newChild</code>is already in the tree, it is first removed.</p></descr><parameters><param name="newChild" type="Node" attr="in"><descr><p>The node to add.</p><p>If it is a<code>DocumentFragment</code>object, the entire contents of the document fragment are moved into the child list of this node</p></descr></param></parameters><returns type="Node"><descr><p>The node added.</p></descr></returns><raises><exception name="DOMException"><descr><p>HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type of the<code>newChild</code>node, or if the node to append is one of this node's<termref def="dt-ancestor">ancestors</termref>or this node itself, or if this node is of type<code>Document</code>and the DOM application attempts to append a second<code>DocumentType</code>or<code>Element</code>node.</p><p>WRONG_DOCUMENT_ERR: Raised if<code>newChild</code>was created from a different document than the one that created this node.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or if the previous parent of the node being inserted is readonly.</p><p>NOT_SUPPORTED_ERR: if the<code>newChild</code>node is a child of the<code>Document</code>node, this exception might be raised if the DOM implementation doesn't support the removal of the<code>DocumentType</code>child or<code>Element</code>child.</p></descr></exception></raises></method><method name="hasChildNodes" id="ID-810594187"><descr><p>Returns whether this node has any children.</p></descr><parameters></parameters><returns type="boolean"><descr><p>Returns<code>true</code>if this node has any children,<code>false</code>otherwise.</p></descr></returns><raises></raises></method><method name="cloneNode" id="ID-3A0ED0A4"><descr><p>Returns a duplicate of this node, i.e., serves as a generic copy constructor for nodes. The duplicate node has no parent (<code>parentNode</code>is<code>null</code>) and no user data. User data associated to the imported node is not carried over. However, if any<code>UserDataHandlers</code>has been specified along with the associated data these handlers will be called with the appropriate parameters before this method returns.</p><p>Cloning an<code>Element</code>copies all attributes and their values, including those generated by the XML processor to represent defaulted attributes, but this method does not copy any children it contains unless it is a deep clone. This includes text contained in an the<code>Element</code>since the text is contained in a child<code>Text</code>node. Cloning an<code>Attr</code>directly, as opposed to be cloned as part of an<code>Element</code>cloning operation, returns a specified attribute (<code>specified</code>is<code>true</code>). Cloning an<code>Attr</code>always clones its children, since they represent its value, no matter whether this is a deep clone or not. Cloning an<code>EntityReference</code>automatically constructs its subtree if a corresponding<code>Entity</code>is available, no matter whether this is a deep clone or not. Cloning any other type of node simply returns a copy of this node.</p><p>Note that cloning an immutable subtree results in a mutable copy, but the children of an<code>EntityReference</code>clone are<termref def="dt-readonly-node">readonly</termref>. In addition, clones of unspecified<code>Attr</code>nodes are specified. And, cloning<code>Document</code>,<code>DocumentType</code>,<code>Entity</code>, and<code>Notation</code>nodes is implementation dependent.</p></descr><parameters><param name="deep" type="boolean" attr="in"><descr><p>If<code>true</code>, recursively clone the subtree under the specified node; if<code>false</code>, clone only the node itself (and its attributes, if it is an<code>Element</code>).</p></descr></param></parameters><returns type="Node"><descr><p>The duplicate node.</p></descr></returns><raises></raises></method><method id="ID-normalize" name="normalize" version="DOM Level 3"><descr><p>Puts all<code>Text</code>nodes in the full depth of the sub-tree underneath this<code>Node</code>, including attribute nodes, into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates<code>Text</code>nodes, i.e., there are neither adjacent<code>Text</code>nodes nor empty<code>Text</code>nodes. This can be used to ensure that the DOM view of a document is the same as if it were saved and re-loaded, and is useful when operations (such as XPointer<bibref role="informative" ref="XPointer"/>lookups) that depend on a particular document tree structure are to be used. If the parameter "<termref def="parameter-normalize-characters">normalize-characters</termref>" of the<code>DOMConfiguration</code>object attached to the<code>Node.ownerDocument</code>is<code>true</code>, this method will also fully normalize the characters of the<code>Text</code>nodes.</p><note><p>In cases where the document contains<code>CDATASections</code>, the normalize operation alone may not be sufficient, since XPointers do not differentiate between<code>Text</code>nodes and<code>CDATASection</code>nodes.</p></note></descr><parameters></parameters><returns type="void"><descr><p/></descr></returns><raises></raises></method><method name="isSupported" id="Level-2-Core-Node-supports" since="DOM Level 2"><descr><p>Tests whether the DOM implementation implements a specific feature and that feature is supported by this node, as specified in<specref ref="DOMFeatures"/>.</p></descr><parameters><param name="feature" type="DOMString" attr="in"><descr><p>The name of the feature to test.</p></descr></param><param name="version" type="DOMString" attr="in"><descr><p>This is the version number of the feature to test.</p></descr></param></parameters><returns type="boolean"><descr><p>Returns<code>true</code>if the specified feature is supported on this node,<code>false</code>otherwise.</p></descr></returns><raises></raises></method><attribute readonly="yes" type="DOMString" name="namespaceURI" id="ID-NodeNSname" since="DOM Level 2"><descr><p>The<termref def="dt-namespaceURI">namespace URI</termref>of this node, or<code>null</code>if it is unspecified (see<specref ref="Namespaces-Considerations"/>).</p><p>This is not a computed value that is the result of a namespace lookup based on an examination of the namespace declarations in scope. It is merely the namespace URI given at creation time.</p><p>For nodes of any type other than<code>ELEMENT_NODE</code>and<code>ATTRIBUTE_NODE</code>and nodes created with a DOM Level 1 method, such as<code>Document.createElement()</code>, this is always<code>null</code>.</p><note><p>Per the<emph>Namespaces in XML</emph>Specification<bibref ref="Namespaces"/>an attribute does not inherit its namespace from the element it is attached to. If an attribute is not explicitly given a namespace, it simply has no namespace.</p></note></descr></attribute><attribute type="DOMString" name="prefix" id="ID-NodeNSPrefix" since="DOM Level 2" readonly="no"><descr><p>The<termref def="dt-namespaceprefix">namespace prefix</termref>of this node, or<code>null</code>if it is unspecified. When it is defined to be<code>null</code>, setting it has no effect, including if the node is<termref def="dt-readonly-node">read-only</termref>.</p><p>Note that setting this attribute, when permitted, changes the<code>nodeName</code>attribute, which holds the<termref def="dt-qualifiedname">qualified name</termref>, as well as the<code>tagName</code>and<code>name</code>attributes of the<code>Element</code>and<code>Attr</code>interfaces, when applicable.</p><p>Setting the prefix to<code>null</code>makes it unspecified, setting it to an empty string is implementation dependent.</p><p>Note also that changing the prefix of an attribute that is known to have a default value, does not make a new attribute with the default value and the original prefix appear, since the<code>namespaceURI</code>and<code>localName</code>do not change.</p><p>For nodes of any type other than<code>ELEMENT_NODE</code>and<code>ATTRIBUTE_NODE</code>and nodes created with a DOM Level 1 method, such as<code>createElement</code>from the<code>Document</code>interface, this is always<code>null</code>.</p></descr><setraises><exception name="DOMException"><descr><p>INVALID_CHARACTER_ERR: Raised if the specified prefix contains an illegal character according to the XML version in use specified in the<code>Document.xmlVersion</code>attribute.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p><p>NAMESPACE_ERR: Raised if the specified<code>prefix</code>is malformed per the Namespaces in XML specification, if the<code>namespaceURI</code>of this node is<code>null</code>, if the specified prefix is "xml" and the<code>namespaceURI</code>of this node is different from "<loc href="http://www.w3.org/XML/1998/namespace" type="simple" show="replace" actuate="onRequest">http://www.w3.org/XML/1998/namespace</loc>", if this node is an attribute and the specified prefix is "xmlns" and the<code>namespaceURI</code>of this node is different from "<loc href="http://www.w3.org/2000/xmlns/" type="simple" show="replace" actuate="onRequest">http://www.w3.org/2000/xmlns/</loc>", or if this node is an attribute and the<code>qualifiedName</code>of this node is "xmlns"<bibref ref="Namespaces"/>.</p></descr></exception></setraises></attribute><attribute readonly="yes" type="DOMString" name="localName" id="ID-NodeNSLocalN" since="DOM Level 2"><descr><p>Returns the local part of the<termref def="dt-qualifiedname">qualified name</termref>of this node.</p><p>For nodes of any type other than<code>ELEMENT_NODE</code>and<code>ATTRIBUTE_NODE</code>and nodes created with a DOM Level 1 method, such as<code>Document.createElement()</code>, this is always<code>null</code>.</p></descr></attribute><method name="hasAttributes" id="ID-NodeHasAttrs" since="DOM Level 2"><descr><p>Returns whether this node (if it is an element) has any attributes.</p></descr><parameters></parameters><returns type="boolean"><descr><p>Returns<code>true</code>if this node has any attributes,<code>false</code>otherwise.</p></descr></returns><raises></raises></method><attribute readonly="yes" type="DOMString" name="baseURI" id="Node3-baseURI" since="DOM Level 3"><descr><p>The absolute base URI of this node or<code>null</code>if the implementation wasn't able to obtain an absolute URI. This value is computed as described in<specref ref="baseURIs-Considerations"/>. However, when the<code>Document</code>supports the feature "HTML"<bibref role="informative" ref="DOM2HTML"/>, the base URI is computed using first the value of the href attribute of the HTML BASE element if any, and the value of the<code>documentURI</code>attribute from the<code>Document</code>interface otherwise.</p></descr></attribute><group id="DocumentPosition" name="DocumentPosition" since="DOM Level 3"><descr><p>A bitmask indicating the relative document position of a node with respect to another node.</p><p>If the two nodes being compared are the same node, then no flags are set on the return.</p><p>Otherwise, the order of two nodes is determined by looking for common containers -- containers which contain both. A node directly contains any child nodes. A node also directly contains any other nodes attached to it such as attributes contained in an element or entities and notations contained in a document type. Nodes contained in contained nodes are also contained, but less-directly as the number of intervening containers increases.</p><p>If there is no common container node, then the order is based upon order between the root container of each node that is in no container. In this case, the result is disconnected and implementation-specific. This result is stable as long as these outer-most containing nodes remain in memory and are not inserted into some other containing node. This would be the case when the nodes belong to different documents or fragments, and cloning the document or inserting a fragment might change the order.</p><p>If one of the nodes being compared contains the other node, then the container precedes the contained node, and reversely the contained node follows the container. For example, when comparing an element against its own attribute or child, the element node precedes its attribute node and its child node, which both follow it.</p><p>If neither of the previous cases apply, then there exists a most-direct container common to both nodes being compared. In this case, the order is determined based upon the two determining nodes directly contained in this most-direct common container that either are or contain the corresponding nodes being compared.</p><p>If these two determining nodes are both child nodes, then the natural DOM order of these determining nodes within the containing node is returned as the order of the corresponding nodes. This would be the case, for example, when comparing two child elements of the same element.</p><p>If one of the two determining nodes is a child node and the other is not, then the corresponding node of the child node follows the corresponding node of the non-child node. This would be the case, for example, when comparing an attribute of an element with a child element of the same element.</p><p>If neither of the two determining node is a child node and one determining node has a greater value of<code>nodeType</code>than the other, then the corresponding node precedes the other. This would be the case, for example, when comparing an entity of a document type against a notation of the same document type.</p><p>If neither of the two determining node is a child node and<code>nodeType</code>is the same for both determining nodes, then an implementation-dependent order between the determining nodes is returned. This order is stable as long as no nodes of the same nodeType are inserted into or removed from the direct container. This would be the case, for example, when comparing two attributes of the same element, and inserting or removing additional attributes might change the order between existing attributes.</p></descr><constant id="Node-DOCUMENT_POSITION_DISCONNECTED" name="DOCUMENT_POSITION_DISCONNECTED" type="unsigned short" value="0x01"><descr><p>The two nodes are disconnected. Order between disconnected nodes is always implementation-specific.</p></descr></constant><constant id="Node-DOCUMENT_POSITION_PRECEDING" name="DOCUMENT_POSITION_PRECEDING" type="unsigned short" value="0x02"><descr><p>The second node precedes the reference node.</p></descr></constant><constant id="Node-DOCUMENT_POSITION_FOLLOWING" name="DOCUMENT_POSITION_FOLLOWING" type="unsigned short" value="0x04"><descr><p>The node follows the reference node.</p></descr></constant><constant id="Node-DOCUMENT_POSITION_CONTAINS" name="DOCUMENT_POSITION_CONTAINS" type="unsigned short" value="0x08"><descr><p>The node contains the reference node. A node which contains is always preceding, too.</p></descr></constant><constant id="Node-DOCUMENT_POSITION_CONTAINED_BY" name="DOCUMENT_POSITION_CONTAINED_BY" type="unsigned short" value="0x10"><descr><p>The node is contained by the reference node. A node which is contained is always following, too.</p></descr></constant><constant id="Node-DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC" name="DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC" type="unsigned short" value="0x20"><descr><p>The determination of preceding versus following is implementation-specific.</p></descr></constant></group><method name="compareDocumentPosition" id="Node3-compareDocumentPosition" since="DOM Level 3"><descr><p>Compares the reference node, i.e. the node on which this method is being called, with a node, i.e. the one passed as a parameter, with regard to their position in the document and according to the<termref def="dt-document-order">document order</termref>.</p></descr><parameters><param attr="in" type="Node" name="other"><descr><p>The node to compare against the reference node.</p></descr></param></parameters><returns type="unsigned short"><descr><p>Returns how the node is positioned relatively to the reference node.</p></descr></returns><raises><exception name="DOMException"><descr><p>NOT_SUPPORTED_ERR: when the compared nodes are from different DOM implementations that do not coordinate to return consistent implementation-specific results.</p></descr></exception></raises></method><attribute name="textContent" id="Node3-textContent" type="DOMString" readonly="no" since="DOM Level 3"><descr><p>This attribute returns the text content of this node and its descendants. When it is defined to be<code>null</code>, setting it has no effect. On setting, any possible children this node may have are removed and, if it the new string is not empty or<code>null</code>, replaced by a single<code>Text</code>node containing the string this attribute is set to.</p><p>On getting, no serialization is performed, the returned string does not contain any markup. No whitespace normalization is performed and the returned string does not contain the white spaces in element content (see the attribute<code>Text.isElementContentWhitespace</code>). Similarly, on setting, no parsing is performed either, the input string is taken as pure textual content.</p><p>The string returned is made of the text content of this node depending on its type, as defined below:</p><table cellpadding="3" summary="The string returned is made of the text content of the node. The first cell of this table contains the type of the Node, the second cell indicates the string returned by textContent." border="1"><tbody><tr><th rowspan="1" colspan="1">Node type</th><th rowspan="1" colspan="1">Content</th></tr><tr><td rowspan="1" colspan="1">ELEMENT_NODE, ATTRIBUTE_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, DOCUMENT_FRAGMENT_NODE</td><td rowspan="1" colspan="1">concatenation of the<code>textContent</code>attribute value of every child node, excluding COMMENT_NODE and PROCESSING_INSTRUCTION_NODE nodes. This is the empty string if the node has no children.</td></tr><tr><td rowspan="1" colspan="1">TEXT_NODE, CDATA_SECTION_NODE, COMMENT_NODE, PROCESSING_INSTRUCTION_NODE</td><td rowspan="1" colspan="1"><code>nodeValue</code></td></tr><tr><td rowspan="1" colspan="1">DOCUMENT_NODE, DOCUMENT_TYPE_NODE, NOTATION_NODE</td><td rowspan="1" colspan="1"><emph>null</emph></td></tr></tbody></table></descr><setraises><exception name="DOMException"><descr><p>NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.</p></descr></exception></setraises><getraises><exception name="DOMException"><descr><p>DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in a<code>DOMString</code>variable on the implementation platform.</p></descr></exception></getraises></attribute><method name="isSameNode" id="Node3-isSameNode" since="DOM Level 3"><descr><p>Returns whether this node is the same node as the given one.</p><p>This method provides a way to determine whether two<code>Node</code>references returned by the implementation reference the same object. When two<code>Node</code>references are references to the same object, even if through a proxy, the references may be used completely interchangeably, such that all attributes have the same values and calling the same DOM method on either reference always has exactly the same effect.</p></descr><parameters><param attr="in" type="Node" name="other"><descr><p>The node to test against.</p></descr></param></parameters><returns type="boolean"><descr><p>Returns<code>true</code>if the nodes are the same,<code>false</code>otherwise.</p></descr></returns><raises></raises></method><method name="lookupPrefix" id="Node3-lookupNamespacePrefix" since="DOM Level 3"><descr><p>Look up the prefix associated to the given namespace URI, starting from this node. The default namespace declarations are ignored by this method.</p><p>See<specref ref="lookupNamespacePrefixAlgo"/>for details on the algorithm used by this method.</p></descr><parameters><param attr="in" type="DOMString" name="namespaceURI"><descr><p>The namespace URI to look for.</p></descr></param></parameters><returns type="DOMString"><descr><p>Returns an associated namespace prefix if found or<code>null</code>if none is found. If more than one prefix are associated to the namespace prefix, the returned namespace prefix is implementation dependent.</p></descr></returns><raises></raises></method><method name="isDefaultNamespace" id="Node3-isDefaultNamespace" since="DOM Level 3"><descr><p>This method checks if the specified<code>namespaceURI</code>is the default namespace or not.</p></descr><parameters><param name="namespaceURI" type="DOMString" attr="in"><descr><p>The namespace URI to look for.</p></descr></param></parameters><returns type="boolean"><descr><p>Returns<code>true</code>if the specified<code>namespaceURI</code>is the default namespace,<code>false</code>otherwise.</p></descr></returns><raises></raises></method><method name="lookupNamespaceURI" id="Node3-lookupNamespaceURI" since="DOM Level 3"><descr><p>Look up the namespace URI associated to the given prefix, starting from this node.</p><p>See<specref ref="lookupNamespaceURIAlgo"/>for details on the algorithm used by this method.</p></descr><parameters><param attr="in" type="DOMString" name="prefix"><descr><p>The prefix to look for. If this parameter is<code>null</code>, the method will return the default namespace URI if any.</p></descr></param></parameters><returns type="DOMString"><descr><p>Returns the associated namespace URI or<code>null</code>if none is found.</p></descr></returns><raises></raises></method><method name="isEqualNode" id="Node3-isEqualNode" since="DOM Level 3"><descr><p>Tests whether two nodes are equal.</p><p>This method tests for equality of nodes, not sameness (i.e., whether the two nodes are references to the same object) which can be tested with<code>Node.isSameNode()</code>. All nodes that are the same will also be equal, though the reverse may not be true.</p><p>Two nodes are equal if and only if the following conditions are satisfied:<ulist><item><p>The two nodes are of the same type.</p></item><item><p>The following string attributes are equal:<code>nodeName</code>,<code>localName</code>,<code>namespaceURI</code>,<code>prefix</code>,<code>nodeValue</code>. This is: they are both<code>null</code>, or they have the same length and are character for character identical.</p></item><item><p>The<code>attributes</code><code>NamedNodeMaps</code>are equal. This is: they are both<code>null</code>, or they have the same length and for each node that exists in one map there is a node that exists in the other map and is equal, although not necessarily at the same index.</p></item><item><p>The<code>childNodes</code><code>NodeLists</code>are equal. This is: they are both<code>null</code>, or they have the same length and contain equal nodes at the same index. Note that normalization can affect equality; to avoid this, nodes should be normalized before being compared.</p></item></ulist></p><p>For two<code>DocumentType</code>nodes to be equal, the following conditions must also be satisfied:<ulist><item><p>The following string attributes are equal:<code>publicId</code>,<code>systemId</code>,<code>internalSubset</code>.</p></item><item><p>The<code>entities</code><code>NamedNodeMaps</code>are equal.</p></item><item><p>The<code>notations</code><code>NamedNodeMaps</code>are equal.</p></item></ulist></p><p>On the other hand, the following do not affect equality: the<code>ownerDocument</code>,<code>baseURI</code>, and<code>parentNode</code>attributes, the<code>specified</code>attribute for<code>Attr</code>nodes, the<code>schemaTypeInfo</code>attribute for<code>Attr</code>and<code>Element</code>nodes, the<code>Text.isElementContentWhitespace</code>attribute for<code>Text</code>nodes, as well as any user data or event listeners registered on the nodes.</p><note><p>As a general rule, anything not mentioned in the description above is not significant in consideration of equality checking. Note that future versions of this specification may take into account more attributes and implementations conform to this specification are expected to be updated accordingly.</p></note></descr><parameters><param name="arg" type="Node" attr="in"><descr><p>The node to compare equality with.</p></descr></param></parameters><returns type="boolean"><descr><p>Returns<code>true</code>if the nodes are equal,<code>false</code>otherwise.</p></descr></returns><raises></raises></method><method name="getFeature" id="Node3-getFeature" since="DOM Level 3"><descr><p>This method returns a specialized object which implements the specialized APIs of the specified feature and version, as specified in<specref ref="DOMFeatures"/>. The specialized object may also be obtained by using binding-specific casting methods but is not necessarily expected to, as discussed in<specref ref="Embedded-DOM"/>. This method also allow the implementation to provide specialized objects which do not support the<code>Node</code>interface.</p></descr><parameters><param name="feature" type="DOMString" attr="in"><descr><p>The name of the feature requested. Note that any plus sign "+" prepended to the name of the feature will be ignored since it is not significant in the context of this method.</p></descr></param><param name="version" type="DOMString" attr="in"><descr><p>This is the version number of the feature to test.</p></descr></param></parameters><returns type="DOMObject"><descr><p>Returns an object which implements the specialized APIs of the specified feature and version, if any, or<code>null</code>if there is no object which implements interfaces associated with that feature. If the<code>DOMObject</code>returned by this method implements the<code>Node</code>interface, it must delegate to the primary core<code>Node</code>and not return results inconsistent with the primary core<code>Node</code>such as attributes, childNodes, etc.</p></descr></returns><raises></raises></method><method name="setUserData" id="Node3-setUserData" since="DOM Level 3"><descr><p>Associate an object to a key on this node. The object can later be retrieved from this node by calling<code>getUserData</code>with the same key.</p></descr><parameters><param name="key" type="DOMString" attr="in"><descr><p>The key to associate the object to.</p></descr></param><param name="data" type="DOMUserData" attr="in"><descr><p>The object to associate to the given key, or<code>null</code>to remove any existing association to that key.</p></descr></param><param name="handler" type="UserDataHandler" attr="in"><descr><p>The handler to associate to that key, or<code>null</code>.</p></descr></param></parameters><returns type="DOMUserData"><descr><p>Returns the<code>DOMUserData</code>previously associated to the given key on this node, or<code>null</code>if there was none.</p></descr></returns><raises></raises></method><method name="getUserData" id="Node3-getUserData" since="DOM Level 3"><descr><p>Retrieves the object associated to a key on a this node. The object must first have been set to this node by calling<code>setUserData</code>with the same key.</p></descr><parameters><param name="key" type="DOMString" attr="in"><descr><p>The key the object is associated to.</p></descr></param></parameters><returns type="DOMUserData"><descr><p>Returns the<code>DOMUserData</code>associated to the given key on this node, or<code>null</code>if there was none.</p></descr></returns><raises></raises></method></interface>
+ <interface name="NodeList" id="ID-536297177"><descr><p>The<code>NodeList</code>interface provides the abstraction of an ordered collection of nodes, without defining or constraining how this collection is implemented.<code>NodeList</code>objects in the DOM are<termref def="td-live">live</termref>.</p><p>The items in the<code>NodeList</code>are accessible via an integral index, starting from 0.</p></descr><method name="item" id="ID-844377136"><descr><p>Returns the<code>index</code>th item in the collection. If<code>index</code>is greater than or equal to the number of nodes in the list, this returns<code>null</code>.</p></descr><parameters><param name="index" type="unsigned long" attr="in"><descr><p>Index into the collection.</p></descr></param></parameters><returns type="Node"><descr><p>The node at the<code>index</code>th position in the<code>NodeList</code>, or<code>null</code>if that is not a valid index.</p></descr></returns><raises></raises></method><attribute type="unsigned long" readonly="yes" name="length" id="ID-203510337"><descr><p>The number of nodes in the list. The range of valid child node indices is 0 to<code>length-1</code>inclusive.</p></descr></attribute></interface>
+ <interface name="NamedNodeMap" id="ID-1780488922"><descr><p>Objects implementing the<code>NamedNodeMap</code>interface are used to represent collections of nodes that can be accessed by name. Note that<code>NamedNodeMap</code>does not inherit from<code>NodeList</code>;<code>NamedNodeMaps</code>are not maintained in any particular order. Objects contained in an object implementing<code>NamedNodeMap</code>may also be accessed by an ordinal index, but this is simply to allow convenient enumeration of the contents of a<code>NamedNodeMap</code>, and does not imply that the DOM specifies an order to these Nodes.</p><p><code>NamedNodeMap</code>objects in the DOM are<termref def="td-live">live</termref>.</p></descr><method name="getNamedItem" id="ID-1074577549"><descr><p>Retrieves a node specified by name.</p></descr><parameters><param name="name" type="DOMString" attr="in"><descr><p>The<code>nodeName</code>of a node to retrieve.</p></descr></param></parameters><returns type="Node"><descr><p>A<code>Node</code>(of any type) with the specified<code>nodeName</code>, or<code>null</code>if it does not identify any node in this map.</p></descr></returns><raises></raises></method><method name="setNamedItem" id="ID-1025163788"><descr><p>Adds a node using its<code>nodeName</code>attribute. If a node with that name is already present in this map, it is replaced by the new one. Replacing a node by itself has no effect.</p><p>As the<code>nodeName</code>attribute is used to derive the name which the node must be stored under, multiple nodes of certain types (those that have a "special" string value) cannot be stored as the names would clash. This is seen as preferable to allowing nodes to be aliased.</p></descr><parameters><param name="arg" type="Node" attr="in"><descr><p>A node to store in this map. The node will later be accessible using the value of its<code>nodeName</code>attribute.</p></descr></param></parameters><returns type="Node"><descr><p>If the new<code>Node</code>replaces an existing node the replaced<code>Node</code>is returned, otherwise<code>null</code>is returned.</p></descr></returns><raises><exception name="DOMException"><descr><p>WRONG_DOCUMENT_ERR: Raised if<code>arg</code>was created from a different document than the one that created this map.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.</p><p>INUSE_ATTRIBUTE_ERR: Raised if<code>arg</code>is an<code>Attr</code>that is already an attribute of another<code>Element</code>object. The DOM user must explicitly clone<code>Attr</code>nodes to re-use them in other elements.</p><p>HIERARCHY_REQUEST_ERR: Raised if an attempt is made to add a node doesn't belong in this NamedNodeMap. Examples would include trying to insert something other than an Attr node into an Element's map of attributes, or a non-Entity node into the DocumentType's map of Entities.</p></descr></exception></raises></method><method name="removeNamedItem" id="ID-D58B193"><descr><p>Removes a node specified by name. When this map contains the attributes attached to an element, if the removed attribute is known to have a default value, an attribute immediately appears containing the default value as well as the corresponding namespace URI, local name, and prefix when applicable.</p></descr><parameters><param name="name" type="DOMString" attr="in"><descr><p>The<code>nodeName</code>of the node to remove.</p></descr></param></parameters><returns type="Node"><descr><p>The node removed from this map if a node with such a name exists.</p></descr></returns><raises><exception name="DOMException"><descr><p>NOT_FOUND_ERR: Raised if there is no node named<code>name</code>in this map.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.</p></descr></exception></raises></method><method name="item" id="ID-349467F9"><descr><p>Returns the<code>index</code>th item in the map. If<code>index</code>is greater than or equal to the number of nodes in this map, this returns<code>null</code>.</p></descr><parameters><param name="index" type="unsigned long" attr="in"><descr><p>Index into this map.</p></descr></param></parameters><returns type="Node"><descr><p>The node at the<code>index</code>th position in the map, or<code>null</code>if that is not a valid index.</p></descr></returns><raises></raises></method><attribute type="unsigned long" readonly="yes" name="length" id="ID-6D0FB19E"><descr><p>The number of nodes in this map. The range of valid child node indices is<code>0</code>to<code>length-1</code>inclusive.</p></descr></attribute><method name="getNamedItemNS" id="ID-getNamedItemNS" since="DOM Level 2"><descr><p>Retrieves a node specified by local name and namespace URI.</p><p>Per<bibref ref="Namespaces"/>, applications must use the value null as the namespaceURI parameter for methods if they wish to have no namespace.</p></descr><parameters><param name="namespaceURI" type="DOMString" attr="in"><descr><p>The<termref def="dt-namespaceURI">namespace URI</termref>of the node to retrieve.</p></descr></param><param name="localName" type="DOMString" attr="in"><descr><p>The<termref def="dt-localname">local name</termref>of the node to retrieve.</p></descr></param></parameters><returns type="Node"><descr><p>A<code>Node</code>(of any type) with the specified local name and namespace URI, or<code>null</code>if they do not identify any node in this map.</p></descr></returns><raises><exception name="DOMException"><descr><p>NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature "XML" and the language exposed through the Document does not support XML Namespaces (such as<bibref role="informative" ref="HTML40"/>).</p></descr></exception></raises></method><method name="setNamedItemNS" id="ID-setNamedItemNS" since="DOM Level 2"><descr><p>Adds a node using its<code>namespaceURI</code>and<code>localName</code>. If a node with that namespace URI and that local name is already present in this map, it is replaced by the new one. Replacing a node by itself has no effect.</p><p>Per<bibref ref="Namespaces"/>, applications must use the value null as the namespaceURI parameter for methods if they wish to have no namespace.</p></descr><parameters><param name="arg" type="Node" attr="in"><descr><p>A node to store in this map. The node will later be accessible using the value of its<code>namespaceURI</code>and<code>localName</code>attributes.</p></descr></param></parameters><returns type="Node"><descr><p>If the new<code>Node</code>replaces an existing node the replaced<code>Node</code>is returned, otherwise<code>null</code>is returned.</p></descr></returns><raises><exception name="DOMException"><descr><p>WRONG_DOCUMENT_ERR: Raised if<code>arg</code>was created from a different document than the one that created this map.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.</p><p>INUSE_ATTRIBUTE_ERR: Raised if<code>arg</code>is an<code>Attr</code>that is already an attribute of another<code>Element</code>object. The DOM user must explicitly clone<code>Attr</code>nodes to re-use them in other elements.</p><p>HIERARCHY_REQUEST_ERR: Raised if an attempt is made to add a node doesn't belong in this NamedNodeMap. Examples would include trying to insert something other than an Attr node into an Element's map of attributes, or a non-Entity node into the DocumentType's map of Entities.</p><p>NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature "XML" and the language exposed through the Document does not support XML Namespaces (such as<bibref role="informative" ref="HTML40"/>).</p></descr></exception></raises></method><method name="removeNamedItemNS" id="ID-removeNamedItemNS" since="DOM Level 2"><descr><p>Removes a node specified by local name and namespace URI. A removed attribute may be known to have a default value when this map contains the attributes attached to an element, as returned by the attributes attribute of the<code>Node</code>interface. If so, an attribute immediately appears containing the default value as well as the corresponding namespace URI, local name, and prefix when applicable.</p><p>Per<bibref ref="Namespaces"/>, applications must use the value null as the namespaceURI parameter for methods if they wish to have no namespace.</p></descr><parameters><param name="namespaceURI" type="DOMString" attr="in"><descr><p>The<termref def="dt-namespaceURI">namespace URI</termref>of the node to remove.</p></descr></param><param name="localName" type="DOMString" attr="in"><descr><p>The<termref def="dt-localname">local name</termref>of the node to remove.</p></descr></param></parameters><returns type="Node"><descr><p>The node removed from this map if a node with such a local name and namespace URI exists.</p></descr></returns><raises><exception name="DOMException"><descr><p>NOT_FOUND_ERR: Raised if there is no node with the specified<code>namespaceURI</code>and<code>localName</code>in this map.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this map is readonly.</p><p>NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature "XML" and the language exposed through the Document does not support XML Namespaces (such as<bibref role="informative" ref="HTML40"/>).</p></descr></exception></raises></method></interface>
+ <interface name="CharacterData" inherits="Node" id="ID-FF21A306"><descr><p>The<code>CharacterData</code>interface extends Node with a set of attributes and methods for accessing character data in the DOM. For clarity this set is defined here rather than on each object that uses these attributes and methods. No DOM objects correspond directly to<code>CharacterData</code>, though<code>Text</code>and others do inherit the interface from it. All<code>offsets</code>in this interface start from<code>0</code>.</p><p>As explained in the<code>DOMString</code>interface, text strings in the DOM are represented in UTF-16, i.e. as a sequence of 16-bit units. In the following, the term<termref def="dt-16-bit-unit">16-bit units</termref>is used whenever necessary to indicate that indexing on CharacterData is done in 16-bit units.</p></descr><attribute type="DOMString" name="data" id="ID-72AB8359" readonly="no"><descr><p>The character data of the node that implements this interface. The DOM implementation may not put arbitrary limits on the amount of data that may be stored in a<code>CharacterData</code>node. However, implementation limits may mean that the entirety of a node's data may not fit into a single<code>DOMString</code>. In such cases, the user may call<code>substringData</code>to retrieve the data in appropriately sized pieces.</p></descr><setraises><exception name="DOMException"><descr><p>NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.</p></descr></exception></setraises><getraises><exception name="DOMException"><descr><p>DOMSTRING_SIZE_ERR: Raised when it would return more characters than fit in a<code>DOMString</code>variable on the implementation platform.</p></descr></exception></getraises></attribute><attribute type="unsigned long" name="length" readonly="yes" id="ID-7D61178C"><descr><p>The number of<termref def="dt-16-bit-unit">16-bit units</termref>that are available through<code>data</code>and the<code>substringData</code>method below. This may have the value zero, i.e.,<code>CharacterData</code>nodes may be empty.</p></descr></attribute><method name="substringData" id="ID-6531BCCF"><descr><p>Extracts a range of data from the node.</p></descr><parameters><param name="offset" type="unsigned long" attr="in"><descr><p>Start offset of substring to extract.</p></descr></param><param name="count" type="unsigned long" attr="in"><descr><p>The number of 16-bit units to extract.</p></descr></param></parameters><returns type="DOMString"><descr><p>The specified substring. If the sum of<code>offset</code>and<code>count</code>exceeds the<code>length</code>, then all 16-bit units to the end of the data are returned.</p></descr></returns><raises><exception name="DOMException"><descr><p>INDEX_SIZE_ERR: Raised if the specified<code>offset</code>is negative or greater than the number of 16-bit units in<code>data</code>, or if the specified<code>count</code>is negative.</p><p>DOMSTRING_SIZE_ERR: Raised if the specified range of text does not fit into a<code>DOMString</code>.</p></descr></exception></raises></method><method name="appendData" id="ID-32791A2F"><descr><p>Append the string to the end of the character data of the node. Upon success,<code>data</code>provides access to the concatenation of<code>data</code>and the<code>DOMString</code>specified.</p></descr><parameters><param name="arg" type="DOMString" attr="in"><descr><p>The<code>DOMString</code>to append.</p></descr></param></parameters><returns type="void"><descr><p/></descr></returns><raises><exception name="DOMException"><descr><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p></descr></exception></raises></method><method name="insertData" id="ID-3EDB695F"><descr><p>Insert a string at the specified<termref def="dt-16-bit-unit">16-bit unit</termref>offset.</p></descr><parameters><param name="offset" type="unsigned long" attr="in"><descr><p>The character offset at which to insert.</p></descr></param><param name="arg" type="DOMString" attr="in"><descr><p>The<code>DOMString</code>to insert.</p></descr></param></parameters><returns type="void"><descr><p/></descr></returns><raises><exception name="DOMException"><descr><p>INDEX_SIZE_ERR: Raised if the specified<code>offset</code>is negative or greater than the number of 16-bit units in<code>data</code>.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p></descr></exception></raises></method><method name="deleteData" id="ID-7C603781"><descr><p>Remove a range of<termref def="dt-16-bit-unit">16-bit units</termref>from the node. Upon success,<code>data</code>and<code>length</code>reflect the change.</p></descr><parameters><param name="offset" type="unsigned long" attr="in"><descr><p>The offset from which to start removing.</p></descr></param><param name="count" type="unsigned long" attr="in"><descr><p>The number of 16-bit units to delete. If the sum of<code>offset</code>and<code>count</code>exceeds<code>length</code>then all 16-bit units from<code>offset</code>to the end of the data are deleted.</p></descr></param></parameters><returns type="void"><descr><p/></descr></returns><raises><exception name="DOMException"><descr><p>INDEX_SIZE_ERR: Raised if the specified<code>offset</code>is negative or greater than the number of 16-bit units in<code>data</code>, or if the specified<code>count</code>is negative.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p></descr></exception></raises></method><method name="replaceData" id="ID-E5CBA7FB"><descr><p>Replace the characters starting at the specified<termref def="dt-16-bit-unit">16-bit unit</termref>offset with the specified string.</p></descr><parameters><param name="offset" type="unsigned long" attr="in"><descr><p>The offset from which to start replacing.</p></descr></param><param name="count" type="unsigned long" attr="in"><descr><p>The number of 16-bit units to replace. If the sum of<code>offset</code>and<code>count</code>exceeds<code>length</code>, then all 16-bit units to the end of the data are replaced; (i.e., the effect is the same as a<code>remove</code>method call with the same range, followed by an<code>append</code>method invocation).</p></descr></param><param name="arg" type="DOMString" attr="in"><descr><p>The<code>DOMString</code>with which the range must be replaced.</p></descr></param></parameters><returns type="void"><descr><p/></descr></returns><raises><exception name="DOMException"><descr><p>INDEX_SIZE_ERR: Raised if the specified<code>offset</code>is negative or greater than the number of 16-bit units in<code>data</code>, or if the specified<code>count</code>is negative.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p></descr></exception></raises></method></interface>
+ <interface name="Attr" inherits="Node" id="ID-637646024"><descr><p>The<code>Attr</code>interface represents an attribute in an<code>Element</code>object. Typically the allowable values for the attribute are defined in a schema associated with the document.</p><p><code>Attr</code>objects inherit the<code>Node</code>interface, but since they are not actually child nodes of the element they describe, the DOM does not consider them part of the document tree. Thus, the<code>Node</code>attributes<code>parentNode</code>,<code>previousSibling</code>, and<code>nextSibling</code>have a<code>null</code>value for<code>Attr</code>objects. The DOM takes the view that attributes are properties of elements rather than having a separate identity from the elements they are associated with; this should make it more efficient to implement such features as default attributes associated with all elements of a given type. Furthermore,<code>Attr</code>nodes may not be immediate children of a<code>DocumentFragment</code>. However, they can be associated with<code>Element</code>nodes contained within a<code>DocumentFragment</code>. In short, users and implementors of the DOM need to be aware that<code>Attr</code>nodes have some things in common with other objects inheriting the<code>Node</code>interface, but they also are quite distinct.</p><p>The attribute's effective value is determined as follows: if this attribute has been explicitly assigned any value, that value is the attribute's effective value; otherwise, if there is a declaration for this attribute, and that declaration includes a default value, then that default value is the attribute's effective value; otherwise, the attribute does not exist on this element in the structure model until it has been explicitly added. Note that the<code>Node.nodeValue</code>attribute on the<code>Attr</code>instance can also be used to retrieve the string version of the attribute's value(s).</p><p>If the attribute was not explicitly given a value in the instance document but has a default value provided by the schema associated with the document, an attribute node will be created with<code>specified</code>set to<code>false</code>. Removing attribute nodes for which a default value is defined in the schema generates a new attribute node with the default value and<code>specified</code>set to<code>false</code>. If validation occurred while invoking<code>Document.normalizeDocument()</code>, attribute nodes with<code>specified</code>equals to<code>false</code>are recomputed according to the default attribute values provided by the schema. If no default value is associate with this attribute in the schema, the attribute node is discarded.</p><p>In XML, where the value of an attribute can contain entity references, the child nodes of the<code>Attr</code>node may be either<code>Text</code>or<code>EntityReference</code>nodes (when these are in use; see the description of<code>EntityReference</code>for discussion).</p><p>The DOM Core represents all attribute values as simple strings, even if the DTD or schema associated with the document declares them of some specific type such as<termref def="dt-tokenized">tokenized</termref>.</p><p>The way attribute value normalization is performed by the DOM implementation depends on how much the implementation knows about the schema in use. Typically, the<code>value</code>and<code>nodeValue</code>attributes of an<code>Attr</code>node initially returns the normalized value given by the parser. It is also the case after<code>Document.normalizeDocument()</code>is called (assuming the right options have been set). But this may not be the case after mutation, independently of whether the mutation is performed by setting the string value directly or by changing the<code>Attr</code>child nodes. In particular, this is true when<xspecref href="http://www.w3.org/TR/2004/REC-xml-20040204#dt-charref" type="simple" show="new" actuate="onRequest">character references</xspecref>are involved, given that they are not represented in the DOM and they impact attribute value normalization. On the other hand, if the implementation knows about the schema in use when the attribute value is changed, and it is of a different type than CDATA, it may normalize it again at that time. This is especially true of specialized DOM implementations, such as SVG DOM implementations, which store attribute values in an internal form different from a string.</p><p>The following table gives some examples of the relations between the attribute value in the original document (parsed attribute), the value as exposed in the DOM, and the serialization of the value:</p><table cellpadding="3" border="1" summary="Examples of differences between a parsed attribute, its DOM representation, and its serialization"><tbody><tr><th rowspan="1" colspan="1">Examples</th><th rowspan="1" colspan="1">Parsed attribute value</th><th rowspan="1" colspan="1">Initial<code>Attr.value</code></th><th rowspan="1" colspan="1">Serialized attribute value</th></tr><tr><td rowspan="1" colspan="1">Character reference</td><td rowspan="1" colspan="1"><eg space="preserve">"x&amp;#178;=5"</eg></td><td rowspan="1" colspan="1"><eg space="preserve">"x²=5"</eg></td><td rowspan="1" colspan="1"><eg space="preserve">"x&amp;#178;=5"</eg></td></tr><tr><td rowspan="1" colspan="1">Built-in character entity</td><td rowspan="1" colspan="1"><eg space="preserve">"y&amp;lt;6"</eg></td><td rowspan="1" colspan="1"><eg space="preserve">"y&lt;6"</eg></td><td rowspan="1" colspan="1"><eg space="preserve">"y&amp;lt;6"</eg></td></tr><tr><td rowspan="1" colspan="1">Literal newline between</td><td rowspan="1" colspan="1"><eg space="preserve">"x=5&amp;#10;y=6"</eg></td><td rowspan="1" colspan="1"><eg space="preserve">"x=5 y=6"</eg></td><td rowspan="1" colspan="1"><eg space="preserve">"x=5&amp;#10;y=6"</eg></td></tr><tr><td rowspan="1" colspan="1">Normalized newline between</td><td rowspan="1" colspan="1"><eg space="preserve">"x=5 y=6"</eg></td><td rowspan="1" colspan="1"><eg space="preserve">"x=5 y=6"</eg></td><td rowspan="1" colspan="1"><eg space="preserve">"x=5 y=6"</eg></td></tr><tr><td rowspan="1" colspan="1">Entity<code>e</code>with literal newline</td><td rowspan="1" colspan="1"><eg space="preserve">&lt;!ENTITY e '...&amp;#10;...'&gt; [...]&gt; "x=5&amp;e;y=6"</eg></td><td rowspan="1" colspan="1"><emph>Dependent on Implementation and Load Options</emph></td><td rowspan="1" colspan="1"><emph>Dependent on Implementation and Load/Save Options</emph></td></tr></tbody></table></descr><attribute type="DOMString" readonly="yes" name="name" id="ID-1112119403"><descr><p>Returns the name of this attribute. If<code>Node.localName</code>is different from<code>null</code>, this attribute is a<termref def="dt-qualifiedname">qualified name</termref>.</p></descr></attribute><attribute type="boolean" readonly="yes" name="specified" id="ID-862529273"><descr><p><code>True</code>if this attribute was explicitly given a value in the instance document,<code>false</code>otherwise. If the application changed the value of this attribute node (even if it ends up having the same value as the default value) then it is set to<code>true</code>. The implementation may handle attributes with default values from other schemas similarly but applications should use<code>Document.normalizeDocument()</code>to guarantee this information is up-to-date.</p></descr></attribute><attribute type="DOMString" name="value" id="ID-221662474" readonly="no"><descr><p>On retrieval, the value of the attribute is returned as a string. Character and general entity references are replaced with their values. See also the method<code>getAttribute</code>on the<code>Element</code>interface.</p><p>On setting, this creates a<code>Text</code>node with the unparsed contents of the string, i.e. any characters that an XML processor would recognize as markup are instead treated as literal text. See also the method<code>Element.setAttribute()</code>.</p><p>Some specialized implementations, such as some<bibref ref="SVG1" role="informative"/>implementations, may do normalization automatically, even after mutation; in such case, the value on retrieval may differ from the value on setting.</p></descr><setraises><exception name="DOMException"><descr><p>NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.</p></descr></exception></setraises></attribute><attribute name="ownerElement" type="Element" readonly="yes" id="Attr-ownerElement" since="DOM Level 2"><descr><p>The<code>Element</code>node this attribute is attached to or<code>null</code>if this attribute is not in use.</p></descr></attribute><attribute name="schemaTypeInfo" type="TypeInfo" id="Attr-schemaTypeInfo" since="DOM Level 3" readonly="yes"><descr><p>The type information associated with this attribute. While the type information contained in this attribute is guarantee to be correct after loading the document or invoking<code>Document.normalizeDocument()</code>,<code>schemaTypeInfo</code>may not be reliable if the node was moved.</p></descr></attribute><attribute name="isId" id="Attr-isId" since="DOM Level 3" readonly="yes" type="boolean"><descr><p>Returns whether this attribute is known to be of type ID (i.e. to contain an identifier for its owner element) or not. When it is and its value is unique, the<code>ownerElement</code>of this attribute can be retrieved using the method<code>Document.getElementById</code>. The implementation could use several ways to determine if an attribute node is known to contain an identifier:</p><ulist><item><p>If validation occurred using an XML Schema<bibref ref="XMLSchema1"/>while loading the document or while invoking<code>Document.normalizeDocument()</code>, the post-schema-validation infoset contributions (PSVI contributions) values are used to determine if this attribute is a<term>schema-determined ID attribute</term>using the<loc href="http://www.w3.org/TR/2003/REC-xptr-framework-20030325/#term-sdi" type="simple" show="replace" actuate="onRequest">schema-determined ID</loc>definition in<bibref ref="XPointer"/>.</p></item><item><p>If validation occurred using a DTD while loading the document or while invoking<code>Document.normalizeDocument()</code>, the infoset<b>[type definition]</b>value is used to determine if this attribute is a<term>DTD-determined ID attribute</term>using the<loc href="http://www.w3.org/TR/2003/REC-xptr-framework-20030325/#term-ddi" type="simple" show="replace" actuate="onRequest">DTD-determined ID</loc>definition in<bibref ref="XPointer"/>.</p></item><item><p>from the use of the methods<code>Element.setIdAttribute()</code>,<code>Element.setIdAttributeNS()</code>, or<code>Element.setIdAttributeNode()</code>, i.e. it is an<term>user-determined ID attribute</term>;</p><note><p>XPointer framework (see section 3.2 in<bibref role="informative" ref="XPointer"/>) consider the DOM<term>user-determined ID attribute</term>as being part of the XPointer<term>externally-determined ID</term>definition.</p></note></item><item><p>using mechanisms that are outside the scope of this specification, it is then an<term>externally-determined ID attribute</term>. This includes using schema languages different from XML schema and DTD.</p></item></ulist><p>If validation occurred while invoking<code>Document.normalizeDocument()</code>, all<term>user-determined ID attributes</term>are reset and all attribute nodes ID information are then reevaluated in accordance to the schema used. As a consequence, if the<code>Attr.schemaTypeInfo</code>attribute contains an ID type,<code>isId</code>will always return true.</p></descr></attribute></interface>
+ <interface name="Element" inherits="Node" id="ID-745549614"><descr><p>The<code>Element</code>interface represents an<termref def="dt-element">element</termref>in an HTML or XML document. Elements may have attributes associated with them; since the<code>Element</code>interface inherits from<code>Node</code>, the generic<code>Node</code>interface attribute<code>attributes</code>may be used to retrieve the set of all attributes for an element. There are methods on the<code>Element</code>interface to retrieve either an<code>Attr</code>object by name or an attribute value by name. In XML, where an attribute value may contain entity references, an<code>Attr</code>object should be retrieved to examine the possibly fairly complex sub-tree representing the attribute value. On the other hand, in HTML, where all attributes have simple string values, methods to directly access an attribute value can safely be used as a<termref def="dt-convenience">convenience</termref>.</p><note><p>In DOM Level 2, the method<code>normalize</code>is inherited from the<code>Node</code>interface where it was moved.</p></note></descr><attribute type="DOMString" name="tagName" readonly="yes" id="ID-104682815"><descr><p>The name of the element. If<code>Node.localName</code>is different from<code>null</code>, this attribute is a<termref def="dt-qualifiedname">qualified name</termref>. For example, in:<eg role="code" space="preserve">&lt;elementExample id="demo"&gt; ... &lt;/elementExample&gt; ,</eg><code>tagName</code>has the value<code>"elementExample"</code>. Note that this is case-preserving in XML, as are all of the operations of the DOM. The HTML DOM returns the<code>tagName</code>of an HTML element in the canonical uppercase form, regardless of the case in the source HTML document.</p></descr></attribute><method name="getAttribute" id="ID-666EE0F9"><descr><p>Retrieves an attribute value by name.</p></descr><parameters><param name="name" type="DOMString" attr="in"><descr><p>The name of the attribute to retrieve.</p></descr></param></parameters><returns type="DOMString"><descr><p>The<code>Attr</code>value as a string, or the empty string if that attribute does not have a specified or default value.</p></descr></returns><raises></raises></method><method name="setAttribute" id="ID-F68F082"><descr><p>Adds a new attribute. If an attribute with that name is already present in the element, its value is changed to be that of the value parameter. This value is a simple string; it is not parsed as it is being set. So any markup (such as syntax to be recognized as an entity reference) is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out. In order to assign an attribute value that contains entity references, the user must create an<code>Attr</code>node plus any<code>Text</code>and<code>EntityReference</code>nodes, build the appropriate subtree, and use<code>setAttributeNode</code>to assign it as the value of an attribute.</p><p>To set an attribute with a qualified name and namespace URI, use the<code>setAttributeNS</code>method.</p></descr><parameters><param name="name" type="DOMString" attr="in"><descr><p>The name of the attribute to create or alter.</p></descr></param><param name="value" type="DOMString" attr="in"><descr><p>Value to set in string form.</p></descr></param></parameters><returns type="void"><descr><p/></descr></returns><raises><exception name="DOMException"><descr><p>INVALID_CHARACTER_ERR: Raised if the specified name is not an XML name according to the XML version in use specified in the<code>Document.xmlVersion</code>attribute.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p></descr></exception></raises></method><method name="removeAttribute" id="ID-6D6AC0F9"><descr><p>Removes an attribute by name. If a default value for the removed attribute is defined in the DTD, a new attribute immediately appears with the default value as well as the corresponding namespace URI, local name, and prefix when applicable. The implementation may handle default values from other schemas similarly but applications should use<code>Document.normalizeDocument()</code>to guarantee this information is up-to-date.</p><p>If no attribute with this name is found, this method has no effect.</p><p>To remove an attribute by local name and namespace URI, use the<code>removeAttributeNS</code>method.</p></descr><parameters><param name="name" type="DOMString" attr="in"><descr><p>The name of the attribute to remove.</p></descr></param></parameters><returns type="void"><descr><p/></descr></returns><raises><exception name="DOMException"><descr><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p></descr></exception></raises></method><method name="getAttributeNode" id="ID-217A91B8"><descr><p>Retrieves an attribute node by name.</p><p>To retrieve an attribute node by qualified name and namespace URI, use the<code>getAttributeNodeNS</code>method.</p></descr><parameters><param name="name" type="DOMString" attr="in"><descr><p>The name (<code>nodeName</code>) of the attribute to retrieve.</p></descr></param></parameters><returns type="Attr"><descr><p>The<code>Attr</code>node with the specified name (<code>nodeName</code>) or<code>null</code>if there is no such attribute.</p></descr></returns><raises></raises></method><method name="setAttributeNode" id="ID-887236154"><descr><p>Adds a new attribute node. If an attribute with that name (<code>nodeName</code>) is already present in the element, it is replaced by the new one. Replacing an attribute node by itself has no effect.</p><p>To add a new attribute node with a qualified name and namespace URI, use the<code>setAttributeNodeNS</code>method.</p></descr><parameters><param name="newAttr" type="Attr" attr="in"><descr><p>The<code>Attr</code>node to add to the attribute list.</p></descr></param></parameters><returns type="Attr"><descr><p>If the<code>newAttr</code>attribute replaces an existing attribute, the replaced<code>Attr</code>node is returned, otherwise<code>null</code>is returned.</p></descr></returns><raises><exception name="DOMException"><descr><p>WRONG_DOCUMENT_ERR: Raised if<code>newAttr</code>was created from a different document than the one that created the element.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p><p>INUSE_ATTRIBUTE_ERR: Raised if<code>newAttr</code>is already an attribute of another<code>Element</code>object. The DOM user must explicitly clone<code>Attr</code>nodes to re-use them in other elements.</p></descr></exception></raises></method><method name="removeAttributeNode" id="ID-D589198"><descr><p>Removes the specified attribute node. If a default value for the removed<code>Attr</code>node is defined in the DTD, a new node immediately appears with the default value as well as the corresponding namespace URI, local name, and prefix when applicable. The implementation may handle default values from other schemas similarly but applications should use<code>Document.normalizeDocument()</code>to guarantee this information is up-to-date.</p></descr><parameters><param name="oldAttr" type="Attr" attr="in"><descr><p>The<code>Attr</code>node to remove from the attribute list.</p></descr></param></parameters><returns type="Attr"><descr><p>The<code>Attr</code>node that was removed.</p></descr></returns><raises><exception name="DOMException"><descr><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p><p>NOT_FOUND_ERR: Raised if<code>oldAttr</code>is not an attribute of the element.</p></descr></exception></raises></method><method name="getElementsByTagName" id="ID-1938918D"><descr><p>Returns a<code>NodeList</code>of all<termref def="dt-descendant">descendant</termref><code>Elements</code>with a given tag name, in<termref def="dt-document-order">document order</termref>.</p></descr><parameters><param name="tagname" type="DOMString" attr="in"><descr><p>The name of the tag to match on. The special value "*" matches all tags.</p></descr></param></parameters><returns type="NodeList"><descr><p>A list of matching<code>Element</code>nodes.</p></descr></returns><raises></raises></method><method name="getAttributeNS" id="ID-ElGetAttrNS" since="DOM Level 2"><descr><p>Retrieves an attribute value by local name and namespace URI.</p><p>Per<bibref ref="Namespaces"/>, applications must use the value<code>null</code>as the<code>namespaceURI</code>parameter for methods if they wish to have no namespace.</p></descr><parameters><param name="namespaceURI" type="DOMString" attr="in"><descr><p>The<termref def="dt-namespaceURI">namespace URI</termref>of the attribute to retrieve.</p></descr></param><param name="localName" type="DOMString" attr="in"><descr><p>The<termref def="dt-localname">local name</termref>of the attribute to retrieve.</p></descr></param></parameters><returns type="DOMString"><descr><p>The<code>Attr</code>value as a string, or the empty string if that attribute does not have a specified or default value.</p></descr></returns><raises><exception name="DOMException"><descr><p>NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature<code>"XML"</code>and the language exposed through the Document does not support XML Namespaces (such as<bibref role="informative" ref="HTML40"/>).</p></descr></exception></raises></method><method name="setAttributeNS" id="ID-ElSetAttrNS" since="DOM Level 2"><descr><p>Adds a new attribute. If an attribute with the same local name and namespace URI is already present on the element, its prefix is changed to be the prefix part of the<code>qualifiedName</code>, and its value is changed to be the<code>value</code>parameter. This value is a simple string; it is not parsed as it is being set. So any markup (such as syntax to be recognized as an entity reference) is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out. In order to assign an attribute value that contains entity references, the user must create an<code>Attr</code>node plus any<code>Text</code>and<code>EntityReference</code>nodes, build the appropriate subtree, and use<code>setAttributeNodeNS</code>or<code>setAttributeNode</code>to assign it as the value of an attribute.</p><p>Per<bibref ref="Namespaces"/>, applications must use the value<code>null</code>as the<code>namespaceURI</code>parameter for methods if they wish to have no namespace.</p></descr><parameters><param name="namespaceURI" type="DOMString" attr="in"><descr><p>The<termref def="dt-namespaceURI">namespace URI</termref>of the attribute to create or alter.</p></descr></param><param name="qualifiedName" type="DOMString" attr="in"><descr><p>The<termref def="dt-qualifiedname">qualified name</termref>of the attribute to create or alter.</p></descr></param><param name="value" type="DOMString" attr="in"><descr><p>The value to set in string form.</p></descr></param></parameters><returns type="void"><descr><p/></descr></returns><raises><exception name="DOMException"><descr><p>INVALID_CHARACTER_ERR: Raised if the specified qualified name is not an XML name according to the XML version in use specified in the<code>Document.xmlVersion</code>attribute.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p><p>NAMESPACE_ERR: Raised if the<code>qualifiedName</code>is malformed per the Namespaces in XML specification, if the<code>qualifiedName</code>has a prefix and the<code>namespaceURI</code>is<code>null</code>, if the<code>qualifiedName</code>has a prefix that is "xml" and the<code>namespaceURI</code>is different from "<loc href="http://www.w3.org/XML/1998/namespace" type="simple" show="replace" actuate="onRequest">http://www.w3.org/XML/1998/namespace</loc>", if the<code>qualifiedName</code>or its prefix is "xmlns" and the<code>namespaceURI</code>is different from "<loc href="http://www.w3.org/2000/xmlns/" type="simple" show="replace" actuate="onRequest">http://www.w3.org/2000/xmlns/</loc>", or if the<code>namespaceURI</code>is "<loc href="http://www.w3.org/2000/xmlns/" type="simple" show="replace" actuate="onRequest">http://www.w3.org/2000/xmlns/</loc>" and neither the<code>qualifiedName</code>nor its prefix is "xmlns".</p><p>NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature<code>"XML"</code>and the language exposed through the Document does not support XML Namespaces (such as<bibref role="informative" ref="HTML40"/>).</p></descr></exception></raises></method><method name="removeAttributeNS" id="ID-ElRemAtNS" since="DOM Level 2"><descr><p>Removes an attribute by local name and namespace URI. If a default value for the removed attribute is defined in the DTD, a new attribute immediately appears with the default value as well as the corresponding namespace URI, local name, and prefix when applicable. The implementation may handle default values from other schemas similarly but applications should use<code>Document.normalizeDocument()</code>to guarantee this information is up-to-date.</p><p>If no attribute with this local name and namespace URI is found, this method has no effect.</p><p>Per<bibref ref="Namespaces"/>, applications must use the value<code>null</code>as the<code>namespaceURI</code>parameter for methods if they wish to have no namespace.</p></descr><parameters><param name="namespaceURI" type="DOMString" attr="in"><descr><p>The<termref def="dt-namespaceURI">namespace URI</termref>of the attribute to remove.</p></descr></param><param name="localName" type="DOMString" attr="in"><descr><p>The<termref def="dt-localname">local name</termref>of the attribute to remove.</p></descr></param></parameters><returns type="void"><descr><p/></descr></returns><raises><exception name="DOMException"><descr><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p><p>NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature<code>"XML"</code>and the language exposed through the Document does not support XML Namespaces (such as<bibref role="informative" ref="HTML40"/>).</p></descr></exception></raises></method><method name="getAttributeNodeNS" id="ID-ElGetAtNodeNS" since="DOM Level 2"><descr><p>Retrieves an<code>Attr</code>node by local name and namespace URI.</p><p>Per<bibref ref="Namespaces"/>, applications must use the value<code>null</code>as the<code>namespaceURI</code>parameter for methods if they wish to have no namespace.</p></descr><parameters><param name="namespaceURI" type="DOMString" attr="in"><descr><p>The<termref def="dt-namespaceURI">namespace URI</termref>of the attribute to retrieve.</p></descr></param><param name="localName" type="DOMString" attr="in"><descr><p>The<termref def="dt-localname">local name</termref>of the attribute to retrieve.</p></descr></param></parameters><returns type="Attr"><descr><p>The<code>Attr</code>node with the specified attribute local name and namespace URI or<code>null</code>if there is no such attribute.</p></descr></returns><raises><exception name="DOMException"><descr><p>NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature<code>"XML"</code>and the language exposed through the Document does not support XML Namespaces (such as<bibref role="informative" ref="HTML40"/>).</p></descr></exception></raises></method><method name="setAttributeNodeNS" id="ID-ElSetAtNodeNS" since="DOM Level 2"><descr><p>Adds a new attribute. If an attribute with that local name and that namespace URI is already present in the element, it is replaced by the new one. Replacing an attribute node by itself has no effect.</p><p>Per<bibref ref="Namespaces"/>, applications must use the value<code>null</code>as the<code>namespaceURI</code>parameter for methods if they wish to have no namespace.</p></descr><parameters><param name="newAttr" type="Attr" attr="in"><descr><p>The<code>Attr</code>node to add to the attribute list.</p></descr></param></parameters><returns type="Attr"><descr><p>If the<code>newAttr</code>attribute replaces an existing attribute with the same<termref def="dt-localname">local name</termref>and<termref def="dt-namespaceURI">namespace URI</termref>, the replaced<code>Attr</code>node is returned, otherwise<code>null</code>is returned.</p></descr></returns><raises><exception name="DOMException"><descr><p>WRONG_DOCUMENT_ERR: Raised if<code>newAttr</code>was created from a different document than the one that created the element.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p><p>INUSE_ATTRIBUTE_ERR: Raised if<code>newAttr</code>is already an attribute of another<code>Element</code>object. The DOM user must explicitly clone<code>Attr</code>nodes to re-use them in other elements.</p><p>NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature<code>"XML"</code>and the language exposed through the Document does not support XML Namespaces (such as<bibref role="informative" ref="HTML40"/>).</p></descr></exception></raises></method><method name="getElementsByTagNameNS" id="ID-A6C90942" since="DOM Level 2"><descr><p>Returns a<code>NodeList</code>of all the<termref def="dt-descendant">descendant</termref><code>Elements</code>with a given local name and namespace URI in<termref def="dt-document-order">document order</termref>.</p></descr><parameters><param name="namespaceURI" type="DOMString" attr="in"><descr><p>The<termref def="dt-namespaceURI">namespace URI</termref>of the elements to match on. The special value "*" matches all namespaces.</p></descr></param><param name="localName" type="DOMString" attr="in"><descr><p>The<termref def="dt-localname">local name</termref>of the elements to match on. The special value "*" matches all local names.</p></descr></param></parameters><returns type="NodeList"><descr><p>A new<code>NodeList</code>object containing all the matched<code>Elements</code>.</p></descr></returns><raises><exception name="DOMException"><descr><p>NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature<code>"XML"</code>and the language exposed through the Document does not support XML Namespaces (such as<bibref role="informative" ref="HTML40"/>).</p></descr></exception></raises></method><method name="hasAttribute" id="ID-ElHasAttr" since="DOM Level 2"><descr><p>Returns<code>true</code>when an attribute with a given name is specified on this element or has a default value,<code>false</code>otherwise.</p></descr><parameters><param name="name" type="DOMString" attr="in"><descr><p>The name of the attribute to look for.</p></descr></param></parameters><returns type="boolean"><descr><p><code>true</code>if an attribute with the given name is specified on this element or has a default value,<code>false</code>otherwise.</p></descr></returns><raises></raises></method><method name="hasAttributeNS" id="ID-ElHasAttrNS" since="DOM Level 2"><descr><p>Returns<code>true</code>when an attribute with a given local name and namespace URI is specified on this element or has a default value,<code>false</code>otherwise.</p><p>Per<bibref ref="Namespaces"/>, applications must use the value<code>null</code>as the<code>namespaceURI</code>parameter for methods if they wish to have no namespace.</p></descr><parameters><param name="namespaceURI" type="DOMString" attr="in"><descr><p>The<termref def="dt-namespaceURI">namespace URI</termref>of the attribute to look for.</p></descr></param><param name="localName" type="DOMString" attr="in"><descr><p>The<termref def="dt-localname">local name</termref>of the attribute to look for.</p></descr></param></parameters><returns type="boolean"><descr><p><code>true</code>if an attribute with the given local name and namespace URI is specified or has a default value on this element,<code>false</code>otherwise.</p></descr></returns><raises><exception name="DOMException"><descr><p>NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature<code>"XML"</code>and the language exposed through the Document does not support XML Namespaces (such as<bibref role="informative" ref="HTML40"/>).</p></descr></exception></raises></method><attribute name="schemaTypeInfo" type="TypeInfo" id="Element-schemaTypeInfo" since="DOM Level 3" readonly="yes"><descr><p>The type information associated with this element.</p></descr></attribute><method name="setIdAttribute" id="ID-ElSetIdAttr" since="DOM Level 3"><descr><p>If the parameter<code>isId</code>is<code>true</code>, this method declares the specified attribute to be a<term>user-determined ID attribute</term>. This affects the value of<code>Attr.isId</code>and the behavior of<code>Document.getElementById</code>, but does not change any schema that may be in use, in particular this does not affect the<code>Attr.schemaTypeInfo</code>of the specified<code>Attr</code>node. Use the value<code>false</code>for the parameter<code>isId</code>to undeclare an attribute for being a<term>user-determined ID attribute</term>.</p><p>To specify an attribute by local name and namespace URI, use the<code>setIdAttributeNS</code>method.</p></descr><parameters><param name="name" type="DOMString" attr="in"><descr><p>The name of the attribute.</p></descr></param><param name="isId" type="boolean" attr="in"><descr><p>Whether the attribute is a of type ID.</p></descr></param></parameters><returns type="void"><descr><p/></descr></returns><raises><exception name="DOMException"><descr><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p><p>NOT_FOUND_ERR: Raised if the specified node is not an attribute of this element.</p></descr></exception></raises></method><method name="setIdAttributeNS" id="ID-ElSetIdAttrNS" since="DOM Level 3"><descr><p>If the parameter<code>isId</code>is<code>true</code>, this method declares the specified attribute to be a<term>user-determined ID attribute</term>. This affects the value of<code>Attr.isId</code>and the behavior of<code>Document.getElementById</code>, but does not change any schema that may be in use, in particular this does not affect the<code>Attr.schemaTypeInfo</code>of the specified<code>Attr</code>node. Use the value<code>false</code>for the parameter<code>isId</code>to undeclare an attribute for being a<term>user-determined ID attribute</term>.</p></descr><parameters><param name="namespaceURI" type="DOMString" attr="in"><descr><p>The<termref def="dt-namespaceURI">namespace URI</termref>of the attribute.</p></descr></param><param name="localName" type="DOMString" attr="in"><descr><p>The<termref def="dt-localname">local name</termref>of the attribute.</p></descr></param><param name="isId" type="boolean" attr="in"><descr><p>Whether the attribute is a of type ID.</p></descr></param></parameters><returns type="void"><descr><p/></descr></returns><raises><exception name="DOMException"><descr><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p><p>NOT_FOUND_ERR: Raised if the specified node is not an attribute of this element.</p></descr></exception></raises></method><method name="setIdAttributeNode" id="ID-ElSetIdAttrNode" since="DOM Level 3"><descr><p>If the parameter<code>isId</code>is<code>true</code>, this method declares the specified attribute to be a<term>user-determined ID attribute</term>. This affects the value of<code>Attr.isId</code>and the behavior of<code>Document.getElementById</code>, but does not change any schema that may be in use, in particular this does not affect the<code>Attr.schemaTypeInfo</code>of the specified<code>Attr</code>node. Use the value<code>false</code>for the parameter<code>isId</code>to undeclare an attribute for being a<term>user-determined ID attribute</term>.</p></descr><parameters><param name="idAttr" type="Attr" attr="in"><descr><p>The attribute node.</p></descr></param><param name="isId" type="boolean" attr="in"><descr><p>Whether the attribute is a of type ID.</p></descr></param></parameters><returns type="void"><descr><p/></descr></returns><raises><exception name="DOMException"><descr><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p><p>NOT_FOUND_ERR: Raised if the specified node is not an attribute of this element.</p></descr></exception></raises></method></interface>
+ <interface name="Text" inherits="CharacterData" id="ID-1312295772"><descr><p>The<code>Text</code>interface inherits from<code>CharacterData</code>and represents the textual content (termed<xspecref href="http://www.w3.org/TR/2004/REC-xml-20040204#syntax" type="simple" show="new" actuate="onRequest">character data</xspecref>in XML) of an<code>Element</code>or<code>Attr</code>. If there is no markup inside an element's content, the text is contained in a single object implementing the<code>Text</code>interface that is the only child of the element. If there is markup, it is parsed into the<termref def="dt-infoitem">information items</termref>(elements, comments, etc.) and<code>Text</code>nodes that form the list of children of the element.</p><p>When a document is first made available via the DOM, there is only one<code>Text</code>node for each block of text. Users may create adjacent<code>Text</code>nodes that represent the contents of a given element without any intervening markup, but should be aware that there is no way to represent the separations between these nodes in XML or HTML, so they will not (in general) persist between DOM editing sessions. The<code>Node.normalize()</code>method merges any such adjacent<code>Text</code>objects into a single node for each block of text.</p><p>No lexical check is done on the content of a<code>Text</code>node and, depending on its position in the document, some characters must be escaped during serialization using character references; e.g. the characters "&lt;&amp;" if the textual content is part of an element or of an attribute, the character sequence "]]&gt;" when part of an element, the quotation mark character " or the apostrophe character ' when part of an attribute.</p></descr><method name="splitText" id="ID-38853C1D"><descr><p>Breaks this node into two nodes at the specified<code>offset</code>, keeping both in the tree as<termref def="dt-sibling">siblings</termref>. After being split, this node will contain all the content up to the<code>offset</code>point. A new node of the same type, which contains all the content at and after the<code>offset</code>point, is returned. If the original node had a parent node, the new node is inserted as the next<termref def="dt-sibling">sibling</termref>of the original node. When the<code>offset</code>is equal to the length of this node, the new node has no data.</p></descr><parameters><param name="offset" type="unsigned long" attr="in"><descr><p>The<termref def="dt-16-bit-unit">16-bit unit</termref>offset at which to split, starting from<code>0</code>.</p></descr></param></parameters><returns type="Text"><descr><p>The new node, of the same type as this node.</p></descr></returns><raises><exception name="DOMException"><descr><p>INDEX_SIZE_ERR: Raised if the specified offset is negative or greater than the number of 16-bit units in<code>data</code>.</p><p>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.</p></descr></exception></raises></method><attribute name="isElementContentWhitespace" id="Text3-isElementContentWhitespace" since="DOM Level 3" readonly="yes" type="boolean"><descr><p>Returns whether this text node contains<xspecref href="http://www.w3.org/TR/2004/REC-xml-infoset-20040204#infoitem.character" type="simple" show="new" actuate="onRequest">element content whitespace</xspecref>, often abusively called "ignorable whitespace". The text node is determined to contain whitespace in element content during the load of the document or if validation occurs while using<code>Document.normalizeDocument()</code>.</p></descr></attribute><attribute readonly="yes" type="DOMString" name="wholeText" id="Text3-wholeText" since="DOM Level 3"><descr><p>Returns all text of<code>Text</code>nodes<termref def="dt-logically-adjacent-text-nodes">logically-adjacent text nodes</termref>to this node, concatenated in document order.</p><p>For instance, in the example below<code>wholeText</code>on the<code>Text</code>node that contains "bar" returns "barfoo", while on the<code>Text</code>node that contains "foo" it returns "barfoo".</p><graphic source="./images/wholeTextExmpl.png" alt="barTextNode.wholeText value is &quot;barfoo&quot;" type="simple" show="embed" actuate="onLoad"/></descr></attribute><method name="replaceWholeText" id="Text3-replaceWholeText" since="DOM Level 3"><descr><p>Replaces the text of the current node and all<termref def="dt-logically-adjacent-text-nodes">logically-adjacent text nodes</termref>with the specified text. All<termref def="dt-logically-adjacent-text-nodes">logically-adjacent text nodes</termref>are removed including the current node unless it was the recipient of the replacement text.</p><p>This method returns the node which received the replacement text. The returned node is:</p><ulist><item><p><code>null</code>, when the replacement text is the empty string;</p></item><item><p>the current node, except when the current node is<termref def="dt-readonly-node">read-only</termref>;</p></item><item><p>a new<code>Text</code>node of the same type (<code>Text</code>or<code>CDATASection</code>) as the current node inserted at the location of the replacement.</p></item></ulist><p>For instance, in the above example calling<code>replaceWholeText</code>on the<code>Text</code>node that contains "bar" with "yo" in argument results in the following:</p><graphic source="./images/wholeTextExmpl2.png" alt="barTextNode.replaceWholeText(&quot;yo&quot;) modifies the textual content of barTextNode with &quot;yo&quot;" type="simple" show="embed" actuate="onLoad"/><p>Where the nodes to be removed are read-only descendants of an<code>EntityReference</code>, the<code>EntityReference</code>must be removed instead of the read-only nodes. If any<code>EntityReference</code>to be removed has descendants that are not<code>EntityReference</code>,<code>Text</code>, or<code>CDATASection</code>nodes, the<code>replaceWholeText</code>method must fail before performing any modification of the document, raising a<code>DOMException</code>with the code<code>NO_MODIFICATION_ALLOWED_ERR</code>.</p><p>For instance, in the example below calling<code>replaceWholeText</code>on the<code>Text</code>node that contains "bar" fails, because the<code>EntityReference</code>node "ent" contains an<code>Element</code>node which cannot be removed.</p><graphic source="./images/wholeTextExmpl3.png" alt="barTextNode.replaceWholeText(&quot;yo&quot;) raises a NO_MODIFICATION_ALLOWED_ERR DOMException" type="simple" show="embed" actuate="onLoad"/></descr><parameters><param name="content" type="DOMString" attr="in"><descr><p>The content of the replacing<code>Text</code>node.</p></descr></param></parameters><returns type="Text"><descr><p>The<code>Text</code>node created with the specified content.</p></descr></returns><raises><exception name="DOMException"><descr><p>NO_MODIFICATION_ALLOWED_ERR: Raised if one of the<code>Text</code>nodes being replaced is readonly.</p></descr></exception></raises></method></interface>
+ <interface name="Comment" inherits="CharacterData" id="ID-1728279322"><descr><p>This interface inherits from<code>CharacterData</code>and represents the content of a comment, i.e., all the characters between the starting '<code>&lt;!--</code>' and ending '<code>--&gt;</code>'. Note that this is the definition of a comment in XML, and, in practice, HTML, although some HTML tools may implement the full SGML comment structure.</p><p>No lexical check is done on the content of a comment and it is therefore possible to have the character sequence<code>"--"</code>(double-hyphen) in the content, which is illegal in a comment per section 2.5 of<bibref ref="XML"/>. The presence of this character sequence must generate a fatal error during serialization.</p></descr></interface>
+ <interface name="TypeInfo" id="TypeInfo" since="DOM Level 3"><descr><p>The<code>TypeInfo</code>interface represents a type referenced from<code>Element</code>or<code>Attr</code>nodes, specified in the<termref def="dt-schema">schemas</termref>associated with the document. The type is a pair of a<termref def="dt-namespaceURI">namespace URI</termref>and name properties, and depends on the document's schema.</p><p>If the document's schema is an XML DTD<bibref ref="XML"/>, the values are computed as follows:</p><ulist><item><p>If this type is referenced from an<code>Attr</code>node,<code>typeNamespace</code>is<code>"http://www.w3.org/TR/REC-xml"</code>and<code>typeName</code>represents the<b>[attribute type]</b>property in the<bibref ref="InfoSet"/>. If there is no declaration for the attribute,<code>typeNamespace</code>and<code>typeName</code>are<code>null</code>.</p></item><item><p>If this type is referenced from an<code>Element</code>node,<code>typeNamespace</code>and<code>typeName</code>are<code>null</code>.</p></item></ulist><p>If the document's schema is an XML Schema<bibref ref="XMLSchema1"/>, the values are computed as follows using the post-schema-validation infoset contributions (also called PSVI contributions):</p><ulist><item><p>If the<b>[validity]</b>property exists AND is<emph>"invalid"</emph>or<emph>"notKnown"</emph>: the {target namespace} and {name} properties of the declared type if available, otherwise<code>null</code>.</p><note><p>At the time of writing, the XML Schema specification does not require exposing the declared type. Thus, DOM implementations might choose not to provide type information if validity is not valid.</p></note></item><item><p>If the<b>[validity]</b>property exists and is<emph>"valid"</emph>:</p><olist><item><p>If<b>[member type definition]</b>exists:</p><olist><item><p>If {name} is not absent, then expose {name} and {target namespace} properties of the<b>[member type definition]</b>property;</p></item><item><p>Otherwise, expose the namespace and local name of the corresponding<termref def="dt-anonymous">anonymous type name</termref>.</p></item></olist></item><item><p>If the<b>[type definition]</b>property exists:<olist><item><p>If {name} is not absent, then expose {name} and {target namespace} properties of the<b>[type definition]</b>property;</p></item><item><p>Otherwise, expose the namespace and local name of the corresponding<termref def="dt-anonymous">anonymous type name</termref>.</p></item></olist></p></item><item><p>If the<b>[member type definition anonymous]</b>exists:<olist><item><p>If it is false, then expose<b>[member type definition name]</b>and<b>[member type definition namespace]</b>properties;</p></item><item><p>Otherwise, expose the namespace and local name of the corresponding<termref def="dt-anonymous">anonymous type name</termref>.</p></item></olist></p></item><item><p>If the<b>[type definition anonymous]</b>exists:<olist><item><p>If it is false, then expose<b>[type definition name]</b>and<b>[type definition namespace]</b>properties;</p></item><item><p>Otherwise, expose the namespace and local name of the corresponding<termref def="dt-anonymous">anonymous type name</termref>.</p></item></olist></p></item></olist></item></ulist><note><p>Other schema languages are outside the scope of the W3C and therefore should define how to represent their type systems using<code>TypeInfo</code>.</p></note></descr><attribute name="typeName" type="DOMString" id="TypeInfo-typeName" readonly="yes"><descr><p>The name of a type declared for the associated element or attribute, or<code>null</code>if unknown.</p></descr></attribute><attribute name="typeNamespace" type="DOMString" id="TypeInfo-typeNamespace" readonly="yes"><descr><p>The namespace of the type declared for the associated element or attribute or<code>null</code>if the element does not have declaration or if no namespace information is available.</p></descr></attribute><group name="DerivationMethods" id="TypeInfo-DerivationMethods"><descr><p>These are the available values for the<code>derivationMethod</code>parameter used by the method<code>TypeInfo.isDerivedFrom()</code>. It is a set of possible types of derivation, and the values represent bit positions. If a bit in the<code>derivationMethod</code>parameter is set to<code>1</code>, the corresponding type of derivation will be taken into account when evaluating the derivation between the reference type definition and the other type definition. When using the<code>isDerivedFrom</code>method, combining all of them in the<code>derivationMethod</code>parameter is equivalent to invoking the method for each of them separately and combining the results with the OR boolean function. This specification only defines the type of derivation for XML Schema.</p><p>In addition to the types of derivation listed below, please note that:</p><ulist><item><p>any type derives from<code>xsd:anyType</code>.</p></item><item><p>any simple type derives from<code>xsd:anySimpleType</code>by<term>restriction</term>.</p></item><item><p>any complex type does not derive from<code>xsd:anySimpleType</code>by<term>restriction</term>.</p></item></ulist></descr><constant id="TypeInfo-DERIVATION_RESTRICTION" name="DERIVATION_RESTRICTION" type="unsigned long" value="0x00000001"><descr><p>If the document's schema is an XML Schema<bibref ref="XMLSchema1"/>, this constant represents the derivation by<xspecref href="http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/#key-typeRestriction" type="simple" show="new" actuate="onRequest">restriction</xspecref>if complex types are involved, or a<xspecref href="http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/#element-restriction" type="simple" show="new" actuate="onRequest">restriction</xspecref>if simple types are involved.</p><p><termdef id="id-restriction" term="restriction">The reference type definition is derived by<term>restriction</term>from the other type definition if the other type definition is the same as the reference type definition, or if the other type definition can be reached recursively following the {base type definition} property from the reference type definition, and all the<emph>derivation methods</emph>involved are<term>restriction</term>.</termdef></p></descr></constant><constant id="TypeInfo-DERIVATION_EXTENSION" name="DERIVATION_EXTENSION" type="unsigned long" value="0x00000002"><descr><p>If the document's schema is an XML Schema<bibref ref="XMLSchema1"/>, this constant represents the derivation by<xspecref href="http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/#key-typeExtension" type="simple" show="new" actuate="onRequest">extension</xspecref>.</p><p><termdef id="id-extension" term="extension">The reference type definition is derived by<term>extension</term>from the other type definition if the other type definition can be reached recursively following the {base type definition} property from the reference type definition, and at least one of the<emph>derivation methods</emph>involved is an<term>extension</term>.</termdef></p></descr></constant><constant id="TypeInfo-DERIVATION_UNION" name="DERIVATION_UNION" type="unsigned long" value="0x00000004"><descr><p>If the document's schema is an XML Schema<bibref ref="XMLSchema1"/>, this constant represents the<xspecref href="http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/#element-union" type="simple" show="new" actuate="onRequest">union</xspecref>if simple types are involved.</p><p><termdef id="id-union" term="union">The reference type definition is derived by<term>union</term>from the other type definition if there exists two type definitions T1 and T2 such as the reference type definition is derived from T1 by<code>DERIVATION_RESTRICTION</code>or<code>DERIVATION_EXTENSION</code>, T2 is derived from the other type definition by<code>DERIVATION_RESTRICTION</code>, T1 has {variety}<emph>union</emph>, and one of the {member type definitions} is T2. Note that T1 could be the same as the reference type definition, and T2 could be the same as the other type definition.</termdef></p></descr></constant><constant id="TypeInfo-DERIVATION_LIST" name="DERIVATION_LIST" type="unsigned long" value="0x00000008"><descr><p>If the document's schema is an XML Schema<bibref ref="XMLSchema1"/>, this constant represents the<xspecref href="http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/#element-list" type="simple" show="new" actuate="onRequest">list</xspecref>.</p><p><termdef id="id-list" term="list">The reference type definition is derived by<term>list</term>from the other type definition if there exists two type definitions T1 and T2 such as the reference type definition is derived from T1 by<code>DERIVATION_RESTRICTION</code>or<code>DERIVATION_EXTENSION</code>, T2 is derived from the other type definition by<code>DERIVATION_RESTRICTION</code>, T1 has {variety}<emph>list</emph>, and T2 is the {item type definition}. Note that T1 could be the same as the reference type definition, and T2 could be the same as the other type definition.</termdef></p></descr></constant></group><method name="isDerivedFrom" id="TypeInfo-isDerivedFrom"><descr><p>This method returns if there is a derivation between the reference type definition, i.e. the<code>TypeInfo</code>on which the method is being called, and the other type definition, i.e. the one passed as parameters.</p></descr><parameters><param name="typeNamespaceArg" type="DOMString" attr="in"><descr><p>the namespace of the other type definition.</p></descr></param><param name="typeNameArg" type="DOMString" attr="in"><descr><p>the name of the other type definition.</p></descr></param><param name="derivationMethod" type="unsigned long" attr="in"><descr><p>the type of derivation and conditions applied between two types, as described in the list of constants provided in this interface.</p></descr></param></parameters><returns type="boolean"><descr><p>If the document's schema is a DTD or no schema is associated with the document, this method will always return<code>false</code>.</p><p>If the document's schema is an XML Schema, the method will<code>true</code>if the reference type definition is derived from the other type definition according to the derivation parameter. If the value of the parameter is<code>0</code>(no bit is set to<code>1</code>for the<code>derivationMethod</code>parameter), the method will return<code>true</code>if the other type definition can be reached by recursing any combination of {base type definition}, {item type definition}, or {member type definitions} from the reference type definition.</p></descr></returns><raises></raises></method></interface>
+ <interface name="UserDataHandler" id="UserDataHandler" since="DOM Level 3" role="ecmascript-function"><descr><p>When associating an object to a key on a node using<code>Node.setUserData()</code>the application can provide a handler that gets called when the node the object is associated to is being cloned, imported, or renamed. This can be used by the application to implement various behaviors regarding the data it associates to the DOM nodes. This interface defines that handler.</p></descr><group id="ID-UserDataOperation" name="OperationType"><descr><p>An integer indicating the type of operation being performed on a node.</p></descr><constant id="UserDataHandler-CLONED" name="NODE_CLONED" type="unsigned short" value="1"><descr><p>The node is cloned, using<code>Node.cloneNode()</code>.</p></descr></constant><constant id="UserDataHandler-IMPORTED" name="NODE_IMPORTED" type="unsigned short" value="2"><descr><p>The node is imported, using<code>Document.importNode()</code>.</p></descr></constant><constant id="UserDataHandler-DELETED" name="NODE_DELETED" type="unsigned short" value="3"><descr><p>The node is deleted.</p><note><p>This may not be supported or may not be reliable in certain environments, such as Java, where the implementation has no real control over when objects are actually deleted.</p></note></descr></constant><constant id="UserDataHandler-RENAMED" name="NODE_RENAMED" type="unsigned short" value="4"><descr><p>The node is renamed, using<code>Document.renameNode()</code>.</p></descr></constant><constant id="UserDataHandler-ADOPTED" name="NODE_ADOPTED" type="unsigned short" value="5"><descr><p>The node is adopted, using<code>Document.adoptNode()</code>.</p></descr></constant></group><method name="handle" id="ID-handleUserDataEvent"><descr><p>This method is called whenever the node for which this handler is registered is imported or cloned.</p><p>DOM applications must not raise exceptions in a<code>UserDataHandler</code>. The effect of throwing exceptions from the handler is DOM implementation dependent.</p></descr><parameters><param name="operation" type="unsigned short" attr="in"><descr><p>Specifies the type of operation that is being performed on the node.</p></descr></param><param name="key" type="DOMString" attr="in"><descr><p>Specifies the key for which this handler is being called.</p></descr></param><param name="data" type="DOMUserData" attr="in"><descr><p>Specifies the data for which this handler is being called.</p></descr></param><param name="src" type="Node" attr="in"><descr><p>Specifies the node being cloned, adopted, imported, or renamed. This is<code>null</code>when the node is being deleted.</p></descr></param><param name="dst" type="Node" attr="in"><descr><p>Specifies the node newly created if any, or<code>null</code>.</p></descr></param></parameters><returns type="void"><descr><p/></descr></returns><raises></raises></method></interface>
+ <interface name="DOMError" id="ERROR-Interfaces-DOMError" since="DOM Level 3"><descr><p><code>DOMError</code>is an interface that describes an error.</p></descr><group id="DOMError-errorSeverityCodes" name="ErrorSeverity"><descr><p>An integer indicating the severity of the error.</p></descr><constant name="SEVERITY_WARNING" id="ERROR-DOMError-severity-warning" type="unsigned short" value="1"><descr><p>The severity of the error described by the<code>DOMError</code>is warning. A<code>SEVERITY_WARNING</code>will not cause the processing to stop, unless<code>DOMErrorHandler.handleError()</code>returns<code>false</code>.</p></descr></constant><constant name="SEVERITY_ERROR" id="ERROR-DOMError-severity-error" type="unsigned short" value="2"><descr><p>The severity of the error described by the<code>DOMError</code>is error. A<code>SEVERITY_ERROR</code>may not cause the processing to stop if the error can be recovered, unless<code>DOMErrorHandler.handleError()</code>returns<code>false</code>.</p></descr></constant><constant name="SEVERITY_FATAL_ERROR" id="ERROR-DOMError-severity-fatal-error" type="unsigned short" value="3"><descr><p>The severity of the error described by the<code>DOMError</code>is fatal error. A<code>SEVERITY_FATAL_ERROR</code>will cause the normal processing to stop. The return value of<code>DOMErrorHandler.handleError()</code>is ignored unless the implementation chooses to continue, in which case the behavior becomes undefined.</p></descr></constant></group><attribute type="unsigned short" readonly="yes" name="severity" id="ERROR-DOMError-severity"><descr><p>The severity of the error, either<code>SEVERITY_WARNING</code>,<code>SEVERITY_ERROR</code>, or<code>SEVERITY_FATAL_ERROR</code>.</p></descr></attribute><attribute type="DOMString" readonly="yes" name="message" id="ERROR-DOMError-message"><descr><p>An implementation specific string describing the error that occurred.</p></descr></attribute><attribute name="type" type="DOMString" readonly="yes" id="ERROR-DOMError-type"><descr><p>A<code>DOMString</code>indicating which related data is expected in<code>relatedData</code>. Users should refer to the specification of the error in order to find its<code>DOMString</code>type and<code>relatedData</code>definitions if any.</p><note><p>As an example,<code>Document.normalizeDocument()</code>does generate warnings when the "<termref def="parameter-split-cdata-sections">split-cdata-sections</termref>" parameter is in use. Therefore, the method generates a<code>SEVERITY_WARNING</code>with<code>type</code><code>"cdata-sections-splitted"</code>and the first<code>CDATASection</code>node in document order resulting from the split is returned by the<code>relatedData</code>attribute.</p></note></descr></attribute><attribute type="DOMObject" readonly="yes" name="relatedException" id="ERROR-DOMError-relatedException"><descr><p>The related platform dependent exception if any.</p></descr></attribute><attribute type="DOMObject" readonly="yes" name="relatedData" id="ERROR-DOMError-relatedData"><descr><p>The related<code>DOMError.type</code>dependent data if any.</p></descr></attribute><attribute type="DOMLocator" readonly="yes" name="location" id="ERROR-DOMError-location"><descr><p>The location of the error.</p></descr></attribute></interface>
+ <interface name="DOMErrorHandler" id="ERROR-Interfaces-DOMErrorHandler" since="DOM Level 3" role="ecmascript-function"><descr><p><code>DOMErrorHandler</code>is a callback interface that the DOM implementation can call when reporting errors that happens while processing XML data, or when doing some other processing (e.g. validating a document). A<code>DOMErrorHandler</code>object can be attached to a<code>Document</code>using the "<termref def="parameter-error-handler">error-handler</termref>" on the<code>DOMConfiguration</code>interface. If more than one error needs to be reported during an operation, the sequence and numbers of the errors passed to the error handler are implementation dependent.</p><p>The application that is using the DOM implementation is expected to implement this interface.</p></descr><method name="handleError" id="ID-ERRORS-DOMErrorHandler-handleError"><descr><p>This method is called on the error handler when an error occurs.</p><p>If an exception is thrown from this method, it is considered to be equivalent of returning<code>true</code>.</p></descr><parameters><param name="error" type="DOMError" attr="in"><descr><p>The error object that describes the error. This object may be reused by the DOM implementation across multiple calls to the<code>handleError</code>method.</p></descr></param></parameters><returns type="boolean"><descr><p>If the<code>handleError</code>method returns<code>false</code>, the DOM implementation should stop the current processing when possible. If the method returns<code>true</code>, the processing may continue depending on<code>DOMError.severity</code>.</p></descr></returns><raises></raises></method></interface>
+ <interface name="DOMLocator" id="Interfaces-DOMLocator" since="DOM Level 3"><descr><p><code>DOMLocator</code>is an interface that describes a location (e.g. where an error occurred).</p></descr><attribute type="long" readonly="yes" name="lineNumber" id="DOMLocator-line-number"><descr><p>The line number this locator is pointing to, or<code>-1</code>if there is no column number available.</p></descr></attribute><attribute type="long" readonly="yes" name="columnNumber" id="DOMLocator-column-number"><descr><p>The column number this locator is pointing to, or<code>-1</code>if there is no column number available.</p></descr></attribute><attribute type="long" readonly="yes" name="byteOffset" id="DOMLocator-byteOffset"><descr><p>The byte offset into the input source this locator is pointing to or<code>-1</code>if there is no byte offset available.</p></descr></attribute><attribute type="long" readonly="yes" name="utf16Offset" id="DOMLocator-utf16Offset"><descr><p>The UTF-16, as defined in<bibref ref="Unicode"/>and Amendment 1 of<bibref ref="ISO10646"/>, offset into the input source this locator is pointing to or<code>-1</code>if there is no UTF-16 offset available.</p></descr></attribute><attribute type="Node" readonly="yes" name="relatedNode" id="DOMLocator-node"><descr><p>The node this locator is pointing to, or<code>null</code>if no node is available.</p></descr></attribute><attribute type="DOMString" readonly="yes" name="uri" id="DOMLocator-uri"><descr><p>The URI this locator is pointing to, or<code>null</code>if no URI is available.</p></descr></attribute></interface>
+ <interface name="DOMConfiguration" id="DOMConfiguration" since="DOM Level 3"><descr><p>The<code>DOMConfiguration</code>interface represents the configuration of a document and maintains a table of recognized parameters. Using the configuration, it is possible to change<code>Document.normalizeDocument()</code>behavior, such as replacing the<code>CDATASection</code>nodes with<code>Text</code>nodes or specifying the type of the<termref def="dt-schema">schema</termref>that must be used when the validation of the<code>Document</code>is requested.<code>DOMConfiguration</code>objects are also used in<bibref role="informative" ref="DOMLS"/>in the<code>DOMParser</code>and<code>DOMSerializer</code>interfaces.</p><p>The parameter names used by the<code>DOMConfiguration</code>object are defined throughout the DOM Level 3 specifications. Names are case-insensitive. To avoid possible conflicts, as a convention, names referring to parameters defined outside the DOM specification should be made unique. Because parameters are exposed as properties in the<specref ref="ecma-binding"/>, names are recommended to follow the section<quote>5.16 Identifiers</quote>of<bibref role="informative" ref="Unicode"/>with the addition of the character '-' (HYPHEN-MINUS) but it is not enforced by the DOM implementation. DOM Level 3 Core Implementations are required to recognize all parameters defined in this specification. Some parameter values may also be required to be supported by the implementation. Refer to the definition of the parameter to know if a value must be supported or not.</p><note><p>Parameters are similar to features and properties used in SAX2<bibref role="informative" ref="SAX"/>.</p></note><p>The following list of parameters defined in the DOM:</p><glist><gitem><label id="parameter-canonical-form"><code>"canonical-form"</code></label><def><glist><gitem><label><code>true</code></label><def><p>[<emph>optional</emph>]</p><p>Canonicalize the document according to the rules specified in<bibref role="informative" ref="c14n"/>, such as removing the<code>DocumentType</code>node (if any) from the tree, or removing superfluous namespace declarations from each element. Note that this is limited to what can be represented in the DOM; in particular, there is no way to specify the order of the attributes in the DOM. In addition,</p><p>Setting this parameter to<code>true</code>will also set the state of the parameters listed below. Later changes to the state of one of those parameters will revert "<termref def="parameter-canonical-form">canonical-form</termref>" back to<code>false</code>.</p><p>Parameters set to<code>false</code>: "<termref def="parameter-entities">entities</termref>", "<termref def="parameter-normalize-characters">normalize-characters</termref>", "<termref def="parameter-cdata-sections">cdata-sections</termref>".</p><p>Parameters set to<code>true</code>: "<termref def="parameter-namespaces">namespaces</termref>", "<termref def="parameter-namespace-declarations">namespace-declarations</termref>", "<termref def="parameter-well-formed">well-formed</termref>", "<termref def="parameter-element-content-whitespace">element-content-whitespace</termref>".</p><p>Other parameters are not changed unless explicitly specified in the description of the parameters.</p></def></gitem><gitem><label><code>false</code></label><def><p>[<emph>required</emph>] (<emph>default</emph>)</p><p>Do not canonicalize the document.</p></def></gitem></glist></def></gitem><gitem><label id="parameter-cdata-sections"><code>"cdata-sections"</code></label><def><glist><gitem><label><code>true</code></label><def><p>[<emph>required</emph>] (<emph>default</emph>)</p><p>Keep<code>CDATASection</code>nodes in the document.</p></def></gitem><gitem><label><code>false</code></label><def><p>[<emph>required</emph>]</p><p>Transform<code>CDATASection</code>nodes in the document into<code>Text</code>nodes. The new<code>Text</code>node is then combined with any adjacent<code>Text</code>node.</p></def></gitem></glist></def></gitem><gitem><label id="parameter-check-character-normalization"><code>"check-character-normalization"</code></label><def><glist><gitem><label><code>true</code></label><def><p>[<emph>optional</emph>]</p><p>Check if the characters in the document are<loc href="http://www.w3.org/TR/2004/REC-xml11-20040204/#dt-fullnorm" type="simple" show="replace" actuate="onRequest">fully normalized</loc>, as defined in appendix B of<bibref ref="XML11"/>. When a sequence of characters is encountered that fails normalization checking, an error with the<code>DOMError.type</code>equals to "check-character-normalization-failure" is issued.</p></def></gitem><gitem><label><code>false</code></label><def><p>[<emph>required</emph>] (<emph>default</emph>)</p><p>Do not check if characters are normalized.</p></def></gitem></glist></def></gitem><gitem><label id="parameter-comments"><code>"comments"</code></label><def><glist><gitem><label><code>true</code></label><def><p>[<emph>required</emph>] (<emph>default</emph>)</p><p>Keep<code>Comment</code>nodes in the document.</p></def></gitem><gitem><label><code>false</code></label><def><p>[<emph>required</emph>]</p><p>Discard<code>Comment</code>nodes in the document.</p></def></gitem></glist></def></gitem><gitem><label id="parameter-datatype-normalization"><code>"datatype-normalization"</code></label><def><glist><gitem><label><code>true</code></label><def><p>[<emph>optional</emph>]</p><p>Expose schema normalized values in the tree, such as<loc href="http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/#key-nv" type="simple" show="replace" actuate="onRequest">XML Schema normalized values</loc>in the case of XML Schema. Since this parameter requires to have<termref def="dt-schema">schema</termref>information, the "<termref def="parameter-validate">validate</termref>" parameter will also be set to<code>true</code>. Having this parameter activated when "validate" is<code>false</code>has no effect and no schema-normalization will happen.</p><note><p>Since the document contains the result of the XML 1.0 processing, this parameter does not apply to attribute value normalization as defined in section 3.3.3 of<bibref ref="XML"/>and is only meant for<termref def="dt-schema">schema</termref>languages other than Document Type Definition (DTD).</p></note></def></gitem><gitem><label><code>false</code></label><def><p>[<emph>required</emph>] (<emph>default</emph>)</p><p>Do not perform schema normalization on the tree.</p></def></gitem></glist></def></gitem><gitem><label id="parameter-element-content-whitespace"><code>"element-content-whitespace"</code></label><def><glist><gitem><label><code>true</code></label><def><p>[<emph>required</emph>] (<emph>default</emph>)</p><p>Keep all whitespaces in the document.</p></def></gitem><gitem><label><code>false</code></label><def><p>[<emph>optional</emph>]</p><p>Discard all<code>Text</code>nodes that contain whitespaces in element content, as described in<xspecref href="http://www.w3.org/TR/2004/REC-xml-infoset-20040204#infoitem.character" type="simple" show="new" actuate="onRequest">[element content whitespace]</xspecref>. The implementation is expected to use the attribute<code>Text.isElementContentWhitespace</code>to determine if a<code>Text</code>node should be discarded or not.</p></def></gitem></glist></def></gitem><gitem><label id="parameter-entities"><code>"entities"</code></label><def><glist><gitem><label><code>true</code></label><def><p>[<emph>required</emph>] (<emph>default</emph>)</p><p>Keep<code>EntityReference</code>nodes in the document.</p></def></gitem><gitem><label><code>false</code></label><def><p>[<emph>required</emph>]</p><p>Remove all<code>EntityReference</code>nodes from the document, putting the entity expansions directly in their place.<code>Text</code>nodes are normalized, as defined in<code>Node.normalize</code>. Only<loc href="http://www.w3.org/TR/2004/REC-xml-infoset-20040204/#infoitem.rse" type="simple" show="replace" actuate="onRequest">unexpanded entity references</loc>are kept in the document.</p></def></gitem></glist><note><p>This parameter does not affect<code>Entity</code>nodes.</p></note></def></gitem><gitem><label id="parameter-error-handler"><code>"error-handler"</code></label><def><p>[<emph>required</emph>]</p><p>Contains a<code>DOMErrorHandler</code>object. If an error is encountered in the document, the implementation will call back the<code>DOMErrorHandler</code>registered using this parameter. The implementation may provide a default<code>DOMErrorHandler</code>object.</p><p>When called,<code>DOMError.relatedData</code>will contain the closest node to where the error occurred. If the implementation is unable to determine the node where the error occurs,<code>DOMError.relatedData</code>will contain the<code>Document</code>node. Mutations to the document from within an error handler will result in implementation dependent behavior.</p></def></gitem><gitem><label id="parameter-infoset"><code>"infoset"</code></label><def><glist><gitem><label><code>true</code></label><def><p>[<emph>required</emph>]</p><p>Keep in the document the information defined in the XML Information Set<bibref ref="InfoSet"/>.</p><p>This forces the following parameters to<code>false</code>: "<termref def="parameter-validate-if-schema">validate-if-schema</termref>", "<termref def="parameter-entities">entities</termref>", "<termref def="parameter-datatype-normalization">datatype-normalization</termref>", "<termref def="parameter-cdata-sections">cdata-sections</termref>".</p><p>This forces the following parameters to<code>true</code>: "<termref def="parameter-namespace-declarations">namespace-declarations</termref>", "<termref def="parameter-well-formed">well-formed</termref>", "<termref def="parameter-element-content-whitespace">element-content-whitespace</termref>", "<termref def="parameter-comments">comments</termref>", "<termref def="parameter-namespaces">namespaces</termref>".</p><p>Other parameters are not changed unless explicitly specified in the description of the parameters.</p><p>Note that querying this parameter with<code>getParameter</code>returns<code>true</code>only if the individual parameters specified above are appropriately set.</p></def></gitem><gitem><label><code>false</code></label><def><p>Setting<code>infoset</code>to<code>false</code>has no effect.</p></def></gitem></glist></def></gitem><gitem><label id="parameter-namespaces"><code>"namespaces"</code></label><def><glist><gitem><label><code>true</code></label><def><p>[<emph>required</emph>] (<emph>default</emph>)</p><p>Perform the namespace processing as defined in<specref ref="normalizeDocumentAlgo"/>.</p></def></gitem><gitem><label><code>false</code></label><def><p>[<emph>optional</emph>]</p><p>Do not perform the namespace processing.</p></def></gitem></glist></def></gitem><gitem><label id="parameter-namespace-declarations"><code>"namespace-declarations"</code></label><def><p>This parameter has no effect if the parameter "<termref def="parameter-namespaces">namespaces</termref>" is set to<code>false</code>.</p><glist><gitem><label><code>true</code></label><def><p>[<emph>required</emph>] (<emph>default</emph>)</p><p>Include namespace declaration attributes, specified or defaulted from the<termref def="dt-schema">schema</termref>, in the document. See also the sections "Declaring Namespaces" in<bibref ref="Namespaces"/>and<bibref ref="Namespaces11"/>.</p></def></gitem><gitem><label><code>false</code></label><def><p>[<emph>required</emph>]</p><p>Discard all namespace declaration attributes. The namespace prefixes (<code>Node.prefix</code>) are retained even if this parameter is set to<code>false</code>.</p></def></gitem></glist></def></gitem><gitem><label id="parameter-normalize-characters"><code>"normalize-characters"</code></label><def><glist><gitem><label><code>true</code></label><def><p>[<emph>optional</emph>]</p><p><loc href="http://www.w3.org/TR/2004/REC-xml11-20040204/#dt-fullnorm" type="simple" show="replace" actuate="onRequest">Fully normalized</loc>the characters in the document as defined in appendix B of<bibref ref="XML11"/>.</p></def></gitem><gitem><label><code>false</code></label><def><p>[<emph>required</emph>] (<emph>default</emph>)</p><p>Do not perform character normalization.</p></def></gitem></glist></def></gitem><gitem><label id="parameter-schema-location"><code>"schema-location"</code></label><def><p>[<emph>optional</emph>]</p><p>Represent a<code>DOMString</code>object containing a list of URIs, separated by whitespaces (characters matching the<xspecref href="http://www.w3.org/TR/2004/REC-xml-20040204#NT-S" type="simple" show="new" actuate="onRequest">nonterminal production S</xspecref>defined in section 2.3<bibref ref="XML"/>), that represents the<termref def="dt-schema">schemas</termref>against which validation should occur, i.e. the current schema. The types of schemas referenced in this list must match the type specified with<code>schema-type</code>, otherwise the behavior of an implementation is undefined.</p><p>The schemas specified using this property take precedence to the schema information specified in the document itself. For namespace aware schema, if a schema specified using this property and a schema specified in the document instance (i.e. using the<code>schemaLocation</code>attribute) in a schema document (i.e. using schema<code>import</code>mechanisms) share the same<code>targetNamespace</code>, the schema specified by the user using this property will be used. If two schemas specified using this property share the same<code>targetNamespace</code>or have no namespace, the behavior is implementation dependent.</p><p>If no location has been provided, this parameter is<code>null</code>.</p><note><p>The<code>"schema-location"</code>parameter is ignored unless the "<termref def="parameter-schema-type">schema-type</termref>" parameter value is set. It is strongly recommended that<code>Document.documentURI</code>will be set so that an implementation can successfully resolve any external entities referenced.</p></note></def></gitem><gitem><label id="parameter-schema-type"><code>"schema-type"</code></label><def><p>[<emph>optional</emph>]</p><p>Represent a<code>DOMString</code>object containing an absolute URI and representing the type of the<termref def="dt-schema">schema</termref>language used to validate a document against. Note that no lexical checking is done on the absolute URI.</p><p>If this parameter is not set, a default value may be provided by the implementation, based on the schema languages supported and on the schema language used at load time. If no value is provided, this parameter is<code>null</code>.</p><note><p>For XML Schema<bibref ref="XMLSchema1"/>, applications must use the value<code>"http://www.w3.org/2001/XMLSchema"</code>. For XML DTD<bibref ref="XML"/>, applications must use the value<code>"http://www.w3.org/TR/REC-xml"</code>. Other schema languages are outside the scope of the W3C and therefore should recommend an absolute URI in order to use this method.</p></note></def></gitem><gitem><label id="parameter-split-cdata-sections"><code>"split-cdata-sections"</code></label><def><glist><gitem><label><code>true</code></label><def><p>[<emph>required</emph>] (<emph>default</emph>)</p><p>Split CDATA sections containing the CDATA section termination marker ']]&gt;'. When a CDATA section is split a warning is issued with a<code>DOMError.type</code>equals to<code>"cdata-sections-splitted"</code>and<code>DOMError.relatedData</code>equals to the first<code>CDATASection</code>node in document order resulting from the split.</p></def></gitem><gitem><label><code>false</code></label><def><p>[<emph>required</emph>]</p><p>Signal an error if a<code>CDATASection</code>contains an unrepresentable character.</p></def></gitem></glist></def></gitem><gitem><label id="parameter-validate"><code>"validate"</code></label><def><glist><gitem><label><code>true</code></label><def><p>[<emph>optional</emph>]</p><p>Require the validation against a<termref def="dt-schema">schema</termref>(i.e. XML schema, DTD, any other type or representation of schema) of the document as it is being normalized as defined by<bibref ref="XML"/>. If validation errors are found, or no schema was found, the error handler is notified. Schema-normalized values will not be exposed according to the schema in used unless the parameter "<termref def="parameter-datatype-normalization">datatype-normalization</termref>" is<code>true</code>.</p><p>This parameter will reevaluate:</p><ulist><item><p>Attribute nodes with<code>Attr.specified</code>equals to<code>false</code>, as specified in the description of the<code>Attr</code>interface;</p></item><item><p>The value of the attribute<code>Text.isElementContentWhitespace</code>for all<code>Text</code>nodes;</p></item><item><p>The value of the attribute<code>Attr.isId</code>for all<code>Attr</code>nodes;</p></item><item><p>The attributes<code>Element.schemaTypeInfo</code>and<code>Attr.schemaTypeInfo</code>.</p></item></ulist><note><p>"<termref def="parameter-validate-if-schema">validate-if-schema</termref>" and "validate" are mutually exclusive, setting one of them to<code>true</code>will set the other one to<code>false</code>. Applications should also consider setting the parameter "<termref def="parameter-well-formed">well-formed</termref>" to<code>true</code>, which is the default for that option, when validating the document.</p></note></def></gitem><gitem><label><code>false</code></label><def><p>[<emph>required</emph>] (<emph>default</emph>)</p><p>Do not accomplish schema processing, including the internal subset processing. Default attribute values information are kept. Note that validation might still happen if "<termref def="parameter-validate-if-schema">validate-if-schema</termref>" is<code>true</code>.</p></def></gitem></glist></def></gitem><gitem><label id="parameter-validate-if-schema"><code>"validate-if-schema"</code></label><def><glist><gitem><label><code>true</code></label><def><p>[<emph>optional</emph>]</p><p>Enable validation only if a declaration for the document element can be found in a<termref def="dt-schema">schema</termref>(independently of where it is found, i.e. XML schema, DTD, or any other type or representation of schema). If validation is enabled, this parameter has the same behavior as the parameter "<termref def="parameter-validate">validate</termref>" set to<code>true</code>.</p><note><p>"validate-if-schema" and "<termref def="parameter-validate">validate</termref>" are mutually exclusive, setting one of them to<code>true</code>will set the other one to<code>false</code>.</p></note></def></gitem><gitem><label><code>false</code></label><def><p>[<emph>required</emph>] (<emph>default</emph>)</p><p>No schema processing should be performed if the document has a schema, including internal subset processing. Default attribute values information are kept. Note that validation must still happen if "<termref def="parameter-validate">validate</termref>" is<code>true</code>.</p></def></gitem></glist></def></gitem><gitem><label id="parameter-well-formed"><code>"well-formed"</code></label><def><glist><gitem><label><code>true</code></label><def><p>[<emph>required</emph>] (<emph>default</emph>)</p><p>Check if all nodes are XML<termref def="dt-well-formed">well formed</termref>according to the XML version in use in<code>Document.xmlVersion</code>:</p><ulist><item><p>check if the attribute<code>Node.nodeName</code>contains invalid characters according to its node type and generate a<code>DOMError</code>of type<code>"wf-invalid-character-in-node-name"</code>, with a<code>DOMError.SEVERITY_ERROR</code>severity, if necessary;</p></item><item><p>check if the text content inside<code>Attr</code>,<code>Element</code>,<code>Comment</code>,<code>Text</code>,<code>CDATASection</code>nodes for invalid characters and generate a<code>DOMError</code>of type<code>"wf-invalid-character"</code>, with a<code>DOMError.SEVERITY_ERROR</code>severity, if necessary;</p></item><item><p>check if the data inside<code>ProcessingInstruction</code>nodes for invalid characters and generate a<code>DOMError</code>of type<code>"wf-invalid-character"</code>, with a<code>DOMError.SEVERITY_ERROR</code>severity, if necessary;</p></item></ulist></def></gitem><gitem><label><code>false</code></label><def><p>[<emph>optional</emph>]</p><p>Do not check for XML well-formedness.</p></def></gitem></glist></def></gitem></glist><p>The resolution of the system identifiers associated with entities is done using<code>Document.documentURI</code>. However, when the feature "LS" defined in<bibref role="informative" ref="DOMLS"/>is supported by the DOM implementation, the parameter "resource-resolver" can also be used on<code>DOMConfiguration</code>objects attached to<code>Document</code>nodes. If this parameter is set,<code>Document.normalizeDocument()</code>will invoke the resource resolver instead of using<code>Document.documentURI</code>.</p></descr><method name="setParameter" id="DOMConfiguration-property"><descr><p>Set the value of a parameter.</p></descr><parameters><param name="name" type="DOMString" attr="in"><descr><p>The name of the parameter to set.</p></descr></param><param name="value" type="DOMUserData" attr="in"><descr><p>The new value or<code>null</code>if the user wishes to unset the parameter. While the type of the value parameter is defined as<code>DOMUserData</code>, the object type must match the type defined by the definition of the parameter. For example, if the parameter is<termref def="parameter-error-handler">"error-handler"</termref>, the value must be of type<code>DOMErrorHandler</code>.</p></descr></param></parameters><returns type="void"><descr></descr></returns><raises><exception name="DOMException"><descr><p>NOT_FOUND_ERR: Raised when the parameter name is not recognized.</p><p>NOT_SUPPORTED_ERR: Raised when the parameter name is recognized but the requested value cannot be set.</p><p>TYPE_MISMATCH_ERR: Raised if the value type for this parameter name is incompatible with the expected value type.</p></descr></exception></raises></method><method name="getParameter" id="DOMConfiguration-getParameter"><descr><p>Return the value of a parameter if known.</p></descr><parameters><param name="name" type="DOMString" attr="in"><descr><p>The name of the parameter.</p></descr></param></parameters><returns type="DOMUserData"><descr><p>The current object associated with the specified parameter or<code>null</code>if no object has been associated or if the parameter is not supported.</p></descr></returns><raises><exception name="DOMException"><descr><p>NOT_FOUND_ERR: Raised when the parameter name is not recognized.</p></descr></exception></raises></method><method name="canSetParameter" id="DOMConfiguration-canSetParameter"><descr><p>Check if setting a parameter to a specific value is supported.</p></descr><parameters><param name="name" type="DOMString" attr="in"><descr><p>The name of the parameter to check.</p></descr></param><param name="value" type="DOMUserData" attr="in"><descr><p>An object. if<code>null</code>, the returned value is<code>true</code>.</p></descr></param></parameters><returns type="boolean"><descr><p><code>true</code>if the parameter could be successfully set to the specified value, or<code>false</code>if the parameter is not recognized or the requested value is not supported. This does not change the current value of the parameter itself.</p></descr></returns><raises></raises></method><attribute name="parameterNames" type="DOMStringList" readonly="yes" id="DOMConfiguration-parameterNames"><descr><p>The list of the parameters supported by this<code>DOMConfiguration</code>object and for which at least one value can be set by the application. Note that this list can also contain parameter names defined outside this specification.</p></descr></attribute></interface>
+ <interface name="CDATASection" inherits="Text" id="ID-667469212"><descr><p>CDATA sections are used to escape blocks of text containing characters that would otherwise be regarded as markup. The only delimiter that is recognized in a CDATA section is the "]]&gt;" string that ends the CDATA section. CDATA sections cannot be nested. Their primary purpose is for including material such as XML fragments, without needing to escape all the delimiters.</p><p>The<code>CharacterData.data</code>attribute holds the text that is contained by the CDATA section. Note that this<emph>may</emph>contain characters that need to be escaped outside of CDATA sections and that, depending on the character encoding ("charset") chosen for serialization, it may be impossible to write out some characters as part of a CDATA section.</p><p>The<code>CDATASection</code>interface inherits from the<code>CharacterData</code>interface through the<code>Text</code>interface. Adjacent<code>CDATASection</code>nodes are not merged by use of the<code>normalize</code>method of the<code>Node</code>interface.</p><p>No lexical check is done on the content of a CDATA section and it is therefore possible to have the character sequence<code>"]]&gt;"</code>in the content, which is illegal in a CDATA section per section 2.7 of<bibref ref="XML"/>. The presence of this character sequence must generate a fatal error during serialization or the cdata section must be splitted before the serialization (see also the parameter<code>"split-cdata-sections"</code>in the<code>DOMConfiguration</code>interface).</p><note><p>Because no markup is recognized within a<code>CDATASection</code>, character numeric references cannot be used as an escape mechanism when serializing. Therefore, action needs to be taken when serializing a<code>CDATASection</code>with a character encoding where some of the contained characters cannot be represented. Failure to do so would not produce well-formed XML.</p><p>One potential solution in the serialization process is to end the CDATA section before the character, output the character using a character reference or entity reference, and open a new CDATA section for any further characters in the text node. Note, however, that some code conversion libraries at the time of writing do not return an error or exception when a character is missing from the encoding, making the task of ensuring that data is not corrupted on serialization more difficult.</p></note></descr></interface>
+ <interface name="DocumentType" inherits="Node" id="ID-412266927"><descr><p>Each<code>Document</code>has a<code>doctype</code>attribute whose value is either<code>null</code>or a<code>DocumentType</code>object. The<code>DocumentType</code>interface in the DOM Core provides an interface to the list of entities that are defined for the document, and little else because the effect of namespaces and the various XML schema efforts on DTD representation are not clearly understood as of this writing.</p><p>DOM Level 3 doesn't support editing<code>DocumentType</code>nodes.<code>DocumentType</code>nodes are<termref def="dt-readonly-node">read-only</termref>.</p></descr><attribute readonly="yes" name="name" type="DOMString" id="ID-1844763134"><descr><p>The name of DTD; i.e., the name immediately following the<code>DOCTYPE</code>keyword.</p></descr></attribute><attribute readonly="yes" name="entities" type="NamedNodeMap" id="ID-1788794630"><descr><p>A<code>NamedNodeMap</code>containing the general entities, both external and internal, declared in the DTD. Parameter entities are not contained. Duplicates are discarded. For example in:<eg role="code" space="preserve">&lt;!DOCTYPE ex SYSTEM "ex.dtd" [ &lt;!ENTITY foo "foo"&gt; &lt;!ENTITY bar "bar"&gt; &lt;!ENTITY bar "bar2"&gt; &lt;!ENTITY % baz "baz"&gt; ]&gt; &lt;ex/&gt;</eg>the interface provides access to<code>foo</code>and the first declaration of<code>bar</code>but not the second declaration of<code>bar</code>or<code>baz</code>. Every node in this map also implements the<code>Entity</code>interface.</p><p>The DOM Level 2 does not support editing entities, therefore<code>entities</code>cannot be altered in any way.</p></descr></attribute><attribute readonly="yes" name="notations" type="NamedNodeMap" id="ID-D46829EF"><descr><p>A<code>NamedNodeMap</code>containing the notations declared in the DTD. Duplicates are discarded. Every node in this map also implements the<code>Notation</code>interface.</p><p>The DOM Level 2 does not support editing notations, therefore<code>notations</code>cannot be altered in any way.</p></descr></attribute><attribute readonly="yes" name="publicId" type="DOMString" id="ID-Core-DocType-publicId" since="DOM Level 2"><descr><p>The public identifier of the external subset.</p></descr></attribute><attribute readonly="yes" name="systemId" type="DOMString" id="ID-Core-DocType-systemId" since="DOM Level 2"><descr><p>The system identifier of the external subset. This may be an absolute URI or not.</p></descr></attribute><attribute readonly="yes" name="internalSubset" type="DOMString" id="ID-Core-DocType-internalSubset" since="DOM Level 2"><descr><p>The internal subset as a string, or<code>null</code>if there is none. This is does not contain the delimiting square brackets.</p><note><p>The actual content returned depends on how much information is available to the implementation. This may vary depending on various parameters, including the XML processor used to build the document.</p></note></descr></attribute></interface>
+ <interface name="Notation" inherits="Node" id="ID-5431D1B9"><descr><p>This interface represents a notation declared in the DTD. A notation either declares, by name, the format of an unparsed entity (see<xspecref href="http://www.w3.org/TR/2004/REC-xml-20040204#Notations" type="simple" show="new" actuate="onRequest">section 4.7</xspecref>of the XML 1.0 specification<bibref ref="XML"/>), or is used for formal declaration of processing instruction targets (see<xspecref href="http://www.w3.org/TR/2004/REC-xml-20040204#sec-pi" type="simple" show="new" actuate="onRequest">section 2.6</xspecref>of the XML 1.0 specification<bibref ref="XML"/>). The<code>nodeName</code>attribute inherited from<code>Node</code>is set to the declared name of the notation.</p><p>The DOM Core does not support editing<code>Notation</code>nodes; they are therefore<termref def="dt-readonly-node">readonly</termref>.</p><p>A<code>Notation</code>node does not have any parent.</p></descr><attribute readonly="yes" name="publicId" type="DOMString" id="ID-54F2B4D0"><descr><p>The public identifier of this notation. If the public identifier was not specified, this is<code>null</code>.</p></descr></attribute><attribute readonly="yes" name="systemId" type="DOMString" id="ID-E8AAB1D0"><descr><p>The system identifier of this notation. If the system identifier was not specified, this is<code>null</code>. This may be an absolute URI or not.</p></descr></attribute></interface>
+ <interface name="Entity" inherits="Node" id="ID-527DCFF2"><descr><p>This interface represents a known entity, either parsed or unparsed, in an XML document. Note that this models the entity itself<emph>not</emph>the entity declaration.</p><p>The<code>nodeName</code>attribute that is inherited from<code>Node</code>contains the name of the entity.</p><p>An XML processor may choose to completely expand entities before the structure model is passed to the DOM; in this case there will be no<code>EntityReference</code>nodes in the document tree.</p><p>XML does not mandate that a non-validating XML processor read and process entity declarations made in the external subset or declared in parameter entities. This means that parsed entities declared in the external subset need not be expanded by some classes of applications, and that the replacement text of the entity may not be available. When the<xspecref href="http://www.w3.org/TR/2004/REC-xml-20040204#intern-replacement" type="simple" show="new" actuate="onRequest">replacement text</xspecref>is available, the corresponding<code>Entity</code>node's child list represents the structure of that replacement value. Otherwise, the child list is empty.</p><p>DOM Level 3 does not support editing<code>Entity</code>nodes; if a user wants to make changes to the contents of an<code>Entity</code>, every related<code>EntityReference</code>node has to be replaced in the structure model by a clone of the<code>Entity</code>'s contents, and then the desired changes must be made to each of those clones instead.<code>Entity</code>nodes and all their<termref def="dt-descendant">descendants</termref>are<termref def="dt-readonly-node">readonly</termref>.</p><p>An<code>Entity</code>node does not have any parent.</p><note><p>If the entity contains an unbound<termref def="dt-namespaceprefix">namespace prefix</termref>, the<code>namespaceURI</code>of the corresponding node in the<code>Entity</code>node subtree is<code>null</code>. The same is true for<code>EntityReference</code>nodes that refer to this entity, when they are created using the<code>createEntityReference</code>method of the<code>Document</code>interface.</p></note></descr><attribute readonly="yes" name="publicId" type="DOMString" id="ID-D7303025"><descr><p>The public identifier associated with the entity if specified, and<code>null</code>otherwise.</p></descr></attribute><attribute readonly="yes" name="systemId" type="DOMString" id="ID-D7C29F3E"><descr><p>The system identifier associated with the entity if specified, and<code>null</code>otherwise. This may be an absolute URI or not.</p></descr></attribute><attribute readonly="yes" name="notationName" type="DOMString" id="ID-6ABAEB38"><descr><p>For unparsed entities, the name of the notation for the entity. For parsed entities, this is<code>null</code>.</p></descr></attribute><attribute readonly="yes" type="DOMString" name="inputEncoding" id="Entity3-inputEncoding" since="DOM Level 3"><descr><p>An attribute specifying the encoding used for this entity at the time of parsing, when it is an external parsed entity. This is<code>null</code>if it an entity from the internal subset or if it is not known.</p></descr></attribute><attribute readonly="yes" type="DOMString" name="xmlEncoding" id="Entity3-encoding" since="DOM Level 3"><descr><p>An attribute specifying, as part of the text declaration, the encoding of this entity, when it is an external parsed entity. This is<code>null</code>otherwise.</p></descr></attribute><attribute readonly="yes" type="DOMString" name="xmlVersion" id="Entity3-version" since="DOM Level 3"><descr><p>An attribute specifying, as part of the text declaration, the version number of this entity, when it is an external parsed entity. This is<code>null</code>otherwise.</p></descr></attribute></interface>
+ <interface name="EntityReference" inherits="Node" id="ID-11C98490"><descr><p><code>EntityReference</code>nodes may be used to represent an entity reference in the tree. Note that character references and references to predefined entities are considered to be expanded by the HTML or XML processor so that characters are represented by their Unicode equivalent rather than by an entity reference. Moreover, the XML processor may completely expand references to entities while building the<code>Document</code>, instead of providing<code>EntityReference</code>nodes. If it does provide such nodes, then for an<code>EntityReference</code>node that represents a reference to a known entity an<code>Entity</code>exists, and the subtree of the<code>EntityReference</code>node is a copy of the<code>Entity</code>node subtree. However, the latter may not be true when an entity contains an unbound<termref def="dt-namespaceprefix">namespace prefix</termref>. In such a case, because the namespace prefix resolution depends on where the entity reference is, the<termref def="dt-descendant">descendants</termref>of the<code>EntityReference</code>node may be bound to different<termref def="dt-namespaceURI">namespace URIs</termref>. When an<code>EntityReference</code>node represents a reference to an unknown entity, the node has no children and its replacement value, when used by<code>Attr.value</code>for example, is empty.</p><p>As for<code>Entity</code>nodes,<code>EntityReference</code>nodes and all their<termref def="dt-descendant">descendants</termref>are<termref def="dt-readonly-node">readonly</termref>.</p><note><p><code>EntityReference</code>nodes may cause element content and attribute value normalization problems when, such as in XML 1.0 and XML Schema, the normalization is performed after entity reference are expanded.</p></note></descr></interface>
+ <interface name="ProcessingInstruction" inherits="Node" id="ID-1004215813"><descr><p>The<code>ProcessingInstruction</code>interface represents a "processing instruction", used in XML as a way to keep processor-specific information in the text of the document.</p><p>No lexical check is done on the content of a processing instruction and it is therefore possible to have the character sequence<code>"?&gt;"</code>in the content, which is illegal a processing instruction per section 2.6 of<bibref ref="XML"/>. The presence of this character sequence must generate a fatal error during serialization.</p></descr><attribute readonly="yes" type="DOMString" name="target" id="ID-1478689192"><descr><p>The target of this processing instruction. XML defines this as being the first<termref def="dt-token">token</termref>following the markup that begins the processing instruction.</p></descr></attribute><attribute type="DOMString" name="data" id="ID-837822393" readonly="no"><descr><p>The content of this processing instruction. This is from the first non white space character after the target to the character immediately preceding the<code>?&gt;</code>.</p></descr><setraises><exception name="DOMException"><descr><p>NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.</p></descr></exception></setraises></attribute></interface>
+ <interface id="i18n-methods-StringExtend" name="StringExtend"><descr><p>Extensions to a language's native String class or interface</p></descr><method id="i18n-methods-StringExtend-findOffset16" name="findOffset16"><descr><p>Returns the UTF-16 offset that corresponds to a UTF-32 offset. Used for random access.</p><note><p>You can always round-trip from a UTF-32 offset to a UTF-16 offset and back. You can round-trip from a UTF-16 offset to a UTF-32 offset and back if and only if the offset16 is not in the middle of a surrogate pair. Unmatched surrogates count as a single UTF-16 value.</p></note></descr><parameters><param name="offset32" type="int" attr="in"><descr><p>UTF-32 offset.</p></descr></param></parameters><returns type="int"><descr><p>UTF-16 offset</p></descr></returns><raises><exception name="StringIndexOutOfBoundsException"><descr><p>if<code>offset32</code>is out of bounds.</p></descr></exception></raises></method><method id="i18n-methods-StringExtend-findOffset32" name="findOffset32"><descr><p>Returns the UTF-32 offset corresponding to a UTF-16 offset. Used for random access. To find the UTF-32 length of a string, use:<eg space="preserve">len32 = findOffset32(source, source.length());</eg></p><note><p>If the UTF-16 offset is into the middle of a surrogate pair, then the UTF-32 offset of the<emph>end</emph>of the pair is returned; that is, the index of the char after the end of the pair. You can always round-trip from a UTF-32 offset to a UTF-16 offset and back. You can round-trip from a UTF-16 offset to a UTF-32 offset and back if and only if the offset16 is not in the middle of a surrogate pair. Unmatched surrogates count as a single UTF-16 value.</p></note></descr><parameters><param attr="in" type="int" name="offset16"><descr><p>UTF-16 offset</p></descr></param></parameters><returns type="int"><descr><p>UTF-32 offset</p></descr></returns><raises><exception name="StringIndexOutOfBoundsException"><descr><p>if offset16 is out of bounds.</p></descr></exception></raises></method></interface>
+</library>
diff --git a/test/leak-test.sh b/test/leak-test.sh
new file mode 100755
index 0000000..4a6ea13
--- /dev/null
+++ b/test/leak-test.sh
@@ -0,0 +1,45 @@
+#!/bin/bash
+#
+# This is a simple script used to test libdom memory leakage.
+# Usage:
+# You should firstly run "run-test.sh", which will genrate a test output directory. In that
+# directory, there are C source files and corresponding executables.
+# Go to the test output directory. For example , for core, level 1, it is output/level1/core
+# And run this script as ../../../leak-test.sh "log-file"
+#
+# This file is part of libdom test suite.
+# Licensed under the MIT License,
+# http://www.opensource.org/licenses/mit-license.php
+# Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+
+log=$1;
+totla=0;
+leak=0;
+ok=0;
+while read f; do
+ #Test defnitely lost
+ echo -n "$f: " >&3;
+ echo -n "$f: ";
+ dl=$(valgrind "$f" 2>&1 | grep "definitely lost" | sed -e 's/definitely lost//g' -e 's/bytes in//g' -e 's/blocks.//g' -e 's/^.*://g' -e 's/ //g' -e 's/,//g');
+ pl=$(valgrind "$f" 2>&1 | grep "possibly lost" | sed -e 's/possibly lost//g' -e 's/bytes in//g' -e 's/blocks.//g' -e 's/^.*://g' -e 's/ //g' -e 's/,//g');
+
+ total=$((total+1));
+ if [ "$dl" -eq "00" -a "$pl" -eq "00" ]; then
+ echo "ok..." >&3;
+ echo "ok...";
+ ok=$((ok+1));
+ else
+ echo "leaked!" >&3;
+ echo "leaked!";
+ leak=$((leak+1));
+ fi
+
+done 3>"$log" < <(find ./ -perm -o=x -type f -print);
+
+echo "Total: $total" >>"$log";
+echo "Leak: $leak" >>"$log";
+echo "Ok: $ok" >>"$log";
+
+echo "Total: $total";
+echo "Leak: $leak";
+echo "Ok: $ok";
diff --git a/test/lib/comparators.c b/test/lib/comparators.c
deleted file mode 100644
index c07236d..0000000
--- a/test/lib/comparators.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#include "comparators.h"
-
-int int_comparator(const int* a, const int* b) {
- return (*a) - (*b);
-}
diff --git a/test/lib/exceptions.h b/test/lib/exceptions.h
deleted file mode 100644
index 8b98d5b..0000000
--- a/test/lib/exceptions.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * This file is part of libdom test suite.
- * Licensed under the MIT License,
- * http://www.opensource.org/licenses/mit-license.php
- * Copyright 2007 James Shaw <jshaw@netsurf-browser.org>
- */
-
-#ifndef exceptions_h_
-#define exceptions_h_
-
-#include <setjmp.h>
-
-#include <dom/core/exceptions.h>
-
-/* Adapted from http://www.math.princeton.edu/~asnowden/c-except.html
- Usage:
- TRY
- THROW(DOM_NOT_FOUND_ERR);
- THROW_IF_ERR(dom_document_get_doctype(...));
- CATCH(ex)
- printf("exception: %d\n", ex);
- ENDTRY
-*/
-#define TRY __exvalue=setjmp(__exbuf); \
- if (__exvalue==0) {
-#define CATCH(x) } else { \
- int x = __exvalue;
-#define ENDTRY }
-#define THROW(x) longjmp(__exbuf, x)
-
-#define THROW_IF_ERR(x) \
- do { \
- int err = x; \
- if (err != DOM_NO_ERR) \
- THROW(err); \
- } while (0)
-
-jmp_buf __exbuf;
-int __exvalue;
-
-#endif
-
diff --git a/test/lib/testassert.c b/test/lib/testassert.c
deleted file mode 100644
index 191a94b..0000000
--- a/test/lib/testassert.c
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * This file is part of libdom test suite.
- * Licensed under the MIT License,
- * http://www.opensource.org/licenses/mit-license.php
- * Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
- * Copyright 2007 James Shaw <jshaw@netsurf-browser.org>
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <dom/core/string.h>
-
-#include "testassert.h"
-#include "comparators.h"
-#include "utils.h"
-
-void __assert2(const char *expr, const char *function,
- const char *file, int line)
-{
- UNUSED(function);
- UNUSED(file);
-
- printf("FAIL - %s at line %d\n", expr, line);
-
- exit(EXIT_FAILURE);
-}
-
-void assert_equals_collection(struct list* expected, struct list* actual,
- comparator comparator)
-{
- assert(expected != NULL);
- assert(actual != NULL);
- assert_equals(&(expected->size), &(actual->size), (int (*)(const void* a, const void* b)) int_comparator);
- list_contains_all(actual, expected, comparator);
-}
-
-void assert_equals(void* expected, void* actual, comparator comparator)
-{
- assert(comparator(expected, actual) == 0);
-}
-
-void assert_same(void* expected, void* actual, comparator comparator)
-{
- if (!(expected == actual)) {
- assert_equals(expected, actual, comparator);
- }
-}
-void assert_uri_equals(char* scheme, char* path, char* host, char* file,
- char* name, char* query, char* fragment, bool isAbsolute,
- char* actual)
-{
- UNUSED(scheme);
- UNUSED(path);
- UNUSED(host);
- UNUSED(file);
- UNUSED(name);
- UNUSED(query);
- UNUSED(fragment);
- UNUSED(isAbsolute);
- UNUSED(actual);
- /* TODO: implement me. Look at netsurf/url.c */
-}
-
diff --git a/test/lib/testassert.h b/test/lib/testassert.h
deleted file mode 100644
index 85472ce..0000000
--- a/test/lib/testassert.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * This file is part of libdom test suite.
- * Licensed under the MIT License,
- * http://www.opensource.org/licenses/mit-license.php
- * Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
- */
-
-#ifndef testassert_h_
-#define testassert_h_
-
-#include "comparators.h"
-#include "list.h"
-
-/* Redefine assert, so we can simply use the standard assert mechanism
- * within testcases and exit with the right output for the testrunner
- * to do the right thing. */
-void __assert2(const char *expr, const char *function,
- const char *file, int line);
-
-#define assert(expr) \
- ((void) ((expr) || (__assert2 (#expr, __func__, __FILE__, __LINE__), 0)))
-
-void assert_equals_collection(struct list* expected, struct list* actual,
- comparator comparator);
-
-void assert_equals(void* expected, void* actual, comparator comparator);
-
-void assert_same(void* expected, void* actual, comparator comparator);
-
-void assert_uri_equals(char* scheme, char* path, char* host, char* file,
- char* name, char* query, char* fragment, bool isAbsolute,
- char* actual);
-
-#endif
diff --git a/test/lib/testobject.c b/test/lib/testobject.c
deleted file mode 100644
index 4c27e0b..0000000
--- a/test/lib/testobject.c
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * This file is part of libdom test suite.
- * Licensed under the MIT License,
- * http://www.opensource.org/licenses/mit-license.php
- * Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
- */
-
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <dom/bootstrap/init_fini.h>
-
-#include "bindings/hubbub/parser.h"
-
-#include "bindings/xml/xmlbinding.h"
-#include "bindings/xml/xmlparser.h"
-
-#include "testassert.h"
-#include "testobject.h"
-#include "utils.h"
-
-static bool parser_initialised;
-
-struct TestObject {
- enum { OBJECT_XML, OBJECT_HTML } type;
- union {
- dom_xml_parser *xml;
- dom_hubbub_parser *html;
- } parser;
- struct dom_document *doc;
-};
-
-static void test_object_cleanup(void);
-
-TestObject *test_object_create(int argc, char **argv,
- const char *uri, bool will_be_modified)
-{
- char fnbuf[1024];
-#define CHUNK_SIZE 4096
- uint8_t buf[CHUNK_SIZE];
- FILE *fp;
- char *dot;
- size_t len;
- TestObject *ret;
-
- UNUSED(will_be_modified);
-
- if (argc != 2) {
- printf("Usage: %s <datapath>\n", argv[0]);
- exit(EXIT_FAILURE);
- }
-
- if (parser_initialised == false) {
- assert(dom_initialise(myrealloc, NULL) == DOM_NO_ERR);
-
- assert(dom_xml_binding_initialise(myrealloc, NULL) ==
- DOM_XML_OK);
-
-// assert(dom_hubbub_binding_initialise(myrealloc, NULL) ==
-// DOM_HUBBUB_OK);
-
- atexit(test_object_cleanup);
-
- parser_initialised = true;
- }
-
- snprintf(fnbuf, sizeof fnbuf, "%s/%s", argv[1], uri);
-
- ret = malloc(sizeof(TestObject));
- if (ret == NULL)
- return NULL;
-
- /* Detect the parser type (this is mildly hacky) */
- dot = strrchr(uri, '.');
- len = strlen(uri);
-
- if (dot == NULL) {
- printf("No file extension, assuming XML\n");
-
- ret->type = OBJECT_XML;
- } else if (len - ((dot + 1) - uri) == 3) {
- if (tolower(dot[1]) == 'x' && tolower(dot[2]) == 'm'
- && tolower(dot[3]) == 'l') {
- ret->type = OBJECT_XML;
- } else if (tolower(dot[1]) == 'h' && tolower(dot[2]) == 't' &&
- tolower(dot[3]) == 'm') {
- ret->type = OBJECT_HTML;
- }
- } else if (len - ((dot + 1) - uri) == 4) {
- if (tolower(dot[1]) == 'h' && tolower(dot[2]) == 't' &&
- tolower(dot[3]) == 'm' &&
- tolower(dot[4]) == 'l') {
- ret->type = OBJECT_HTML;
- }
- } else {
- /* Assume XML */
- ret->type = OBJECT_XML;
- }
-
- switch (ret->type) {
- case OBJECT_XML:
- ret->parser.xml = dom_xml_parser_create(NULL, "UTF-8",
- myrealloc, NULL, mymsg, NULL);
- if (ret->parser.xml == NULL) {
- free(ret);
- return NULL;
- }
- break;
- case OBJECT_HTML:
- {
- char abuf[1024];
- snprintf(abuf, sizeof abuf, "%s/Aliases", argv[1]);
-
- ret->parser.html = dom_hubbub_parser_create(abuf,
- NULL, true, myrealloc, NULL, mymsg, NULL);
- if (ret->parser.html == NULL) {
- free(ret);
- return NULL;
- }
- break;
- }
- }
-
- fp = fopen(fnbuf, "r");
- if (fp == NULL) {
- switch (ret->type) {
- case OBJECT_XML:
- dom_xml_parser_destroy(ret->parser.xml);
- break;
- case OBJECT_HTML:
- dom_hubbub_parser_destroy(ret->parser.html);
- break;
- }
- free(ret);
- return NULL;
- }
-
- fseek(fp, 0, SEEK_END);
- len = ftell(fp);
- fseek(fp, 0, SEEK_SET);
-
- while (len > CHUNK_SIZE) {
- fread(buf, 1, CHUNK_SIZE, fp);
-
- switch (ret->type) {
- case OBJECT_XML:
- assert(dom_xml_parser_parse_chunk(ret->parser.xml,
- buf, CHUNK_SIZE) == DOM_XML_OK);
- break;
- case OBJECT_HTML:
- assert(dom_hubbub_parser_parse_chunk(ret->parser.html,
- buf, CHUNK_SIZE) == DOM_HUBBUB_OK);
- break;
- }
-
- len -= CHUNK_SIZE;
- }
-
- if (len > 0) {
- fread(buf, 1, len, fp);
-
- switch (ret->type) {
- case OBJECT_XML:
- assert(dom_xml_parser_parse_chunk(ret->parser.xml,
- buf, len) == DOM_XML_OK);
- break;
- case OBJECT_HTML:
- assert(dom_hubbub_parser_parse_chunk(ret->parser.html,
- buf, len) == DOM_HUBBUB_OK);
- break;
- }
-
- len = 0;
- }
-
- switch (ret->type) {
- case OBJECT_XML:
- assert(dom_xml_parser_completed(ret->parser.xml) == DOM_XML_OK);
- break;
- case OBJECT_HTML:
- assert(dom_hubbub_parser_completed(ret->parser.html) ==
- DOM_HUBBUB_OK);
- break;
- }
-
- fclose(fp);
-
- switch (ret->type) {
- case OBJECT_XML:
- ret->doc = dom_xml_parser_get_document(ret->parser.xml);
- break;
- case OBJECT_HTML:
- ret->doc = dom_hubbub_parser_get_document(ret->parser.html);
- break;
- }
-
- switch (ret->type) {
- case OBJECT_XML:
- dom_xml_parser_destroy(ret->parser.xml);
- ret->parser.xml = NULL;
- break;
- case OBJECT_HTML:
- dom_hubbub_parser_destroy(ret->parser.html);
- ret->parser.html = NULL;
- break;
- }
-
- return ret;
-
-#undef CHUNK_SIZE
-}
-
-struct dom_document *test_object_get_doc(TestObject *obj)
-{
- return obj->doc;
-}
-
-const char *test_object_get_mimetype(TestObject *obj)
-{
- return (obj->type == OBJECT_XML ? "text/xml" : "text/html");
-}
-
-void test_object_cleanup(void)
-{
- if (parser_initialised) {
-// dom_hubbub_binding_finalise();
- dom_xml_binding_finalise();
- dom_finalise();
- }
-}
-
diff --git a/test/lib/testobject.h b/test/lib/testobject.h
deleted file mode 100644
index c72b39f..0000000
--- a/test/lib/testobject.h
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * This file is part of libdom test suite.
- * Licensed under the MIT License,
- * http://www.opensource.org/licenses/mit-license.php
- * Copyright 2007 John-Mark Bell <jmb@netsurf-browser.org>
- */
-
-#ifndef testobject_h_
-#define testobject_h_
-
-#include <stdbool.h>
-
-struct TestObject;
-typedef struct TestObject TestObject;
-
-TestObject *test_object_create(int argc, char **argv,
- const char *uri, bool will_be_modified);
-struct dom_document *test_object_get_doc(TestObject *obj);
-const char *test_object_get_mimetype(TestObject *obj);
-
-#endif
-
diff --git a/test/run-single-test.sh b/test/run-single-test.sh
new file mode 100755
index 0000000..5118dcc
--- /dev/null
+++ b/test/run-single-test.sh
@@ -0,0 +1,144 @@
+#!/bin/bash
+#
+# This is a simple script to convert the a XML testcae to C source file, compile it, run it, and report the result.
+# Usage:
+# This script is designed to run under the libdom/test directory.
+#
+# domts="testcases" dtd="dom1-interfaces.xml" level="level1" ./run-single-test.sh
+#
+# The above command will convert the XML testcase in directory testcases/tests/level/core and
+# use dom1-interfaces.xml to convert it.
+# This script will generate a output/ directory in libdom/test, and in that directory, there is a same structure
+# as in DOMTS XML testcases files.
+#
+# This file is part of libdom test suite.
+# Licensed under the MIT License,
+# http://www.opensource.org/licenses/mit-license.php
+# Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+
+level=${level:-"level1"};
+module=${module:-"core"};
+domts=${domts:?"The \$domts must be assigned some value"};
+output=${output:-"output"};
+dtd=${dtd:?"The DTD file must be given"};
+
+testdir="$domts"/tests/"$level"/"$module"
+log="$output"/"$level"/"$module"/test.log;
+
+src="testutils/comparators.c testutils/domtsasserts.c testutils/foreach.c testutils/list.c testutils/load.c testutils/utils.c testutils/domtscondition.c"
+domdir="../build-Linux-Linux-debug-lib-static"
+ldflags="-L$domdir -ldom -L/usr/local/lib -lwapcaplet -L/usr/lib -lxml2 -lhubbub -lparserutils"
+#ldflags="-L/usr/lib -lm -lz -L$domdir -ldom -L/usr/local/lib -lwapcaplet -lxml2 -lhubbub -lparserutils"
+cflags="-Itestutils/ -I../bindings/xml -I../include -I../bindings/hubbub -I/usr/local/include"
+
+total=0;
+fail=0;
+pass=0;
+conversion=0;
+compile=0;
+run=0;
+nsupport=0;
+
+# Create the directories if necessary
+if [ ! -e "$ouput" ]; then
+ mkdir -p "$output";
+fi
+if [ ! -e "$level" ]; then
+ mkdir -p "$output"/"$level";
+fi
+if [ ! -e "$module" ]; then
+ mkdir -p "$output"/"$level"/"$module";
+fi
+
+# Prepare the test files
+if [ -e "files" ]; then
+ rm -fr files;
+fi
+cp -fr "$testdir/files" ./;
+
+while read test; do
+ total=$(($total+1));
+
+ file=`basename "$test"`;
+ name=${file%%.xml};
+
+ cfile="$output"/"$level"/"$module"/"$name".c;
+ ofile="$output"/"$level"/"$module"/"$name";
+ tfile="$testdir"/"$file";
+
+ echo -n "$file:";
+
+ # Generate the test C program
+ out=`perl transform.pl "$dtd" "$tfile" 2>&1 >"${cfile}.unindent"`;
+ if [ "$?" != "0" ]; then
+ fail=$((fail+1));
+ conversion=$((conversion+1));
+ echo "$tfile Conversion Error:" >& 3;
+ echo "Please make sure you have XML::XPath perl module installed!" >& 3;
+ echo "$out" >&3;
+ echo -e "----------------------------------------\n\n" >& 3;
+ echo "failed!";
+ rm -fr "${cfile}.unindent";
+ continue;
+ fi
+ out=`indent "${cfile}.unindent" -o "$cfile" 2>&1`;
+ if [ "$?" != "0" ]; then
+ rm -fr "${cfile}.unindent";
+ fail=$((fail+1));
+ conversion=$((conversion+1));
+ echo "$tfile Conversion Error:" >& 3;
+ echo "$out" >& 3;
+ echo -e "----------------------------------------\n\n" >& 3;
+ echo "failed!";
+ continue;
+ fi
+ rm -fr "${cfile}.unindent";
+
+ # Compile it now
+ out=` ( gcc -g $cflags $src $cfile $ldflags -o "$ofile" ) 2>&1`;
+ if [ "$?" != "0" ]; then
+ fail=$((fail+1));
+ compile=$((compile+1));
+ echo "$tfile Compile Error:" >& 3;
+ echo "$out" >& 3;
+ echo -e "----------------------------------------\n\n" >& 3;
+ echo "failed!";
+ continue;
+ fi
+
+ # Run the test and test the result
+ cd files;
+ out=$(../$ofile 2>&1);
+ ret="$?";
+ if [ "$ret" != "0" ]; then
+ cd ..;
+ fail=$((fail+1));
+ if [ "$ret" == "9" ]; then
+ nsupport=$((nsupport+1))
+ echo "$tfile Not Support:" >& 3;
+ echo "$out" >& 3;
+ echo -e "----------------------------------------\n\n" >& 3;
+ echo "not supported!";
+ else
+ run=$((run+1));
+ echo "$tfile Run Error:" >& 3;
+ echo "$out" >& 3;
+ echo -e "----------------------------------------\n\n" >& 3;
+ echo "failed!";
+ fi
+ continue;
+ fi
+ cd ..;
+
+ pass=$((pass+1));
+ echo "passed.";
+
+done 3>&1 < <(echo $1);
+
+echo "Total: $total";
+echo "Passed: $pass";
+echo "Failed: $fail";
+echo "Conversion Error: $conversion";
+echo "Compile Error: $compile";
+echo "Run Error: $run";
+echo "Not Support: $nsupport";
diff --git a/test/run-test.sh b/test/run-test.sh
new file mode 100755
index 0000000..c856ace
--- /dev/null
+++ b/test/run-test.sh
@@ -0,0 +1,146 @@
+#!/bin/bash
+#
+# This is a simple script to convert the XML testcaes to C source file, compile it, run it, and report the result.
+# Usage:
+# This script is designed to run under the libdom/test directory.
+#
+# domts="testcases" dtd="dom1-interfaces.xml" level="level1" ./run-test.sh
+#
+# The above command will convert the XML testcase in directory testcases/tests/level/core and
+# use dom1-interfaces.xml to convert it.
+# This script will generate a output/ directory in libdom/test, and in that directory, there is a same structure
+# as in DOMTS XML testcases files.
+#
+# This file is part of libdom test suite.
+# Licensed under the MIT License,
+# http://www.opensource.org/licenses/mit-license.php
+# Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+
+level=${level:-"level1"};
+module=${module:-"core"};
+domts=${domts:?"The \$domts must be assigned some value"};
+output=${output:-"output"};
+dtd=${dtd:?"The DTD file must be given"};
+
+testdir="$domts"/tests/"$level"/"$module"
+log="$output"/"$level"/"$module"/test.log;
+
+src="testutils/comparators.c testutils/domtsasserts.c testutils/foreach.c testutils/list.c testutils/load.c testutils/utils.c testutils/domtscondition.c"
+domdir="../build-Linux-Linux-debug-lib-static"
+ldflags="-L$domdir -ldom -L/usr/local/lib -lwapcaplet -L/usr/lib -lxml2 -lhubbub -lparserutils"
+#ldflags="-L/usr/lib -lm -lz -L$domdir -ldom -L/usr/local/lib -lwapcaplet -lxml2 -lhubbub -lparserutils"
+cflags="-Itestutils/ -I../bindings/xml -I../include -I../bindings/hubbub -I/usr/local/include"
+
+total=0;
+fail=0;
+pass=0;
+conversion=0;
+compile=0;
+run=0;
+nsupport=0;
+
+# Create the directories if necessary
+if [ ! -e "$ouput" ]; then
+ mkdir -p "$output";
+fi
+if [ ! -e "$level" ]; then
+ mkdir -p "$output"/"$level";
+fi
+if [ ! -e "$module" ]; then
+ mkdir -p "$output"/"$level"/"$module";
+fi
+
+# Prepare the test files
+if [ -e "files" ]; then
+ rm -fr files;
+fi
+cp -fr "$testdir/files" ./;
+
+while read test; do
+ total=$(($total+1));
+
+ file=`basename "$test"`;
+ name=${file%%.xml};
+
+ cfile="$output"/"$level"/"$module"/"$name".c;
+ ofile="$output"/"$level"/"$module"/"$name";
+ tfile="$testdir"/"$file";
+
+ echo -n "$file:";
+
+ # Generate the test C program
+ out=`perl transform.pl "$dtd" "$tfile" 2>&1 >"${cfile}.unindent"`;
+ if [ "$?" != "0" ]; then
+ fail=$((fail+1));
+ conversion=$((conversion+1));
+ echo "$tfile Conversion Error:" >& 3;
+ echo "Please make sure you have XML::XPath perl module installed!" >& 3;
+ echo "$out" >&3;
+ echo -e "----------------------------------------\n\n" >& 3;
+ echo "failed!";
+ rm -fr "${cfile}.unindent";
+ continue;
+ fi
+ out=`indent "${cfile}.unindent" -o "$cfile" 2>&1`;
+ if [ "$?" != "0" ]; then
+ rm -fr "${cfile}.unindent";
+ fail=$((fail+1));
+ conversion=$((conversion+1));
+ echo "$tfile Conversion Error:" >& 3;
+ echo "$out" >& 3;
+ echo -e "----------------------------------------\n\n" >& 3;
+ echo "failed!";
+ continue;
+ fi
+ rm -fr "${cfile}.unindent";
+
+ # Compile it now
+ out=` ( gcc -g $cflags $src $cfile $ldflags -o "$ofile" ) 2>&1`;
+ if [ "$?" != "0" ]; then
+ fail=$((fail+1));
+ compile=$((compile+1));
+ echo "$tfile Compile Error:" >& 3;
+ echo "$out" >& 3;
+ echo -e "----------------------------------------\n\n" >& 3;
+ echo "failed!";
+ continue;
+ fi
+
+ # Run the test and test the result
+ cd files;
+ out=$(../$ofile 2>&1);
+ ret="$?";
+ if [ "$ret" != "0" ]; then
+ cd ..;
+ fail=$((fail+1));
+ if [ "$ret" == "9" ]; then
+ nsupport=$((nsupport+1))
+ echo "$tfile Not Support:" >& 3;
+ echo "$out" >& 3;
+ echo -e "----------------------------------------\n\n" >& 3;
+ echo "not supported!";
+ else
+ run=$((run+1));
+ echo "$tfile Run Error:" >& 3;
+ echo "$out" >& 3;
+ echo -e "----------------------------------------\n\n" >& 3;
+ echo "failed!";
+ fi
+ continue;
+ fi
+ cd ..;
+
+ pass=$((pass+1));
+ echo "passed.";
+
+done 3>"$log" < <(perl -ne 'if ($_ =~ /href=\"(.*\.xml)\"/) { print "$1\n"; }' -- "$testdir"/alltests.xml);
+
+echo "Total: $total" | tee >>"$log";
+echo "Passed: $pass" | tee >>"$log";
+echo "Failed: $fail" | tee >>"$log";
+echo "Conversion Error: $conversion" | tee >>"$log";
+echo "Compile Error: $compile" | tee >>"$log";
+echo "Run Error: $run" | tee >>"$log";
+echo "Not Support: $nsupport" | tee >>"$log";
+
+cat "$log";
diff --git a/test/test-list.c b/test/test-list.c
deleted file mode 100644
index 7871286..0000000
--- a/test/test-list.c
+++ /dev/null
@@ -1,56 +0,0 @@
-#include <stdbool.h>
-#include <stdio.h>
-#include <string.h>
-
-#include "testutils.h"
-
-void test_add_remove(void);
-void test_contains_all_true(void);
-
-void test_add_remove(void)
-{
- struct list* list = list_new();
-
- char s[] = "hello";
-
- /* add element */
- list_add(list, s);
- assert(strcmp(list->head->data, "hello") == 0);
- assert(list->size == 1);
-
- /* remove element */
- bool found = list_remove(list, s);
- assert(found == true);
- assert(list->size == 0);
- assert(list->head == NULL);
-
- list_destroy(list);
-}
-
-void test_contains_all_true(void)
-{
- struct list* superList = list_new();
- struct list* subList = list_new();
-
- list_add(superList, (void*) "hello");
- list_add(superList, (void*) "world");
-
- list_add(subList, (void*) "hello");
-
- bool b = list_contains_all(superList, subList, (comparator) strcmp);
- assert(b == true);
- assert(superList->size == 2);
- assert(superList->head->next->next == NULL);
-
- list_destroy(superList);
- list_destroy(subList);
-}
-
-int main(void)
-{
- test_add_remove();
- test_contains_all_true();
- //test_different_size_lists();
-
- printf("PASS\n");
-}
diff --git a/test/testutils.h b/test/testutils.h
deleted file mode 100644
index 9fa8241..0000000
--- a/test/testutils.h
+++ /dev/null
@@ -1,11 +0,0 @@
-#ifndef dom_test_testutils_h_
-#define dom_test_testutils_h_
-
-#include "lib/exceptions.h"
-#include "lib/list.h"
-#include "lib/testassert.h"
-#include "lib/testobject.h"
-#include "lib/utils.h"
-
-#endif
-
diff --git a/test/testutils/comparators.c b/test/testutils/comparators.c
new file mode 100644
index 0000000..20630c6
--- /dev/null
+++ b/test/testutils/comparators.c
@@ -0,0 +1,80 @@
+/*
+ * This file is part of libdom test suite.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+ */
+
+#include "comparators.h"
+#include "domts.h"
+
+#include <string.h>
+
+#include <dom/dom.h>
+
+/* Compare to integer, return zero if equal */
+int int_comparator(const void* a, const void* b) {
+ return *((const int *)a) - *((const int *)b);
+}
+
+/* Compare two string. The first one is a char * and the second
+ * one is a dom_string, return zero if equal */
+int str_cmp(const void *a, const void *b)
+{
+ const char *excepted = (const char *) a;
+ dom_string *actual = (dom_string *) b;
+ dom_string *exp;
+ dom_exception err;
+ bool ret;
+
+ err = dom_string_create(myrealloc, NULL, excepted, strlen(excepted),
+ &exp);
+ if (err != DOM_NO_ERR)
+ return false;
+
+ ret = dom_string_cmp(exp, actual) == 0;
+
+ dom_string_unref(exp);
+
+ if (ret == true)
+ return 0;
+ else
+ return 1;
+}
+
+/* Similar with str_cmp but the first param is a dom_string the second
+ * param is a char * */
+int str_cmp_r(const void *a, const void *b)
+{
+ return str_cmp(b, a);
+}
+
+/* Similar with str_cmp but ignore the case of letters */
+int str_icmp(const void *a, const void *b)
+{
+ const char *excepted = (const char *) a;
+ dom_string *actual = (dom_string *) b;
+ dom_string *exp;
+ dom_exception err;
+ bool ret;
+
+ err = dom_string_create(myrealloc, NULL, excepted, strlen(excepted),
+ &exp);
+ if (err != DOM_NO_ERR)
+ return false;
+
+ ret = dom_string_icmp(exp, actual) == 0;
+
+ dom_string_unref(exp);
+
+ if (ret == true)
+ return 0;
+ else
+ return 1;
+}
+
+/* Similar with str_icmp, but the param order are reverse */
+int str_icmp_r(const void *a, const void *b)
+{
+ return str_icmp(b, a);
+}
diff --git a/test/lib/comparators.h b/test/testutils/comparators.h
index 4cdeb97..cad79e1 100644
--- a/test/lib/comparators.h
+++ b/test/testutils/comparators.h
@@ -3,6 +3,7 @@
* Licensed under the MIT License,
* http://www.opensource.org/licenses/mit-license.php
* Copyright 2007 James Shaw <jshaw@netsurf-browser.org>
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
*/
#ifndef comparators_h_
@@ -13,6 +14,10 @@
*/
typedef int (*comparator)(const void* a, const void* b);
-int int_comparator(const int* a, const int* b);
+int int_comparator(const void* a, const void* b);
+int str_icmp(const void *a, const void *b);
+int str_icmp_r(const void *a, const void *b);
+int str_cmp(const void *a, const void *b);
+int str_cmp_r(const void *a, const void *b);
#endif
diff --git a/test/testutils/domts.h b/test/testutils/domts.h
new file mode 100644
index 0000000..14f4e9e
--- /dev/null
+++ b/test/testutils/domts.h
@@ -0,0 +1,25 @@
+/*
+ * This file is part of libdom test suite.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+ */
+
+#ifndef domts_h_
+#define domts_h_
+
+#include <domtscondition.h>
+#include <domtsasserts.h>
+#include <list.h>
+#include <foreach.h>
+#include <utils.h>
+#include <comparators.h>
+
+struct lwc_context_s;
+
+extern struct lwc_context_s *ctx;
+
+dom_document *load_xml(char *file, bool willBeModified);
+dom_document *load_html(char *file, bool willBeModified);
+
+#endif
diff --git a/test/testutils/domtsasserts.c b/test/testutils/domtsasserts.c
new file mode 100644
index 0000000..affa881
--- /dev/null
+++ b/test/testutils/domtsasserts.c
@@ -0,0 +1,253 @@
+/*
+ * This file is part of libdom test suite.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+ */
+
+#include <stdio.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <dom/dom.h>
+
+#include "domts.h"
+
+extern dom_implementation *doc_impl;
+
+void __assert2(const char *expr, const char *function,
+ const char *file, int line)
+{
+ UNUSED(function);
+ UNUSED(file);
+
+ printf("FAIL - %s at line %d\n", expr, line);
+
+ exit(EXIT_FAILURE);
+}
+
+/**
+ * Following are the test conditions which defined in the DOMTS, please refer
+ * the DOM Test Suite for details
+ */
+
+bool is_true(bool arg)
+{
+ return arg == true;
+}
+
+bool is_null(void *arg)
+{
+ return arg == NULL;
+}
+
+bool is_same(void *excepted, void *actual)
+{
+ return excepted == actual;
+}
+
+bool is_same_int(int excepted, int actual)
+{
+ return excepted == actual;
+}
+
+bool is_same_unsigned_long(unsigned long excepted, unsigned long actual)
+{
+ return excepted == actual;
+}
+
+bool is_equals_int(int excepted, int actual, bool dummy)
+{
+ UNUSED(dummy);
+
+ return excepted == actual;
+}
+
+bool is_equals_unsigned_long(unsigned long excepted, unsigned long actual, bool dummy)
+{
+ UNUSED(dummy);
+
+ return excepted == actual;
+}
+
+/**
+ * Test whether two string are equal
+ *
+ * \param excepted The excepted string
+ * \param actual The actual string
+ * \param ignoreCase Whether to ignore letter case
+ */
+bool is_equals_string(const char *excepted, dom_string *actual,
+ bool ignoreCase)
+{
+ dom_string *exp;
+ dom_exception err;
+ bool ret;
+
+ err = dom_string_create(myrealloc, NULL, excepted, strlen(excepted),
+ &exp);
+ if (err != DOM_NO_ERR)
+ return false;
+
+ if (ignoreCase == true)
+ ret = dom_string_icmp(exp, actual) == 0;
+ else
+ ret = dom_string_cmp(exp, actual) == 0;
+
+ dom_string_unref(exp);
+ return ret;
+}
+
+/* Compare whether two dom_string are equal */
+bool is_equals_domstring(dom_string *excepted, dom_string *actual,
+ bool ignoreCase)
+{
+ if (ignoreCase == true)
+ return dom_string_icmp(excepted, actual) == 0;
+ else
+ return dom_string_cmp(excepted, actual) == 0;
+}
+
+/* The param actual should always contain dom_sting and expectd should
+ * contain char * */
+bool is_equals_list(list *expected, list *actual, bool ignoreCase)
+{
+ assert((expected->type && 0xff00) == (actual->type && 0xff00));
+
+ comparator cmp = NULL;
+ comparator rcmp = NULL;
+
+ if (expected->type == INT)
+ cmp = int_comparator;
+ if (expected->type == STRING) {
+ if (actual->type == DOM_STRING) {
+ cmp = ignoreCase? str_icmp : str_cmp;
+ rcmp = ignoreCase? str_icmp_r : str_cmp_r;
+ }
+ }
+ if (expected->type == DOM_STRING) {
+ if (actual->type == STRING) {
+ cmp = ignoreCase? str_icmp_r : str_cmp_r;
+ rcmp = ignoreCase? str_icmp : str_cmp;
+ }
+ }
+
+ assert(cmp != NULL);
+
+ bool ret = list_contains_all(expected, actual, cmp);
+ if (ret)
+ return list_contains_all(actual, expected, rcmp);
+}
+
+
+
+bool is_instanceof(const char *type, dom_node *node)
+{
+ assert("There is no instanceOf in the test-suite" == NULL);
+
+ return false;
+}
+
+
+bool is_size_domnamednodemap(int size, dom_namednodemap *map)
+{
+ unsigned long len;
+ dom_exception err;
+
+ err = dom_namednodemap_get_length(map, &len);
+ if (err != DOM_NO_ERR) {
+ assert("Exception occured" == NULL);
+ return false;
+ }
+
+ return size == len;
+}
+
+bool is_size_domnodelist(int size, dom_nodelist *list)
+{
+ unsigned long len;
+ dom_exception err;
+
+ err = dom_nodelist_get_length(list, &len);
+ if (err != DOM_NO_ERR) {
+ assert("Exception occured" == NULL);
+ return false;
+ }
+
+ return size == len;
+}
+
+bool is_size_list(int size, list *list)
+{
+ return size == list->size;
+}
+
+
+bool is_uri_equals(char *scheme, char *path, char *host,
+ char *file, char *query, char *fragment,
+ bool isAbsolute, dom_string *actual)
+{
+ UNUSED(scheme);
+ UNUSED(path);
+ UNUSED(host);
+ UNUSED(file);
+ UNUSED(query);
+ UNUSED(fragment);
+ UNUSED(isAbsolute);
+ UNUSED(actual);
+
+ return false;
+}
+
+
+bool is_contenttype(const char *type)
+{
+ /* Now, we use the libxml2 parser for DOM parsing, so the content type
+ * is always "text/xml" */
+ if (strcmp(type, "text/xml") == 0)
+ return true;
+ else
+ return false;
+}
+
+bool has_feature(char *feature, char *version)
+{
+ dom_exception err;
+ bool ret;
+ dom_string *df, *dv;
+
+ err = dom_string_create(myrealloc, NULL, feature,
+ feature == NULL ? 0 : strlen(feature), &df);
+ if (err != DOM_NO_ERR)
+ return false;
+
+ err = dom_string_create(myrealloc, NULL, version,
+ version == NULL ? 0 : strlen(version), &dv);
+ if (err != DOM_NO_ERR) {
+ dom_string_unref(df);
+ return false;
+ }
+
+ err = dom_implementation_has_feature(doc_impl, df, dv, &ret);
+ /* Here, when we come with exception, we should return false,
+ * TODO: this need to be improved, but I can't figure out how */
+ if (err != DOM_NO_ERR) {
+ dom_string_unref(df);
+ dom_string_unref(dv);
+ return false;
+ }
+
+ dom_string_unref(df);
+ dom_string_unref(dv);
+ return ret;
+}
+
+bool implementation_attribute(char *name, bool value)
+{
+ /* We didnot support DOMConfigure for implementation now */
+ UNUSED(name);
+ UNUSED(value);
+
+ return true;
+}
diff --git a/test/testutils/domtsasserts.h b/test/testutils/domtsasserts.h
new file mode 100644
index 0000000..ee0fb72
--- /dev/null
+++ b/test/testutils/domtsasserts.h
@@ -0,0 +1,61 @@
+/*
+ * This file is part of libdom test suite.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+ */
+
+#ifndef domtsasserts_h_
+#define domtsasserts_h_
+
+#include <stdbool.h>
+
+#include <dom/dom.h>
+
+#include "list.h"
+
+
+/* Redefine assert, so we can simply use the standard assert mechanism
+ * within testcases and exit with the right output for the testrunner
+ * to do the right thing. */
+void __assert2(const char *expr, const char *function,
+ const char *file, int line);
+
+#define assert(expr) \
+ ((void) ((expr) || (__assert2 (#expr, __func__, __FILE__, __LINE__), 0)))
+
+bool is_true(bool arg);
+
+bool is_null(void *arg);
+
+bool is_same(void *excepted, void *actual);
+bool is_same_int(int excepted, int actual);
+bool is_same_unsigned_long(unsigned long excepted, unsigned long actual);
+
+bool is_equals_int(int excepted, int actual, bool dummy);
+bool is_equals_unsigned_long(unsigned long excepted, unsigned long actual, bool dummy);
+bool is_equals_string(const char *excepted, dom_string *actual,
+ bool ignoreCase);
+bool is_equals_domstring(dom_string *excepted, dom_string *actual, bool ignoreCase);
+
+/* We may use two different string types in libDOM, but the expected string type is
+ always "char *" */
+bool is_equals_list(list *expected, list *actual, bool ignoreCase);
+
+bool is_instanceof(const char *type, dom_node *node);
+
+bool is_size_domnamednodemap(int size, dom_namednodemap *map);
+bool is_size_domnodelist(int size, dom_nodelist *list);
+bool is_size_list(int size, list *list);
+
+bool is_uri_equals(char *scheme, char *path, char *host,
+ char *file, char *query, char *fragment,
+ bool isAbsolute, dom_string *actual);
+
+bool is_contenttype(const char *type);
+
+bool has_feature(char *feature, char *version);
+
+bool implementation_attribute(char *name, bool value);
+
+#endif
diff --git a/test/testutils/domtscondition.c b/test/testutils/domtscondition.c
new file mode 100644
index 0000000..39f6c68
--- /dev/null
+++ b/test/testutils/domtscondition.c
@@ -0,0 +1,32 @@
+/*
+ * This file is part of libdom test suite.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+ */
+
+#include <stdbool.h>
+
+/**
+ * Just simple functions which meet the needs of DOMTS conditions
+ */
+
+bool less(int excepted, int actual)
+{
+ return actual < excepted;
+}
+
+bool less_or_equals(int excepted, int actual)
+{
+ return actual <= excepted;
+}
+
+bool greater(int excepted, int actual)
+{
+ return actual > excepted;
+}
+
+bool greater_or_equals(int excepted, int actual)
+{
+ return actual >= excepted;
+}
diff --git a/test/testutils/domtscondition.h b/test/testutils/domtscondition.h
new file mode 100644
index 0000000..164977f
--- /dev/null
+++ b/test/testutils/domtscondition.h
@@ -0,0 +1,18 @@
+/*
+ * This file is part of libdom test suite.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+ */
+
+#ifndef domtscondition_h_
+#define domtscondition_h_
+
+#include <stdbool.h>
+
+inline bool less(int excepted, int actual);
+inline bool less_or_equals(int excepted, int actual);
+inline bool greater(int excepted, int actual);
+inline bool greater_or_equals(int excepted, int actual);
+
+#endif
diff --git a/test/testutils/foreach.c b/test/testutils/foreach.c
new file mode 100644
index 0000000..c3868df
--- /dev/null
+++ b/test/testutils/foreach.c
@@ -0,0 +1,96 @@
+/*
+ * This file is part of libdom test suite.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+ */
+
+#include <stdbool.h>
+
+#include "foreach.h"
+#include "list.h"
+
+#include <dom/dom.h>
+
+/**
+ * Please see foreach.h for the usage of the following functions
+ */
+
+void foreach_initialise_domnodelist(dom_nodelist *list, unsigned int *iterator)
+{
+ *iterator = 0;
+}
+
+void foreach_initialise_list(list *list, unsigned int *iterator)
+{
+ *iterator = 0;
+}
+
+void foreach_initialise_domnamednodemap(dom_namednodemap *map, unsigned int *iterator)
+{
+ *iterator = 0;
+}
+
+
+bool _get_next_domnodelist(dom_nodelist *list, unsigned int *iterator, dom_node **ret)
+{
+ dom_exception err;
+ unsigned long len;
+
+ err = dom_nodelist_get_length(list, &len);
+ if (err != DOM_NO_ERR)
+ return false;
+
+ if (*iterator >= len)
+ return false;
+
+ err = dom_nodelist_item(list, (*iterator), ret);
+ if (err != DOM_NO_ERR)
+ return false;
+
+ (*iterator)++;
+ return true;
+}
+
+bool get_next_list(list *list, unsigned int *iterator, void **ret)
+{
+ unsigned int len = *iterator;
+ unsigned int i = 0;
+ struct list_elt *elt = list->head;
+
+ for (; i < len; i++) {
+ if (elt == NULL)
+ return false;
+ elt = elt->next;
+ }
+
+ if (elt == NULL)
+ return false;
+
+ *ret = elt->data;
+
+ (*iterator)++;
+
+ return true;
+}
+
+bool _get_next_domnamednodemap(dom_namednodemap *map, unsigned int *iterator, dom_node **ret)
+{
+ dom_exception err;
+ unsigned long len;
+
+ err = dom_namednodemap_get_length(map, &len);
+ if (err != DOM_NO_ERR)
+ return false;
+
+ if (*iterator >= len)
+ return false;
+
+ err = dom_namednodemap_item(map, (*iterator), ret);
+ if (err != DOM_NO_ERR)
+ return false;
+
+ (*iterator)++;
+
+ return true;
+}
diff --git a/test/testutils/foreach.h b/test/testutils/foreach.h
new file mode 100644
index 0000000..75874bc
--- /dev/null
+++ b/test/testutils/foreach.h
@@ -0,0 +1,41 @@
+/*
+ * This file is part of libdom test suite.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+ */
+
+#ifndef domts_foreach_h_
+#define domts_foreach_h_
+
+#include <dom/dom.h>
+
+#include <list.h>
+
+/* The following six functions are used for the XML testcase's
+ <for-each> element.
+ And the <for-each> element can be converted to :
+
+ unsigned int iterator;
+ foreach_initialise_*(list, &iterator);
+ while(get_next_*(list, &iterator, ret)){
+ do the loop work.
+ }
+*/
+
+void foreach_initialise_domnodelist(dom_nodelist *list, unsigned int *iterator);
+void foreach_initialise_list(list *list, unsigned int *iterator);
+void foreach_initialise_domnamednodemap(dom_namednodemap *map, unsigned int *iterator);
+
+bool _get_next_domnodelist(dom_nodelist *list, unsigned int *iterator, dom_node **ret);
+#define get_next_domnodelist(l, i, r) _get_next_domnodelist( \
+ (dom_nodelist *) (l), (unsigned int *) (i), (dom_node **) (r))
+
+bool get_next_list(list *list, unsigned int *iterator, void **ret);
+
+bool _get_next_domnamednodemap(dom_namednodemap *map, unsigned int *iterator, dom_node **ret);
+#define get_next_domnamednodemap(m, i, r) _get_next_domnamednodemap( \
+ (dom_namednodemap *) (m), (unsigned int *) (i), (dom_node **) (r))
+
+
+#endif
diff --git a/test/lib/list.c b/test/testutils/list.c
index e72b50c..09a8cfc 100644
--- a/test/lib/list.c
+++ b/test/testutils/list.c
@@ -1,8 +1,9 @@
/*
* This file is part of libdom test suite.
* Licensed under the MIT License,
- * http://www.opensource.org/licenses/mit-license.php
+ * http://www.opensource.org/licenses/mit-license.php
* Copyright 2007 James Shaw <jshaw@netsurf-browser.org>
+ * Copyright 2009 Bo Yang <struggeleyb.nku@gmail.com>
*/
@@ -10,9 +11,12 @@
#include <stdio.h>
#include <stdlib.h>
+#include <dom/core/string.h>
+#include <dom/core/node.h>
+
#include "comparators.h"
#include "list.h"
-#include "testassert.h"
+#include "domtsasserts.h"
/**
* Private helper function.
@@ -28,11 +32,12 @@ struct list_elt* list_new_elt(void* data) {
return elt;
}
-struct list* list_new(void)
+struct list* list_new(TYPE type)
{
struct list* list = malloc(sizeof(struct list));
assert(list != NULL);
list->size = 0;
+ list->type = type;
list->head = NULL;
list->tail = NULL;
return list;
@@ -42,6 +47,10 @@ void list_destroy(struct list* list)
{
struct list_elt* elt = list->head;
while (elt != NULL) {
+ if (list->type == DOM_STRING)
+ dom_string_unref((dom_string *) elt->data);
+ if (list->type == NODE)
+ dom_node_unref(elt->data);
struct list_elt* nextElt = elt->next;
free(elt);
elt = nextElt;
@@ -68,6 +77,10 @@ void list_add(struct list* list, void* data)
/* inc the size of the list */
list->size++;
+ if (list->type == DOM_STRING)
+ dom_string_ref((dom_string *) data);
+ if (list->type == NODE)
+ dom_node_ref(data);
}
bool list_remove(struct list* list, void* data)
@@ -102,7 +115,7 @@ bool list_remove(struct list* list, void* data)
struct list* list_clone(struct list* list)
{
- struct list* newList = list_new();
+ struct list* newList = list_new(list->type);
struct list_elt* elt = list->head;
while (elt != NULL) {
@@ -138,15 +151,19 @@ bool list_contains_all(struct list* superList, struct list* subList,
found = false;
while (superElt != NULL && found == false) {
- if (comparator(subElt->data, superElt->data) == 0) {
+ if (comparator(superElt->data, subElt->data) == 0) {
found = true;
list_remove(superListClone, superElt->data);
+ break;
}
superElt = superElt->next;
}
+ if (found == false)
+ break;
subElt = subElt->next;
}
+
free(superListClone);
return found;
diff --git a/test/lib/list.h b/test/testutils/list.h
index 7c27796..6b0f209 100644
--- a/test/lib/list.h
+++ b/test/testutils/list.h
@@ -12,18 +12,32 @@
#include "comparators.h"
+/* The element type in the list
+ *
+ * The high byte is used for category type
+ * The low byte is used for concrete type
+ */
+typedef enum TYPE {
+ INT = 0x0001,
+ STRING = 0x0100,
+ DOM_STRING = 0x0101,
+ NODE = 0x0200
+} TYPE;
+
+
struct list_elt {
void* data;
struct list_elt* next;
};
-struct list {
+typedef struct list {
unsigned int size;
+ TYPE type;
struct list_elt* head;
struct list_elt* tail;
-};
+} list;
-struct list* list_new(void);
+struct list* list_new(TYPE type);
void list_destroy(struct list* list);
/**
@@ -41,7 +55,6 @@ void list_add(struct list* list, void* data);
bool list_remove(struct list* list, void* data);
struct list* list_clone(struct list* list);
-
/**
* Tests if data is equal to any element in the list.
*/
diff --git a/test/testutils/load.c b/test/testutils/load.c
new file mode 100644
index 0000000..74cc009
--- /dev/null
+++ b/test/testutils/load.c
@@ -0,0 +1,151 @@
+/*
+ * This file is part of libdom test suite.
+ * Licensed under the MIT License,
+ * http://www.opensource.org/licenses/mit-license.php
+ * Copyright 2009 Bo Yang <struggleyb.nku@gmail.com>
+ */
+
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <sys/types.h>
+#include <sys/uio.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#include <libwapcaplet/libwapcaplet.h>
+
+// For parsers
+#include <dom/dom.h>
+#include <xmlparser.h>
+#include <parser.h>
+#include <errors.h>
+
+#include "utils.h"
+
+extern lwc_context *ctx;
+
+/**
+ * Load the file as it is a XML file
+ *
+ * \param file The file path
+ * \param willBeModified Whether this file will be modified, not used
+ */
+dom_document *load_xml(char *file, bool willBeModified)
+{
+ dom_xml_parser *parser = NULL;
+ int handle;
+ int readed;
+ dom_xml_error error;
+ dom_document *ret;
+ char buffer[1024];
+
+ UNUSED(willBeModified);
+
+ parser = dom_xml_parser_create(NULL, NULL,
+ myrealloc, NULL, mymsg, NULL, ctx);
+ if (parser == NULL) {
+ fprintf(stderr, "Can't create XMLParser\n");
+ return NULL;
+ }
+
+ handle = open(file, O_RDONLY);
+ if (handle == -1) {
+ dom_xml_parser_destroy(parser);
+ fprintf(stderr, "Can't open test input file: %s\n", file);
+ return NULL;
+ }
+
+ readed = read(handle, buffer, 1024);
+ error = dom_xml_parser_parse_chunk(parser, buffer, readed);
+ if (error != DOM_XML_OK) {
+ dom_xml_parser_destroy(parser);
+ fprintf(stderr, "Parsing errors occur\n");
+ return NULL;
+ }
+
+ while(readed == 1024) {
+ readed = read(handle, buffer, 1024);
+ error = dom_xml_parser_parse_chunk(parser, buffer, readed);
+ if (error != DOM_XML_OK) {
+ dom_xml_parser_destroy(parser);
+ fprintf(stderr, "Parsing errors occur\n");
+ return NULL;
+ }
+ }
+
+ error = dom_xml_parser_completed(parser);
+ if (error != DOM_XML_OK) {
+ dom_xml_parser_destroy(parser);
+ fprintf(stderr, "Parsing error when construct DOM\n");
+ return NULL;
+ }
+
+ ret = dom_xml_parser_get_document(parser);
+ dom_xml_parser_destroy(parser);
+
+ return ret;
+}
+
+/**
+ * Load the file as it is a HTML file
+ *
+ * \param file The file path
+ * \param willBeModified Whether this file will be modified, not used
+ */
+dom_document *load_html(char *file, bool willBeModified)
+{
+ dom_hubbub_parser *parser = NULL;
+ int handle;
+ int readed;
+ dom_hubbub_error error;
+ dom_document *ret;
+ char buffer[1024];
+
+ UNUSED(willBeModified);
+
+ parser = dom_hubbub_parser_create("data/Aliases", NULL, true,
+ myrealloc, NULL, mymsg, NULL, ctx);
+ if (parser == NULL) {
+ fprintf(stderr, "Can't create XMLParser\n");
+ return NULL;
+ }
+
+ handle = open(file, O_RDONLY);
+ if (handle == -1) {
+ dom_hubbub_parser_destroy(parser);
+ fprintf(stderr, "Can't open test input file: %s\n", file);
+ return NULL;
+ }
+
+ readed = read(handle, buffer, 1024);
+ error = dom_hubbub_parser_parse_chunk(parser, buffer, readed);
+ if (error != DOM_HUBBUB_OK) {
+ dom_hubbub_parser_destroy(parser);
+ fprintf(stderr, "Parsing errors occur\n");
+ return NULL;
+ }
+
+ while(readed == 1024) {
+ readed = read(handle, buffer, 1024);
+ error = dom_hubbub_parser_parse_chunk(parser, buffer, readed);
+ if (error != DOM_HUBBUB_OK) {
+ dom_hubbub_parser_destroy(parser);
+ fprintf(stderr, "Parsing errors occur\n");
+ return NULL;
+ }
+ }
+
+ error = dom_hubbub_parser_completed(parser);
+ if (error != DOM_HUBBUB_OK) {
+ dom_hubbub_parser_destroy(parser);
+ fprintf(stderr, "Parsing error when construct DOM\n");
+ return NULL;
+ }
+
+ ret = dom_hubbub_parser_get_document(parser);
+ dom_hubbub_parser_destroy(parser);
+
+ return ret;
+}
diff --git a/test/lib/utils.c b/test/testutils/utils.c
index 739933f..739933f 100644
--- a/test/lib/utils.c
+++ b/test/testutils/utils.c
diff --git a/test/lib/utils.h b/test/testutils/utils.h
index b57db36..b57db36 100644
--- a/test/lib/utils.h
+++ b/test/testutils/utils.h
diff --git a/test/transform.pl b/test/transform.pl
new file mode 100755
index 0000000..4ab0b46
--- /dev/null
+++ b/test/transform.pl
@@ -0,0 +1,21 @@
+#!/bin/perl
+# This file is part of libdom.
+# It is used to generate libdom test files from the W3C DOMTS.
+#
+# Licensed under the MIT License,
+# http://www.opensource.org/licenses/mit-license.php
+# Author: Bo Yang <struggleyb.nku@gmail.com>
+
+use warnings;
+use strict;
+
+use XML::Parser::PerlSAX;
+use DOMTSHandler;
+
+if ($#ARGV ne 1) {
+ die "Usage: perl transform.pl dtd-file testcase-file";
+}
+
+my $handler = DOMTSHandler->new($ARGV[0]);
+my $parser = XML::Parser::PerlSAX->new(Handler => $handler);
+$parser->parse(Source => {SystemId => "$ARGV[1]"});
diff --git a/test/transform/ctypes.xml b/test/transform/ctypes.xml
deleted file mode 100644
index 579e317..0000000
--- a/test/transform/ctypes.xml
+++ /dev/null
@@ -1,71 +0,0 @@
-<?xml version="1.0" ?>
-<types>
- <primitive idl="int" c="int"/>
- <primitive idl="boolean" c="bool"/>
-
- <type idl="Attr" c="dom_attr"/>
- <type idl="Document" c="dom_document">
- <attribute idl="documentElement" c="document_element"/>
- <method idl="createElement" c="create_element"/>
- <method idl="createDocumentFragment" c="create_document_fragment"/>
- <method idl="createTextNode" c="create_text_node"/>
- <method idl="createComment" c="create_comment"/>
- <method idl="createCDATASection" c="create_cdata_section"/>
- <method idl="createProcessingInstruction" c="create_processing_instruction"/>
- <method idl="createAttribute" c="create_attribute"/>
- <method idl="createEntityReference" c="create_entity_reference"/>
- <method idl="getElementsByTagName" c="get_elements_by_tag_name"/>
-
- </type>
- <type idl="DocumentType" c="dom_document_type">
-
- </type>
- <type idl="DocumentFragment" c="dom_document_fragment">
-
- </type>
- <type idl="DOMString" c="dom_string">
- </type>
- <type idl="Element" c="dom_element">
- <attribute idl="tagName" c="tag_name"/>
- <method idl="getAttribute" c="get_attribute"/>
- <method idl="setAttribute" c="set_attribute"/>
- <method idl="removeAttribute" c="remove_attribute"/>
- <method idl="getAttributeNode" c="get_attribute_node"/>
- <method idl="setAttributeNode" c="set_attribute_node"/>
- <method idl="removeAttributeNode" c="remove_attribute_node"/>
- <method idl="getElementsByTagName" c="get_elements_by_tag_name"/>
- </type>
-
- <type idl="NamedNodeMap" c="dom_namednodemap">
- <method idl="getNamedItem" c="get_named_item"/>
- <method idl="setNamedItem" c="set_named_item"/>
- <method idl="removeNamedItem" c="remove_named_item"/>
- </type>
-
- <type idl="Node" c="dom_node">
- <attribute idl="nodeName" c="node_name"/>
- <attribute idl="nodeValue" c="node_value"/>
- <attribute idl="nodeType" c="node_type">
- <override-type>dom_node_type</override-type>
- </attribute>
- <attribute idl="parentNode" c="parent_node"/>
- <attribute idl="childNodes" c="child_nodes"/>
- <attribute idl="firstChild" c="first_child"/>
- <attribute idl="lastChild" c="last_child"/>
- <attribute idl="previousSibling" c="previous_sibling"/>
- <attribute idl="nextSibling" c="next_sibling"/>
- <attribute idl="ownerDocument" c="owner_document"/>
- <method idl="insertBefore" c="insert_before"/>
- <method idl="replaceChild" c="replace_child"/>
- <method idl="removeChild" c="remove_child"/>
- <method idl="appendChild" c="append_child"/>
- <method idl="hasChildNodes" c="has_child_nodes"/>
- <method idl="cloneNode" c="clone_node"/>
- </type>
-
- <type idl="NodeList" c="dom_nodelist">
- </type>
-
- <type idl="Text" c="dom_text">
- </type>
-</types> \ No newline at end of file
diff --git a/test/transform/string.xsl b/test/transform/string.xsl
deleted file mode 100644
index 7b51102..0000000
--- a/test/transform/string.xsl
+++ /dev/null
@@ -1,1233 +0,0 @@
-<?xml version="1.0"?>
-
-<xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:doc="http://xsltsl.org/xsl/documentation/1.0"
- xmlns:str="http://xsltsl.org/string"
- extension-element-prefixes="doc str">
-
- <doc:reference xmlns="">
- <referenceinfo>
- <releaseinfo role="meta">
- $Id: string.xsl,v 1.13 2004/10/08 06:37:25 balls Exp $
- </releaseinfo>
- <author>
- <surname>Ball</surname>
- <firstname>Steve</firstname>
- </author>
- <copyright>
- <year>2002</year>
- <year>2001</year>
- <holder>Steve Ball</holder>
- </copyright>
- </referenceinfo>
-
- <title>String Processing</title>
-
- <partintro>
- <section>
- <title>Introduction</title>
-
- <para>This module provides templates for manipulating strings.</para>
-
- </section>
- </partintro>
-
- </doc:reference>
-
- <!-- Common string constants and datasets as XSL variables -->
-
- <!-- str:lower and str:upper contain pairs of lower and upper case
- characters. Below insanely long strings should contain the
- official lower/uppercase pairs, making this stylesheet working
- for every language on earth. Hopefully. -->
- <!-- These values are not enough, however. There are some
- exceptions, dealt with below. -->
- <xsl:variable name="xsltsl-str-lower" select="'&#x0061;&#x0062;&#x0063;&#x0064;&#x0065;&#x0066;&#x0067;&#x0068;&#x0069;&#x006A;&#x006B;&#x006C;&#x006D;&#x006E;&#x006F;&#x0070;&#x0071;&#x0072;&#x0073;&#x0074;&#x0075;&#x0076;&#x0077;&#x0078;&#x0079;&#x007A;&#x00B5;&#x00E0;&#x00E1;&#x00E2;&#x00E3;&#x00E4;&#x00E5;&#x00E6;&#x00E7;&#x00E8;&#x00E9;&#x00EA;&#x00EB;&#x00EC;&#x00ED;&#x00EE;&#x00EF;&#x00F0;&#x00F1;&#x00F2;&#x00F3;&#x00F4;&#x00F5;&#x00F6;&#x00F8;&#x00F9;&#x00FA;&#x00FB;&#x00FC;&#x00FD;&#x00FE;&#x00FF;&#x0101;&#x0103;&#x0105;&#x0107;&#x0109;&#x010B;&#x010D;&#x010F;&#x0111;&#x0113;&#x0115;&#x0117;&#x0119;&#x011B;&#x011D;&#x011F;&#x0121;&#x0123;&#x0125;&#x0127;&#x0129;&#x012B;&#x012D;&#x012F;&#x0131;&#x0133;&#x0135;&#x0137;&#x013A;&#x013C;&#x013E;&#x0140;&#x0142;&#x0144;&#x0146;&#x0148;&#x014B;&#x014D;&#x014F;&#x0151;&#x0153;&#x0155;&#x0157;&#x0159;&#x015B;&#x015D;&#x015F;&#x0161;&#x0163;&#x0165;&#x0167;&#x0169;&#x016B;&#x016D;&#x016F;&#x0171;&#x0173;&#x0175;&#x0177;&#x017A;&#x017C;&#x017E;&#x017F;&#x0183;&#x0185;&#x0188;&#x018C;&#x0192;&#x0195;&#x0199;&#x01A1;&#x01A3;&#x01A5;&#x01A8;&#x01AD;&#x01B0;&#x01B4;&#x01B6;&#x01B9;&#x01BD;&#x01BF;&#x01C5;&#x01C6;&#x01C8;&#x01C9;&#x01CB;&#x01CC;&#x01CE;&#x01D0;&#x01D2;&#x01D4;&#x01D6;&#x01D8;&#x01DA;&#x01DC;&#x01DD;&#x01DF;&#x01E1;&#x01E3;&#x01E5;&#x01E7;&#x01E9;&#x01EB;&#x01ED;&#x01EF;&#x01F2;&#x01F3;&#x01F5;&#x01F9;&#x01FB;&#x01FD;&#x01FF;&#x0201;&#x0203;&#x0205;&#x0207;&#x0209;&#x020B;&#x020D;&#x020F;&#x0211;&#x0213;&#x0215;&#x0217;&#x0219;&#x021B;&#x021D;&#x021F;&#x0223;&#x0225;&#x0227;&#x0229;&#x022B;&#x022D;&#x022F;&#x0231;&#x0233;&#x0253;&#x0254;&#x0256;&#x0257;&#x0259;&#x025B;&#x0260;&#x0263;&#x0268;&#x0269;&#x026F;&#x0272;&#x0275;&#x0280;&#x0283;&#x0288;&#x028A;&#x028B;&#x0292;&#x0345;&#x03AC;&#x03AD;&#x03AE;&#x03AF;&#x03B1;&#x03B2;&#x03B3;&#x03B4;&#x03B5;&#x03B6;&#x03B7;&#x03B8;&#x03B9;&#x03BA;&#x03BB;&#x03BC;&#x03BD;&#x03BE;&#x03BF;&#x03C0;&#x03C1;&#x03C2;&#x03C3;&#x03C4;&#x03C5;&#x03C6;&#x03C7;&#x03C8;&#x03C9;&#x03CA;&#x03CB;&#x03CC;&#x03CD;&#x03CE;&#x03D0;&#x03D1;&#x03D5;&#x03D6;&#x03DB;&#x03DD;&#x03DF;&#x03E1;&#x03E3;&#x03E5;&#x03E7;&#x03E9;&#x03EB;&#x03ED;&#x03EF;&#x03F0;&#x03F1;&#x03F2;&#x03F5;&#x0430;&#x0431;&#x0432;&#x0433;&#x0434;&#x0435;&#x0436;&#x0437;&#x0438;&#x0439;&#x043A;&#x043B;&#x043C;&#x043D;&#x043E;&#x043F;&#x0440;&#x0441;&#x0442;&#x0443;&#x0444;&#x0445;&#x0446;&#x0447;&#x0448;&#x0449;&#x044A;&#x044B;&#x044C;&#x044D;&#x044E;&#x044F;&#x0450;&#x0451;&#x0452;&#x0453;&#x0454;&#x0455;&#x0456;&#x0457;&#x0458;&#x0459;&#x045A;&#x045B;&#x045C;&#x045D;&#x045E;&#x045F;&#x0461;&#x0463;&#x0465;&#x0467;&#x0469;&#x046B;&#x046D;&#x046F;&#x0471;&#x0473;&#x0475;&#x0477;&#x0479;&#x047B;&#x047D;&#x047F;&#x0481;&#x048D;&#x048F;&#x0491;&#x0493;&#x0495;&#x0497;&#x0499;&#x049B;&#x049D;&#x049F;&#x04A1;&#x04A3;&#x04A5;&#x04A7;&#x04A9;&#x04AB;&#x04AD;&#x04AF;&#x04B1;&#x04B3;&#x04B5;&#x04B7;&#x04B9;&#x04BB;&#x04BD;&#x04BF;&#x04C2;&#x04C4;&#x04C8;&#x04CC;&#x04D1;&#x04D3;&#x04D5;&#x04D7;&#x04D9;&#x04DB;&#x04DD;&#x04DF;&#x04E1;&#x04E3;&#x04E5;&#x04E7;&#x04E9;&#x04EB;&#x04ED;&#x04EF;&#x04F1;&#x04F3;&#x04F5;&#x04F9;&#x0561;&#x0562;&#x0563;&#x0564;&#x0565;&#x0566;&#x0567;&#x0568;&#x0569;&#x056A;&#x056B;&#x056C;&#x056D;&#x056E;&#x056F;&#x0570;&#x0571;&#x0572;&#x0573;&#x0574;&#x0575;&#x0576;&#x0577;&#x0578;&#x0579;&#x057A;&#x057B;&#x057C;&#x057D;&#x057E;&#x057F;&#x0580;&#x0581;&#x0582;&#x0583;&#x0584;&#x0585;&#x0586;&#x1E01;&#x1E03;&#x1E05;&#x1E07;&#x1E09;&#x1E0B;&#x1E0D;&#x1E0F;&#x1E11;&#x1E13;&#x1E15;&#x1E17;&#x1E19;&#x1E1B;&#x1E1D;&#x1E1F;&#x1E21;&#x1E23;&#x1E25;&#x1E27;&#x1E29;&#x1E2B;&#x1E2D;&#x1E2F;&#x1E31;&#x1E33;&#x1E35;&#x1E37;&#x1E39;&#x1E3B;&#x1E3D;&#x1E3F;&#x1E41;&#x1E43;&#x1E45;&#x1E47;&#x1E49;&#x1E4B;&#x1E4D;&#x1E4F;&#x1E51;&#x1E53;&#x1E55;&#x1E57;&#x1E59;&#x1E5B;&#x1E5D;&#x1E5F;&#x1E61;&#x1E63;&#x1E65;&#x1E67;&#x1E69;&#x1E6B;&#x1E6D;&#x1E6F;&#x1E71;&#x1E73;&#x1E75;&#x1E77;&#x1E79;&#x1E7B;&#x1E7D;&#x1E7F;&#x1E81;&#x1E83;&#x1E85;&#x1E87;&#x1E89;&#x1E8B;&#x1E8D;&#x1E8F;&#x1E91;&#x1E93;&#x1E95;&#x1E9B;&#x1EA1;&#x1EA3;&#x1EA5;&#x1EA7;&#x1EA9;&#x1EAB;&#x1EAD;&#x1EAF;&#x1EB1;&#x1EB3;&#x1EB5;&#x1EB7;&#x1EB9;&#x1EBB;&#x1EBD;&#x1EBF;&#x1EC1;&#x1EC3;&#x1EC5;&#x1EC7;&#x1EC9;&#x1ECB;&#x1ECD;&#x1ECF;&#x1ED1;&#x1ED3;&#x1ED5;&#x1ED7;&#x1ED9;&#x1EDB;&#x1EDD;&#x1EDF;&#x1EE1;&#x1EE3;&#x1EE5;&#x1EE7;&#x1EE9;&#x1EEB;&#x1EED;&#x1EEF;&#x1EF1;&#x1EF3;&#x1EF5;&#x1EF7;&#x1EF9;&#x1F00;&#x1F01;&#x1F02;&#x1F03;&#x1F04;&#x1F05;&#x1F06;&#x1F07;&#x1F10;&#x1F11;&#x1F12;&#x1F13;&#x1F14;&#x1F15;&#x1F20;&#x1F21;&#x1F22;&#x1F23;&#x1F24;&#x1F25;&#x1F26;&#x1F27;&#x1F30;&#x1F31;&#x1F32;&#x1F33;&#x1F34;&#x1F35;&#x1F36;&#x1F37;&#x1F40;&#x1F41;&#x1F42;&#x1F43;&#x1F44;&#x1F45;&#x1F51;&#x1F53;&#x1F55;&#x1F57;&#x1F60;&#x1F61;&#x1F62;&#x1F63;&#x1F64;&#x1F65;&#x1F66;&#x1F67;&#x1F70;&#x1F71;&#x1F72;&#x1F73;&#x1F74;&#x1F75;&#x1F76;&#x1F77;&#x1F78;&#x1F79;&#x1F7A;&#x1F7B;&#x1F7C;&#x1F7D;&#x1F80;&#x1F81;&#x1F82;&#x1F83;&#x1F84;&#x1F85;&#x1F86;&#x1F87;&#x1F90;&#x1F91;&#x1F92;&#x1F93;&#x1F94;&#x1F95;&#x1F96;&#x1F97;&#x1FA0;&#x1FA1;&#x1FA2;&#x1FA3;&#x1FA4;&#x1FA5;&#x1FA6;&#x1FA7;&#x1FB0;&#x1FB1;&#x1FB3;&#x1FBE;&#x1FC3;&#x1FD0;&#x1FD1;&#x1FE0;&#x1FE1;&#x1FE5;&#x1FF3;&#x2170;&#x2171;&#x2172;&#x2173;&#x2174;&#x2175;&#x2176;&#x2177;&#x2178;&#x2179;&#x217A;&#x217B;&#x217C;&#x217D;&#x217E;&#x217F;&#x24D0;&#x24D1;&#x24D2;&#x24D3;&#x24D4;&#x24D5;&#x24D6;&#x24D7;&#x24D8;&#x24D9;&#x24DA;&#x24DB;&#x24DC;&#x24DD;&#x24DE;&#x24DF;&#x24E0;&#x24E1;&#x24E2;&#x24E3;&#x24E4;&#x24E5;&#x24E6;&#x24E7;&#x24E8;&#x24E9;&#xFF41;&#xFF42;&#xFF43;&#xFF44;&#xFF45;&#xFF46;&#xFF47;&#xFF48;&#xFF49;&#xFF4A;&#xFF4B;&#xFF4C;&#xFF4D;&#xFF4E;&#xFF4F;&#xFF50;&#xFF51;&#xFF52;&#xFF53;&#xFF54;&#xFF55;&#xFF56;&#xFF57;&#xFF58;&#xFF59;&#xFF5A;&#x10428;&#x10429;&#x1042A;&#x1042B;&#x1042C;&#x1042D;&#x1042E;&#x1042F;&#x10430;&#x10431;&#x10432;&#x10433;&#x10434;&#x10435;&#x10436;&#x10437;&#x10438;&#x10439;&#x1043A;&#x1043B;&#x1043C;&#x1043D;&#x1043E;&#x1043F;&#x10440;&#x10441;&#x10442;&#x10443;&#x10444;&#x10445;&#x10446;&#x10447;&#x10448;&#x10449;&#x1044A;&#x1044B;&#x1044C;&#x1044D;'"/>
- <xsl:variable name="xsltsl-str-upper" select="'&#x0041;&#x0042;&#x0043;&#x0044;&#x0045;&#x0046;&#x0047;&#x0048;&#x0049;&#x004A;&#x004B;&#x004C;&#x004D;&#x004E;&#x004F;&#x0050;&#x0051;&#x0052;&#x0053;&#x0054;&#x0055;&#x0056;&#x0057;&#x0058;&#x0059;&#x005A;&#x039C;&#x00C0;&#x00C1;&#x00C2;&#x00C3;&#x00C4;&#x00C5;&#x00C6;&#x00C7;&#x00C8;&#x00C9;&#x00CA;&#x00CB;&#x00CC;&#x00CD;&#x00CE;&#x00CF;&#x00D0;&#x00D1;&#x00D2;&#x00D3;&#x00D4;&#x00D5;&#x00D6;&#x00D8;&#x00D9;&#x00DA;&#x00DB;&#x00DC;&#x00DD;&#x00DE;&#x0178;&#x0100;&#x0102;&#x0104;&#x0106;&#x0108;&#x010A;&#x010C;&#x010E;&#x0110;&#x0112;&#x0114;&#x0116;&#x0118;&#x011A;&#x011C;&#x011E;&#x0120;&#x0122;&#x0124;&#x0126;&#x0128;&#x012A;&#x012C;&#x012E;&#x0049;&#x0132;&#x0134;&#x0136;&#x0139;&#x013B;&#x013D;&#x013F;&#x0141;&#x0143;&#x0145;&#x0147;&#x014A;&#x014C;&#x014E;&#x0150;&#x0152;&#x0154;&#x0156;&#x0158;&#x015A;&#x015C;&#x015E;&#x0160;&#x0162;&#x0164;&#x0166;&#x0168;&#x016A;&#x016C;&#x016E;&#x0170;&#x0172;&#x0174;&#x0176;&#x0179;&#x017B;&#x017D;&#x0053;&#x0182;&#x0184;&#x0187;&#x018B;&#x0191;&#x01F6;&#x0198;&#x01A0;&#x01A2;&#x01A4;&#x01A7;&#x01AC;&#x01AF;&#x01B3;&#x01B5;&#x01B8;&#x01BC;&#x01F7;&#x01C4;&#x01C4;&#x01C7;&#x01C7;&#x01CA;&#x01CA;&#x01CD;&#x01CF;&#x01D1;&#x01D3;&#x01D5;&#x01D7;&#x01D9;&#x01DB;&#x018E;&#x01DE;&#x01E0;&#x01E2;&#x01E4;&#x01E6;&#x01E8;&#x01EA;&#x01EC;&#x01EE;&#x01F1;&#x01F1;&#x01F4;&#x01F8;&#x01FA;&#x01FC;&#x01FE;&#x0200;&#x0202;&#x0204;&#x0206;&#x0208;&#x020A;&#x020C;&#x020E;&#x0210;&#x0212;&#x0214;&#x0216;&#x0218;&#x021A;&#x021C;&#x021E;&#x0222;&#x0224;&#x0226;&#x0228;&#x022A;&#x022C;&#x022E;&#x0230;&#x0232;&#x0181;&#x0186;&#x0189;&#x018A;&#x018F;&#x0190;&#x0193;&#x0194;&#x0197;&#x0196;&#x019C;&#x019D;&#x019F;&#x01A6;&#x01A9;&#x01AE;&#x01B1;&#x01B2;&#x01B7;&#x0399;&#x0386;&#x0388;&#x0389;&#x038A;&#x0391;&#x0392;&#x0393;&#x0394;&#x0395;&#x0396;&#x0397;&#x0398;&#x0399;&#x039A;&#x039B;&#x039C;&#x039D;&#x039E;&#x039F;&#x03A0;&#x03A1;&#x03A3;&#x03A3;&#x03A4;&#x03A5;&#x03A6;&#x03A7;&#x03A8;&#x03A9;&#x03AA;&#x03AB;&#x038C;&#x038E;&#x038F;&#x0392;&#x0398;&#x03A6;&#x03A0;&#x03DA;&#x03DC;&#x03DE;&#x03E0;&#x03E2;&#x03E4;&#x03E6;&#x03E8;&#x03EA;&#x03EC;&#x03EE;&#x039A;&#x03A1;&#x03A3;&#x0395;&#x0410;&#x0411;&#x0412;&#x0413;&#x0414;&#x0415;&#x0416;&#x0417;&#x0418;&#x0419;&#x041A;&#x041B;&#x041C;&#x041D;&#x041E;&#x041F;&#x0420;&#x0421;&#x0422;&#x0423;&#x0424;&#x0425;&#x0426;&#x0427;&#x0428;&#x0429;&#x042A;&#x042B;&#x042C;&#x042D;&#x042E;&#x042F;&#x0400;&#x0401;&#x0402;&#x0403;&#x0404;&#x0405;&#x0406;&#x0407;&#x0408;&#x0409;&#x040A;&#x040B;&#x040C;&#x040D;&#x040E;&#x040F;&#x0460;&#x0462;&#x0464;&#x0466;&#x0468;&#x046A;&#x046C;&#x046E;&#x0470;&#x0472;&#x0474;&#x0476;&#x0478;&#x047A;&#x047C;&#x047E;&#x0480;&#x048C;&#x048E;&#x0490;&#x0492;&#x0494;&#x0496;&#x0498;&#x049A;&#x049C;&#x049E;&#x04A0;&#x04A2;&#x04A4;&#x04A6;&#x04A8;&#x04AA;&#x04AC;&#x04AE;&#x04B0;&#x04B2;&#x04B4;&#x04B6;&#x04B8;&#x04BA;&#x04BC;&#x04BE;&#x04C1;&#x04C3;&#x04C7;&#x04CB;&#x04D0;&#x04D2;&#x04D4;&#x04D6;&#x04D8;&#x04DA;&#x04DC;&#x04DE;&#x04E0;&#x04E2;&#x04E4;&#x04E6;&#x04E8;&#x04EA;&#x04EC;&#x04EE;&#x04F0;&#x04F2;&#x04F4;&#x04F8;&#x0531;&#x0532;&#x0533;&#x0534;&#x0535;&#x0536;&#x0537;&#x0538;&#x0539;&#x053A;&#x053B;&#x053C;&#x053D;&#x053E;&#x053F;&#x0540;&#x0541;&#x0542;&#x0543;&#x0544;&#x0545;&#x0546;&#x0547;&#x0548;&#x0549;&#x054A;&#x054B;&#x054C;&#x054D;&#x054E;&#x054F;&#x0550;&#x0551;&#x0552;&#x0553;&#x0554;&#x0555;&#x0556;&#x1E00;&#x1E02;&#x1E04;&#x1E06;&#x1E08;&#x1E0A;&#x1E0C;&#x1E0E;&#x1E10;&#x1E12;&#x1E14;&#x1E16;&#x1E18;&#x1E1A;&#x1E1C;&#x1E1E;&#x1E20;&#x1E22;&#x1E24;&#x1E26;&#x1E28;&#x1E2A;&#x1E2C;&#x1E2E;&#x1E30;&#x1E32;&#x1E34;&#x1E36;&#x1E38;&#x1E3A;&#x1E3C;&#x1E3E;&#x1E40;&#x1E42;&#x1E44;&#x1E46;&#x1E48;&#x1E4A;&#x1E4C;&#x1E4E;&#x1E50;&#x1E52;&#x1E54;&#x1E56;&#x1E58;&#x1E5A;&#x1E5C;&#x1E5E;&#x1E60;&#x1E62;&#x1E64;&#x1E66;&#x1E68;&#x1E6A;&#x1E6C;&#x1E6E;&#x1E70;&#x1E72;&#x1E74;&#x1E76;&#x1E78;&#x1E7A;&#x1E7C;&#x1E7E;&#x1E80;&#x1E82;&#x1E84;&#x1E86;&#x1E88;&#x1E8A;&#x1E8C;&#x1E8E;&#x1E90;&#x1E92;&#x1E94;&#x1E60;&#x1EA0;&#x1EA2;&#x1EA4;&#x1EA6;&#x1EA8;&#x1EAA;&#x1EAC;&#x1EAE;&#x1EB0;&#x1EB2;&#x1EB4;&#x1EB6;&#x1EB8;&#x1EBA;&#x1EBC;&#x1EBE;&#x1EC0;&#x1EC2;&#x1EC4;&#x1EC6;&#x1EC8;&#x1ECA;&#x1ECC;&#x1ECE;&#x1ED0;&#x1ED2;&#x1ED4;&#x1ED6;&#x1ED8;&#x1EDA;&#x1EDC;&#x1EDE;&#x1EE0;&#x1EE2;&#x1EE4;&#x1EE6;&#x1EE8;&#x1EEA;&#x1EEC;&#x1EEE;&#x1EF0;&#x1EF2;&#x1EF4;&#x1EF6;&#x1EF8;&#x1F08;&#x1F09;&#x1F0A;&#x1F0B;&#x1F0C;&#x1F0D;&#x1F0E;&#x1F0F;&#x1F18;&#x1F19;&#x1F1A;&#x1F1B;&#x1F1C;&#x1F1D;&#x1F28;&#x1F29;&#x1F2A;&#x1F2B;&#x1F2C;&#x1F2D;&#x1F2E;&#x1F2F;&#x1F38;&#x1F39;&#x1F3A;&#x1F3B;&#x1F3C;&#x1F3D;&#x1F3E;&#x1F3F;&#x1F48;&#x1F49;&#x1F4A;&#x1F4B;&#x1F4C;&#x1F4D;&#x1F59;&#x1F5B;&#x1F5D;&#x1F5F;&#x1F68;&#x1F69;&#x1F6A;&#x1F6B;&#x1F6C;&#x1F6D;&#x1F6E;&#x1F6F;&#x1FBA;&#x1FBB;&#x1FC8;&#x1FC9;&#x1FCA;&#x1FCB;&#x1FDA;&#x1FDB;&#x1FF8;&#x1FF9;&#x1FEA;&#x1FEB;&#x1FFA;&#x1FFB;&#x1F88;&#x1F89;&#x1F8A;&#x1F8B;&#x1F8C;&#x1F8D;&#x1F8E;&#x1F8F;&#x1F98;&#x1F99;&#x1F9A;&#x1F9B;&#x1F9C;&#x1F9D;&#x1F9E;&#x1F9F;&#x1FA8;&#x1FA9;&#x1FAA;&#x1FAB;&#x1FAC;&#x1FAD;&#x1FAE;&#x1FAF;&#x1FB8;&#x1FB9;&#x1FBC;&#x0399;&#x1FCC;&#x1FD8;&#x1FD9;&#x1FE8;&#x1FE9;&#x1FEC;&#x1FFC;&#x2160;&#x2161;&#x2162;&#x2163;&#x2164;&#x2165;&#x2166;&#x2167;&#x2168;&#x2169;&#x216A;&#x216B;&#x216C;&#x216D;&#x216E;&#x216F;&#x24B6;&#x24B7;&#x24B8;&#x24B9;&#x24BA;&#x24BB;&#x24BC;&#x24BD;&#x24BE;&#x24BF;&#x24C0;&#x24C1;&#x24C2;&#x24C3;&#x24C4;&#x24C5;&#x24C6;&#x24C7;&#x24C8;&#x24C9;&#x24CA;&#x24CB;&#x24CC;&#x24CD;&#x24CE;&#x24CF;&#xFF21;&#xFF22;&#xFF23;&#xFF24;&#xFF25;&#xFF26;&#xFF27;&#xFF28;&#xFF29;&#xFF2A;&#xFF2B;&#xFF2C;&#xFF2D;&#xFF2E;&#xFF2F;&#xFF30;&#xFF31;&#xFF32;&#xFF33;&#xFF34;&#xFF35;&#xFF36;&#xFF37;&#xFF38;&#xFF39;&#xFF3A;&#x10400;&#x10401;&#x10402;&#x10403;&#x10404;&#x10405;&#x10406;&#x10407;&#x10408;&#x10409;&#x1040A;&#x1040B;&#x1040C;&#x1040D;&#x1040E;&#x1040F;&#x10410;&#x10411;&#x10412;&#x10413;&#x10414;&#x10415;&#x10416;&#x10417;&#x10418;&#x10419;&#x1041A;&#x1041B;&#x1041C;&#x1041D;&#x1041E;&#x1041F;&#x10420;&#x10421;&#x10422;&#x10423;&#x10424;&#x10425;'"/>
- <xsl:variable name="xsltsl-str-digits" select="'0123456789'"/>
- <!-- space (#x20) characters, carriage returns, line feeds, or tabs. -->
- <xsl:variable name="xsltsl-str-ws" select="'&#x20;&#x9;&#xD;&#xA;'"/>
-
- <doc:template name="str:to-upper" xmlns="">
- <refpurpose>Make string uppercase</refpurpose>
-
- <refdescription>
- <para>Converts all lowercase letters to uppercase.</para>
- </refdescription>
-
- <refparameter>
- <variablelist>
- <varlistentry>
- <term>text</term>
- <listitem>
- <para>The string to be converted</para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refparameter>
-
- <refreturn>
- <para>Returns string with all uppercase letters.</para>
- </refreturn>
- </doc:template>
-
- <xsl:template name="str:to-upper">
- <xsl:param name="text"/>
-
- <!-- Below exception is extracted from unicode's SpecialCasing.txt
- file. It's the german lowercase "eszett" (the thing looking
- like a greek beta) that's to become "SS" in uppercase (note:
- that are *two* characters, that's why it doesn't fit in the
- list of upper/lowercase characters). There are more
- characters in that file (103, excluding the locale-specific
- ones), but they seemed to be much less used to me and they
- add up to a hellish long stylesheet.... - Reinout -->
- <xsl:param name="modified-text">
- <xsl:call-template name="str:subst">
- <xsl:with-param name="text">
- <xsl:value-of select="$text"/>
- </xsl:with-param>
- <xsl:with-param name="replace">
- <xsl:text>&#x00DF;</xsl:text>
- </xsl:with-param>
- <xsl:with-param name="with">
- <xsl:text>&#x0053;</xsl:text>
- <xsl:text>&#x0053;</xsl:text>
- </xsl:with-param>
- </xsl:call-template>
- </xsl:param>
-
- <xsl:value-of select="translate($modified-text, $xsltsl-str-lower, $xsltsl-str-upper)"/>
- </xsl:template>
-
- <doc:template name="str:to-lower" xmlns="">
- <refpurpose>Make string lowercase</refpurpose>
-
- <refdescription>
- <para>Converts all uppercase letters to lowercase.</para>
- </refdescription>
-
- <refparameter>
- <variablelist>
- <varlistentry>
- <term>text</term>
- <listitem>
- <para>The string to be converted</para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refparameter>
-
- <refreturn>
- <para>Returns string with all lowercase letters.</para>
- </refreturn>
- </doc:template>
-
- <xsl:template name="str:to-lower">
- <xsl:param name="text"/>
-
- <xsl:value-of select="translate($text, $xsltsl-str-upper, $xsltsl-str-lower)"/>
- </xsl:template>
-
- <doc:template name="str:capitalise" xmlns="">
- <refpurpose>Capitalise string</refpurpose>
-
- <refdescription>
- <para>Converts first character of string to an uppercase letter. All remaining characters are converted to lowercase.</para>
- </refdescription>
-
- <refparameter>
- <variablelist>
- <varlistentry>
- <term>text</term>
- <listitem>
- <para>The string to be capitalised</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>all</term>
- <listitem>
- <para>Boolean controlling whether all words in the string are capitalised.</para>
- <para>Default is true.</para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refparameter>
-
- <refreturn>
- <para>Returns string with first character uppcase and all remaining characters lowercase.</para>
- </refreturn>
- </doc:template>
-
- <xsl:template name="str:capitalise">
- <xsl:param name="text"/>
- <xsl:param name="all" select="true()"/>
-
- <xsl:choose>
- <xsl:when test="$all and (contains($text, ' ') or contains($text, ' ') or contains($text, '&#10;'))">
- <xsl:variable name="firstword">
- <xsl:call-template name="str:substring-before-first">
- <xsl:with-param name="text" select="$text"/>
- <xsl:with-param name="chars" select="$xsltsl-str-ws"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:call-template name="str:capitalise">
- <xsl:with-param name="text">
- <xsl:value-of select="$firstword"/>
- </xsl:with-param>
- <xsl:with-param name="all" select="false()"/>
- </xsl:call-template>
- <xsl:value-of select="substring($text, string-length($firstword) + 1, 1)"/>
- <xsl:call-template name="str:capitalise">
- <xsl:with-param name="text">
- <xsl:value-of select="substring($text, string-length($firstword) + 2)"/>
- </xsl:with-param>
- </xsl:call-template>
- </xsl:when>
-
- <xsl:otherwise>
- <xsl:call-template name="str:to-upper">
- <xsl:with-param name="text" select="substring($text, 1, 1)"/>
- </xsl:call-template>
- <xsl:call-template name="str:to-lower">
- <xsl:with-param name="text" select="substring($text, 2)"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <doc:template name="str:to-camelcase" xmlns="">
- <refpurpose>Convert a string to one camelcase word</refpurpose>
-
- <refdescription>
- <para>Converts a string to one lowerCamelCase or UpperCamelCase
- word, depending on the setting of the "upper"
- parameter. UpperCamelCase is also called MixedCase while
- lowerCamelCase is also called just camelCase. The template
- removes any spaces, tabs and slashes, but doesn't deal with
- other punctuation. It's purpose is to convert strings like
- "hollow timber flush door" to a term suitable as identifier or
- XML tag like "HollowTimberFlushDoor".
- </para>
- </refdescription>
-
- <refparameter>
- <variablelist>
- <varlistentry>
- <term>text</term>
- <listitem>
- <para>The string to be capitalised</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>upper</term>
- <listitem>
- <para>Boolean controlling whether the string becomes an
- UpperCamelCase word or a lowerCamelCase word.</para>
- <para>Default is true.</para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refparameter>
-
- <refreturn>
- <para>Returns string with first character uppcase and all remaining characters lowercase.</para>
- </refreturn>
- </doc:template>
-
- <xsl:template name="str:to-camelcase">
- <xsl:param name="text"/>
- <xsl:param name="upper" select="true()"/>
- <!-- First change all 'strange' characters to spaces -->
- <xsl:param name="string-with-only-spaces">
- <xsl:value-of select="translate($text,concat($xsltsl-str-ws,'/'),' ')"/>
- </xsl:param>
- <!-- Then process them -->
- <xsl:param name="before-space-removal">
- <xsl:variable name="firstword">
- <xsl:call-template name="str:substring-before-first">
- <xsl:with-param name="text" select="$string-with-only-spaces"/>
- <xsl:with-param name="chars" select="$xsltsl-str-ws"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:choose>
- <xsl:when test="$upper">
- <xsl:call-template name="str:to-upper">
- <xsl:with-param name="text" select="substring($firstword, 1, 1)"/>
- </xsl:call-template>
- <xsl:call-template name="str:to-lower">
- <xsl:with-param name="text" select="substring($firstword, 2)"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="str:to-lower">
- <xsl:with-param name="text" select="$firstword"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
-
- <xsl:call-template name="str:capitalise">
- <xsl:with-param name="text">
- <xsl:value-of select="substring($string-with-only-spaces, string-length($firstword) + 2)"/>
- </xsl:with-param>
- <xsl:with-param name="all" select="true()"/>
- </xsl:call-template>
- </xsl:param>
- <xsl:value-of select="translate($before-space-removal,' ','')"/>
- </xsl:template>
-
- <doc:template name="str:substring-before-first" xmlns="">
- <refpurpose>String extraction</refpurpose>
-
- <refdescription>
- <para>Extracts the portion of string 'text' which occurs before any of the characters in string 'chars'.</para>
- </refdescription>
-
- <refparameter>
- <variablelist>
- <varlistentry>
- <term>text</term>
- <listitem>
- <para>The string from which to extract a substring.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>chars</term>
- <listitem>
- <para>The string containing characters to find.</para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refparameter>
-
- <refreturn>
- <para>Returns string.</para>
- </refreturn>
- </doc:template>
-
- <xsl:template name="str:substring-before-first">
- <xsl:param name="text"/>
- <xsl:param name="chars"/>
-
- <xsl:choose>
-
- <xsl:when test="string-length($text) = 0"/>
-
- <xsl:when test="string-length($chars) = 0">
- <xsl:value-of select="$text"/>
- </xsl:when>
-
- <xsl:when test="contains($text, substring($chars, 1, 1))">
- <xsl:variable name="this" select="substring-before($text, substring($chars, 1, 1))"/>
- <xsl:variable name="rest">
- <xsl:call-template name="str:substring-before-first">
- <xsl:with-param name="text" select="$text"/>
- <xsl:with-param name="chars" select="substring($chars, 2)"/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:choose>
- <xsl:when test="string-length($this) &lt; string-length($rest)">
- <xsl:value-of select="$this"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$rest"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
-
- <xsl:otherwise>
- <xsl:call-template name="str:substring-before-first">
- <xsl:with-param name="text" select="$text"/>
- <xsl:with-param name="chars" select="substring($chars, 2)"/>
- </xsl:call-template>
- </xsl:otherwise>
-
- </xsl:choose>
- </xsl:template>
-
- <doc:template name="str:substring-after-last" xmlns="">
- <refpurpose>String extraction</refpurpose>
-
- <refdescription>
- <para>Extracts the portion of string 'text' which occurs after the last of the character in string 'chars'.</para>
- </refdescription>
-
- <refparameter>
- <variablelist>
- <varlistentry>
- <term>text</term>
- <listitem>
- <para>The string from which to extract a substring.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>chars</term>
- <listitem>
- <para>The string containing characters to find.</para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refparameter>
-
- <refreturn>
- <para>Returns string.</para>
- </refreturn>
- </doc:template>
-
- <xsl:template name="str:substring-after-last">
- <xsl:param name="text"/>
- <xsl:param name="chars"/>
-
- <xsl:choose>
-
- <xsl:when test="contains($text, $chars)">
- <xsl:variable name="last" select="substring-after($text, $chars)"/>
-
- <xsl:choose>
- <xsl:when test="contains($last, $chars)">
- <xsl:call-template name="str:substring-after-last">
- <xsl:with-param name="text" select="$last"/>
- <xsl:with-param name="chars" select="$chars"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$last"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
-
- <xsl:otherwise>
- <xsl:value-of select="$text"/>
- </xsl:otherwise>
-
- </xsl:choose>
- </xsl:template>
-
- <doc:template name="str:substring-before-last" xmlns="">
- <refpurpose>String extraction</refpurpose>
-
- <refdescription>
- <para>Extracts the portion of string 'text' which occurs before the first character of the last occurance of string 'chars'.</para>
- </refdescription>
-
- <refparameter>
- <variablelist>
- <varlistentry>
- <term>text</term>
- <listitem>
- <para>The string from which to extract a substring.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>chars</term>
- <listitem>
- <para>The string containing characters to find.</para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refparameter>
-
- <refreturn>
- <para>Returns string.</para>
- </refreturn>
- </doc:template>
-
- <xsl:template name="str:substring-before-last">
- <xsl:param name="text"/>
- <xsl:param name="chars"/>
-
- <xsl:choose>
-
- <xsl:when test="string-length($text) = 0"/>
-
- <xsl:when test="string-length($chars) = 0">
- <xsl:value-of select="$text"/>
- </xsl:when>
-
- <xsl:when test="contains($text, $chars)">
- <xsl:call-template name="str:substring-before-last-aux">
- <xsl:with-param name="text" select="$text"/>
- <xsl:with-param name="chars" select="$chars"/>
- </xsl:call-template>
- </xsl:when>
-
- <xsl:otherwise>
- <xsl:value-of select="$text"/>
- </xsl:otherwise>
-
- </xsl:choose>
- </xsl:template>
-
- <xsl:template name="str:substring-before-last-aux">
- <xsl:param name="text"/>
- <xsl:param name="chars"/>
-
- <xsl:choose>
- <xsl:when test="string-length($text) = 0"/>
-
- <xsl:when test="contains($text, $chars)">
- <xsl:variable name="after">
- <xsl:call-template name="str:substring-before-last-aux">
- <xsl:with-param name="text" select="substring-after($text, $chars)"/>
- <xsl:with-param name="chars" select="$chars"/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:value-of select="substring-before($text, $chars)"/>
- <xsl:if test="string-length($after) &gt; 0">
- <xsl:value-of select="$chars"/>
- <xsl:copy-of select="$after"/>
- </xsl:if>
- </xsl:when>
-
- <xsl:otherwise/>
- </xsl:choose>
- </xsl:template>
-
- <doc:template name="str:subst" xmlns="">
- <refpurpose>String substitution</refpurpose>
-
- <refdescription>
- <para>Substitute 'replace' for 'with' in string 'text'.</para>
- </refdescription>
-
- <refparameter>
- <variablelist>
- <varlistentry>
- <term>text</term>
- <listitem>
- <para>The string upon which to perform substitution.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>replace</term>
- <listitem>
- <para>The string to substitute.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>with</term>
- <listitem>
- <para>The string to be substituted.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>disable-output-escaping</term>
- <listitem>
- <para>A value of <literal>yes</literal> indicates that the result should have output escaping disabled. Any other value allows normal escaping of text values. The default is to enable output escaping.</para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refparameter>
-
- <refreturn>
- <para>Returns string.</para>
- </refreturn>
- </doc:template>
-
- <xsl:template name="str:subst">
- <xsl:param name="text"/>
- <xsl:param name="replace"/>
- <xsl:param name="with"/>
- <xsl:param name='disable-output-escaping'>no</xsl:param>
-
- <xsl:choose>
- <xsl:when test="string-length($replace) = 0 and $disable-output-escaping = 'yes'">
- <xsl:value-of select="$text" disable-output-escaping='yes'/>
- </xsl:when>
- <xsl:when test="string-length($replace) = 0">
- <xsl:value-of select="$text"/>
- </xsl:when>
- <xsl:when test="contains($text, $replace)">
-
- <xsl:variable name="before" select="substring-before($text, $replace)"/>
- <xsl:variable name="after" select="substring-after($text, $replace)"/>
-
- <xsl:choose>
- <xsl:when test='$disable-output-escaping = "yes"'>
- <xsl:value-of select="$before" disable-output-escaping="yes"/>
- <xsl:value-of select="$with" disable-output-escaping="yes"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$before"/>
- <xsl:value-of select="$with"/>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:call-template name="str:subst">
- <xsl:with-param name="text" select="$after"/>
- <xsl:with-param name="replace" select="$replace"/>
- <xsl:with-param name="with" select="$with"/>
- <xsl:with-param name="disable-output-escaping" select="$disable-output-escaping"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test='$disable-output-escaping = "yes"'>
- <xsl:value-of select="$text" disable-output-escaping="yes"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$text"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <doc:template name="str:count-substring" xmlns="">
- <refpurpose>Count Substrings</refpurpose>
-
- <refdescription>
- <para>Counts the number of times a substring occurs in a string. This can also counts the number of times a character occurs in a string, since a character is simply a string of length 1.</para>
- </refdescription>
-
- <example>
- <title>Counting Lines</title>
- <programlisting><![CDATA[
-<xsl:call-template name="str:count-substring">
- <xsl:with-param name="text" select="$mytext"/>
- <xsl:with-param name="chars" select="'&#x0a;'"/>
-</xsl:call-template>
-]]></programlisting>
- </example>
-
- <refparameter>
- <variablelist>
- <varlistentry>
- <term>text</term>
- <listitem>
- <para>The source string.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>chars</term>
- <listitem>
- <para>The substring to count.</para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refparameter>
-
- <refreturn>
- <para>Returns a non-negative integer value.</para>
- </refreturn>
- </doc:template>
-
- <xsl:template name="str:count-substring">
- <xsl:param name="text"/>
- <xsl:param name="chars"/>
-
- <xsl:choose>
- <xsl:when test="string-length($text) = 0 or string-length($chars) = 0">
- <xsl:text>0</xsl:text>
- </xsl:when>
- <xsl:when test="contains($text, $chars)">
- <xsl:variable name="remaining">
- <xsl:call-template name="str:count-substring">
- <xsl:with-param name="text" select="substring-after($text, $chars)"/>
- <xsl:with-param name="chars" select="$chars"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:value-of select="$remaining + 1"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>0</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <doc:template name="str:substring-after-at" xmlns="">
- <refpurpose>String extraction</refpurpose>
- <refdescription>
- <para>Extracts the portion of a 'char' delimited 'text' string "array" at a given 'position'.</para>
- </refdescription>
- <refparameter>
- <variablelist>
- <varlistentry>
- <term>text</term>
- <listitem>
- <para>The string from which to extract a substring.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>chars</term>
- <listitem>
- <para>delimiters</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>position</term>
- <listitem>
- <para>position of the elements</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>all</term>
- <listitem>
- <para>If true all of the remaining string is returned, otherwise only the element at the given position is returned. Default: false().</para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refparameter>
- <refreturn>
- <para>Returns string.</para>
- </refreturn>
- </doc:template>
-
-
- <xsl:template name="str:substring-after-at">
- <xsl:param name="text"/>
- <xsl:param name="chars"/>
- <xsl:param name="position"/>
- <xsl:param name="all" select='false()'/>
-
- <xsl:choose>
- <xsl:when test='number($position) = 0 and $all'>
- <xsl:value-of select='$text'/>
- </xsl:when>
- <xsl:when test='number($position) = 0 and not($chars)'>
- <xsl:value-of select='$text'/>
- </xsl:when>
- <xsl:when test='number($position) = 0 and not(contains($text, $chars))'>
- <xsl:value-of select='$text'/>
- </xsl:when>
- <xsl:when test='not(contains($text, $chars))'>
- </xsl:when>
- <xsl:when test="number($position) = 0">
- <xsl:value-of select="substring-before($text, $chars)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="str:substring-after-at">
- <xsl:with-param name="text" select="substring-after($text, $chars)"/>
- <xsl:with-param name="chars" select="$chars"/>
- <xsl:with-param name="all" select="$all"/>
- <xsl:with-param name="position" select="$position - 1"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <doc:template name="str:substring-before-at" xmlns="">
- <refpurpose>String extraction</refpurpose>
- <refdescription>
- <para>Extracts the portion of a 'char' delimited 'text' string "array" at a given 'position' </para>
- </refdescription>
- <refparameter>
- <variablelist>
- <varlistentry>
- <term>text</term>
- <listitem>
- <para>The string from which to extract a substring.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>chars</term>
- <listitem>
- <para>delimiters</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>position</term>
- <listitem>
- <para>position of the elements</para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refparameter>
- <refreturn>
- <para>Returns string.</para>
- </refreturn>
- </doc:template>
-
- <xsl:template name="str:substring-before-at">
- <xsl:param name="text"/>
- <xsl:param name="chars"/>
- <xsl:param name="position"/>
-
- <xsl:choose>
- <xsl:when test="$position &lt;= 0"/>
- <xsl:when test="not(contains($text, $chars))"/>
- <xsl:otherwise>
- <xsl:value-of select='substring-before($text, $chars)'/>
- <xsl:value-of select='$chars'/>
-
- <xsl:call-template name="str:substring-before-at">
- <xsl:with-param name="text" select="substring-after($text, $chars)"/>
- <xsl:with-param name="position" select="$position - 1"/>
- <xsl:with-param name="chars" select="$chars"/>
- </xsl:call-template>
-
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <doc:template name="str:insert-at" xmlns="">
- <refpurpose>String insertion</refpurpose>
- <refdescription>
- <para>Insert 'chars' into "text' at any given "position'</para>
- </refdescription>
- <refparameter>
- <variablelist>
- <varlistentry>
- <term>text</term>
- <listitem>
- <para>The string upon which to perform insertion</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>position</term>
- <listitem>
- <para>the position where insertion will be performed</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>with</term>
- <listitem>
- <para>The string to be inserted</para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refparameter>
- <refreturn>
- <para>Returns string.</para>
- </refreturn>
- </doc:template>
-
- <xsl:template name="str:insert-at">
- <xsl:param name="text"/>
- <xsl:param name="position"/>
- <xsl:param name="chars"/>
-
- <xsl:variable name="firstpart" select="substring($text, 0, $position)"/>
- <xsl:variable name="secondpart" select="substring($text, $position, string-length($text))"/>
-
- <xsl:value-of select="concat($firstpart, $chars, $secondpart)"/>
- </xsl:template>
-
-
- <doc:template name="str:backward" xmlns="">
- <refpurpose>String reversal</refpurpose>
-
- <refdescription>
- <para>Reverse the content of a given string</para>
- </refdescription>
-
- <refparameter>
- <variablelist>
- <varlistentry>
- <term>text</term>
- <listitem>
- <para>The string to be reversed</para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refparameter>
-
- <refreturn>
- <para>Returns string.</para>
- </refreturn>
- </doc:template>
-
- <xsl:template name="str:backward">
- <xsl:param name="text"/>
- <xsl:variable name="mirror">
- <xsl:call-template name="str:build-mirror">
- <xsl:with-param name="text" select="$text"/>
- <xsl:with-param name="position" select="string-length($text)"/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:value-of select="substring($mirror, string-length($text) + 1, string-length($text))"/>
- </xsl:template>
-
- <xsl:template name="str:build-mirror">
- <xsl:param name="text"/>
- <xsl:param name="position"/>
-
- <xsl:choose>
- <xsl:when test="$position &gt; 0">
- <xsl:call-template name="str:build-mirror">
- <xsl:with-param name="text" select="concat($text, substring($text, $position, 1))"/>
- <xsl:with-param name="position" select="$position - 1"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$text"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <doc:template name="str:justify" xmlns="">
- <refpurpose>Format a string</refpurpose>
-
- <refdescription>
- <para>Inserts newlines and spaces into a string to format it as a block of text.</para>
- </refdescription>
-
- <refparameter>
- <variablelist>
- <varlistentry>
- <term>text</term>
- <listitem>
- <para>String to be formatted.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>max</term>
- <listitem>
- <para>Maximum line length.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>indent</term>
- <listitem>
- <para>Number of spaces to insert at the beginning of each line.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>justify</term>
- <listitem>
- <para>Justify left, right or both. Not currently implemented (fixed at "left").</para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refparameter>
-
- <refreturn>
- <para>Formatted block of text.</para>
- </refreturn>
- </doc:template>
-
- <xsl:template name='str:justify'>
- <xsl:param name='text'/>
- <xsl:param name='max' select='"80"'/>
- <xsl:param name='indent' select='"0"'/>
- <xsl:param name='justify' select='"left"'/>
-
- <xsl:choose>
- <xsl:when test='string-length($text) = 0 or $max &lt;= 0'/>
-
- <xsl:when test='string-length($text) > $max and contains($text, " ") and string-length(substring-before($text, " ")) > $max'>
- <xsl:call-template name='str:generate-string'>
- <xsl:with-param name='text' select='" "'/>
- <xsl:with-param name='count' select='$indent'/>
- </xsl:call-template>
- <xsl:value-of select='substring-before($text, " ")'/>
- <xsl:text>
-</xsl:text>
- <xsl:call-template name='str:justify'>
- <xsl:with-param name='text' select='substring-after($text, " ")'/>
- <xsl:with-param name='max' select='$max'/>
- <xsl:with-param name='indent' select='$indent'/>
- <xsl:with-param name='justify' select='$justify'/>
- </xsl:call-template>
- </xsl:when>
-
- <xsl:when test='string-length($text) > $max and contains($text, " ")'>
- <xsl:variable name='first'>
- <xsl:call-template name='str:substring-before-last'>
- <xsl:with-param name='text' select='substring($text, 1, $max)'/>
- <xsl:with-param name='chars' select='" "'/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:call-template name='str:generate-string'>
- <xsl:with-param name='text' select='" "'/>
- <xsl:with-param name='count' select='$indent'/>
- </xsl:call-template>
- <xsl:value-of select='$first'/>
- <xsl:text>
-</xsl:text>
- <xsl:call-template name='str:justify'>
- <xsl:with-param name='text' select='substring($text, string-length($first) + 2)'/>
- <xsl:with-param name='max' select='$max'/>
- <xsl:with-param name='indent' select='$indent'/>
- <xsl:with-param name='justify' select='$justify'/>
- </xsl:call-template>
- </xsl:when>
-
- <xsl:otherwise>
- <xsl:call-template name='str:generate-string'>
- <xsl:with-param name='text' select='" "'/>
- <xsl:with-param name='count' select='$indent'/>
- </xsl:call-template>
- <xsl:value-of select='$text'/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <doc:template name="str:character-first" xmlns="">
- <refpurpose>Find first occurring character in a string</refpurpose>
-
- <refdescription>
- <para>Finds which of the given characters occurs first in a string.</para>
- </refdescription>
-
- <refparameter>
- <variablelist>
- <varlistentry>
- <term>text</term>
- <listitem>
- <para>The source string.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>chars</term>
- <listitem>
- <para>The characters to search for.</para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refparameter>
- </doc:template>
-
- <xsl:template name="str:character-first">
- <xsl:param name="text"/>
- <xsl:param name="chars"/>
-
- <xsl:choose>
- <xsl:when test="string-length($text) = 0 or string-length($chars) = 0"/>
-
- <xsl:when test="contains($text, substring($chars, 1, 1))">
- <xsl:variable name="next-character">
- <xsl:call-template name="str:character-first">
- <xsl:with-param name="text" select="$text"/>
- <xsl:with-param name="chars" select="substring($chars, 2)"/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:choose>
- <xsl:when test="string-length($next-character)">
- <xsl:variable name="first-character-position" select="string-length(substring-before($text, substring($chars, 1, 1)))"/>
- <xsl:variable name="next-character-position" select="string-length(substring-before($text, $next-character))"/>
-
- <xsl:choose>
- <xsl:when test="$first-character-position &lt; $next-character-position">
- <xsl:value-of select="substring($chars, 1, 1)"/>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$next-character"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="substring($chars, 1, 1)"/>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name="str:character-first">
- <xsl:with-param name="text" select="$text"/>
- <xsl:with-param name="chars" select="substring($chars, 2)"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <doc:template name="str:string-match" xmlns="">
- <refpurpose>Match A String To A Pattern</refpurpose>
-
- <refdescription>
- <para>Performs globbing-style pattern matching on a string.</para>
- </refdescription>
-
- <example>
- <title>Match Pattern</title>
- <programlisting><![CDATA[
-<xsl:call-template name="str:string-match">
- <xsl:with-param name="text" select="$mytext"/>
- <xsl:with-param name="pattern" select="'abc*def?g'"/>
-</xsl:call-template>
-]]></programlisting>
- </example>
-
- <refparameter>
- <variablelist>
- <varlistentry>
- <term>text</term>
- <listitem>
- <para>The source string.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>pattern</term>
- <listitem>
- <para>The pattern to match against. Certain characters have special meaning:</para>
- <variablelist>
- <varlistentry>
- <term>*</term>
- <listitem>
- <para>Matches zero or more characters.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>?</term>
- <listitem>
- <para>Matches a single character.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>\</term>
- <listitem>
- <para>Character escape. The next character is taken as a literal character.</para>
- </listitem>
- </varlistentry>
- </variablelist>
- </listitem>
- </varlistentry>
- </variablelist>
- </refparameter>
-
- <refreturn>
- <para>Returns "1" if the string matches the pattern, "0" otherwise.</para>
- </refreturn>
- </doc:template>
-
- <xsl:template name="str:string-match">
- <xsl:param name="text"/>
- <xsl:param name="pattern"/>
-
- <xsl:choose>
- <xsl:when test="$pattern = '*'">
- <!-- Special case: always matches -->
- <xsl:text>1</xsl:text>
- </xsl:when>
- <xsl:when test="string-length($text) = 0 and string-length($pattern) = 0">
- <xsl:text>1</xsl:text>
- </xsl:when>
- <xsl:when test="string-length($text) = 0 or string-length($pattern) = 0">
- <xsl:text>0</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:variable name='before-special'>
- <xsl:call-template name='str:substring-before-first'>
- <xsl:with-param name='text' select='$pattern'/>
- <xsl:with-param name='chars' select='"*?\"'/>
- </xsl:call-template>
- </xsl:variable>
- <xsl:variable name='special'>
- <xsl:call-template name='str:character-first'>
- <xsl:with-param name='text' select='$pattern'/>
- <xsl:with-param name='chars' select='"*?\"'/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:variable name='new-text' select='substring($text, string-length($before-special) + 1)'/>
- <xsl:variable name='new-pattern' select='substring($pattern, string-length($before-special) + 1)'/>
-
- <xsl:choose>
- <xsl:when test="not(starts-with($text, $before-special))">
- <!-- Verbatim characters don't match -->
- <xsl:text>0</xsl:text>
- </xsl:when>
-
- <xsl:when test="$special = '*' and string-length($new-pattern) = 1">
- <xsl:text>1</xsl:text>
- </xsl:when>
- <xsl:when test="$special = '*'">
- <xsl:call-template name='str:match-postfix'>
- <xsl:with-param name='text' select='$new-text'/>
- <xsl:with-param name='pattern' select='substring($new-pattern, 2)'/>
- </xsl:call-template>
- </xsl:when>
-
- <xsl:when test="$special = '?'">
- <xsl:call-template name="str:string-match">
- <xsl:with-param name='text' select='substring($new-text, 2)'/>
- <xsl:with-param name='pattern' select='substring($new-pattern, 2)'/>
- </xsl:call-template>
- </xsl:when>
-
- <xsl:when test="$special = '\' and substring($new-text, 1, 1) = substring($new-pattern, 2, 1)">
- <xsl:call-template name="str:string-match">
- <xsl:with-param name='text' select='substring($new-text, 2)'/>
- <xsl:with-param name='pattern' select='substring($new-pattern, 3)'/>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="$special = '\' and substring($new-text, 1, 1) != substring($new-pattern, 2, 1)">
- <xsl:text>0</xsl:text>
- </xsl:when>
-
- <xsl:otherwise>
- <!-- There were no special characters in the pattern -->
- <xsl:choose>
- <xsl:when test='$text = $pattern'>
- <xsl:text>1</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:text>0</xsl:text>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
- <xsl:template name="str:match-postfix">
- <xsl:param name="text"/>
- <xsl:param name="pattern"/>
-
- <xsl:variable name='result'>
- <xsl:call-template name='str:string-match'>
- <xsl:with-param name='text' select='$text'/>
- <xsl:with-param name='pattern' select='$pattern'/>
- </xsl:call-template>
- </xsl:variable>
-
- <xsl:choose>
- <xsl:when test='$result = "1"'>
- <xsl:value-of select='$result'/>
- </xsl:when>
- <xsl:when test='string-length($text) = 0'>
- <xsl:text>0</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:call-template name='str:match-postfix'>
- <xsl:with-param name='text' select='substring($text, 2)'/>
- <xsl:with-param name='pattern' select='$pattern'/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
-
- </xsl:template>
-
- <doc:template name="str:generate-string" xmlns="">
- <refpurpose>Create A Repeating Sequence of Characters</refpurpose>
-
- <refdescription>
- <para>Repeats a string a given number of times.</para>
- </refdescription>
-
- <refparameter>
- <variablelist>
- <varlistentry>
- <term>text</term>
- <listitem>
- <para>The string to repeat.</para>
- </listitem>
- </varlistentry>
- <varlistentry>
- <term>count</term>
- <listitem>
- <para>The number of times to repeat the string.</para>
- </listitem>
- </varlistentry>
- </variablelist>
- </refparameter>
- </doc:template>
-
- <xsl:template name="str:generate-string">
- <xsl:param name="text"/>
- <xsl:param name="count"/>
-
- <xsl:choose>
- <xsl:when test="string-length($text) = 0 or $count &lt;= 0"/>
- <xsl:otherwise>
- <xsl:value-of select="$text"/>
- <xsl:call-template name="str:generate-string">
- <xsl:with-param name="text" select="$text"/>
- <xsl:with-param name="count" select="$count - 1"/>
- </xsl:call-template>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:template>
-
-</xsl:stylesheet>
-
diff --git a/test/transform/test-to-c.xsl b/test/transform/test-to-c.xsl
deleted file mode 100644
index fd44e93..0000000
--- a/test/transform/test-to-c.xsl
+++ /dev/null
@@ -1,511 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
-This file is part of libdom.
-Licensed under the MIT License,
- http://www.opensource.org/licenses/mit-license.php
-Copyright 2007 James Shaw <jshaw@netsurf-browser.org>
--->
-<!--
-This transform generates C source code from a language independent
-test representation.
--->
-
-<xsl:stylesheet version="1.0"
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- xmlns:str="http://xsltsl.org/string">
-
- <!--
- Import string functions from XSLT Standard Library
- http://xsltsl.sourceforge.net/
- -->
- <xsl:import href="string.xsl"/>
-
- <!--
- The interfaces document is generated from the W3C test suite.
- It contains the signatures of DOM interfaces, their methods
- and attributes
- -->
- <xsl:param name="interfaces-docname">dom1-interfaces.xml</xsl:param>
-
- <xsl:param name="target-uri-base">http://www.w3.org/2001/DOM-Test-Suite/tests/Level-1/</xsl:param>
- <xsl:output method="text" encoding="UTF-8"/>
- <xsl:variable name="domspec" select="document($interfaces-docname)"/>
-
-<xsl:template match="text()" mode="body">
-</xsl:template>
-
-<!--
-for anything that doesn't match another template,
-we expect this the element to be found in the library located
-at $interfaces-docname.
-
-This should either be a <method> or <attribute>. If it is neither,
-we generate an <xsl:message> reporting that the element is not known, then
-terminate.
--->
-<xsl:template match="*" mode="body">
- <xsl:param name="vardefs"/>
- <xsl:param name="throw"/>
- <!-- the element name matched by this template -->
- <xsl:variable name="feature" select="local-name(.)"/>
- <xsl:variable name="interface" select="@interface"/>
-
- <!--
- Try to find a method having the @name of $feature.
- If $interface is defined, make sure search for
- a match on that interface in the $domspec document.
- -->
- <xsl:variable name="method" select="$domspec/library/interface[not($interface) or @name = $interface]/method[@name = $feature]"/>
- <xsl:choose>
- <xsl:when test="$method">
- <xsl:call-template name="produce-method">
- <xsl:with-param name="vardefs" select="$vardefs"/>
- <xsl:with-param name="throw" select="$throw"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:otherwise>
- <!--
- Try to find an attribute having the name of $feature.
- Again, if $interface is defined, restrict the search to
- that interface
- -->
- <xsl:variable name="attribute" select="$domspec/library/interface[not($interface) or @name = $interface]/attribute[@name = $feature]"/>
- <xsl:choose>
- <xsl:when test="$attribute">
- <xsl:call-template name="produce-attribute">
- <xsl:with-param name="vardefs" select="$vardefs"/>
- <xsl:with-param name="throw" select="$throw"/>
- </xsl:call-template>
- </xsl:when>
-
- <xsl:otherwise>
- <xsl:message terminate="yes"><xsl:text>Unrecognized element </xsl:text><xsl:value-of select="local-name(.)"/></xsl:message>
- </xsl:otherwise>
- </xsl:choose>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:text>
- </xsl:text>
-</xsl:template>
-
-<xsl:template match="/">
- <xsl:apply-templates/>
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'test']">
- <xsl:text>int main(int argc, char **argv)
-{
-</xsl:text>
- <xsl:apply-templates mode="body">
- <xsl:with-param name="vardefs" select="*[local-name() = 'var']"/>
- <xsl:with-param name="throw">false</xsl:with-param>
- </xsl:apply-templates>
- <xsl:text> return 0;
-}
-</xsl:text>
-</xsl:template>
-
-<!--
- <package>
-
- Not used.
- -->
-<xsl:template match="*[local-name() = 'package']">
- <xsl:message terminate="yes"><xsl:text>package not implemented</xsl:text></xsl:message>
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'suite']">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'suite.member']">
-</xsl:template>
-
-<!--
-================================================================
-Asserts
-================================================================
--->
-
-<xsl:template match="*[local-name() = 'fail']" mode="body">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'assertNull']" mode="body">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'assertNotNull']" mode="body">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'assertTrue']" mode="body">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'assertFalse']" mode="body">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'assertEquals']" mode="body">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'assertNotEquals']" mode="body">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'assertInstanceOf']" mode="body">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'assertSize']" mode="body">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'assertDOMException']" mode="body">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'assertURIEquals']" mode="body">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'assertDOMException']" mode="body">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'assertImplementationException']" mode="body">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'assertLowerSeverity']" mode="body">
-</xsl:template>
-
-<!--
- <assertEventCount>
-
- Not used.
- -->
-<xsl:template match="*[local-name() = 'assertEventCount']">
- <xsl:message terminate="yes"><xsl:text>assertEventCount not implemented</xsl:text></xsl:message>
-</xsl:template>
-
-<!--
-================================================================
-Statements
-================================================================
--->
-
-<xsl:template match="*[local-name() = 'var']" mode="body">
- <xsl:value-of select="@name"/>
- <xsl:text>
-</xsl:text>
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'assign']">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'increment']">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'decrement']">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'append']">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'plus']">
-</xsl:template>
-
-<!--
- <subtract>
-
- Not used.
- -->
-<xsl:template match="*[local-name() = 'subtract']">
- <xsl:message terminate="yes"><xsl:text>subtract not implemented</xsl:text></xsl:message>
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'mult']">
-</xsl:template>
-
-<!--
- <divide>
-
- Not used.
- -->
-<xsl:template match="*[local-name() = 'divide']">
- <xsl:message terminate="yes"><xsl:text>divide not implemented</xsl:text></xsl:message>
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'load']">
-</xsl:template>
-
-<!--
- <if>
-
- <if>
- <condition ... />
- <statement/>
- ...
- <else/> (optional)
- </if>
-
- -->
-<xsl:template match="*[local-name() = 'if']" mode="body">
- <xsl:param name="vardefs"/>
- <xsl:param name="throw"/>
- <xsl:apply-templates mode="condition-before"/>
- <xsl:text> if (</xsl:text>
- <xsl:apply-templates select="*[1]" mode="condition"/>
- <xsl:text>) {
-</xsl:text>
- <!-- apply body of if -->
- <xsl:apply-templates select="*[position() &gt; 1 and local-name() != 'else']" mode="body">
- <xsl:with-param name="vardefs" select="$vardefs"/>
- <xsl:with-param name="throw" select="$throw"/>
- </xsl:apply-templates>
- <xsl:text>}</xsl:text>
- <!-- there is only ever one <else>, this is just for convenience.
- could replace it with an <xsl:if>, then do a <xsl:apply-templates select="..."> -->
- <xsl:for-each select="*[local-name()='else']">
-<xsl:text> else {
- </xsl:text>
- <xsl:apply-templates mode="body">
- <xsl:with-param name="vardefs" select="$vardefs"/>
- <xsl:with-param name="throw" select="$throw"/>
- </xsl:apply-templates>
- <xsl:text>}</xsl:text>
- </xsl:for-each>
- <xsl:text>
- </xsl:text>
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'while']">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'try']" mode="body">
- <xsl:text> TRY
-</xsl:text>
- <xsl:apply-templates select="*[local-name() != 'catch']" mode="body">
- <xsl:with-param name="vardefs" select="$vardefs"/>
- <xsl:with-param name="throw">true</xsl:with-param>
- </xsl:apply-templates>
- <xsl:text> ENDTRY
-</xsl:text>
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'for-each']">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'comment']">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'return']">
-</xsl:template>
-
-<!--
- <wait>
-
- Not used.
- -->
-<xsl:template match="*[local-name() = 'wait']" mode="body">
- <xsl:message terminate="yes"><xsl:text>wait not implemented</xsl:text></xsl:message>
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'substring']">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'createTempURI']">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'allErrors']">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'allNotifications']">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'operation']">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'key']">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'dst']">
-</xsl:template>
-
-<!--
- <userObj>
-
- Not used.
- -->
-<xsl:template match="*[local-name() = 'userObj']">
- <xsl:message terminate="yes"><xsl:text>userObj not implemented</xsl:text></xsl:message>
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'atEvents']">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'capturedEvents']">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'bubbledEvents']">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'allEvents']">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'allEvents']">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'allEvents']">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'createXPathEvaluator']">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'getResourceURI']">
-</xsl:template>
-
-<!--
-================================================================
-Conditions
-================================================================
--->
-
-<!--
- <same>
-
- Not used.
- -->
-<xsl:template match="*[local-name() = 'same']" mode="condition">
- <xsl:message terminate="yes"><xsl:text>same not implemented</xsl:text></xsl:message>
-</xsl:template>
-
-<!-- set up temporary DOMStrings and stuff here.
-condition-before mode is applied before entering a statement (such as 'if') -->
-<xsl:template match="*[local-name() = 'equals']" mode="condition-before">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'equals']" mode="condition">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'notEquals']" mode="condition">
-</xsl:template>
-
-<!--
- <lessOrEquals>
-
- Not used.
- -->
-<xsl:template match="*[local-name() = 'lessOrEquals']" mode="condition">
- <xsl:message terminate="yes"><xsl:text>lessOrEquals not implemented</xsl:text></xsl:message>
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'greater']" mode="condition">
-</xsl:template>
-
-<!--
- <greaterOrEquals>
-
- Not used.
- -->
-<xsl:template match="*[local-name() = 'greaterOrEquals']" mode="condition">
- <xsl:message terminate="yes"><xsl:text>greaterOrEquals not implemented</xsl:text></xsl:message>
-</xsl:template>
-
-<!--
- <isNull>
-
- Not used.
- -->
-<xsl:template match="*[local-name() = 'isNull']" mode="condition">
- <xsl:message terminate="yes"><xsl:text>isNull not implemented</xsl:text></xsl:message>
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'notNull']" mode="condition">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'and']" mode="condition">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'or']" mode="condition">
- (<xsl:apply-templates select="*[1]" mode="condition"/>
- <xsl:for-each select="*[position() &gt; 1]">
- <xsl:text> | </xsl:text>
- <xsl:apply-templates select="." mode="condition"/>
- </xsl:for-each>)
-</xsl:template>
-
-<!--
- <xor>
-
- Not used.
- -->
-<xsl:template match="*[local-name() = 'xor']" mode="condition">
- <xsl:message terminate="yes"><xsl:text>xor not implemented</xsl:text></xsl:message>
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'not']" mode="condition">
-</xsl:template>
-
-<!--
- <instanceOf>
-
- Not used.
- -->
-<xsl:template match="*[local-name() = 'instanceOf']" mode="condition">
- <xsl:message terminate="yes"><xsl:text>instanceOf not implemented</xsl:text></xsl:message>
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'isTrue']" mode="condition">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'isFalse']" mode="condition">
-</xsl:template>
-
-<!--
- <hasSize>
-
- Not used.
- -->
-<xsl:template match="*[local-name() = 'hasSize']" mode="condition">
- <xsl:message terminate="yes"><xsl:text>hasSize not implemented</xsl:text></xsl:message>
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'contentType']">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'contains']">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'hasFeature']">
-</xsl:template>
-
-<xsl:template match="*[local-name() = 'implementationAttribute']">
-</xsl:template>
-
-
-<!--
-================================================================
-Helper templates
-================================================================
--->
-
-<xsl:template name="produce-type">
- <xsl:param name="type"/>
-</xsl:template>
-
-<xsl:template name="produce-attribute">
- <xsl:param name="vardefs"/>
- <xsl:variable name="attributeName" select="local-name(.)"/>
- <xsl:choose>
- <!-- if interface is specified -->
- <xsl:when test="@interface">
- </xsl:when>
- <xsl:otherwise>
- </xsl:otherwise>
- </xsl:choose>
-
-</xsl:template>
-
-<xsl:template name="produce-method">
- <xsl:param name="vardefs"/>
- <xsl:variable name="methodName" select="local-name(.)"/>
- <xsl:choose>
- <!-- if interface is specified -->
- <xsl:when test="@interface">
- </xsl:when>
- <xsl:otherwise>
- </xsl:otherwise>
- </xsl:choose>
-</xsl:template>
-
-</xsl:stylesheet>
diff --git a/test/xml/tests/dom1.dtd b/test/xml/tests/dom1.dtd
deleted file mode 100644
index ad7492d..0000000
--- a/test/xml/tests/dom1.dtd
+++ /dev/null
@@ -1,2500 +0,0 @@
-
-<!--
- Copyright (c) 2001-2004 World Wide Web Consortium,
- (Massachusetts Institute of Technology, Institut National de
- Recherche en Informatique et en Automatique, Keio University). All
- Rights Reserved. This program is distributed under the W3C's Software
- Intellectual Property License. This program is distributed in the
- hope that it will be useful, but WITHOUT ANY WARRANTY; without even
- the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
- PURPOSE.
- See W3C License http://www.w3.org/Consortium/Legal/ for more details.
-
-This schema was generated from by dom-to-dtd.xsl.
-
--->
-
-<!ENTITY % framework-assertion "fail|assertTrue|assertFalse|assertNull|assertNotNull|assertEquals|assertNotEquals|assertSame|assertInstanceOf|assertSize|assertEventCount|assertURIEquals|assertImplementationException">
-
-<!ENTITY % framework-statement "assign|increment|decrement|append|plus|subtract|mult|divide|load|implementation|hasFeature|implementationAttribute|if|while|try|for-each|comment|return|userObj|atEvents|capturedEvents|bubbledEvents|allEvents|createXPathEvaluator|getResourceURI|substring|createTempURI|DOMImplementationRegistry.newInstance|allErrors|assertLowerSeverity|allNotifications|operation|key|dst">
-
-<!ENTITY % implementation-condition "hasFeature | implementationAttribute">
-
-<!ENTITY % condition "same|equals|notEquals|less|lessOrEquals|greater|greaterOrEquals|isNull|notNull|and|or|xor|not|instanceOf|isTrue|isFalse|hasSize|contentType|contains| %implementation-condition;">
-
-<!ENTITY % assertion "%framework-assertion;| assertDOMException" >
-<!ENTITY % variable-type "int|short|double|boolean|DOMString|List|Collection|EventMonitor|DOMErrorMonitor|UserDataMonitor|UserDataNotification|Attr|CDATASection|CharacterData|Comment|Document|DocumentFragment|DocumentType|DOMImplementation|Element|Entity|EntityReference|HTMLAnchorElement|HTMLAppletElement|HTMLAreaElement|HTMLBaseElement|HTMLBaseFontElement|HTMLBodyElement|HTMLBRElement|HTMLButtonElement|HTMLCollection|HTMLDirectoryElement|HTMLDivElement|HTMLDListElement|HTMLDocument|HTMLElement|HTMLFieldSetElement|HTMLFontElement|HTMLFormElement|HTMLFrameElement|HTMLFrameSetElement|HTMLHeadElement|HTMLHeadingElement|HTMLHRElement|HTMLHtmlElement|HTMLIFrameElement|HTMLImageElement|HTMLInputElement|HTMLIsIndexElement|HTMLLabelElement|HTMLLegendElement|HTMLLIElement|HTMLLinkElement|HTMLMapElement|HTMLMenuElement|HTMLMetaElement|HTMLModElement|HTMLObjectElement|HTMLOListElement|HTMLOptGroupElement|HTMLOptionElement|HTMLParagraphElement|HTMLParamElement|HTMLPreElement|HTMLQuoteElement|HTMLScriptElement|HTMLSelectElement|HTMLStyleElement|HTMLTableCaptionElement|HTMLTableCellElement|HTMLTableColElement|HTMLTableElement|HTMLTableRowElement|HTMLTableSectionElement|HTMLTextAreaElement|HTMLTitleElement|HTMLUListElement|NamedNodeMap|Node|NodeList|Notation|ProcessingInstruction|Text">
-<!ENTITY % statement "%framework-statement;|%assertion; | abbr | accept | acceptCharset | accessKey | action | align | aLink | alt | anchors | applets | archive | areas | attributes | axis | background | bgColor | body | border | caption | cellIndex | cellPadding | cells | cellSpacing | ch | charset | checked | childNodes | chOff | cite | className | clear | code | codeBase | codeType | color | cols | colSpan | compact | content | cookie | coords | data | dateTime | declare | defaultChecked | defaultSelected | defaultValue | defer | dir | disabled | doctype | documentElement | domain | elements | enctype | entities | event | face | firstChild | form | forms | frame | frameBorder | headers | height | href | hreflang | hspace | htmlFor | httpEquiv | id | images | implementation | index | isMap | label | lang | lastChild | length | link | links | longDesc | lowSrc | marginHeight | marginWidth | maxLength | media | method | multiple | name | nextSibling | nodeName | nodeType | nodeValue | noHref | noResize | noShade | notationName | notations | noWrap | object | options | ownerDocument | parentNode | previousSibling | profile | prompt | publicId | readOnly | referrer | rel | rev | rowIndex | rows | rowSpan | rules | scheme | scope | scrolling | sectionRowIndex | selected | selectedIndex | shape | size | span | specified | src | standby | start | summary | systemId | tabIndex | tagName | target | tBodies | text | tFoot | tHead | title | type | URL | useMap | vAlign | value | valueType | version | vLink | vspace | width | add | appendChild | appendData | blur | click | cloneNode | close | createAttribute | createCaption | createCDATASection | createComment | createDocumentFragment | createElement | createEntityReference | createProcessingInstruction | createTextNode | createTFoot | createTHead | deleteCaption | deleteCell | deleteData | deleteRow | deleteTFoot | deleteTHead | focus | getAttribute | getAttributeNode | getElementById | getElementsByName | getElementsByTagName | getNamedItem | hasChildNodes | hasFeature | insertBefore | insertCell | insertData | insertRow | item | namedItem | normalize | open | remove | removeAttribute | removeAttributeNode | removeChild | removeNamedItem | replaceChild | replaceData | reset | select | setAttribute | setAttributeNode | setNamedItem | splitText | submit | substringData | write | writeln ">
-<!ELEMENT assertDOMException (metadata?,(INDEX_SIZE_ERR|DOMSTRING_SIZE_ERR|HIERARCHY_REQUEST_ERR|WRONG_DOCUMENT_ERR|INVALID_CHARACTER_ERR|NO_DATA_ALLOWED_ERR|NO_MODIFICATION_ALLOWED_ERR|NOT_FOUND_ERR|NOT_SUPPORTED_ERR|INUSE_ATTRIBUTE_ERR))>
-<!ATTLIST assertDOMException id ID #REQUIRED>
-<!ELEMENT INDEX_SIZE_ERR ( substringData | insertData | deleteData | replaceData | splitText ) >
-<!ELEMENT DOMSTRING_SIZE_ERR ( nodeValue | data | substringData ) >
-<!ELEMENT HIERARCHY_REQUEST_ERR ( insertBefore | replaceChild | appendChild ) >
-<!ELEMENT WRONG_DOCUMENT_ERR ( insertBefore | replaceChild | appendChild | setNamedItem | setAttributeNode ) >
-<!ELEMENT INVALID_CHARACTER_ERR ( createElement | createProcessingInstruction | createAttribute | createEntityReference | setAttribute ) >
-<!ELEMENT NO_DATA_ALLOWED_ERR EMPTY >
-<!ELEMENT NO_MODIFICATION_ALLOWED_ERR ( nodeValue | data | value | data | insertBefore | replaceChild | removeChild | appendChild | setNamedItem | removeNamedItem | appendData | insertData | deleteData | replaceData | setAttribute | removeAttribute | setAttributeNode | removeAttributeNode | splitText ) >
-<!ELEMENT NOT_FOUND_ERR ( insertBefore | replaceChild | removeChild | removeNamedItem | removeAttributeNode ) >
-<!ELEMENT NOT_SUPPORTED_ERR ( createCDATASection | createProcessingInstruction | createEntityReference ) >
-<!ELEMENT INUSE_ATTRIBUTE_ERR ( setNamedItem | setAttributeNode ) >
-
-
-
-<!ELEMENT abbr EMPTY>
-<!ATTLIST abbr
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLTableCellElement ) #IMPLIED>
-
-
-<!ELEMENT accept EMPTY>
-<!ATTLIST accept
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLInputElement ) #IMPLIED>
-
-
-<!ELEMENT acceptCharset EMPTY>
-<!ATTLIST acceptCharset
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLFormElement ) #IMPLIED>
-
-
-<!ELEMENT accessKey EMPTY>
-<!ATTLIST accessKey
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLInputElement | HTMLTextAreaElement | HTMLButtonElement | HTMLLabelElement | HTMLLegendElement | HTMLAnchorElement | HTMLAreaElement ) #REQUIRED>
-
-
-<!ELEMENT action EMPTY>
-<!ATTLIST action
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLFormElement ) #IMPLIED>
-
-
-<!ELEMENT align EMPTY>
-<!ATTLIST align
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLInputElement | HTMLLegendElement | HTMLDivElement | HTMLParagraphElement | HTMLHeadingElement | HTMLHRElement | HTMLImageElement | HTMLObjectElement | HTMLAppletElement | HTMLTableElement | HTMLTableCaptionElement | HTMLTableColElement | HTMLTableSectionElement | HTMLTableRowElement | HTMLTableCellElement | HTMLIFrameElement ) #REQUIRED>
-
-
-<!ELEMENT aLink EMPTY>
-<!ATTLIST aLink
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLBodyElement ) #IMPLIED>
-
-
-<!ELEMENT alt EMPTY>
-<!ATTLIST alt
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLInputElement | HTMLImageElement | HTMLAppletElement | HTMLAreaElement ) #REQUIRED>
-
-
-<!ELEMENT anchors EMPTY>
-<!ATTLIST anchors
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( HTMLDocument ) #IMPLIED>
-
-
-<!ELEMENT applets EMPTY>
-<!ATTLIST applets
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( HTMLDocument ) #IMPLIED>
-
-
-<!ELEMENT archive EMPTY>
-<!ATTLIST archive
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLObjectElement | HTMLAppletElement ) #REQUIRED>
-
-
-<!ELEMENT areas EMPTY>
-<!ATTLIST areas
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( HTMLMapElement ) #IMPLIED>
-
-
-<!ELEMENT attributes EMPTY>
-<!ATTLIST attributes
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( Node ) #IMPLIED>
-
-
-<!ELEMENT axis EMPTY>
-<!ATTLIST axis
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLTableCellElement ) #IMPLIED>
-
-
-<!ELEMENT background EMPTY>
-<!ATTLIST background
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLBodyElement ) #IMPLIED>
-
-
-<!ELEMENT bgColor EMPTY>
-<!ATTLIST bgColor
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLBodyElement | HTMLTableElement | HTMLTableRowElement | HTMLTableCellElement ) #REQUIRED>
-
-
-<!ELEMENT body EMPTY>
-<!ATTLIST body
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLDocument ) #IMPLIED>
-
-
-<!ELEMENT border EMPTY>
-<!ATTLIST border
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLImageElement | HTMLObjectElement | HTMLTableElement ) #REQUIRED>
-
-
-<!ELEMENT caption EMPTY>
-<!ATTLIST caption
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLTableElement ) #IMPLIED>
-
-
-<!ELEMENT cellIndex EMPTY>
-<!ATTLIST cellIndex
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLTableCellElement ) #IMPLIED>
-
-
-<!ELEMENT cellPadding EMPTY>
-<!ATTLIST cellPadding
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLTableElement ) #IMPLIED>
-
-
-<!ELEMENT cells EMPTY>
-<!ATTLIST cells
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLTableRowElement ) #IMPLIED>
-
-
-<!ELEMENT cellSpacing EMPTY>
-<!ATTLIST cellSpacing
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLTableElement ) #IMPLIED>
-
-
-<!ELEMENT ch EMPTY>
-<!ATTLIST ch
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLTableColElement | HTMLTableSectionElement | HTMLTableRowElement | HTMLTableCellElement ) #REQUIRED>
-
-
-<!ELEMENT charset EMPTY>
-<!ATTLIST charset
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLLinkElement | HTMLAnchorElement | HTMLScriptElement ) #REQUIRED>
-
-
-<!ELEMENT checked EMPTY>
-<!ATTLIST checked
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLInputElement ) #IMPLIED>
-
-
-<!ELEMENT childNodes EMPTY>
-<!ATTLIST childNodes
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( Node ) #IMPLIED>
-
-
-<!ELEMENT chOff EMPTY>
-<!ATTLIST chOff
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLTableColElement | HTMLTableSectionElement | HTMLTableRowElement | HTMLTableCellElement ) #REQUIRED>
-
-
-<!ELEMENT cite EMPTY>
-<!ATTLIST cite
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLQuoteElement | HTMLModElement ) #REQUIRED>
-
-
-<!ELEMENT className EMPTY>
-<!ATTLIST className
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLElement ) #IMPLIED>
-
-
-<!ELEMENT clear EMPTY>
-<!ATTLIST clear
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLBRElement ) #IMPLIED>
-
-
-<!ELEMENT code EMPTY>
-<!ATTLIST code
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLObjectElement | HTMLAppletElement ) #REQUIRED>
-
-
-<!ELEMENT codeBase EMPTY>
-<!ATTLIST codeBase
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLObjectElement | HTMLAppletElement ) #REQUIRED>
-
-
-<!ELEMENT codeType EMPTY>
-<!ATTLIST codeType
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLObjectElement ) #IMPLIED>
-
-
-<!ELEMENT color EMPTY>
-<!ATTLIST color
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLBaseFontElement | HTMLFontElement ) #REQUIRED>
-
-
-<!ELEMENT cols EMPTY>
-<!ATTLIST cols
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLTextAreaElement | HTMLFrameSetElement ) #REQUIRED>
-
-
-<!ELEMENT colSpan EMPTY>
-<!ATTLIST colSpan
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLTableCellElement ) #IMPLIED>
-
-
-<!ELEMENT compact EMPTY>
-<!ATTLIST compact
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLUListElement | HTMLOListElement | HTMLDListElement | HTMLDirectoryElement | HTMLMenuElement ) #REQUIRED>
-
-
-<!ELEMENT content EMPTY>
-<!ATTLIST content
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLMetaElement ) #IMPLIED>
-
-
-<!ELEMENT cookie EMPTY>
-<!ATTLIST cookie
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLDocument ) #IMPLIED>
-
-
-<!ELEMENT coords EMPTY>
-<!ATTLIST coords
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLAnchorElement | HTMLAreaElement ) #REQUIRED>
-
-
-<!ELEMENT data EMPTY>
-<!ATTLIST data
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( CharacterData | ProcessingInstruction | HTMLObjectElement | UserDataNotification ) #REQUIRED>
-
-
-<!ELEMENT dateTime EMPTY>
-<!ATTLIST dateTime
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLModElement ) #IMPLIED>
-
-
-<!ELEMENT declare EMPTY>
-<!ATTLIST declare
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLObjectElement ) #IMPLIED>
-
-
-<!ELEMENT defaultChecked EMPTY>
-<!ATTLIST defaultChecked
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLInputElement ) #IMPLIED>
-
-
-<!ELEMENT defaultSelected EMPTY>
-<!ATTLIST defaultSelected
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLOptionElement ) #IMPLIED>
-
-
-<!ELEMENT defaultValue EMPTY>
-<!ATTLIST defaultValue
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLInputElement | HTMLTextAreaElement ) #REQUIRED>
-
-
-<!ELEMENT defer EMPTY>
-<!ATTLIST defer
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLScriptElement ) #IMPLIED>
-
-
-<!ELEMENT dir EMPTY>
-<!ATTLIST dir
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLElement ) #IMPLIED>
-
-
-<!ELEMENT disabled EMPTY>
-<!ATTLIST disabled
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLLinkElement | HTMLStyleElement | HTMLSelectElement | HTMLOptGroupElement | HTMLOptionElement | HTMLInputElement | HTMLTextAreaElement | HTMLButtonElement ) #REQUIRED>
-
-
-<!ELEMENT doctype EMPTY>
-<!ATTLIST doctype
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( Document ) #IMPLIED>
-
-
-<!ELEMENT documentElement EMPTY>
-<!ATTLIST documentElement
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( Document ) #IMPLIED>
-
-
-<!ELEMENT domain EMPTY>
-<!ATTLIST domain
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( HTMLDocument ) #IMPLIED>
-
-
-<!ELEMENT elements EMPTY>
-<!ATTLIST elements
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( HTMLFormElement ) #IMPLIED>
-
-
-<!ELEMENT enctype EMPTY>
-<!ATTLIST enctype
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLFormElement ) #IMPLIED>
-
-
-<!ELEMENT entities EMPTY>
-<!ATTLIST entities
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( DocumentType ) #IMPLIED>
-
-
-<!ELEMENT event EMPTY>
-<!ATTLIST event
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLScriptElement ) #IMPLIED>
-
-
-<!ELEMENT face EMPTY>
-<!ATTLIST face
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLBaseFontElement | HTMLFontElement ) #REQUIRED>
-
-
-<!ELEMENT firstChild EMPTY>
-<!ATTLIST firstChild
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( Node ) #IMPLIED>
-
-
-<!ELEMENT form EMPTY>
-<!ATTLIST form
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( HTMLIsIndexElement | HTMLSelectElement | HTMLOptionElement | HTMLInputElement | HTMLTextAreaElement | HTMLButtonElement | HTMLLabelElement | HTMLFieldSetElement | HTMLLegendElement | HTMLObjectElement ) #REQUIRED>
-
-
-<!ELEMENT forms EMPTY>
-<!ATTLIST forms
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( HTMLDocument ) #IMPLIED>
-
-
-<!ELEMENT frame EMPTY>
-<!ATTLIST frame
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLTableElement ) #IMPLIED>
-
-
-<!ELEMENT frameBorder EMPTY>
-<!ATTLIST frameBorder
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLFrameElement | HTMLIFrameElement ) #REQUIRED>
-
-
-<!ELEMENT headers EMPTY>
-<!ATTLIST headers
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLTableCellElement ) #IMPLIED>
-
-
-<!ELEMENT height EMPTY>
-<!ATTLIST height
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLImageElement | HTMLObjectElement | HTMLAppletElement | HTMLTableCellElement | HTMLIFrameElement ) #REQUIRED>
-
-
-<!ELEMENT href EMPTY>
-<!ATTLIST href
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLLinkElement | HTMLBaseElement | HTMLAnchorElement | HTMLAreaElement ) #REQUIRED>
-
-
-<!ELEMENT hreflang EMPTY>
-<!ATTLIST hreflang
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLLinkElement | HTMLAnchorElement ) #REQUIRED>
-
-
-<!ELEMENT hspace EMPTY>
-<!ATTLIST hspace
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLImageElement | HTMLObjectElement | HTMLAppletElement ) #REQUIRED>
-
-
-<!ELEMENT htmlFor EMPTY>
-<!ATTLIST htmlFor
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLLabelElement | HTMLScriptElement ) #REQUIRED>
-
-
-<!ELEMENT httpEquiv EMPTY>
-<!ATTLIST httpEquiv
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLMetaElement ) #IMPLIED>
-
-
-<!ELEMENT id EMPTY>
-<!ATTLIST id
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLElement ) #IMPLIED>
-
-
-<!ELEMENT images EMPTY>
-<!ATTLIST images
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( HTMLDocument ) #IMPLIED>
-
-
-<!ELEMENT index EMPTY>
-<!ATTLIST index
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLOptionElement ) #IMPLIED>
-
-
-<!ELEMENT isMap EMPTY>
-<!ATTLIST isMap
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLImageElement ) #IMPLIED>
-
-
-<!ELEMENT label EMPTY>
-<!ATTLIST label
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLOptGroupElement | HTMLOptionElement ) #REQUIRED>
-
-
-<!ELEMENT lang EMPTY>
-<!ATTLIST lang
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLElement ) #IMPLIED>
-
-
-<!ELEMENT lastChild EMPTY>
-<!ATTLIST lastChild
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( Node ) #IMPLIED>
-
-
-<!ELEMENT length EMPTY>
-<!ATTLIST length
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( NodeList | NamedNodeMap | CharacterData | HTMLCollection | HTMLFormElement | HTMLSelectElement | DOMString ) #REQUIRED>
-
-
-<!ELEMENT link EMPTY>
-<!ATTLIST link
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLBodyElement ) #IMPLIED>
-
-
-<!ELEMENT links EMPTY>
-<!ATTLIST links
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( HTMLDocument ) #IMPLIED>
-
-
-<!ELEMENT longDesc EMPTY>
-<!ATTLIST longDesc
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLImageElement | HTMLFrameElement | HTMLIFrameElement ) #REQUIRED>
-
-
-<!ELEMENT lowSrc EMPTY>
-<!ATTLIST lowSrc
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLImageElement ) #IMPLIED>
-
-
-<!ELEMENT marginHeight EMPTY>
-<!ATTLIST marginHeight
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLFrameElement | HTMLIFrameElement ) #REQUIRED>
-
-
-<!ELEMENT marginWidth EMPTY>
-<!ATTLIST marginWidth
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLFrameElement | HTMLIFrameElement ) #REQUIRED>
-
-
-<!ELEMENT maxLength EMPTY>
-<!ATTLIST maxLength
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLInputElement ) #IMPLIED>
-
-
-<!ELEMENT media EMPTY>
-<!ATTLIST media
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLLinkElement | HTMLStyleElement ) #REQUIRED>
-
-
-<!ELEMENT method EMPTY>
-<!ATTLIST method
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLFormElement ) #IMPLIED>
-
-
-<!ELEMENT multiple EMPTY>
-<!ATTLIST multiple
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLSelectElement ) #IMPLIED>
-
-
-<!ELEMENT name EMPTY>
-<!ATTLIST name
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( Attr | DocumentType | HTMLMetaElement | HTMLFormElement | HTMLSelectElement | HTMLInputElement | HTMLTextAreaElement | HTMLButtonElement | HTMLAnchorElement | HTMLImageElement | HTMLObjectElement | HTMLParamElement | HTMLAppletElement | HTMLMapElement | HTMLFrameElement | HTMLIFrameElement ) #REQUIRED>
-
-
-<!ELEMENT nextSibling EMPTY>
-<!ATTLIST nextSibling
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( Node ) #IMPLIED>
-
-
-<!ELEMENT nodeName EMPTY>
-<!ATTLIST nodeName
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( Node ) #IMPLIED>
-
-
-<!ELEMENT nodeType EMPTY>
-<!ATTLIST nodeType
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( Node ) #IMPLIED>
-
-
-<!ELEMENT nodeValue EMPTY>
-<!ATTLIST nodeValue
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( Node ) #IMPLIED>
-
-
-<!ELEMENT noHref EMPTY>
-<!ATTLIST noHref
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLAreaElement ) #IMPLIED>
-
-
-<!ELEMENT noResize EMPTY>
-<!ATTLIST noResize
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLFrameElement ) #IMPLIED>
-
-
-<!ELEMENT noShade EMPTY>
-<!ATTLIST noShade
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLHRElement ) #IMPLIED>
-
-
-<!ELEMENT notationName EMPTY>
-<!ATTLIST notationName
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( Entity ) #IMPLIED>
-
-
-<!ELEMENT notations EMPTY>
-<!ATTLIST notations
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( DocumentType ) #IMPLIED>
-
-
-<!ELEMENT noWrap EMPTY>
-<!ATTLIST noWrap
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLTableCellElement ) #IMPLIED>
-
-
-<!ELEMENT object EMPTY>
-<!ATTLIST object
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLAppletElement ) #IMPLIED>
-
-
-<!ELEMENT options EMPTY>
-<!ATTLIST options
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( HTMLSelectElement ) #IMPLIED>
-
-
-<!ELEMENT ownerDocument EMPTY>
-<!ATTLIST ownerDocument
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( Node ) #IMPLIED>
-
-
-<!ELEMENT parentNode EMPTY>
-<!ATTLIST parentNode
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( Node ) #IMPLIED>
-
-
-<!ELEMENT previousSibling EMPTY>
-<!ATTLIST previousSibling
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( Node ) #IMPLIED>
-
-
-<!ELEMENT profile EMPTY>
-<!ATTLIST profile
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLHeadElement ) #IMPLIED>
-
-
-<!ELEMENT prompt EMPTY>
-<!ATTLIST prompt
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLIsIndexElement ) #IMPLIED>
-
-
-<!ELEMENT publicId EMPTY>
-<!ATTLIST publicId
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( Notation | Entity ) #REQUIRED>
-
-
-<!ELEMENT readOnly EMPTY>
-<!ATTLIST readOnly
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLInputElement | HTMLTextAreaElement ) #REQUIRED>
-
-
-<!ELEMENT referrer EMPTY>
-<!ATTLIST referrer
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( HTMLDocument ) #IMPLIED>
-
-
-<!ELEMENT rel EMPTY>
-<!ATTLIST rel
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLLinkElement | HTMLAnchorElement ) #REQUIRED>
-
-
-<!ELEMENT rev EMPTY>
-<!ATTLIST rev
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLLinkElement | HTMLAnchorElement ) #REQUIRED>
-
-
-<!ELEMENT rowIndex EMPTY>
-<!ATTLIST rowIndex
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLTableRowElement ) #IMPLIED>
-
-
-<!ELEMENT rows EMPTY>
-<!ATTLIST rows
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLTextAreaElement | HTMLTableElement | HTMLTableSectionElement | HTMLFrameSetElement ) #REQUIRED>
-
-
-<!ELEMENT rowSpan EMPTY>
-<!ATTLIST rowSpan
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLTableCellElement ) #IMPLIED>
-
-
-<!ELEMENT rules EMPTY>
-<!ATTLIST rules
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLTableElement ) #IMPLIED>
-
-
-<!ELEMENT scheme EMPTY>
-<!ATTLIST scheme
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLMetaElement ) #IMPLIED>
-
-
-<!ELEMENT scope EMPTY>
-<!ATTLIST scope
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLTableCellElement ) #IMPLIED>
-
-
-<!ELEMENT scrolling EMPTY>
-<!ATTLIST scrolling
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLFrameElement | HTMLIFrameElement ) #REQUIRED>
-
-
-<!ELEMENT sectionRowIndex EMPTY>
-<!ATTLIST sectionRowIndex
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLTableRowElement ) #IMPLIED>
-
-
-<!ELEMENT selected EMPTY>
-<!ATTLIST selected
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( HTMLOptionElement ) #IMPLIED>
-
-
-<!ELEMENT selectedIndex EMPTY>
-<!ATTLIST selectedIndex
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLSelectElement ) #IMPLIED>
-
-
-<!ELEMENT shape EMPTY>
-<!ATTLIST shape
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLAnchorElement | HTMLAreaElement ) #REQUIRED>
-
-
-<!ELEMENT size EMPTY>
-<!ATTLIST size
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLSelectElement | HTMLInputElement | HTMLBaseFontElement | HTMLFontElement | HTMLHRElement ) #REQUIRED>
-
-
-<!ELEMENT span EMPTY>
-<!ATTLIST span
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLTableColElement ) #IMPLIED>
-
-
-<!ELEMENT specified EMPTY>
-<!ATTLIST specified
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( Attr ) #IMPLIED>
-
-
-<!ELEMENT src EMPTY>
-<!ATTLIST src
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLInputElement | HTMLImageElement | HTMLScriptElement | HTMLFrameElement | HTMLIFrameElement | UserDataNotification ) #REQUIRED>
-
-
-<!ELEMENT standby EMPTY>
-<!ATTLIST standby
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLObjectElement ) #IMPLIED>
-
-
-<!ELEMENT start EMPTY>
-<!ATTLIST start
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLOListElement ) #IMPLIED>
-
-
-<!ELEMENT summary EMPTY>
-<!ATTLIST summary
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLTableElement ) #IMPLIED>
-
-
-<!ELEMENT systemId EMPTY>
-<!ATTLIST systemId
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( Notation | Entity ) #REQUIRED>
-
-
-<!ELEMENT tabIndex EMPTY>
-<!ATTLIST tabIndex
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLSelectElement | HTMLInputElement | HTMLTextAreaElement | HTMLButtonElement | HTMLAnchorElement | HTMLObjectElement | HTMLAreaElement ) #REQUIRED>
-
-
-<!ELEMENT tagName EMPTY>
-<!ATTLIST tagName
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( Element ) #IMPLIED>
-
-
-<!ELEMENT target EMPTY>
-<!ATTLIST target
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( ProcessingInstruction | HTMLLinkElement | HTMLBaseElement | HTMLFormElement | HTMLAnchorElement | HTMLAreaElement ) #REQUIRED>
-
-
-<!ELEMENT tBodies EMPTY>
-<!ATTLIST tBodies
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( HTMLTableElement ) #IMPLIED>
-
-
-<!ELEMENT text EMPTY>
-<!ATTLIST text
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLTitleElement | HTMLBodyElement | HTMLOptionElement | HTMLScriptElement ) #REQUIRED>
-
-
-<!ELEMENT tFoot EMPTY>
-<!ATTLIST tFoot
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLTableElement ) #IMPLIED>
-
-
-<!ELEMENT tHead EMPTY>
-<!ATTLIST tHead
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLTableElement ) #IMPLIED>
-
-
-<!ELEMENT type EMPTY>
-<!ATTLIST type
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLLinkElement | HTMLStyleElement | HTMLSelectElement | HTMLInputElement | HTMLTextAreaElement | HTMLButtonElement | HTMLUListElement | HTMLOListElement | HTMLLIElement | HTMLAnchorElement | HTMLObjectElement | HTMLParamElement | HTMLScriptElement ) #REQUIRED>
-
-
-<!ELEMENT URL EMPTY>
-<!ATTLIST URL
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface ( HTMLDocument ) #IMPLIED>
-
-
-<!ELEMENT useMap EMPTY>
-<!ATTLIST useMap
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLInputElement | HTMLImageElement | HTMLObjectElement ) #REQUIRED>
-
-
-<!ELEMENT vAlign EMPTY>
-<!ATTLIST vAlign
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLTableColElement | HTMLTableSectionElement | HTMLTableRowElement | HTMLTableCellElement ) #REQUIRED>
-
-
-<!ELEMENT value EMPTY>
-<!ATTLIST value
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( Attr | HTMLSelectElement | HTMLOptionElement | HTMLInputElement | HTMLTextAreaElement | HTMLButtonElement | HTMLLIElement | HTMLParamElement ) #REQUIRED>
-
-
-<!ELEMENT valueType EMPTY>
-<!ATTLIST valueType
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLParamElement ) #IMPLIED>
-
-
-<!ELEMENT version EMPTY>
-<!ATTLIST version
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLHtmlElement ) #IMPLIED>
-
-
-<!ELEMENT vLink EMPTY>
-<!ATTLIST vLink
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLBodyElement ) #IMPLIED>
-
-
-<!ELEMENT vspace EMPTY>
-<!ATTLIST vspace
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLImageElement | HTMLObjectElement | HTMLAppletElement ) #REQUIRED>
-
-
-<!ELEMENT width EMPTY>
-<!ATTLIST width
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface ( HTMLPreElement | HTMLHRElement | HTMLImageElement | HTMLObjectElement | HTMLAppletElement | HTMLTableElement | HTMLTableColElement | HTMLTableCellElement | HTMLIFrameElement ) #REQUIRED>
-<!ELEMENT add EMPTY >
-<!ATTLIST add
- id ID #IMPLIED
- obj CDATA #REQUIRED
- element CDATA #REQUIRED
- before CDATA #REQUIRED
- interface (HTMLSelectElement) #IMPLIED
->
-
-
-<!ELEMENT appendChild EMPTY >
-<!ATTLIST appendChild
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- newChild CDATA #REQUIRED
- interface (Node) #IMPLIED
->
-
-
-<!ELEMENT appendData EMPTY >
-<!ATTLIST appendData
- id ID #IMPLIED
- obj CDATA #REQUIRED
- arg CDATA #REQUIRED
- interface (CharacterData) #IMPLIED
->
-
-
-<!ELEMENT blur EMPTY >
-<!ATTLIST blur
- id ID #IMPLIED
- obj CDATA #REQUIRED
- interface (HTMLSelectElement|HTMLInputElement|HTMLTextAreaElement|HTMLAnchorElement) #REQUIRED
->
-
-
-<!ELEMENT click EMPTY >
-<!ATTLIST click
- id ID #IMPLIED
- obj CDATA #REQUIRED
- interface (HTMLInputElement) #IMPLIED
->
-
-
-<!ELEMENT cloneNode EMPTY >
-<!ATTLIST cloneNode
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- deep CDATA #REQUIRED
- interface (Node) #IMPLIED
->
-
-
-<!ELEMENT close EMPTY >
-<!ATTLIST close
- id ID #IMPLIED
- obj CDATA #REQUIRED
- interface (HTMLDocument) #IMPLIED
->
-
-
-<!ELEMENT createAttribute EMPTY >
-<!ATTLIST createAttribute
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- name CDATA #REQUIRED
- interface (Document) #IMPLIED
->
-
-
-<!ELEMENT createCaption EMPTY >
-<!ATTLIST createCaption
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface (HTMLTableElement) #IMPLIED
->
-
-
-<!ELEMENT createCDATASection EMPTY >
-<!ATTLIST createCDATASection
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- data CDATA #REQUIRED
- interface (Document) #IMPLIED
->
-
-
-<!ELEMENT createComment EMPTY >
-<!ATTLIST createComment
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- data CDATA #REQUIRED
- interface (Document) #IMPLIED
->
-
-
-<!ELEMENT createDocumentFragment EMPTY >
-<!ATTLIST createDocumentFragment
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface (Document) #IMPLIED
->
-
-
-<!ELEMENT createElement EMPTY >
-<!ATTLIST createElement
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- tagName CDATA #REQUIRED
- interface (Document) #IMPLIED
->
-
-
-<!ELEMENT createEntityReference EMPTY >
-<!ATTLIST createEntityReference
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- name CDATA #REQUIRED
- interface (Document) #IMPLIED
->
-
-
-<!ELEMENT createProcessingInstruction EMPTY >
-<!ATTLIST createProcessingInstruction
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- target CDATA #REQUIRED
- data CDATA #REQUIRED
- interface (Document) #IMPLIED
->
-
-
-<!ELEMENT createTextNode EMPTY >
-<!ATTLIST createTextNode
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- data CDATA #REQUIRED
- interface (Document) #IMPLIED
->
-
-
-<!ELEMENT createTFoot EMPTY >
-<!ATTLIST createTFoot
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface (HTMLTableElement) #IMPLIED
->
-
-
-<!ELEMENT createTHead EMPTY >
-<!ATTLIST createTHead
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface (HTMLTableElement) #IMPLIED
->
-
-
-<!ELEMENT deleteCaption EMPTY >
-<!ATTLIST deleteCaption
- id ID #IMPLIED
- obj CDATA #REQUIRED
- interface (HTMLTableElement) #IMPLIED
->
-
-
-<!ELEMENT deleteCell EMPTY >
-<!ATTLIST deleteCell
- id ID #IMPLIED
- obj CDATA #REQUIRED
- index CDATA #REQUIRED
- interface (HTMLTableRowElement) #IMPLIED
->
-
-
-<!ELEMENT deleteData EMPTY >
-<!ATTLIST deleteData
- id ID #IMPLIED
- obj CDATA #REQUIRED
- offset CDATA #REQUIRED
- count CDATA #REQUIRED
- interface (CharacterData) #IMPLIED
->
-
-
-<!ELEMENT deleteRow EMPTY >
-<!ATTLIST deleteRow
- id ID #IMPLIED
- obj CDATA #REQUIRED
- index CDATA #REQUIRED
- interface (HTMLTableElement|HTMLTableSectionElement) #REQUIRED
->
-
-
-<!ELEMENT deleteTFoot EMPTY >
-<!ATTLIST deleteTFoot
- id ID #IMPLIED
- obj CDATA #REQUIRED
- interface (HTMLTableElement) #IMPLIED
->
-
-
-<!ELEMENT deleteTHead EMPTY >
-<!ATTLIST deleteTHead
- id ID #IMPLIED
- obj CDATA #REQUIRED
- interface (HTMLTableElement) #IMPLIED
->
-
-
-<!ELEMENT focus EMPTY >
-<!ATTLIST focus
- id ID #IMPLIED
- obj CDATA #REQUIRED
- interface (HTMLSelectElement|HTMLInputElement|HTMLTextAreaElement|HTMLAnchorElement) #REQUIRED
->
-
-
-<!ELEMENT getAttribute EMPTY >
-<!ATTLIST getAttribute
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- name CDATA #REQUIRED
- interface (Element) #IMPLIED
->
-
-
-<!ELEMENT getAttributeNode EMPTY >
-<!ATTLIST getAttributeNode
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- name CDATA #REQUIRED
- interface (Element) #IMPLIED
->
-
-
-<!ELEMENT getElementById EMPTY >
-<!ATTLIST getElementById
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- elementId CDATA #REQUIRED
- interface (HTMLDocument) #IMPLIED
->
-
-
-<!ELEMENT getElementsByName EMPTY >
-<!ATTLIST getElementsByName
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- elementName CDATA #REQUIRED
- interface (HTMLDocument) #IMPLIED
->
-
-
-<!ELEMENT getElementsByTagName EMPTY >
-<!ATTLIST getElementsByTagName
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- tagname CDATA #REQUIRED
- interface (Document|Element) #REQUIRED
->
-
-
-<!ELEMENT getNamedItem EMPTY >
-<!ATTLIST getNamedItem
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- name CDATA #REQUIRED
- interface (NamedNodeMap) #IMPLIED
->
-
-
-<!ELEMENT hasChildNodes EMPTY >
-<!ATTLIST hasChildNodes
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- interface (Node) #IMPLIED
->
-
-
-<!ELEMENT insertBefore EMPTY >
-<!ATTLIST insertBefore
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- newChild CDATA #REQUIRED
- refChild CDATA #REQUIRED
- interface (Node) #IMPLIED
->
-
-
-<!ELEMENT insertCell EMPTY >
-<!ATTLIST insertCell
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- index CDATA #REQUIRED
- interface (HTMLTableRowElement) #IMPLIED
->
-
-
-<!ELEMENT insertData EMPTY >
-<!ATTLIST insertData
- id ID #IMPLIED
- obj CDATA #REQUIRED
- offset CDATA #REQUIRED
- arg CDATA #REQUIRED
- interface (CharacterData) #IMPLIED
->
-
-
-<!ELEMENT insertRow EMPTY >
-<!ATTLIST insertRow
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- index CDATA #REQUIRED
- interface (HTMLTableElement|HTMLTableSectionElement) #REQUIRED
->
-
-
-<!ELEMENT item EMPTY >
-<!ATTLIST item
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- index CDATA #REQUIRED
- interface (NodeList|NamedNodeMap|HTMLCollection) #REQUIRED
->
-
-
-<!ELEMENT namedItem EMPTY >
-<!ATTLIST namedItem
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- name CDATA #REQUIRED
- interface (HTMLCollection) #IMPLIED
->
-
-
-<!ELEMENT normalize EMPTY >
-<!ATTLIST normalize
- id ID #IMPLIED
- obj CDATA #REQUIRED
- interface (Element) #IMPLIED
->
-
-
-<!ELEMENT open EMPTY >
-<!ATTLIST open
- id ID #IMPLIED
- obj CDATA #REQUIRED
- interface (HTMLDocument) #IMPLIED
->
-
-
-<!ELEMENT remove EMPTY >
-<!ATTLIST remove
- id ID #IMPLIED
- obj CDATA #REQUIRED
- index CDATA #REQUIRED
- interface (HTMLSelectElement) #IMPLIED
->
-
-
-<!ELEMENT removeAttribute EMPTY >
-<!ATTLIST removeAttribute
- id ID #IMPLIED
- obj CDATA #REQUIRED
- name CDATA #REQUIRED
- interface (Element) #IMPLIED
->
-
-
-<!ELEMENT removeAttributeNode EMPTY >
-<!ATTLIST removeAttributeNode
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- oldAttr CDATA #REQUIRED
- interface (Element) #IMPLIED
->
-
-
-<!ELEMENT removeChild EMPTY >
-<!ATTLIST removeChild
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- oldChild CDATA #REQUIRED
- interface (Node) #IMPLIED
->
-
-
-<!ELEMENT removeNamedItem EMPTY >
-<!ATTLIST removeNamedItem
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- name CDATA #REQUIRED
- interface (NamedNodeMap) #IMPLIED
->
-
-
-<!ELEMENT replaceChild EMPTY >
-<!ATTLIST replaceChild
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- newChild CDATA #REQUIRED
- oldChild CDATA #REQUIRED
- interface (Node) #IMPLIED
->
-
-
-<!ELEMENT replaceData EMPTY >
-<!ATTLIST replaceData
- id ID #IMPLIED
- obj CDATA #REQUIRED
- offset CDATA #REQUIRED
- count CDATA #REQUIRED
- arg CDATA #REQUIRED
- interface (CharacterData) #IMPLIED
->
-
-
-<!ELEMENT reset EMPTY >
-<!ATTLIST reset
- id ID #IMPLIED
- obj CDATA #REQUIRED
- interface (HTMLFormElement) #IMPLIED
->
-
-
-<!ELEMENT select EMPTY >
-<!ATTLIST select
- id ID #IMPLIED
- obj CDATA #REQUIRED
- interface (HTMLInputElement|HTMLTextAreaElement) #REQUIRED
->
-
-
-<!ELEMENT setAttribute EMPTY >
-<!ATTLIST setAttribute
- id ID #IMPLIED
- obj CDATA #REQUIRED
- name CDATA #REQUIRED
- value CDATA #REQUIRED
- interface (Element) #IMPLIED
->
-
-
-<!ELEMENT setAttributeNode EMPTY >
-<!ATTLIST setAttributeNode
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- newAttr CDATA #REQUIRED
- interface (Element) #IMPLIED
->
-
-
-<!ELEMENT setNamedItem EMPTY >
-<!ATTLIST setNamedItem
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- arg CDATA #REQUIRED
- interface (NamedNodeMap) #IMPLIED
->
-
-
-<!ELEMENT splitText EMPTY >
-<!ATTLIST splitText
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- offset CDATA #REQUIRED
- interface (Text) #IMPLIED
->
-
-
-<!ELEMENT submit EMPTY >
-<!ATTLIST submit
- id ID #IMPLIED
- obj CDATA #REQUIRED
- interface (HTMLFormElement) #IMPLIED
->
-
-
-<!ELEMENT substringData EMPTY >
-<!ATTLIST substringData
- id ID #IMPLIED
- obj CDATA #REQUIRED
- var CDATA #REQUIRED
- offset CDATA #REQUIRED
- count CDATA #REQUIRED
- interface (CharacterData) #IMPLIED
->
-
-
-<!ELEMENT write EMPTY >
-<!ATTLIST write
- id ID #IMPLIED
- obj CDATA #REQUIRED
- text CDATA #REQUIRED
- interface (HTMLDocument) #IMPLIED
->
-
-
-<!ELEMENT writeln EMPTY >
-<!ATTLIST writeln
- id ID #IMPLIED
- obj CDATA #REQUIRED
- text CDATA #REQUIRED
- interface (HTMLDocument) #IMPLIED
->
-
-
-
-<!ELEMENT test (metadata?,(%implementation-condition;)*,var*,(load|implementation|DOMImplementationRegistry.newInstance),(%statement;)*) >
-<!ATTLIST test
- xmlns CDATA #FIXED "http://www.w3.org/2001/DOM-Test-Suite/Level-1"
- id ID #IMPLIED
- name CDATA #REQUIRED
- xmlns:xsi CDATA #FIXED "http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation CDATA "http://www.w3.org/2001/DOM-Test-Suite/Level-1 dom1.xsd"
->
-
-<!ELEMENT package (metadata?, (test|suite)*)>
-<!ATTLIST package
- xmlns CDATA #FIXED "http://www.w3.org/2001/DOM-Test-Suite/Level-1"
- id ID #IMPLIED
->
-
-<!ELEMENT suite (metadata?,(%implementation-condition;)*,(suite.member)*)>
-<!ATTLIST suite
- xmlns CDATA #FIXED "http://www.w3.org/2001/DOM-Test-Suite/Level-1"
- id ID #IMPLIED
- name CDATA #REQUIRED
- xmlns:xsi CDATA #FIXED "http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation CDATA "http://www.w3.org/2001/DOM-Test-Suite/Level-1 dom1.xsd"
->
-
-<!ELEMENT suite.member EMPTY>
-<!ATTLIST suite.member
- href CDATA #REQUIRED
->
-
-
-<!ELEMENT comment (#PCDATA)>
-<!ATTLIST comment
- id ID #IMPLIED
->
-
-<!ELEMENT wait EMPTY>
-<!ATTLIST wait
- id ID #IMPLIED
- milliseconds CDATA #REQUIRED
->
-
-<!ELEMENT append EMPTY>
-<!ATTLIST append
- id ID #IMPLIED
- collection CDATA #REQUIRED
- item CDATA #REQUIRED
->
-
-<!ELEMENT assign ((%condition;)?)?>
-<!ATTLIST assign
- id ID #IMPLIED
- var CDATA #REQUIRED
- value CDATA #IMPLIED
->
-
-<!ELEMENT increment EMPTY>
-<!ATTLIST increment
- id ID #IMPLIED
- var CDATA #REQUIRED
- value CDATA #REQUIRED
->
-
-<!ELEMENT decrement EMPTY>
-<!ATTLIST decrement
- id ID #IMPLIED
- var CDATA #REQUIRED
- value CDATA #REQUIRED
->
-
-<!ELEMENT plus EMPTY>
-<!ATTLIST plus
- id ID #IMPLIED
- var CDATA #REQUIRED
- op1 CDATA #REQUIRED
- op2 CDATA #REQUIRED
->
-
-<!ELEMENT subtract EMPTY>
-<!ATTLIST subtract
- id ID #IMPLIED
- var CDATA #REQUIRED
- op1 CDATA #REQUIRED
- op2 CDATA #REQUIRED
->
-
-<!ELEMENT mult EMPTY>
-<!ATTLIST mult
- id ID #IMPLIED
- var CDATA #REQUIRED
- op1 CDATA #REQUIRED
- op2 CDATA #REQUIRED
->
-
-<!ELEMENT divide EMPTY>
-<!ATTLIST divide
- id ID #IMPLIED
- var CDATA #REQUIRED
- op1 CDATA #REQUIRED
- op2 CDATA #REQUIRED
->
-
-<!ELEMENT return EMPTY>
-<!ATTLIST return
- id ID #IMPLIED
- value CDATA #IMPLIED
->
-
-<!ELEMENT get (var*, (%statement;)* )>
-<!ELEMENT set (var*, (%statement;)* )>
-
-
-<!ELEMENT var (member*) >
-<!ATTLIST var
- id ID #IMPLIED
- name CDATA #REQUIRED
- type (%variable-type;) #REQUIRED
- value CDATA #IMPLIED
- isNull (true|false) #IMPLIED
->
-
-
-<!ELEMENT member (#PCDATA)>
-<!ATTLIST member
- type (int|short|double|boolean|DOMString) #IMPLIED
->
-
-
-<!ELEMENT load EMPTY>
-<!ATTLIST load
- var CDATA #REQUIRED
- href CDATA #IMPLIED
- uri CDATA #IMPLIED
- obj CDATA #IMPLIED
- interface (DocumentLS) #IMPLIED
- willBeModified (true | false) #IMPLIED
->
-
-<!ELEMENT implementation EMPTY>
-<!ATTLIST implementation
- var CDATA #REQUIRED
- obj CDATA #IMPLIED
->
-
-<!ELEMENT DOMImplementationRegistry.newInstance EMPTY>
-<!ATTLIST DOMImplementationRegistry.newInstance
- var CDATA #REQUIRED
->
-
-
-<!-- since title is used both as a metadata element and
- a read-write attribute, it is hard coded here -->
-<!ELEMENT title (#PCDATA)>
-<!ATTLIST title
- id ID #IMPLIED
- obj CDATA #IMPLIED
- var CDATA #IMPLIED
- value CDATA #IMPLIED
- interface CDATA #IMPLIED
->
-
-
-<!ELEMENT metadata (metadata | title | creator | subject | description | contributor | date | source | relation)*>
-<!ATTLIST metadata
- xmlns CDATA #FIXED "http://www.w3.org/2001/DOM-Test-Suite/Level-1"
- id ID #IMPLIED
- about CDATA #IMPLIED
->
-
-<!ELEMENT creator (#PCDATA)>
-<!ATTLIST creator
- id ID #IMPLIED
- resource CDATA #IMPLIED
- type CDATA #IMPLIED
->
-
-<!ELEMENT subject (#PCDATA)>
-<!ATTLIST subject
- id ID #IMPLIED
- resource CDATA #IMPLIED
- type CDATA #IMPLIED
->
-
-<!ELEMENT description (#PCDATA)>
-<!ATTLIST description
- id ID #IMPLIED
- resource CDATA #IMPLIED
- type CDATA #IMPLIED
->
-
-<!ELEMENT contributor (#PCDATA)>
-<!ATTLIST contributor
- id ID #IMPLIED
- resource CDATA #IMPLIED
- type CDATA #IMPLIED
->
-
-<!ELEMENT date (#PCDATA)>
-<!ATTLIST date
- id ID #IMPLIED
- qualifier (created | valid | available | issued | modified) #REQUIRED
->
-
-<!ELEMENT source (#PCDATA)>
-<!ATTLIST source
- id ID #IMPLIED
- resource CDATA #IMPLIED
- type CDATA #IMPLIED
->
-
-<!ELEMENT relation (#PCDATA)>
-<!ATTLIST relation
- id ID #IMPLIED
- resource CDATA #IMPLIED
- type CDATA #IMPLIED
- qualifier (isVersionOf | hasVersion | isReplacedBy | isRequiredBy | requires | isPartOf | hasPart | isReferenceBy | references) #REQUIRED
->
-
-<!ELEMENT fail EMPTY>
-<!ATTLIST fail
- id ID #REQUIRED
->
-
-<!ELEMENT assertTrue ((%condition;)?)>
-<!ATTLIST assertTrue
- id ID #REQUIRED
- actual CDATA #IMPLIED
->
-
-<!ELEMENT assertFalse ((%condition;)?)>
-<!ATTLIST assertFalse
- id ID #REQUIRED
- actual CDATA #IMPLIED
->
-
-<!ELEMENT assertNull (metadata?, (%statement;)*)>
-<!ATTLIST assertNull
- actual CDATA #REQUIRED
- id ID #REQUIRED
->
-
-<!ELEMENT assertNotNull (metadata?, (%statement;)*)>
-<!ATTLIST assertNotNull
- actual CDATA #REQUIRED
- id ID #REQUIRED
->
-
-<!ELEMENT assertSame (metadata?, (%statement;)*)>
-<!ATTLIST assertSame
- actual CDATA #REQUIRED
- expected CDATA #REQUIRED
- id ID #REQUIRED
->
-
-<!ELEMENT assertInstanceOf (metadata?, (%statement;)*)>
-<!ATTLIST assertInstanceOf
- obj CDATA #REQUIRED
- type (%variable-type;) #REQUIRED
- id ID #REQUIRED
->
-
-
-<!ELEMENT assertSize (metadata?, (%statement;)*)>
-<!ATTLIST assertSize
- collection CDATA #REQUIRED
- size CDATA #REQUIRED
- id ID #REQUIRED
->
-
-<!ELEMENT assertEquals (metadata?, (%statement;)*)>
-<!ATTLIST assertEquals
- actual CDATA #REQUIRED
- expected CDATA #REQUIRED
- id ID #REQUIRED
- ignoreCase (true|false|auto) #REQUIRED
- context (attribute|element) #IMPLIED
- bitmask CDATA #IMPLIED
->
-
-<!ELEMENT assertNotEquals (metadata?, (%statement;)*)>
-<!ATTLIST assertNotEquals
- actual CDATA #REQUIRED
- expected CDATA #REQUIRED
- id ID #REQUIRED
- ignoreCase (true|false|auto) #REQUIRED
- context (attribute|element) #IMPLIED
- bitmask CDATA #IMPLIED
->
-
-<!ELEMENT assertEventCount (metadata?, (%statement;)*)>
-<!ATTLIST assertEventCount
- atCount CDATA #IMPLIED
- captureCount CDATA #IMPLIED
- bubbleCount CDATA #IMPLIED
- totalCount CDATA #IMPLIED
- monitor CDATA #REQUIRED
- id ID #REQUIRED
->
-
-<!ELEMENT assertURIEquals (metadata?)>
-<!ATTLIST assertURIEquals
- actual CDATA #REQUIRED
- scheme CDATA #IMPLIED
- path CDATA #IMPLIED
- host CDATA #IMPLIED
- file CDATA #IMPLIED
- name CDATA #IMPLIED
- query CDATA #IMPLIED
- fragment CDATA #IMPLIED
- isAbsolute CDATA #IMPLIED
- id ID #REQUIRED
->
-
-<!ELEMENT assertImplementationException (metadata?, (%statement;))>
-<!ATTLIST assertImplementationException
- id ID #REQUIRED
->
-
-
-<!ELEMENT same EMPTY>
-<!ATTLIST same
- id ID #IMPLIED
- actual CDATA #REQUIRED
- expected CDATA #REQUIRED
->
-
-<!ELEMENT equals EMPTY>
-<!ATTLIST equals
- id ID #IMPLIED
- actual CDATA #REQUIRED
- expected CDATA #REQUIRED
- ignoreCase (true|false|auto) "false"
- context (attribute|element) #IMPLIED
- bitmask CDATA #IMPLIED
->
-
-<!ELEMENT notEquals EMPTY>
-<!ATTLIST notEquals
- id ID #IMPLIED
- actual CDATA #REQUIRED
- expected CDATA #REQUIRED
- ignoreCase (true|false|auto) "false"
- context (attribute|element) #IMPLIED
- bitmask CDATA #IMPLIED
->
-
-<!ELEMENT less EMPTY>
-<!ATTLIST less
- id ID #IMPLIED
- actual CDATA #REQUIRED
- expected CDATA #REQUIRED
->
-
-<!ELEMENT lessOrEquals EMPTY>
-<!ATTLIST lessOrEquals
- id ID #IMPLIED
- actual CDATA #REQUIRED
- expected CDATA #REQUIRED
->
-
-<!ELEMENT greater EMPTY>
-<!ATTLIST greater
- id ID #IMPLIED
- actual CDATA #REQUIRED
- expected CDATA #REQUIRED
->
-
-<!ELEMENT greaterOrEquals EMPTY>
-<!ATTLIST greaterOrEquals
- id ID #IMPLIED
- actual CDATA #REQUIRED
- expected CDATA #REQUIRED
->
-
-<!ELEMENT isNull EMPTY>
-<!ATTLIST isNull
- id ID #IMPLIED
- obj CDATA #REQUIRED
->
-
-<!ELEMENT notNull EMPTY>
-<!ATTLIST notNull
- id ID #IMPLIED
- obj CDATA #REQUIRED
->
-
-<!ELEMENT instanceOf EMPTY>
-<!ATTLIST instanceOf
- id ID #IMPLIED
- obj CDATA #REQUIRED
- type (%variable-type;) #REQUIRED
->
-
-<!ELEMENT hasSize EMPTY>
-<!ATTLIST hasSize
- id ID #IMPLIED
- obj CDATA #REQUIRED
- expected CDATA #REQUIRED
->
-
-<!ELEMENT contentType EMPTY>
-<!ATTLIST contentType
- id ID #IMPLIED
- type CDATA #IMPLIED
- obj CDATA #IMPLIED
- var CDATA #IMPLIED
- interface (ElementEditVAL) #IMPLIED
->
-
-
-<!ELEMENT contains EMPTY>
-<!ATTLIST contains
- id ID #IMPLIED
- obj CDATA #REQUIRED
- str CDATA #REQUIRED
- var CDATA #IMPLIED
- interface (DOMStringList|NameList|DOMString) #REQUIRED
-
->
-
-<!ELEMENT implementationAttribute EMPTY>
-<!ATTLIST implementationAttribute
- id ID #IMPLIED
- value (true|false) #REQUIRED
- name (validating|coalescing|expandEntityReferences|namespaceAware|ignoringElementContentWhitespace|signed|hasNullString|schemaValidating|ignoringComments) #REQUIRED
->
-
-
-<!ELEMENT hasFeature EMPTY>
-<!ATTLIST hasFeature
- id ID #IMPLIED
- feature CDATA #REQUIRED
- version CDATA #IMPLIED
- value (true | false) #IMPLIED
- var CDATA #IMPLIED
- obj CDATA #IMPLIED
->
-
-<!ELEMENT not ((%condition;))>
-<!ATTLIST not
- id ID #IMPLIED
->
-
-<!ELEMENT isTrue EMPTY>
-<!ATTLIST isTrue
- id ID #IMPLIED
- value CDATA #REQUIRED
->
-
-<!ELEMENT isFalse EMPTY>
-<!ATTLIST isFalse
- id ID #IMPLIED
- value CDATA #REQUIRED
->
-
-<!ELEMENT or ((%condition;),(%condition;)+)>
-<!ATTLIST or
- id ID #IMPLIED
->
-
-<!ELEMENT and ((%condition;),(%condition;)+)>
-<!ATTLIST and
- id ID #IMPLIED
->
-
-<!ELEMENT xor ((%condition;),(%condition;))>
-<!ATTLIST xor
- id ID #IMPLIED
->
-
-<!ELEMENT else ((%statement;)+)>
-<!ATTLIST else
- id ID #IMPLIED
->
-
-<!ELEMENT if ((%condition;), (%statement;)+, else?)>
-<!ATTLIST if
- id ID #IMPLIED
->
-
-<!ELEMENT while ((%condition;),(%statement;)+)>
-<!ATTLIST while
- id ID #IMPLIED
->
-
-<!ELEMENT for-each ((%statement;)*)>
-<!ATTLIST for-each
- collection CDATA #REQUIRED
- member CDATA #REQUIRED
- id ID #IMPLIED
->
-
-<!ELEMENT try ((%statement;)+, catch)>
-<!ATTLIST try
- id ID #IMPLIED
->
-
-
-<!ELEMENT catch ((DOMException*,ImplementationException?))>
-<!ATTLIST catch
- id ID #IMPLIED>
-
-<!ELEMENT ImplementationException ((%statement;)*)>
-<!ATTLIST ImplementationException
- id ID #IMPLIED>
-
- <!ELEMENT DOMException ((%statement;)*)>
- <!ATTLIST DOMException code (INDEX_SIZE_ERR|DOMSTRING_SIZE_ERR|HIERARCHY_REQUEST_ERR|WRONG_DOCUMENT_ERR|INVALID_CHARACTER_ERR|NO_DATA_ALLOWED_ERR|NO_MODIFICATION_ALLOWED_ERR|NOT_FOUND_ERR|NOT_SUPPORTED_ERR|INUSE_ATTRIBUTE_ERR) #REQUIRED>
-
-
-
-<!ELEMENT atEvents EMPTY>
-<!ATTLIST atEvents
- id ID #IMPLIED
- obj CDATA #REQUIRED
- interface (EventMonitor) #IMPLIED
- var CDATA #REQUIRED
->
-
-<!ELEMENT bubbledEvents EMPTY>
-<!ATTLIST bubbledEvents
- id ID #IMPLIED
- obj CDATA #REQUIRED
- interface (EventMonitor) #IMPLIED
- var CDATA #REQUIRED
->
-
-<!ELEMENT capturedEvents EMPTY>
-<!ATTLIST capturedEvents
- id ID #IMPLIED
- obj CDATA #REQUIRED
- interface (EventMonitor) #IMPLIED
- var CDATA #REQUIRED
->
-
-
-<!ELEMENT allEvents EMPTY>
-<!ATTLIST allEvents
- id ID #IMPLIED
- obj CDATA #REQUIRED
- interface (EventMonitor) #IMPLIED
- var CDATA #REQUIRED
->
-
-<!ELEMENT allNotifications EMPTY>
-<!ATTLIST allNotifications
- id ID #IMPLIED
- obj CDATA #REQUIRED
- interface (UserDataMonitor) #IMPLIED
- var CDATA #REQUIRED
->
-
-<!ELEMENT operation EMPTY>
-<!ATTLIST operation
- id ID #IMPLIED
- var CDATA #REQUIRED
- obj CDATA #REQUIRED
- interface (UserDataNotification) #IMPLIED
->
-
-<!ELEMENT key EMPTY>
-<!ATTLIST key
- id ID #IMPLIED
- var CDATA #REQUIRED
- obj CDATA #REQUIRED
- interface (UserDataNotification) #IMPLIED
->
-
-<!ELEMENT dst EMPTY>
-<!ATTLIST dst
- id ID #IMPLIED
- var CDATA #REQUIRED
- obj CDATA #REQUIRED
- interface (UserDataNotification) #IMPLIED
->
-
-
-
-
-
-<!ELEMENT allErrors EMPTY>
-<!ATTLIST allErrors
- id ID #IMPLIED
- obj CDATA #REQUIRED
- interface (DOMErrorMonitor) #IMPLIED
- var CDATA #REQUIRED
->
-
-<!ELEMENT assertLowerSeverity EMPTY>
-<!ATTLIST assertLowerSeverity
- id ID #REQUIRED
- obj CDATA #REQUIRED
- interface (DOMErrorMonitor) #IMPLIED
- severity (SEVERITY_WARNING|SEVERITY_ERROR|SEVERITY_FATAL_ERROR) #REQUIRED
->
-
-<!ELEMENT createXPathEvaluator EMPTY>
-<!ATTLIST createXPathEvaluator
- id ID #IMPLIED
- var CDATA #REQUIRED
- document CDATA #REQUIRED
->
-
-<!ELEMENT getResourceURI EMPTY>
-<!ATTLIST getResourceURI
- id ID #IMPLIED
- var CDATA #REQUIRED
- href CDATA #REQUIRED
- scheme (file|http) #IMPLIED
- contentType CDATA #IMPLIED
->
-
-
-<!ELEMENT substring EMPTY>
-<!ATTLIST substring
- id ID #IMPLIED
- var CDATA #REQUIRED
- obj CDATA #REQUIRED
- beginIndex CDATA #REQUIRED
- endIndex CDATA #IMPLIED
->
-
-<!ELEMENT createTempURI EMPTY>
-<!ATTLIST createTempURI
- id ID #IMPLIED
- var CDATA #REQUIRED
- scheme (file|http) #REQUIRED
->
-
-
-
- \ No newline at end of file