Skip to content

Commit 9a14da6

Browse files
committed
[selectors-nonelement] Rephrase the text around the attr grammar.
1 parent c9dc722 commit 9a14da6

2 files changed

Lines changed: 67 additions & 50 deletions

File tree

selectors-nonelement/Overview.bs

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Editor: Jirka Kosek, Invited Expert, jirka@kosek.cz
1010
Editor: Tab Atkins Jr., Google, http://xanthir.com/contact/
1111
Abstract: Non-element Selectors extends [[!SELECTORS4]] and allow selecting other kinds of document nodes then elements. This is useful when selectors are used as a general document query language.
1212
Abstract: Non-element Selectors are not intended to be used in CSS, but only as a separate query language in other host environments.
13+
Link Defaults: css-namespaces (dfn) namespace prefix, selectors (dfn) originating element/pseudo-element
1314
</pre>
1415

1516
<h2 id="intro">
@@ -38,43 +39,51 @@ Attribute node selector</h3>
3839
An <dfn export>attribute node selector</dfn> represents an attribute node in a document tree.
3940
Its syntax is:
4041

41-
<pre class='prod'><dfn selector>::attr()</dfn> = ::attr( [ <<qualified-name>> | '*' | <<qname_prefix>> '|*' ] )</pre>
42+
<pre class='prod'>
43+
<dfn selector>::attr()</dfn> = ::attr( <<namespace-attr>> )
44+
<dfn>&lt;namespace-attr></dfn> = [ [ <<ident>> | '*' ]? '|' ]? [ <<ident>> | '*' ]
45+
</pre>
4246

43-
Where <dfn>&lt;qualified-name></dfn> is a <a
44-
spec=css-namespaces>CSS qualified name</a> which allows
45-
wildcard prefixes and must conform to <code>wqname</code>
46-
production given in [[!CSS3NAMESPACE]]. <dfn>&lt;qname_prefix></dfn> must conform
47-
to <code>qname_prefix</code> production given in [[!CSS3NAMESPACE]].
47+
No whitespace is allowed between the tokens of <<namespace-attr>>.
4848

49-
The selector uses <a spec=selectors>pseudo-element</a> syntax.
49+
<<namespace-attr>> is divided into two halves:
50+
an optional prefix preceding a '|' character,
51+
and an attribute name following it.
5052

51-
The selector matches an attribute node with the given qualified name,
52-
if such an attribute exists on the <a spec=selectors>originating element</a>.
53+
If the prefix is provided as an <<ident>>,
54+
it must match a declared <a>namespace prefix</a>,
55+
in which case the selector only matches attributes in that namespace;
56+
if it doesn't match a declared <a>namespace prefix</a>,
57+
the selector is invalid.
58+
If the prefix is provided as a '*' character,
59+
the selector matches attributes in any namespace.
60+
If the prefix is omitted,
61+
the selector only matches attributes in no namespace.
5362

54-
If '<code>*</code>' is used inside <code>::attr()</code> the
55-
selector matches all attribute nodes on the <a
56-
spec=selectors>originating element</a>.
63+
If the attribute name is an <<ident>>,
64+
the selector matches attributes with that name.
65+
If the attribute name is a '*' character,
66+
it matches any attribute.
5767

58-
If '<code>prefix|*</code>' is used inside
59-
<code>::attr()</code> the selector matches all attribute nodes
60-
in a namespace bound to the <code>prefix</coce> on the <a
61-
spec=selectors>originating element</a>.
68+
The selector matches an attribute node with the given namespace and name on the <a>originating element</a>,
69+
if such an attribute exists.
6270

71+
The selector uses <a>pseudo-element</a> syntax.
6372

6473
<div class="example">
6574
For example,
6675
the selector ''::attr(title)'' selects all the <code>title</code> attributes in the document.
6776
</div>
6877

