KHTML: Namespace handling

David Faure faure at kde.org
Wed Jun 25 12:44:22 BST 2003


On Wednesday 25 June 2003 12:04, Lars Knoll wrote:
> 
> > On Wednesday 25 June 2003 04:39, Dirk Mueller wrote:
> > > Nope, thats wrong. While there was certainly a few bugs in the
> > > implementation, searching by ID is enough. the non-NS variants of the
> > > methods were masking out the namespace part, so that they would match ids
> > > with same local name but different namespaces. Thats what the IdMask code
> > > was for btw.
> >
> > So you make sure that foo:localname and bar:localname will get
> > assigned the same ID (in the non-NS part of the ID field)?
> 
> AFAIK yes. Namespace support in the CSS parser (which is there, just not 
> enabled because of the problems with the new code Dirk described) does also 
> rely on same names getting same ids.
> 
> > Is it correct to say that the tagnames without namespace (like those passed
> > to getElementsByTagName()) are equivalent to tags with an empty prefix?
> > And/or to tags with an empty namespaceURI? Does that also mean they
> > have 0 in the NS part of the ID field (the upper 16 bits)?
> 
> Yes, they do have 0 in there. At least as long as no one declares a default 
> namespace, in which case the upper part gets the id of that namespace.

Thanks. My problem is now: how to solve getElementsByTagNameNS( "foo", "*" ).

I need to get the id of any tag in the namespace foo, to get a correct value for
the namespace part of the id (the local mask will be 0, so no problem there).

But if I call tagId("foo", "", readonly=true) (empty name) I get 0 (first line
checks against empty names) and if I call tagId("foo", "*", readonly=true)
I'll get 0 too (NS found, but unknown name).

What should I do? A separate getNamespaceId(DOMString) method?
Or fix the handling of "empty localname but namespace set" to return
(namespaceid << 16 + 0)? (is there any risk this could screw things up
for other uses of tagId(), i.e. during parsing?)

-- 
David FAURE, faure at kde.org, sponsored by Trolltech to work on KDE,
Konqueror (http://www.konqueror.org), and KOffice (http://www.koffice.org).
Qtella users - stability patches at http://blackie.dk/~dfaure/qtella.html




More information about the kfm-devel mailing list