[gdome]Accessing Namespace Declarations
- From: "T.J. Mather" <tjmather tjmather com>
- To: <gdome gnome org>
- Subject: [gdome]Accessing Namespace Declarations
- Date: Tue, 15 Jan 2002 19:28:21 -0500 (EST)
According to the DOM Level 2 Core spec, section 1.1.8:
"As far as the DOM is concerned, special attributes used for declaring XML
namespaces are still exposed and can be manipulated just like any other
attribute."
So this leads me to believe that getAttributes, getAttribute, etc should
return XML namespace declarations as well as normal attributes. The
current behavior doesn't return namespace declarations.
In libxml2's xmlNode structure, XML namespace declarations are stored
in "nsDef", and all other attributes are stored in "properties". The
current implementation only accesses "properties", hence the current
behavior that doesn't return namespace attributes.
See:
http://xmlsoft.org/html/libxml-tree.html#XMLNODE
So we could use "nsDef" to access the xml namespace declaration
attributes, as follows:
* namespace declarations will be wrapped in the GdomeAttr interface
when exposed through attribute methods. Note that this is
different from the XPath module where the namespace
declarations exposed through XPath are wrapped in the
GdomeXPathNamespace interface.
* getAttribute* and hasAttribute* methods will continue
to access "properties" for attributes, but will also look in "nsDef"
for namespace attributes.
* setAttribute* and removeAttribute* methods will work as before, except
will die with NO_MODIFICATION_ALLOWED_ERR if attribute is wrapper
to nsDef. that is, pre-existing namespace declarations can not
be removed, modified or used to set attributes. this is consistent with
the fact that XPathNamespace nodes are read-only and cannot be
placed in the document hierarchy.
* an additional member will be added to the _Gdome_xml_Attr structure:
GdomeBoolean namespaceDecl;
If set to 1, then *n contains a xmlNs pointer, otherwise
contains a xmlAttr pointer.
Thoughts? This seems to be a tricky problem, so I like to hear back from
some of the experts on this list. I can take care of implementing it, as
I do need this to work soon, like in the next day or so.
In case any one is curious, I need this for XML::Canonical to work
properly with XML::GDOME.
Thanks,
TJ
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]