6978
<div class="example">
70-
The following ITS rules use attribute node selector to switch off
71-
translatability of <code>title</code> attribute on <code>abbr</code> elements.
79+
The following ITS rules use an attribute node selector
80+
to switch off translatability of <code>title</code> attribute on <code>abbr</code> elements.
7281
<pre>
73-
&lt;rules xmlns="http://www.w3.org/2005/11/its"
74-
version="2.0"
75-
queryLanguage="css">
76-
&lt;translateRule selector="abbr::attr(title)" translate="no"/>
77-
&lt;/rules>
82+
&lt;rules xmlns="http://www.w3.org/2005/11/its"
83+
version="2.0"
84+
queryLanguage="css">
85+
&lt;translateRule selector="abbr::attr(title)" translate="no"/>
86+
&lt;/rules>
7887
</pre>
7988

8089
</div>

selectors-nonelement/Overview.html

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -153,38 +153,48 @@ <h3 class="heading settled heading" data-level=2.1 id=attribute-node-selector><s
153153
<p> An <dfn data-dfn-type=dfn data-export="" id=attribute-node-selector0>attribute node selector<a class=self-link href=#attribute-node-selector0></a></dfn> represents an attribute node in a document tree.
154154
Its syntax is:
155155

156-
<pre class=prod><dfn class=css-code data-dfn-type=selector data-export="" id=selectordef-attr>::attr()<a class=self-link href=#selectordef-attr></a></dfn> = ::attr( [ <a class="production css-code" data-link-type=type href=#typedef-qualified-name title="<qualified-name>">&lt;qualified-name&gt;</a> | '*' | <a class="production css-code" data-link-type=type href=#typedef-qname_prefix title="<qname_prefix>">&lt;qname_prefix&gt;</a> '|*' ] )</pre>
157-
<p> Where <dfn class=css-code data-dfn-type=type data-export="" id=typedef-qualified-name>&lt;qualified-name&gt;<a class=self-link href=#typedef-qualified-name></a></dfn> is a <a data-link-spec=css-namespaces data-link-type=dfn href=http://dev.w3.org/csswg/css-namespaces-1/#css-qualified-name title="css qualified name">CSS qualified name</a> which allows
158-
wildcard prefixes and must conform to <code>wqname</code>
159-
production given in <a data-biblio-type=normative data-link-type=biblio href=#css3namespace title=css3namespace>[CSS3NAMESPACE]</a>. <dfn class=css-code data-dfn-type=type data-export="" id=typedef-qname_prefix>&lt;qname_prefix&gt;<a class=self-link href=#typedef-qname_prefix></a></dfn> must conform
160-
to <code>qname_prefix</code> production given in <a data-biblio-type=normative data-link-type=biblio href=#css3namespace title=css3namespace>[CSS3NAMESPACE]</a>.
156+
<pre class=prod> <dfn class=css-code data-dfn-type=selector data-export="" id=selectordef-attr>::attr()<a class=self-link href=#selectordef-attr></a></dfn> = ::attr( <a class="production css-code" data-link-type=type href=#typedef-namespace-attr title="<namespace-attr>">&lt;namespace-attr&gt;</a> )
157+
<dfn class=css-code data-dfn-type=type data-export="" id=typedef-namespace-attr>&lt;namespace-attr&gt;<a class=self-link href=#typedef-namespace-attr></a></dfn> = [ [ <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#ltident title="<ident>">&lt;ident&gt;</a> | '*' ]? '|' ]? [ <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#ltident title="<ident>">&lt;ident&gt;</a> | '*' ]
158+
</pre>
159+
<p> No whitespace is allowed between the tokens of <a class="production css-code" data-link-type=type href=#typedef-namespace-attr title="<namespace-attr>">&lt;namespace-attr&gt;</a>.
161160

162-
<p> The selector uses <a data-link-spec=selectors data-link-type=dfn href=http://dev.w3.org/csswg/selectors-4/#pseudo-element title=pseudo-element>pseudo-element</a> syntax.
161+
<a class="production css-code" data-link-type=type href=#typedef-namespace-attr title="<namespace-attr>">&lt;namespace-attr&gt;</a> is divided into two halves:
162+
an optional prefix preceding a '|' character,
163+
and an attribute name following it.
163164

