E4X: should xmlObject.attributes() return all attributes or only those in no namespace?
flag
3 messages - Collapse all
/groups/adfetch?adid=w-H64xEAAACIoWADXvIHTqKbNC8V7J0XnT3luubDeskUok6AUQ17nQ
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
1.  Martin Honnen  
View profile  
 More options Apr 8 2005, 12:59 pm
Newsgroups: netscape.public.mozilla.jseng
From: Martin Honnen <mahotr...@yahoo.de>
Date: Fri, 08 Apr 2005 18:59:10 +0200
Local: Fri, Apr 8 2005 12:59 pm
Subject: E4X: should xmlObject.attributes() return all attributes or only those in no namespace?

Test case:

var p = <p id="p1" class="style1" xml:lang="en">Kibology for all.</p>;
print("attributes().length(): " + p.attributes().length());

yields 2 with Spidermonkey and 3 with Rhino.

The specs says "The attributes method returns an XMLList containing the
XML attributes of this object." which lets me expect I get all
attributes. However the formal definition then says
   Return the result of calling the [[Get]] method of x with argument
ToAttributeName("*")
and trying to read through the specification to understand what that
should return it appears that only the attributes in no namespace are to
be returned.
Is that a bug in the spec? If there is a method called attributes why
does it not return all attributes regardless of whether they are in a
namespace or not?

The only way to consistently get all attributes with Rhino and
Spidermonkey is
   print("p.@*::*.length(): " + p.@*::*.length());
but it seems odd that the method attributes does not yield all
attributes. If that is intended then the spec should maybe be fixed to
specificially state that the method attributes only returns attributes
in no namespace.

--

        Martin Honnen
        http://JavaScript.FAQTs.com/


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
2.  Brendan Eich  
View profile  
 More options Apr 8 2005, 6:21 pm
Newsgroups: netscape.public.mozilla.jseng
From: Brendan Eich <bren...@meer.net>
Date: Fri, 08 Apr 2005 15:21:35 -0700
Local: Fri, Apr 8 2005 6:21 pm
Subject: Re: E4X: should xmlObject.attributes() return all attributes or only those in no namespace?

Martin Honnen wrote:

> Test case:

> var p = <p id="p1" class="style1" xml:lang="en">Kibology for all.</p>;
> print("attributes().length(): " + p.attributes().length());

> yields 2 with Spidermonkey and 3 with Rhino.

> The specs says "The attributes method returns an XMLList containing the
> XML attributes of this object." which lets me expect I get all
> attributes. However the formal definition then says

Here is where the nice prose with examples added to aid understanding in
ECMA-357, missing from ECMA-262, can be a hazard.  This is not a
rigorous definition, and in fact it's either misleading, or the
algorithm in the spec is buggy.

>   Return the result of calling the [[Get]] method of x with argument
> ToAttributeName("*")
> and trying to read through the specification to understand what that
> should return it appears that only the attributes in no namespace are to
> be returned.

That's correct.  From 13.4.4.5, see 10.5, then see 10.5.1, then see
13.2.2 2(b) in particular.  The resulting AttributeName used to match
attributes has a [[Name]] internal property that's a QName with uri ===
"" and localName === "*".

That will not match all attributes.  It will match only attributes in
the null namespace (or in no namespace, another way of saying the same
thing), which unprefixed attributes go in by default (even if there's a
default namespace declared for the containing tag).

> Is that a bug in the spec? If there is a method called attributes why
> does it not return all attributes regardless of whether they are in a
> namespace or not?

It may be a bug in the spec, because ToAttributeName("*") does something
different from new QName("*").  The latter results in a name whose uri
=== null, which would match any attribute, no matter what namespace it
is in.

> The only way to consistently get all attributes with Rhino and
> Spidermonkey is
>   print("p.@*::*.length(): " + p.@*::*.length());
> but it seems odd that the method attributes does not yield all
> attributes. If that is intended then the spec should maybe be fixed to
> specificially state that the method attributes only returns attributes
> in no namespace.

Bcc'ing once again some folks who might be able to do something about
the spec.

/be


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
3.  Brendan Eich  
View profile  
 More options Apr 8 2005, 6:29 pm
Newsgroups: netscape.public.mozilla.jseng
From: Brendan Eich <bren...@meer.net>
Date: Fri, 08 Apr 2005 15:29:29 -0700
Local: Fri, Apr 8 2005 6:29 pm
Subject: Re: E4X: should xmlObject.attributes() return all attributes or only those in no namespace?

Brendan Eich wrote:
> That will not match all attributes.  It will match only attributes in
> the null namespace (or in no namespace, another way of saying the same
> thing), which unprefixed attributes go in by default (even if there's a
> default namespace declared for the containing tag).

Strike the "by default" -- unprefixed attributes are in the null
namespace, period -- whether there is a declared default xmlns= or not.

/be


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google