10 |
<div class="header"> |
<div class="header"> |
11 |
<h1>Selectors Serialization Format for Testing (<abbr>SSFT</abbr>) |
<h1>Selectors Serialization Format for Testing (<abbr>SSFT</abbr>) |
12 |
Specification</h1> |
Specification</h1> |
13 |
<h2>Working Draft 25 September 2007</h2> |
<h2>Working Draft <time datetime=2007-10-22>22 October 2007</time></h2> |
14 |
|
|
15 |
<dl class="versions-uri"> |
<dl class="versions-uri"> |
16 |
<dt>This Version</dt> |
<dt>This Version</dt> |
23 |
<dt>Latest Working Draft</dt> |
<dt>Latest Working Draft</dt> |
24 |
--> |
--> |
25 |
<!-- <dt>Previous Version</dt> --> |
<!-- <dt>Previous Version</dt> --> |
26 |
|
<dt>Version History</dt> |
27 |
|
<dd><code class=URI><<a href="http://suika.fam.cx/gate/cvs/markup/selectors/ssft/ssft.en.html">http://suika.fam.cx/gate/cvs/markup/selectors/ssft/ssft.en.html</a>></code></dd> |
28 |
</dl> |
</dl> |
29 |
<dl class="authors" id="author"> |
<dl class="authors" id="author"> |
30 |
<dt>Author</dt> |
<dt>Author</dt> |
34 |
>w@suika.fam.cx</a>></code></dd> |
>w@suika.fam.cx</a>></code></dd> |
35 |
</dl> |
</dl> |
36 |
|
|
37 |
<p class="copyright" lang="en">© 2007 <a |
<p class="copyright" lang="en">© <time>2007</time> <a |
38 |
href="http://suika.fam.cx/~wakaba/who?" rel="author">Wakaba</a>. |
href="http://suika.fam.cx/~wakaba/who?" rel="author">Wakaba</a>. |
39 |
Permission is granted to copy, distribute and/or modify this document |
Permission is granted to copy, distribute and/or modify this document |
40 |
under the terms of the <a rel="license" |
under the terms of the <a rel="license" |
59 |
<div id="status" class="section"> |
<div id="status" class="section"> |
60 |
<h2>Status of This Document</h2> |
<h2>Status of This Document</h2> |
61 |
|
|
62 |
<p><em>This section describes the status of this document |
<p class=section-info><em>This section describes the status of this document |
63 |
at the time of its publication. Other documents |
at the time of its publication. Other documents |
64 |
might supersede this document.</em></p> |
might supersede this document.</em></p> |
65 |
|
|
66 |
<p>This document is a working draft. |
<p>This document is a working draft, produced as part of the |
67 |
It might be updated, replaced, or obsoleted by |
<a href="http://suika.fam.cx/www/markup/html/whatpm/readme">Whatpm</a> |
68 |
|
subproject |
69 |
|
of the <a href="http://suika.fam.cx/www/manakai-core/doc/web/">manakai</a> |
70 |
|
project. It might be updated, replaced, or obsoleted by |
71 |
other documents at any time. It is inappropriate to |
other documents at any time. It is inappropriate to |
72 |
cite this document as other than <q>work in progress</q>.</p> |
cite this document as other than <q>work in progress</q>.</p> |
73 |
|
|
82 |
<div id="introduction" class="section"> |
<div id="introduction" class="section"> |
83 |
<h2>Introduction</h2> |
<h2>Introduction</h2> |
84 |
|
|
85 |
<p>This section is <em>informative</em>.</p> |
<p class=section-info>This section is <em>non$B!>(Bnormative</em>.</p> |
86 |
|
|
87 |
|
<p>Selectors |
88 |
|
<cite class="bibref normative">[<a href="#ref-SELECTORS">SELECTORS</a>]</cite> |
89 |
|
are patterns that match against elements |
90 |
|
in a tree structure and are used in Web technologies, including |
91 |
|
<a href="http://www.w3.org/TR/CSS21"><abbr title="Cascading Style Sheets">CSS</abbr></a> |
92 |
|
<cite class="bibref informative">[<a href="#ref-CSS">CSS</a>]</cite>, |
93 |
|
<a href="http://whatwg.org/html5"><abbr title="Hypertext Markup Language">HTML</abbr>5</a> |
94 |
|
<cite class="bibref informative">[<a href="#ref-HTML5">HTML5</a>]</cite>, |
95 |
|
<a href="http://www.mozilla.org/projects/xbl/xbl2.html"><abbr title="XML Binding Language">XBL</abbr>2</a> |
96 |
|
<cite class="bibref informative">[<a href="#ref-XBL2">XBL2</a>]</cite>, and |
97 |
|
<a href="http://dev.w3.org/cvsweb/~checkout~/2006/webapi/selectors-api/Overview.html?rev=1.28&content-type=text/html;%20charset=utf-8">Selectors |
98 |
|
<abbr>API</abbr></a> |
99 |
|
<cite class="bibref informative">[<a href="#ref-SAPI">SAPI</a>]</cite>.</p> |
100 |
|
|
101 |
<div class="issue ed">...</div> |
<div class="issue ed">...</div> |
102 |
|
|
103 |
<p><a href="http://dev.w3.org/cvsweb/csswg/cssom/Overview.html">The |
<p><a href="http://dev.w3.org/cvsweb/csswg/cssom/Overview.html">The |
104 |
<abbr title="Cascading Style Sheets Object Model">CSSOM</abbr> |
<abbr title="Cascading Style Sheets Object Model">CSSOM</abbr> |
105 |
specification</a> |
specification</a> |
106 |
<cite class="bibref informative">[<a href="#bib-CSSOM">CSSOM</a>]</cite> |
<cite class="bibref informative">[<a href="#ref-CSSOM">CSSOM</a>]</cite> |
107 |
is trying to define an algorithm to |
is trying to define an algorithm to |
108 |
<a href="http://dev.w3.org/cvsweb/~checkout~/csswg/cssom/Overview.html?rev=1.55&content-type=text/html;%20charset=utf-8#serializing0">serialize |
<a href="http://dev.w3.org/cvsweb/~checkout~/csswg/cssom/Overview.html?rev=1.55&content-type=text/html;%20charset=utf-8#serializing0">serialize |
109 |
a group of selectors</a> for the purpose of <code>selectorText</code> |
a group of selectors</a> for the purpose of <code>selectorText</code> |
110 |
attribute. However, the algorithm is incomplete |
attribute. However, the algorithm is incomplete |
111 |
at the time of the writing. Note that current Web browser implementations |
<time datetime=2007-09-25>at the time of the writing</time>. |
112 |
|
Note that current Web browser implementations |
113 |
of the <code>selectorText</code> attribute are consistently broken |
of the <code>selectorText</code> attribute are consistently broken |
114 |
in not escaping unsafe identifiers.</p> |
in not escaping unsafe identifiers.</p> |
115 |
|
|
118 |
<div class="section" id="terminology"> |
<div class="section" id="terminology"> |
119 |
<h2>Terminology</h2> |
<h2>Terminology</h2> |
120 |
|
|
121 |
<p>The key words <q><em class="rfc2119">MUST</em></q>, |
<p>The key words <q><dfn id=must><em class="rfc2119">MUST</em></dfn></q>, |
122 |
<q><em class="rfc2119">MUST NOT</em></q>, |
<q><dfn id=must-not><em class="rfc2119">MUST NOT</em></dfn></q>, |
123 |
<q><em class="rfc2119">SHOULD</em></q>, |
<q><dfn id=should><em class="rfc2119">SHOULD</em></dfn></q>, |
124 |
<q><em class="rfc2119">SHOULD NOT</em></q>, and |
<q><dfn id=should-not><em class="rfc2119">SHOULD NOT</em></dfn></q>, and |
125 |
<q><em class=rfc2119>MAY</em></q> in this |
<q><dfn id=may><em class=rfc2119>MAY</em></dfn></q> in this |
126 |
document are to be interpreted as described in |
document are to be interpreted as described in |
127 |
<abbr title="Request for Comments">RFC</abbr> 2119 |
<a href="urn:ietf:rfc:2119"><abbr title="Request for Comments">RFC</abbr> |
128 |
|
2119</a> |
129 |
<cite class="bibref normative">[<a href="#ref-KEYWORDS">KEYWORDS</a>]</cite>.</p> |
<cite class="bibref normative">[<a href="#ref-KEYWORDS">KEYWORDS</a>]</cite>.</p> |
130 |
|
|
131 |
|
<!-- Strictly speaking the paragraph below is not part of terminology. --> |
132 |
|
<p>All examples and notes in this specification are non$B!>(Bnormative, |
133 |
|
as are all sections explicitly marked non$B!>(Bnormative. Everything |
134 |
|
else in this specification is normative.</p> |
135 |
|
|
136 |
|
<p>For the purpose of this specification, pseudo$B!>(Belements are also |
137 |
|
referred to as <dfn title="simple selector" id=simple-selector>simple |
138 |
|
selectors</dfn> and are considered as part of the last sequence of |
139 |
|
simple selector in a selector.</p> |
140 |
</div> |
</div> |
141 |
|
|
142 |
<div class="section" id="serializing"> |
<div class="section" id="serializing"> |
147 |
for now.</p> |
for now.</p> |
148 |
</div> |
</div> |
149 |
|
|
150 |
<p><dfn id=newline>Newline</dfn> is <code class=char>U+000A</code> |
<p>No <abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
151 |
<code class=charname>LINE FEED</code> <span class=ed>or |
representation is defined for an invalid group of selectors.</p> |
152 |
U+000D U+000A or U+000A ??</span>.</p> |
|
153 |
|
<div class="note memo"> |
154 |
|
<p>The serialized representation will not contain any comment.</p> |
155 |
|
</div> |
156 |
|
|
157 |
<!-- TODO: link terms to Selectors --> |
<!-- TODO: link terms to Selectors --> |
158 |
|
|
159 |
|
<p>To |
160 |
|
<dfn id=algorithm-serialize-a-group-of-selectors title="serialize a group of selectors">serialize |
161 |
|
a group of selectors (<dfn id=var-gs><var>gs</var></dfn>)</dfn>:</p> |
162 |
<ol> |
<ol> |
163 |
<li>Let <var>result</var> an empty string.</li> |
<li>Let <dfn id=var-result><var>result</var></dfn> an empty string.</li> |
164 |
<li>For each selector (<var>selector</var>) in the group of selectors: |
<li>For each selector (<dfn id=var-selector><var>selector</var></dfn>) in |
165 |
|
<var>gs</var>: |
166 |
<ol> |
<ol> |
167 |
<li>If <var>selector</var> is <em>not</em> the first selector |
<li>If <var>selector</var> is <em>not</em> the first selector |
168 |
in the group of selectors, then append a <code class=char>U+002C</code> |
in the group of selectors, then append a <code class=char>U+002C</code> |
169 |
<code class=charname>COMMA</code> followed by a |
<code class=charname>COMMA</code> (<code class=char>,</code>) followed by a |
170 |
<a href="#newline">newline</a> to <var>result</var>.</li> |
<a href="#newline">newline</a> to <var>result</var>.</li> |
171 |
<li>Append four <code class=char>U+0020</code> |
<li>Append four <code class=char>U+0020</code> |
172 |
<code class=charname>SPACE</code> characters to <var>result</var>.</li> |
<code class=charname>SPACE</code> characters to <var>result</var>.</li> |
173 |
<li>Process each sequence of simple selectors or |
<li>Process each sequence of simple selectors or |
174 |
combinator in <var>selector</var> by following algorithm: |
combinator in <var>selector</var> by following algorithm: |
175 |
<dl class=switch> |
<dl class=switch> |
176 |
<dt>If it is a sequence of simle selector (<var>sss</var>)</dt> |
<dt>If it is a sequence of simle selector |
177 |
<dd class=ed>@@</dd> |
(<dfn id=var-sss><var>sss</var></dfn>)</dt> |
178 |
<dt>If it is a combinator (<var>c</var>)</dt> |
<dd> |
179 |
|
<ol> |
180 |
|
<li class=ed><a href="#algorithm-serialize-a-simple-selector">Serialize |
181 |
|
each simple selector</a> in <var>sss</var>.</li> |
182 |
|
<li class=ed>sort</li> |
183 |
|
<li>Append a <a href="#newline">newline</a> to <var>result</var>.</li> |
184 |
|
</ol> |
185 |
|
</dd> |
186 |
|
<dt>If it is a combinator (<dfn id=var-c><var>c</var></dfn>)</dt> |
187 |
<dd> |
<dd> |
188 |
<ol> |
<ol> |
189 |
<li>Append two <code class=char>U+0020</code> |
<li>Append two <code class=char>U+0020</code> |
197 |
<dt>If <var>c</var> is child combinator |
<dt>If <var>c</var> is child combinator |
198 |
(<code class=char>></code>)</dt> |
(<code class=char>></code>)</dt> |
199 |
<dd>Append a <code class=char>U+003E</code> |
<dd>Append a <code class=char>U+003E</code> |
200 |
<code class=charname>GREATER-THAN SIGN</code> character to |
<code class=charname>GREATER-THAN SIGN</code> |
201 |
<var>result</var>.</dd> |
(<code class=char>></code>) character to <var>result</var>.</dd> |
202 |
<dt>If <var>c</var> is adjacent sibling combinator |
<dt>If <var>c</var> is adjacent sibling combinator |
203 |
(<code class=char>+</code>)</dt> |
(<code class=char>+</code>)</dt> |
204 |
<dd>Append a <code class=char>U+0020</code> |
<dd>Append a <code class=char>U+002B</code> |
205 |
<code class=charname>SPACE</code> character to |
<code class=charname>PLUS SIGN</code> (<code class=char>+</code>) |
206 |
<var>result</var>.</dd> |
character to <var>result</var>.</dd> |
207 |
<dt>If <var>c</var> is general sibling combinator |
<dt>If <var>c</var> is general sibling combinator |
208 |
(<code class=char>~</code>)</dt> |
(<code class=char>~</code>)</dt> |
209 |
<dd>Append a <code class=char>U+007E</code> |
<dd>Append a <code class=char>U+007E</code> |
210 |
<code class=charname>TILDE</code> character to |
<code class=charname>TILDE</code> (<code class=char>~</code>) |
211 |
<var>result</var>.</dd> |
character to <var>result</var>.</dd> |
212 |
</dl> |
</dl> |
213 |
</li> |
</li> |
214 |
<li>Append a <code class=char>U+0020</code> |
<li>Append a <code class=char>U+0020</code> |
220 |
</ol> |
</ol> |
221 |
</li> |
</li> |
222 |
<li>Then, <var>result</var> is the |
<li>Then, <var>result</var> is the |
223 |
<abbr title="Selectors Serialization Format for Testing">SFFT</abbr> |
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
224 |
representation of the group of selectors.</li> |
representation of <var>gs</var>.</li> |
225 |
</ol> |
</ol> |
226 |
|
|
227 |
|
<p>To |
228 |
|
<dfn id=algorithm-serialize-a-simple-selector title="serialize a simple selector">serialize |
229 |
|
a simple selector (<dfn><var id=var-ss>ss</var></dfn>)</dfn>:</p> |
230 |
|
<dl class=switch> |
231 |
|
<dt>If <var>ss</var> is a type or universal selector</dt> |
232 |
|
<dd> |
233 |
|
<ol> |
234 |
|
<li> |
235 |
|
<dl class=switch> |
236 |
|
<dt>If a namespace URI is specified (via namespace prefix, or |
237 |
|
by omitting namespace prefix where a default namespace is specified)</dt> |
238 |
|
<dd class="ed">@@</dd> |
239 |
|
<dt>If the null namespace is specified (by zero$B!>(Blength namespace |
240 |
|
prefix)</dt> |
241 |
|
<dd>Append a <code class=char>U+007C</code> |
242 |
|
<code class=charname>VERTICAL BAR</code> (<code class=char>|</code>) |
243 |
|
character to <var>result</var>.</dd> |
244 |
|
<dt>If no namespace is specified (by namespace prefix <code>*</code>, |
245 |
|
or by omitting namespace prefix where no default namespace is |
246 |
|
specified)</dt> |
247 |
|
<dd>Append a <code class=char>U+002A</code> |
248 |
|
<code class=charname>ASTERISK</code> (<code class=char>*</code>) |
249 |
|
character, followed by a <code class=char>U+007C</code> |
250 |
|
<code class=charname>VERTICAL BAR</code> (<code class=char>|</code>) |
251 |
|
character, to <var>result</var>.</dd> |
252 |
|
</dl> |
253 |
|
</li> |
254 |
|
<li>If <var>ss</var> is a type selector, append the |
255 |
|
<a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
256 |
|
local name to <var>result</var>.</li> |
257 |
|
<li>If <var>ss</var> is a universal selector, append |
258 |
|
a <code class=char>U+002A</code> <code class=charname>ASTERISK</code> |
259 |
|
(<code class=char>*</code>) character to <var>result</var>.</li> |
260 |
|
</ol> |
261 |
|
</dd> |
262 |
|
<dt>If <var>ss</var> is an attribute selector</dt> |
263 |
|
<dd> |
264 |
|
<ol> |
265 |
|
<li>Append a <code class=char>U+005B</code> <code class=charname>LEFT |
266 |
|
SQUARE BRACKET</code> (<code class=char>[</code>) to |
267 |
|
<var>result</var>.</li> |
268 |
|
<li> |
269 |
|
Append a namespace prefix as following: |
270 |
|
<dl> |
271 |
|
<dt>If a namespace URI is specified</dt> |
272 |
|
<dd class=ed>@@</dd> |
273 |
|
<dd class=ed>@@ Current reference implementation is wrong, |
274 |
|
since its result of sorting depends on namespace prefix.</dd> |
275 |
|
<dt>If the null namespace is specified</dt> |
276 |
|
<dd>Append a <code class=char>U+007C</code> |
277 |
|
<code class=charname>VERTICAL BAR</code> character to |
278 |
|
<var>result</var>.</dd> |
279 |
|
<dt>If no namespace is specified</dt> |
280 |
|
<dd>Append a <code class=char>U+002A</code> |
281 |
|
<code class=charname>ASTERISK</code> (<code class=char>*</code>) |
282 |
|
character, followed by a <code class=char>U+007C</code> |
283 |
|
<code class=charname>VERTICAL BAR</code> (<code class=char>|</code>) |
284 |
|
character, to <var>result</var>.</dd> |
285 |
|
</dl> |
286 |
|
</li> |
287 |
|
<li>Append the |
288 |
|
<a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
289 |
|
local name to <var>result</var>.</li> |
290 |
|
<li>If a value is specified in <var>ss</var>: |
291 |
|
<ol> |
292 |
|
<li>Depending on the way to match, append <code>=</code>, |
293 |
|
<code>~=</code>, <code>|=</code>, <code>^=</code>, |
294 |
|
<code>$=</code>, or <code>*=</code> to <var>result</var>.</li> |
295 |
|
<li>Append the |
296 |
|
<a href="#algorithm-normalize-a-string" title="normalize a string">normalized</a> |
297 |
|
value to <var>result</var>.</li> |
298 |
|
</ol> |
299 |
|
</li> |
300 |
|
<li>Append a <code class=char>U+005D</code> <code class=charname>RIGHT |
301 |
|
SQUARE BRACKET</code> (<code class=char>]</code>) to |
302 |
|
<var>result</var>.</li> |
303 |
|
</ol> |
304 |
|
</dd> |
305 |
|
<dt>If <var>ss</var> is a class selector</dt> |
306 |
|
<dd>Append a <code class=char>U+002E</code> <code class=charname>FULL |
307 |
|
STOP</code> (<code class=char>.</code>) character, followed |
308 |
|
by <a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
309 |
|
class name, <var>result</var>.</dd> |
310 |
|
<dt>If <var>ss</var> is an <abbr>ID</abbr> selector</dt> |
311 |
|
<dd>Append a <code class=char>U+0023</code> <code class=charname>NUMBER |
312 |
|
SIGN</code> (<code class=char>#</code>) character, followed |
313 |
|
by <a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
314 |
|
<abbr>ID</abbr>, to <var>result</var>.</dd> |
315 |
|
<dt>If <var>ss</var> is a pseudo$B!>(Bclass selector</dt> |
316 |
|
<dd> |
317 |
|
<ol> |
318 |
|
<li>Append a <code class=char>U+003A</code> |
319 |
|
<code class=charname>COLON</code> (<code class=char>:</code>) character |
320 |
|
to <var>result</var>.</li> |
321 |
|
<li>Append the |
322 |
|
<a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
323 |
|
name of the pseudo$B!>(Bclass to <var>result</var>.</li> |
324 |
|
<li>Append any arguments as following: |
325 |
|
<dl class=switch> |
326 |
|
<dt>If the name of the pseudo$B!>(Bclass is <code>lang</code></dt> |
327 |
|
<dd> |
328 |
|
<ol> |
329 |
|
<li>Append a <code class=char>U+0028</code> <code class=charname>LEFT |
330 |
|
PARENTHESIS</code> (<code class=char>(</code>) character |
331 |
|
to <var>result</var>.</li> |
332 |
|
<li>Append the |
333 |
|
<a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
334 |
|
language tag (the argument) to <var>result</var>.</li> |
335 |
|
<li>Append a <code class=char>U+0029</code> |
336 |
|
<code class=charname>RIGHT PARENTHESIS</code> |
337 |
|
(<code class=char>)</code>) character |
338 |
|
to <var>result</var>.</li> |
339 |
|
</ol> |
340 |
|
</dd> |
341 |
|
<dt>If the name of the pseudo$B!>(Bclass is |
342 |
|
<code>-manakai-contains</code></dt> |
343 |
|
<dd> |
344 |
|
<ol> |
345 |
|
<li>Append a <code class=char>U+0028</code> <code class=charname>LEFT |
346 |
|
PARENTHESIS</code> (<code class=char>(</code>) character |
347 |
|
to <var>result</var>.</li> |
348 |
|
<li>Append the |
349 |
|
<a href="#algorithm-normalize-a-string" title="normalize a string">normalized</a> |
350 |
|
string (the argument) to <var>result</var>.</li> |
351 |
|
<li>Append a <code class=char>U+0029</code> |
352 |
|
<code class=charname>RIGHT PARENTHESIS</code> |
353 |
|
(<code class=char>)</code>) character |
354 |
|
to <var>result</var>.</li> |
355 |
|
</ol> |
356 |
|
</dd> |
357 |
|
<dt>If name of the pseudo$B!>(Bclass is either <code>nth-child</code>, |
358 |
|
<code>nth-last-child</code>, <code>nth-of-type</code>, or |
359 |
|
<code>nth-last-of-type</code></dt> |
360 |
|
<dd> |
361 |
|
<ol> |
362 |
|
<li>Append a <code class=char>U+0028</code> <code class=charname>LEFT |
363 |
|
PARENTHESIS</code> (<code class=char>(</code>) character |
364 |
|
to <var>result</var>.</li> |
365 |
|
<li>Append <span class=ed>@@ normalized</span> |
366 |
|
integer <var>a</var> to <var>result</var>. |
367 |
|
If the argument is a keyword <code>odd</code> or <code>even</code>, |
368 |
|
<var>a</var> is <code>2</code>. If <var>a</var> and |
369 |
|
<code>n</code> is omitted, <var>a</var> is assumed as |
370 |
|
<code>0</code>. Otherwise, if <var>a</var> is omitted, |
371 |
|
it is assumed as <code>1</code> (or <code>-1</code>, |
372 |
|
if there is a <code class=char>U+002D</code> |
373 |
|
<code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>) |
374 |
|
character).</li> |
375 |
|
<li>Append a <code class=char>U+006E</code> |
376 |
|
<code class=charname>LATIN SMALL LETTER N</code> |
377 |
|
(<code class=char>n</code>) character to <var>result</var>.</li> |
378 |
|
<li>Append <span class=ed>@@ normalized</span> |
379 |
|
integer <var>b</var> to <var>result</var>. |
380 |
|
It <em class=rfc2119>MUST</em> be preceded by a sign, |
381 |
|
either <code class=char>U+002B</code> <code class=charname>PLUS |
382 |
|
SIGN</code> (<code class=char>+</code>) or |
383 |
|
<code class=char>U+002D</code> |
384 |
|
<code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>) |
385 |
|
character. If the argument is a keyword <code>odd</code>, |
386 |
|
<var>b</var> is <code>1</code>. If the argument |
387 |
|
is a keyword <code>even</code>, <var>b</var> is |
388 |
|
<code>0</code>. If <var>b</var> is omitted, it is assumed as |
389 |
|
<code>0</code>. The sign of <code>0</code> |
390 |
|
<em class=rfc2119>MUST</em> be <code class=char>U+002B</code> |
391 |
|
<code class=charname>PLUS SIGN</code> |
392 |
|
(<code class=char>+</code>).</li> |
393 |
|
<li>Append a <code class=char>U+0029</code> |
394 |
|
<code class=charname>RIGHT PARENTHESIS</code> |
395 |
|
(<code class=char>)</code>) character |
396 |
|
to <var>result</var>.</li> |
397 |
|
</ol> |
398 |
|
</dd> |
399 |
|
<dt>If the name of the pseudo$B!>(Bclass is <code>not</code></dt> |
400 |
|
<dd> |
401 |
|
<ol> |
402 |
|
<li>Append a string of <code class=char>U+003A</code> |
403 |
|
<code class=charname>COLON</code>, <code class=char>U+006E</code> |
404 |
|
<code class=charname>LATIN SMALL LETTER N</code>, |
405 |
|
<code class=char>U+006F</code> <code class=charname>LATIN |
406 |
|
SMALL LETTER O</code>, <code class=char>U+0074</code> |
407 |
|
<code class=charname>LATIN SMALL LETTER T</code>, and |
408 |
|
<code class=char>U+0028</code> <code class=charname>LEFT |
409 |
|
PARENTHESIS</code> (<code>:not(</code>), followed by a |
410 |
|
<a href="#newline">newline</a>, to <var>result</var>.</li> |
411 |
|
<li>Append four <code class=char>U+0020</code> |
412 |
|
<code class=charname>SPACE</code> characters to |
413 |
|
<var>result</var>.</li> |
414 |
|
<li>Append four <code class=char>U+0020</code> |
415 |
|
<code class=charname>SPACE</code> characters to |
416 |
|
<var>result</var> again.</li> |
417 |
|
<li><a href="#algorithm-serialize-a-simple-selector">Serialize |
418 |
|
the simple selector specified as the argument to the |
419 |
|
<code>not</code> pseudo$B!>(Bclass</a>.</li> |
420 |
|
<li>Append a <a href="#newline">newline</a> to |
421 |
|
<var>result</var>.</li> |
422 |
|
<li>Append four <code class=char>U+0020</code> |
423 |
|
<code class=charname>SPACE</code> characters to |
424 |
|
<var>result</var>.</li> |
425 |
|
<li>Append a <code class=char>U+0029</code> |
426 |
|
<code class=charname>RIGHT PARENTHESIS</code> |
427 |
|
(<code class=char>)</code>) character |
428 |
|
to <var>result</var>.</li> |
429 |
|
</ol> |
430 |
|
</dd> |
431 |
|
</dl> |
432 |
|
</li> |
433 |
|
</ol> |
434 |
|
</dd> |
435 |
|
<dt>If <var>ss</var> is a pseudo$B!>(Belement</dt> |
436 |
|
<dd> |
437 |
|
<ol> |
438 |
|
<li>Append two <code class=char>U+003A</code> |
439 |
|
<code class=charname>COLON</code> characters (<code>::</code>) |
440 |
|
to <var>result</var>.</li> |
441 |
|
<li>Append the |
442 |
|
<a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
443 |
|
name of the pseudo$B!>(Belement to <var>result</var>.</li> |
444 |
|
<!-- For future version: append "(", arguments, ")", if any. --> |
445 |
|
</ol> |
446 |
|
</dd> |
447 |
|
</dl> |
448 |
|
|
449 |
|
<p>To <dfn id=algorithm-normalize-an-ident title="normalize an IDENT">normalize |
450 |
|
an <code>IDENT</code> (<dfn id=var-n><var>n</var></dfn>)</dfn>:</p> |
451 |
|
<ol> |
452 |
|
<li>Replace the escape sequences (<code>\</code> and following |
453 |
|
characters) in <var>n</var> by characters represented by them |
454 |
|
respectively.</li> |
455 |
|
<li>If there is any character that is <em>not</em> one of |
456 |
|
<code class=char>U+002D</code> <code class=charname>HYPHEN-MINUS</code> |
457 |
|
(<code class=char>-</code>), <code class=char>U+0030</code> |
458 |
|
<code class=charname>DIGIT ZERO</code> |
459 |
|
(<code class=char>0</code>) to <code class=char>U+0039</code> |
460 |
|
<code class=charname>DIGIT NINE</code> (<code class=char>9</code>), |
461 |
|
<code class=char>U+0041</code> <code class=charname>LATIN CAPITAL LETTER |
462 |
|
A</code> (<code class=char>A</code>) to <code class=char>U+005A</code> |
463 |
|
<code class=charname>LATIN CAPITAL LETTER Z</code> (<code class=char>Z</code>), |
464 |
|
<code class=char>U+005F</code> <code class=charname>LOW LINE</code> |
465 |
|
(<code class=char>_</code>), <code class=char>U+0061</code> |
466 |
|
<code class=charname>LATIN SMALL LETTER A</code> |
467 |
|
(<code class=char>a</code>) to <code class=char>U+006A</code> |
468 |
|
<code class=charname>LATIN SMALL LETTER Z</code> (<code class=char>z</code>), |
469 |
|
<code class=char>U+0080</code> to <code class=char>U+D7FF</code>, or |
470 |
|
<code class=char>U+E000</code> to <code class=char>U+10FFFF</code> in |
471 |
|
<var>n</var>, then replace it by string <code>\<var>HHHHHH</var></code>, where |
472 |
|
<dfn id=var-HHHHHH><var>HHHHHH</var></dfn> is the upper$B!>(Bcase zero$B!>(Bpadded |
473 |
|
hexadecimal representation of the character. If the character |
474 |
|
is outside the range of <code>[<code class=char>U+0000</code>, |
475 |
|
<code class=char>U+10FFFF</code>]</code>, <var>HHHHHH</var> |
476 |
|
<em class=rfc2119>MUST</em> be <code>FFFFFF</code>.</li> |
477 |
|
<li>If the first character in <var>n</var> is one of |
478 |
|
<code class=char>U+0030</code> <code class=charname>DIGIT ZERO</code> |
479 |
|
(<code class=char>0</code>) to <code class=char>U+0039</code> |
480 |
|
<code class=charname>DIGIT NINE</code> (<code class=char>9</code>), |
481 |
|
then prepend a string <code>\00003</code> at the beginning of |
482 |
|
<var>n</var>.</li> |
483 |
|
<li>If the first character in <var>n</var> is <code class=char>U+002D</code> |
484 |
|
<code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>) and |
485 |
|
the second character, if any, is <em>not</em> one of |
486 |
|
<code class=char>U+0041</code> <code class=charname>LATIN CAPITAL LETTER |
487 |
|
A</code> (<code class=char>A</code>) to <code class=char>U+005A</code> |
488 |
|
<code class=charname>LATIN CAPITAL LETTER Z</code> (<code class=char>Z</code>), |
489 |
|
<code class=char>U+005F</code> <code class=charname>LOW LINE</code> |
490 |
|
(<code class=char>_</code>), <code class=char>U+0061</code> |
491 |
|
<code class=charname>LATIN SMALL LETTER A</code> |
492 |
|
(<code class=char>a</code>) to <code class=char>U+006A</code> |
493 |
|
<code class=charname>LATIN SMALL LETTER Z</code> (<code class=char>z</code>), |
494 |
|
<code>U+0080</code> to <code>U+D7FF</code>, or |
495 |
|
<code>U+E000</code> to <code>U+10FFFF</code>, or |
496 |
|
<var>n</var> is equal to <code class=char>U+002D</code> |
497 |
|
<code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>), then |
498 |
|
replace the <code class=char>U+002D</code> |
499 |
|
<code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>) |
500 |
|
character by string <code>\00002D</code>.</li> |
501 |
|
<li>Then, <var>n</var> is the result of the algorithm.</li> |
502 |
|
</ol> |
503 |
|
|
504 |
|
<p>To <dfn id=algorithm-normalize-a-string title="normalize a STRING">normalize |
505 |
|
a <code>STRING</code> (<dfn id=var-s><var>s</var></dfn>)</dfn>:</p> |
506 |
|
<ol> |
507 |
|
<li>Replace the escape sequences (<code>\</code> and following |
508 |
|
characters) in <var>s</var> by characters represented by them |
509 |
|
(or an empty string if <code>\</code> is immediately followed by |
510 |
|
newline character(s)) respectively.</li> |
511 |
|
<li>Remove the quotation characters in <var>s</var> |
512 |
|
if <var>s</var> is a <code>STRING</code>.</li> |
513 |
|
<li>If there is any character that is <em>not</em> one of |
514 |
|
<code class=char>U+0020</code> <code class=charname>SPACE</code>, |
515 |
|
<code class=char>U+0021</code> <code class=charname>EXCLAMATION MARK</code> |
516 |
|
(<code class=char>!</code>), <code class=char>U+0023</code> |
517 |
|
<code class=charname>NUMBER SIGN</code> (<code class=char>#</code>) to |
518 |
|
<code class=char>U+005B</code> <code class=charname>LEFT SQUARE |
519 |
|
BRACKET</code>, <code class=char>U+005D</code> <code class=charname>RIGHT |
520 |
|
SQUARE BRACKET</code> to <code class=char>U+D7FF</code>, or |
521 |
|
<code class=char>U+E000</code> to <code class=char>U+10FFFF</code> in |
522 |
|
<var>s</var>, then replace it by string <code>\<var>HHHHHH</var></code>, where |
523 |
|
<dfn id=var-HHHHHH><var>HHHHHH</var></dfn> is the upper$B!>(Bcase zero$B!>(Bpadded |
524 |
|
hexadecimal representation of the character. If the character |
525 |
|
is outside the range of <code>[<code class=char>U+0000</code>, |
526 |
|
<code class=char>U+10FFFF</code>]</code>, <var>HHHHHH</var> |
527 |
|
<em class=rfc2119>MUST</em> be <code>FFFFFF</code>.</li> |
528 |
|
<li>Insert a <code class=char>U+0022</code> <code class=charname>QUOTATION |
529 |
|
MARK</code> (<code class=char>"</code>) at the beginning of <var>s</var>.</li> |
530 |
|
<li>Insert a <code class=char>U+0022</code> <code class=charname>QUOTATION |
531 |
|
MARK</code> (<code class=char>"</code>) at the end of <var>s</var>.</li> |
532 |
|
<li>Then, <var>s</var> is the result of the algorithm.</li> |
533 |
|
</ol> |
534 |
|
|
535 |
|
<p>A <dfn id=newline title=newline>newline</dfn> |
536 |
|
<em class=rfc2119>SHOULD</em> be represented as a |
537 |
|
<code class=char>U+000A</code> <code class=charname>LINE FEED</code> |
538 |
|
character. However, depending on the context where |
539 |
|
the <abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
540 |
|
representation is in use, a sequence of |
541 |
|
<code class=char>U+000D</code> <code class=charname>CARRIAGE RETURN</code> |
542 |
|
followed by a <code class=char>U+000A</code> |
543 |
|
<code class=charname>LINE FEED</code> (i.e. a |
544 |
|
<code>CRLF</code> sequence) or a character |
545 |
|
<code class=char>U+000D</code> <code class=charname>CARRIAGE RETURN</code> |
546 |
|
<em class=rfc2119>MAY</em> be used as a <a href="#newline">newline</a> instead. |
547 |
|
<a href="#newline">Newline</a> representations |
548 |
|
<em class=rfc2119>SHOULD</em> be consistent in an |
549 |
|
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
550 |
|
representation.</p> |
551 |
|
|
552 |
|
<div class="note memo"> |
553 |
|
<p>Therefore, newlines must be normalized before |
554 |
|
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
555 |
|
representations are literally compared.</p> |
556 |
|
</div> |
557 |
|
|
558 |
</div> |
</div> |
559 |
|
|
560 |
<div class="section" id="parsing"> |
<div class="section" id="parsing"> |
561 |
<h2>Parsing |
<h2>Parsing |
562 |
<abbr title="Selectors Serialization Format for Testing">SFFT</abbr> |
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
563 |
Groups of Selectors</h2> |
Groups of Selectors</h2> |
564 |
|
|
565 |
<p>Since <a href="#serializing">the serializing algorithm</a> is |
<p>Since <a href="#serializing">the serializing algorithm</a> is |
566 |
so designed that it always output a valid |
so designed that it always output a valid |
567 |
<a href="http://www.w3.org/TR/css3-selectors/#grouping">group of |
<a href="http://www.w3.org/TR/css3-selectors/#grouping">group of |
568 |
selectors</a>, no special parser for |
selectors</a>, no special parser for the |
569 |
<abbr title="Selectors Serialization Format for Testing">SFFT</abbr> |
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
570 |
is necessary. Any conforming |
representation is necessary. Any conforming parser for |
571 |
<a href="http://www.w3.org/TR/css3-selectors/#grouping">group of |
<a href="http://www.w3.org/TR/css3-selectors/#grouping">groups of |
572 |
selectors</a> parser <em class=rfc2119>MAY</em> be used |
selectors</a> <em class=rfc2119>MAY</em> be used |
573 |
to parse <abbr title="Selectors Serialization Format for Testing">SFFT</abbr> |
to parse <abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
574 |
groups of selectors.</p> |
representations of groups of selectors.</p> |
575 |
</div> |
</div> |
576 |
|
|
577 |
<div class="section" id="examples"> |
<div class="section" id="examples"> |
578 |
<h2>Examples</h2> |
<h2>Examples</h2> |
579 |
|
|
580 |
<p>This section is <em>informative</em>.</p> |
<p class=section-info>This section is <em>non$B!>(Bnormative</em>.</p> |
581 |
|
|
582 |
<div class="ed issue"> |
<div class="ed issue"> |
583 |
<p><a href="http://suika.fam.cx/gate/2007/css/parser-interface">Try demo</a>, |
<p><a href="http://suika.fam.cx/gate/2007/css/parser-interface">Try demo</a>, |
584 |
by choosing <q>Selectors</q> radio button.</a></p> |
by choosing <q>Selectors</q> radio button.</p> |
585 |
|
|
586 |
<div class="example figure block"> |
<div class="example figure block"> |
587 |
<div class="caption">...</div> |
<div class="caption">...</div> |
594 |
</div> |
</div> |
595 |
|
|
596 |
<div id="references" class="section reference"> |
<div id="references" class="section reference"> |
597 |
<h2>References</h1> |
<h2>References</h2> |
598 |
|
|
599 |
<div id="normative-references" class="section normative reference"> |
<div id="normative-references" class="section normative reference"> |
600 |
<h3>Normative References</h3> |
<h3>Normative References</h3> |
605 |
<abbr>RFCs</abbr> to Indicate Requirement Levels</a></cite>, |
<abbr>RFCs</abbr> to Indicate Requirement Levels</a></cite>, |
606 |
<abbr title="Internet Engineering Task Force">IETF</abbr> |
<abbr title="Internet Engineering Task Force">IETF</abbr> |
607 |
<a href="urn:ietf:bcp:14"><abbr title="Best Current Practice">BCP</abbr> |
<a href="urn:ietf:bcp:14"><abbr title="Best Current Practice">BCP</abbr> |
608 |
14</a>, <abbr title="Request for Comments">RFC</abbr> 2119, March 1997. |
14</a>, <abbr title="Request for Comments">RFC</abbr> 2119, |
609 |
|
<time datetime=1997-03>March 1997</time>. |
610 |
This version of the specification is referenced</dd> |
This version of the specification is referenced</dd> |
611 |
<dt id=ref-SELECTORS>SELECTORS</dt> |
<dt id=ref-SELECTORS>SELECTORS</dt> |
612 |
<dd><a href="http://www.w3.org/TR/2005/WD-css3-selectors-20051215"><cite>Selectors</cite></a>, |
<dd><a href="http://www.w3.org/TR/2005/WD-css3-selectors-20051215"><cite>Selectors</cite></a>, |
613 |
<abbr title="World Wide Web Consortium">W3C</abbr> Working Draft, |
<abbr title="World Wide Web Consortium">W3C</abbr> Working Draft, |
614 |
15 December 2005. Work in progress. |
<time datetime=2005-12-15>15 December 2005</time>. Work in progress. |
615 |
<a href="http://www.w3.org/TR/css3-selectors">The latest version</a> |
<a href="http://www.w3.org/TR/css3-selectors">The latest version</a> |
616 |
of the specification is referenced.</dd> |
of the specification is referenced.</dd> |
617 |
</dl> |
</dl> |
618 |
</div> |
</div> |
619 |
|
|
620 |
<div id="informative-references" class="section informative reference"> |
<div id="informative-references" class="section informative reference"> |
621 |
<h3>Informative References</h3> |
<h3>Non$B!>(Bnormative References</h3> |
622 |
|
|
623 |
<dl> |
<dl> |
624 |
|
<dt id=ref-CSS>CSS</dt> |
625 |
|
<dd><cite><a href="http://www.w3.org/TR/2007/CR-CSS21-20070719">Cascading |
626 |
|
Style Sheets Level 2 Revision 1 (<abbr>CSS</abbr> 2.1) |
627 |
|
Specification</a></cite>, |
628 |
|
<abbr title="World Wide Web Consortium">W3C</abbr> Candidate |
629 |
|
Recommendation, <time datetime=2007-07-19>19 July 2007</time>. |
630 |
|
Work in progress. The latest version of the specification is |
631 |
|
available at |
632 |
|
<code class=URI><<a href="http://www.w3.org/TR/CSS21">http://www.w3.org/TR/CSS21</a>></code>.</dd> |
633 |
<dt id=ref-CSSOM>CSSOM</dt> |
<dt id=ref-CSSOM>CSSOM</dt> |
634 |
<dd><cite><a href="http://dev.w3.org/cvsweb/~checkout~/csswg/cssom/Overview.html?rev=1.55&content-type=text/html;%20charset=utf-8">Cascading |
<dd><cite><a href="http://dev.w3.org/cvsweb/~checkout~/csswg/cssom/Overview.html?rev=1.55&content-type=text/html;%20charset=utf-8">Cascading |
635 |
Style Sheets Object Model (<abbr>CSSOM</abbr>)</a></cite>, |
Style Sheets Object Model (<abbr>CSSOM</abbr>)</a></cite>, |
636 |
<abbr title="World Wide Web Consortium">W3C</abbr> Editor's Draft, |
<abbr title="World Wide Web Consortium">W3C</abbr> Editor's Draft, |
637 |
18 June 2007. Work in progress. The latest Editor's Draft |
<time datetime=2007-06-18>18 June 2007</time>. Work in progress. |
638 |
of the specification is available at |
The latest Editor's Draft of the specification is available at |
639 |
<code class=uri><<a href="http://dev.w3.org/csswg/cssom/Overview.html">http://dev.w3.org/csswg/cssom/Overview.html</a>></code>.</dd> |
<code class=URI><<a href="http://dev.w3.org/csswg/cssom/Overview.html">http://dev.w3.org/csswg/cssom/Overview.html</a>></code>.</dd> |
640 |
|
<dt id=ref-HTML5>HTML5</dt> |
641 |
|
<dd><cite><a href="http://whatwg.org/html5"><abbr>HTML</abbr> 5</a></cite>, |
642 |
|
<abbr title="Web Hypertext Application Technology Working Group">WHATWG</abbr> |
643 |
|
Working Draft. Work in progress.</dd> |
644 |
|
<dt id=ref-SAPI>SAPI</dt> |
645 |
|
<dd><cite><a href="http://dev.w3.org/cvsweb/~checkout~/2006/webapi/selectors-api/Overview.html?rev=1.28&content-type=text/html;%20charset=utf-8">Selectors <abbr>API</abbr></a></cite>, |
646 |
|
<abbr title="World Wide Web Consortium">W3C</abbr> Editor's Draft, |
647 |
|
<time datetime=2007-08-29>29 August 2007</time>. Work in progress. |
648 |
|
The latest Editor's Draft of the specification is available at |
649 |
|
<code class=URI><<a href="http://dev.w3.org/2006/webapi/selectors-api/Overview.html">http://dev.w3.org/2006/webapi/selectors-api/Overview.html</a>></code>. |
650 |
|
The latest published version of the specification is available at |
651 |
|
<code class=URI><<a href="http://www.w3.org/TR/selectors-api/">http://www.w3.org/TR/selectors-api/</a>></code>.</dd> |
652 |
|
<dt id=ref-XBL2>XBL2</dt> |
653 |
|
<dd><cite><a href="http://www.mozilla.org/projects/xbl/xbl2.html"><abbr>XBL</abbr> |
654 |
|
2.0</a></cite>, Mozilla.org, <time datetime=2007-03-15>15 Mar 2007</time>. |
655 |
|
Work in progress. The latest |
656 |
|
<abbr title="World Wide Web Consortium">W3C</abbr>$B!>(Bpublished |
657 |
|
version of the specification is available at |
658 |
|
<code class=URI><<a href="http://www.w3.org/TR/xbl/">http://www.w3.org/TR/xbl/</a>></code>.</dd> |
659 |
</dl> |
</dl> |
660 |
</div> |
</div> |
661 |
|
|