164-
<p> The selector matches an attribute node with the given qualified name,
165-
if such an attribute exists on the <a data-link-spec=selectors data-link-type=dfn href=http://dev.w3.org/csswg/selectors-4/#originating-element title="originating element">originating element</a>.
165+
<p> If the prefix is provided as an <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#ltident title="<ident>">&lt;ident&gt;</a>,
166+
it must match a declared <a data-link-type=dfn href=http://dev.w3.org/csswg/css-namespaces-1/#namespace-prefix title="namespace prefix">namespace prefix</a>,
167+
in which case the selector only matches attributes in that namespace;
168+
if it doesn’t match a declared <a data-link-type=dfn href=http://dev.w3.org/csswg/css-namespaces-1/#namespace-prefix title="namespace prefix">namespace prefix</a>,
169+
the selector is invalid.
170+
If the prefix is provided as a <a class=property data-link-type=propdesc title=*>*</a> character,
171+
the selector matches attributes in any namespace.
172+
If the prefix is omitted,
173+
the selector only matches attributes in no namespace.
166174

167-
<p> If '<code>*</code>' is used inside <code>::attr()</code> the
168-
selector matches all attribute nodes on the <a data-link-spec=selectors data-link-type=dfn href=http://dev.w3.org/csswg/selectors-4/#originating-element title="originating element">originating element</a>.
175+
<p> If the attribute name is an <a class="production css-code" data-link-type=type href=http://dev.w3.org/csswg/css-values-3/#ltident title="<ident>">&lt;ident&gt;</a>,
176+
the selector matches attributes with that name.
177+
If the attribute name is a <a class=property data-link-type=propdesc title=*>*</a> character,
178+
it matches any attribute.
169179

170-
<p> If '<code>prefix|*</code>' is used inside
171-
<code>::attr()</code> the selector matches all attribute nodes
172-
in a namespace bound to the <code>prefix on the <a data-link-spec=selectors data-link-type=dfn href=http://dev.w3.org/csswg/selectors-4/#originating-element title="originating element">originating element</a>.
180+
<p> The selector matches an attribute node with the given namespace and name on the <a data-link-type=dfn href=http://dev.w3.org/csswg/selectors-4/#originating-element title="originating element">originating element</a>,
181+
if such an attribute exists.
173182

183+
<p> The selector uses <a data-link-type=dfn href=http://dev.w3.org/csswg/selectors-4/#pseudo-element title=pseudo-element>pseudo-element</a> syntax.
174184

175-
</code><div class=example><code>
185+
<div class=example>
176186
For example,
177187
the selector <span class=css data-link-type=maybe title=::attr(title)>::attr(title)</span> selects all the <code>title</code> attributes in the document.
178-
</code></div><code>
188+
</div>
179189

180190
<div class=example>
181-
The following ITS rules use attribute node selector to switch off
182-
translatability of <code>title</code> attribute on <code>abbr</code> elements.
183-
<pre>&lt;rules xmlns="http://www.w3.org/2005/11/its"
184-
version="2.0"
185-
queryLanguage="css"&gt;
186-
&lt;translateRule selector="abbr::attr(title)" translate="no"/&gt;
187-
&lt;/rules&gt;
191+
The following ITS rules use an attribute node selector
192+
to switch off translatability of <code>title</code> attribute on <code>abbr</code> elements.
193+
<pre> &lt;rules xmlns="http://www.w3.org/2005/11/its"
194+
version="2.0"
195+
queryLanguage="css"&gt;
196+
&lt;translateRule selector="abbr::attr(title)" translate="no"/&gt;
197+
&lt;/rules&gt;
188198
</pre>
189199
</div>
190200

@@ -206,7 +216,7 @@ <h3 class="no-ref heading settled heading" id=conventions><span class=content>
206216
letters in this specification.
207217

