You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
11
+
Abstract: Non-element Selectors are not intended to be used in CSS, but only as a separate query language in other host environments.
12
+
</pre>
13
+
14
+
<h2 id="intro">
15
+
Introduction</h2>
16
+
17
+
Selectors are a very popular mechanism for selecting things in HTML and XML content.
18
+
They are not used only in CSS [[CSS3SYN]]
19
+
but also as a standalone query language in libraries like <a href="http://jquery.com/">jQuery</a>,
20
+
in newer standardized browser APIs like [[SELECTORS-API]]
21
+
and in other Web standards like <a href="http://www.w3.org/TR/its20/">ITS 2.0</a>.
22
+
23
+
The [[SELECTORS4]] specification only defines selectors for selecting element nodes from the document,
24
+
but some uses of Selectors would like to select other types of nodes as well.
25
+
This specification extends [[SELECTORS4]] with additional selectors
26
+
that can be used for selecting non-element nodes in a document tree.
27
+
28
+
Note: Currently the draft only defines means for selecting and matching attribute nodes,
29
+
but other kinds of nodes, such as comments or processing instructions, might be supported in the future.
30
+
31
+
<h2 id="non-element-selectors">
32
+
Non-element Selectors</h2>
33
+
34
+
<h3 id="attribute-node-selector">
35
+
Attribute node selector</h3>
36
+
37
+
An <dfn export>attribute node pseudo-element</dfn> represents an attribute node in a document tree.
<p>Selectors are very popular selection mechanism for HTML and XML
129
-
content. They are not used only in CSS <adata-biblio-type=informativedata-link-type=bibliohref=#css3syntitle=css3syn>[CSS3SYN]</a> but also as a
130
-
standalone query language in libraries like <ahref=http://jquery.com/>jQuery</a>, in a newer standardized browser
131
-
APIs like <adata-biblio-type=informativedata-link-type=bibliohref=#selectors-apititle=selectors-api>[SELECTORS-API]</a> or in another Web standards like <ahref=http://www.w3.org/TR/its20/>ITS 2.0</a>. <adata-biblio-type=informativedata-link-type=bibliohref=#selectors4title=selectors4>[SELECTORS4]</a> are
132
-
able to select just element nodes from the document tree which is
133
-
limiting for some use-cases. This specification extends <adata-biblio-type=informativedata-link-type=bibliohref=#selectors4title=selectors4>[SELECTORS4]</a>
134
-
with additional selectors that can be used for selecting other kinds
135
-
of nodes in a document tree. Currently the draft only defines means for
136
-
selecting and matching attribute nodes, but in future, based on
137
-
feedback, other kinds of nodes like comments or processing
138
-
instructions might be supported.</p>
130
+
<p> Selectors are a very popular mechanism for selecting things in HTML and XML content.
131
+
They are not used only in CSS <adata-biblio-type=informativedata-link-type=bibliohref=#css3syntitle=css3syn>[CSS3SYN]</a>
132
+
but also as a standalone query language in libraries like <ahref=http://jquery.com/>jQuery</a>,
133
+
in newer standardized browser APIs like <adata-biblio-type=informativedata-link-type=bibliohref=#selectors-apititle=selectors-api>[SELECTORS-API]</a>
134
+
and in other Web standards like <ahref=http://www.w3.org/TR/its20/>ITS 2.0</a>.
139
135
140
-
<h2class="heading settled heading" data-level=2id=syntax><spanclass=secno>2 </span><spanclass=content>Non-element Selector Syntax and Structure</span><aclass=self-linkhref=#syntax></a></h2>
136
+
<p> The <adata-biblio-type=informativedata-link-type=bibliohref=#selectors4title=selectors4>[SELECTORS4]</a> specification only defines selectors for selecting element nodes from the document,
137
+
but some uses of Selectors would like to select other types of nodes as well.
138
+
This specification extends <adata-biblio-type=informativedata-link-type=bibliohref=#selectors4title=selectors4>[SELECTORS4]</a> with additional selectors
139
+
that can be used for selecting non-element nodes in a document tree.
141
140
142
-
<p>Syntax and structure is the same as in <adata-biblio-type=informativedata-link-type=bibliohref=#selectors4title=selectors4>[SELECTORS4]</a> with the following exception:</p>
141
+
<pclass=note> Note: Currently the draft only defines means for selecting and matching attribute nodes,
142
+
but other kinds of nodes, such as comments or processing instructions, might be supported in the future.
143
143
144
-
<p><ul>
145
-
<li>A <adata-link-spec=SELECTORS4href=../selectors/Overview.html#simple>simple selector</a> can be also <adata-link-type=dfnhref=#attribute-node-selector0title="attribute node selector">attribute node selector</a>.
<p> An <dfndata-dfn-type=dfndata-export="" id=attribute-node-pseudo-element>attribute node pseudo-element<aclass=self-linkhref=#attribute-node-pseudo-element></a></dfn> represents an attribute node in a document tree.
151
+
Its syntax is:
151
152
152
-
<p>A <dfndata-dfn-type=dfndata-noexport="" id=attribute-node-selector0>attribute node selector<aclass=self-linkhref=#attribute-node-selector0></a></dfn> represents an attribute node
153
-
in a document tree. It’s written using <code>::attr(<ahref=http://www.w3.org/TR/css3-namespace/#css-qnames>CSS qualified
<p> Where <dfnclass=css-codedata-dfn-type=typedata-export="" id=typedef-qualified-name><qualified-name><aclass=self-linkhref=#typedef-qualified-name></a></dfn> is a <adata-link-spec=css-namespacesdata-link-type=dfnhref=http://dev.w3.org/csswg/css-namespaces-1/#css-qualified-nametitle="css qualified name">CSS qualified name</a>.
155
155
156
-
<divclass=example>
157
-
<p>Example:
158
-
<p>The following selector represents <code>title</code> attributes in the document tree:
<adata-biblio-type=informativedata-link-type=bibliohref=#xml-namestitle=xml-names>[XML-NAMES]</a> for the use of namespaces in XML.)
170
-
171
-
<p>The namespace component may be left empty (no prefix before the
172
-
namespace separator) to indicate that the selector is only to
173
-
represent attributes with no namespace.
174
-
175
-
<p>An asterisk may be used for the namespace prefix, indicating that
176
-
the selector represents attributes in any namespace (including attributes
177
-
with no namespace).
178
-
179
-
<p>An attribute node selector containing a namespace prefix that has not been
180
-
previously <ahref=#nsdecl>declared</a> for namespaced selectors is
181
-
an <ahref=#conformance>invalid</a> selector.
182
-
183
-
<p>In a namespace-aware client, the name part of attribute node
184
-
selectors (the part after the namespace separator, if it is present)
185
-
will only match against the <ahref=http://www.w3.org/TR/REC-xml-names/#NT-LocalPart>local part</a>
186
-
of the attribute’s <ahref=http://www.w3.org/TR/REC-xml-names/#ns-qualnames>qualified
187
-
name</a>.
188
-
189
-
<p>In summary:
190
-
191
-
<dl>
192
-
<dt><code>ns|A</code>
193
-
<dd>attributes with name A in namespace ns
194
-
<dt><code>*|A</code>
195
-
<dd>attributes with name A in any namespace, including those without a
196
-
namespace
197
-
<dt><code>|A</code>
198
-
<dd>attributes with name A without a namespace
199
-
<dt><code>A</code>
200
-
<dd>attributes with name A without a namespace
201
-
</dl>
202
-
203
-
<divclass=example>
204
-
<p>Examples:
205
-
206
-
<p>Following examples assume that prefix <code>xlink</code> is
207
-
bound to the <code>http://www.w3.org/1999/xlink</code> namespace
208
-
(XLink namespace).
209
-
210
-
<pre>xlink:title /* title attribute in XLink namespace */
211
-
title /* title attribute in no namespace, for example title as used in HTML language */
212
-
*|title /* any title attribute */</pre>
213
-
214
-
</div>
156
+
<p> The pseudo-element matches an attribute node with the given qualified name,
157
+
if such an attribute exists on the <adata-link-spec=selectorsdata-link-type=dfnhref=http://dev.w3.org/csswg/selectors-4/#originating-elementtitle="originating element">originating element</a>.
215
158
159
+
<divclass=example>
160
+
For example,
161
+
the selector <spanclass=cssdata-link-type=maybetitle=::attr(title)>::attr(title)</span> selects all the <code>title</code> attributes in the document.
162
+
</div>
216
163
164
+
<divclass=example>
165
+
TODO: Provide a real-world example from ITS or something.
166
+
</div>
217
167
168
+
<p> In CSS, <adata-link-type=dfnhref=#attribute-node-pseudo-elementtitle="attribute node pseudo-elements">attribute node pseudo-elements</a> never generate boxes.
<divdata-fill-with=normative-references><dl><dtid=css3namespacetitle=CSS3NAMESPACE><aclass=self-linkhref=#css3namespace></a>[CSS3NAMESPACE]<dd>Elika J. Etemad; Anne van Kesteren. <ahref=http://www.w3.org/TR/2011/REC-css3-namespace-20110929/>CSS Namespaces Module</a>. 29 September 2011. W3C Recommendation. URL: <ahref=http://www.w3.org/TR/2011/REC-css3-namespace-20110929/>http://www.w3.org/TR/2011/REC-css3-namespace-20110929/</a><dtid=rfc2119title=RFC2119><aclass=self-linkhref=#rfc2119></a>[RFC2119]<dd>S. Bradner. <ahref=http://www.ietf.org/rfc/rfc2119.txt>Key words for use in RFCs to Indicate Requirement Levels</a>. URL: <ahref=http://www.ietf.org/rfc/rfc2119.txt>http://www.ietf.org/rfc/rfc2119.txt</a><dtid=selectors4title=SELECTORS4><aclass=self-linkhref=#selectors4></a>[SELECTORS4]<dd>Elika J. Etemad; Tab Atkins Jr.. <ahref=http://www.w3.org/TR/2013/WD-selectors4-20130502/>Selectors Level 4</a>. 2 May 2013. W3C Working Draft. (Work in progress.) URL: <ahref=http://www.w3.org/TR/2013/WD-selectors4-20130502/>http://www.w3.org/TR/2013/WD-selectors4-20130502/</a></dl></div>
295
+
<divdata-fill-with=normative-references><dl><dtid=rfc2119title=RFC2119><aclass=self-linkhref=#rfc2119></a>[RFC2119]<dd>S. Bradner. <ahref=http://www.ietf.org/rfc/rfc2119.txt>Key words for use in RFCs to Indicate Requirement Levels</a>. URL: <ahref=http://www.ietf.org/rfc/rfc2119.txt>http://www.ietf.org/rfc/rfc2119.txt</a><dtid=selectors4title=SELECTORS4><aclass=self-linkhref=#selectors4></a>[SELECTORS4]<dd>Elika J. Etemad; Tab Atkins Jr.. <ahref=http://www.w3.org/TR/2013/WD-selectors4-20130502/>Selectors Level 4</a>. 2 May 2013. W3C Working Draft. (Work in progress.) URL: <ahref=http://www.w3.org/TR/2013/WD-selectors4-20130502/>http://www.w3.org/TR/2013/WD-selectors4-20130502/</a></dl></div>
<divdata-fill-with=informative-references><dl><dtid=css3syntitle=CSS3SYN><aclass=self-linkhref=#css3syn></a>[CSS3SYN]<dd>L. David Baron. <ahref=http://www.w3.org/TR/2003/WD-css3-syntax-20030813>CSS3 module: Syntax</a>. 13 August 2003. W3C Working Draft. (Work in progress.) URL: <ahref=http://www.w3.org/TR/2003/WD-css3-syntax-20030813>http://www.w3.org/TR/2003/WD-css3-syntax-20030813</a><dtid=selectors-apititle=SELECTORS-API><aclass=self-linkhref=#selectors-api></a>[SELECTORS-API]<dd>Anne van Kesteren; Lachlan Hunt. <ahref=http://www.w3.org/TR/2013/REC-selectors-api-20130221/>Selectors API Level 1</a>. 21 February 2013. W3C Recommendation. URL: <ahref=http://www.w3.org/TR/2013/REC-selectors-api-20130221/>http://www.w3.org/TR/2013/REC-selectors-api-20130221/</a><dtid=xml-namestitle=XML-NAMES><aclass=self-linkhref=#xml-names></a>[XML-NAMES]<dd>Tim Bray; et al. <ahref=http://www.w3.org/TR/2009/REC-xml-names-20091208/>Namespaces in XML 1.0 (Third Edition)</a>. 8 December 2009. W3C Recommendation. URL: <ahref=http://www.w3.org/TR/2009/REC-xml-names-20091208/>http://www.w3.org/TR/2009/REC-xml-names-20091208/</a></dl></div>
299
+
<divdata-fill-with=informative-references><dl><dtid=css3syntitle=CSS3SYN><aclass=self-linkhref=#css3syn></a>[CSS3SYN]<dd>Tab Atkins Jr.; Simon Sapin. <ahref=http://www.w3.org/TR/2013/WD-css-syntax-3-20131105/>CSS Syntax Module</a>. 5 November 2013. W3C Working Draft. (Work in progress.) URL: <ahref=http://www.w3.org/TR/2013/WD-css-syntax-3-20131105/>http://www.w3.org/TR/2013/WD-css-syntax-3-20131105/</a><dtid=selectors-apititle=SELECTORS-API><aclass=self-linkhref=#selectors-api></a>[SELECTORS-API]<dd>Anne van Kesteren; Lachlan Hunt. <ahref=http://www.w3.org/TR/2013/REC-selectors-api-20130221/>Selectors API Level 1</a>. 21 February 2013. W3C Recommendation. URL: <ahref=http://www.w3.org/TR/2013/REC-selectors-api-20130221/>http://www.w3.org/TR/2013/REC-selectors-api-20130221/</a></dl></div>
0 commit comments