Re: [gdome] DOM semantics for absent prefix on setAttributeNS qualifiedName



Quoting Paolo Casarini <paolo casarini org>:

> Hi Andrew,
>
>   checking the code of the gdome_xml_el_setAttributeNS function wrt to
> DOM2 semantics I notice a bug, but it is not the one you have
> described.
>
>
> On Monday, February 20, 2006, 11:26:00 PM, Andrew Miller wrote:
> > The current Gdome returns an exception when you call setAttributeNS with a
> > namespace but a qualifiedName without a prefix. This is incorrect according
> to
> > my reading of the DOM specification...
>
> > The code:
> >   } else if (!strs[1] && namespaceURI != NULL) {     /* there's no ':' */
> >     prefix = g_strdup("");
> >     localName = g_strdup(strs[0]);
> >     if (strcmp (localName, "xmlns"))
> >       *exc = GDOME_NAMESPACE_ERR;
>
> If there is no prefix the exception is thrown only if the
> qualifiedName is equal to "xmlns".

Except that strcmp returns 0 if the strings are equal, and non-zero otherwise.
So if that was your intention, the logic is reversed(i.e. the current check
returns an exception only if localName is not equal to xmlns).

>
> > The text of the DOM Level 2 specification:
> >
> ------------------------------------------------------------------------------
> > [...]
> >     NAMESPACE_ERR: Raised if the qualifiedName is malformed, if the
> > qualifiedName has a prefix and the namespaceURI is null, if the
> qualifiedName
> > has a prefix that is "xml" and the namespaceURI is different from
> > "http://www.w3.org/XML/1998/namespace";, or if the qualifiedName is "xmlns"
> and
> > the namespaceURI is different from "http://www.w3.org/2000/xmlns/";.
> > [...]
>
> The bug I notice is that now the exception is thrown even if the
> namespaceURI is equal to "http://www.w3.org/2000/xmlns/"; and this
> incorrect.
>
> Do you agree?

I think that interpretation is correct, although I believe foo:xmlns="something"
is legitimate, so you have to compare the qualifiedName, not the localName.

So something like
if (!strcmp(qualifiedName, "xmlns") &&
    !strcmp(namespaceURI, "http://www.w3.org/2000/xmlns/";))
  *exc = GDOME_NAMESPACE_ERR;

Best regards,
Andrew Miller


----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]