W3C home > Mailing lists > Public > www-style@w3.org > February 2014

Re: [selectors-nonelement] ::attr(*|localname), ::attr(ns|*), and ::attr(*)

From: Jirka Kosek <jirka@kosek.cz>
Date: Mon, 24 Feb 2014 17:01:31 +0100
Message-ID: <530B6CDB.6040305@kosek.cz>
To: Simon Pieters <simonp@opera.com>
CC: "Tab Atkins Jr." <jackalmage@gmail.com>, Simon Sapin <simon.sapin@exyr.org>, www-style <www-style@w3.org>
On 24.2.2014 15:38, Simon Pieters wrote:
>> ::attr(*) should select all attributes to be consistent with universal
>> selector, equivalent to ::attr(*|*)
> 
> This is not exactly consistent with the universal selector, since it uses
> the default namespace:
> 
> @namespace "foo";
> @namespace a "foo";
> * {}
> a|* {}
> 
> Those two are equivalent but different to *|*.

As I wrote before, default namespace is not applied to attributes, so
for ::attr() it doesn't make sense to take default namespace into account.

Consider document:

<foo xmlns="http://www.example.com/">
  <bar x="1" y="2"/>
</foo>

and default namespace declared for selectors:

@namespace "http://www.example.com/";

then with what you seem to propose

bar ::attr(*)

would return no attributes. That seems counter intuitive and different
to what developers would expect.

As * was not in past used for attributes (it's not even allow inside
attr() function) I don't see why behaviour couldn't be as I propose.

>> This is also consistent with XPath, and should create less surprises to
>> developers.
> 
> Consistency with XPath seems like a weird motivation if the move to
> Selectors in ITS was because people are more familiar with Selectors.

Consistency with XPath is just additional benefit here, not reason to
model feature this way.

> When would you want to select all attributes, by the way?

When there is a need to operate on all attributes.

> How do you declare a namespace prefix for the selector in ITS when using
> Selectors?

By using in-scope declared namespaces -- same way as in XPath. Although
this is not explicitly stated in ITS 2.0.

						Jirka


-- 
------------------------------------------------------------------
  Jirka Kosek      e-mail: jirka@kosek.cz      http://xmlguru.cz
------------------------------------------------------------------
       Professional XML consulting and training services
  DocBook customization, custom XSLT/XSL-FO document processing
------------------------------------------------------------------
 OASIS DocBook TC member, W3C Invited Expert, ISO JTC1/SC34 rep.
------------------------------------------------------------------
    Bringing you XML Prague conference    http://xmlprague.cz
------------------------------------------------------------------


Received on Monday, 24 February 2014 16:02:05 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:39:19 UTC