- From: Simon Sapin <simon.sapin@exyr.org>
- Date: Wed, 25 Sep 2013 14:41:51 +0100
- To: Leif Halvard Silli <xn--mlform-iua@xn--mlform-iua.no>, "www-style@w3.org" <www-style@w3.org>
Le 25/09/2013 12:43, Leif Halvard Silli a écrit : > The section on ‘Attribute selectors and namespaces’ says: [1] > > ]] > [|att] { color: green } > [att] { color: green } > [ … snip … ] > The last two rules are equivalent and will match only elements > with the attribute att where the attribute is not in a namespace. > [[ > > Hence, these rules would not work in a namespace aware XML parser: > > [xmlns] { color: green } > [xml:lang] { color: green } [xml:lang] is not valid Selector syntax. You probably want this: @namespace xml "http://www.w3.org/XML/1998/namespace"; [xml|lang] { color: green } As to [xmlns], some testing shows that a bare xmlns attribute (defining the default namespace) ends up in the DOM with 'namespaceURI' set to "http://www.w3.org/2000/xmlns/". I have no idea why. So the way to select it (though I don’t know why you would want that) is: @namespace xmlns "http://www.w3.org/2000/xmlns/"; [xmlns|xmlns] { color: green } Test cases: data:application/xhtml+xml,<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr"><style>@namespace xml "http://www.w3.org/XML/1998/namespace";[xml|lang]{color:green}</style>Test</html> data:application/xhtml+xml,<html xmlns="http://www.w3.org/1999/xhtml"><style>@namespace xmlns "http://www.w3.org/2000/xmlns/";[xmlns|xmlns]{color:green}</style>Test</html> > Proposal: Please add a note/info that mentions @xml:foo and @xmlns as > examples of common attributes that cannot, when occurring in a XML > document, be styled with a simple [att]{} selector. It helps authors to > understand the concept if they see an actual, non-theoretical, example. > > [1] http://dev.w3.org/csswg/selectors4/#attrnmsp I find this @xmlns parsing oddity more confusing than helpful in understanding namespaces. -- Simon Sapin
Received on Wednesday, 25 September 2013 13:42:19 UTC