208218
<p>All of the text of this specification is normative except sections
209-
explicitly marked as non-normative, examples, and notes. [[!RFC2119]]</p>
219+
explicitly marked as non-normative, examples, and notes. <a data-biblio-type=normative data-link-type=biblio href=#rfc2119 title=rfc2119>[RFC2119]</a></p>
210220

211221
<p>Examples in this specification are introduced with the words "for example"
212222
or are set apart from the normative text with <code>class="example"</code>,
@@ -316,7 +326,7 @@ <h2 class="no-num no-ref heading settled heading" id=references><span class=cont
316326

317327
<h3 class="no-num no-ref heading settled heading" id=normative><span class=content>
318328
Normative References</span><a class=self-link href=#normative></a></h3>
319-
<div data-fill-with=normative-references><dl><dt id=css3namespace title=CSS3NAMESPACE><a class=self-link href=#css3namespace></a>[CSS3NAMESPACE]<dd>Elika J. Etemad; Anne van Kesteren. <a href=http://www.w3.org/TR/2011/REC-css3-namespace-20110929/>CSS Namespaces Module</a>. 29 September 2011. W3C Recommendation. URL: <a href=http://www.w3.org/TR/2011/REC-css3-namespace-20110929/>http://www.w3.org/TR/2011/REC-css3-namespace-20110929/</a><dt id=selectors4 title=SELECTORS4><a class=self-link href=#selectors4></a>[SELECTORS4]<dd>Elika J. Etemad; Tab Atkins Jr.. <a href=http://www.w3.org/TR/2013/WD-selectors4-20130502/>Selectors Level 4</a>. 2 May 2013. W3C Working Draft. (Work in progress.) URL: <a href=http://www.w3.org/TR/2013/WD-selectors4-20130502/>http://www.w3.org/TR/2013/WD-selectors4-20130502/</a></dl></div>
329+
<div data-fill-with=normative-references><dl><dt id=rfc2119 title=RFC2119><a class=self-link href=#rfc2119></a>[RFC2119]<dd>S. Bradner. <a href=http://www.ietf.org/rfc/rfc2119.txt>Key words for use in RFCs to Indicate Requirement Levels</a>. URL: <a href=http://www.ietf.org/rfc/rfc2119.txt>http://www.ietf.org/rfc/rfc2119.txt</a><dt id=selectors4 title=SELECTORS4><a class=self-link href=#selectors4></a>[SELECTORS4]<dd>Elika J. Etemad; Tab Atkins Jr.. <a href=http://www.w3.org/TR/2013/WD-selectors4-20130502/>Selectors Level 4</a>. 2 May 2013. W3C Working Draft. (Work in progress.) URL: <a href=http://www.w3.org/TR/2013/WD-selectors4-20130502/>http://www.w3.org/TR/2013/WD-selectors4-20130502/</a></dl></div>
320330

321331
<h3 class="no-num no-ref heading settled heading" id=informative><span class=content>
322332
Informative References</span><a class=self-link href=#informative></a></h3>
@@ -327,13 +337,11 @@ <h2 class="no-num no-ref heading settled heading" id=index><span class=content>
327337
<div data-fill-with=index><ul class=indexlist>
328338
<li>::attr(), <a href=#selectordef-attr title="section 2.1">2.1</a>
329339
<li>attribute node selector, <a href=#attribute-node-selector0 title="section 2.1">2.1</a>
330-
<li>&lt;qname_prefix&gt;, <a href=#typedef-qname_prefix title="section 2.1">2.1</a>
331-
<li>&lt;qualified-name&gt;, <a href=#typedef-qualified-name title="section 2.1">2.1</a>
340+
<li>&lt;namespace-attr&gt;, <a href=#typedef-namespace-attr title="section 2.1">2.1</a>
332341
</ul></div>
333342

334343
<h2 class="no-num no-ref heading settled heading" id=property-index><span class=content>
335344
Property index</span><a class=self-link href=#property-index></a></h2>
336345
<div data-fill-with=property-index><p>No properties defined.</div>
337346

338347

339-
</code>

0 commit comments

Comments
 (0)