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 <time datetime=2007-10-07>7 October 2007</time></h2> |
<h2>Working Draft <time datetime=2007-10-15>15 October 2007</time></h2> |
14 |
|
|
15 |
<dl class="versions-uri"> |
<dl class="versions-uri"> |
16 |
<dt>This Version</dt> |
<dt>This Version</dt> |
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, produced as part |
<p>This document is a working draft, produced as part of the |
67 |
|
<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> |
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 |
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 |
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 |
<a href="urn:ietf:rfc:2119"><abbr title="Request for Comments">RFC</abbr> |
<a href="urn:ietf:rfc:2119"><abbr title="Request for Comments">RFC</abbr> |
128 |
2119</a> |
2119</a> |
147 |
for now.</p> |
for now.</p> |
148 |
</div> |
</div> |
149 |
|
|
150 |
<p><dfn id=newline title=newline>Newline</dfn> is |
<p>No <abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
151 |
<code class=char>U+000A</code> <code class=charname>LINE FEED</code> |
representation is defined for an invalid group of selectors.</p> |
152 |
<span class=ed>or 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 |
|
|
175 |
<dl class=switch> |
<dl class=switch> |
176 |
<dt>If it is a sequence of simle selector |
<dt>If it is a sequence of simle selector |
177 |
(<dfn id=var-sss><var>sss</var></dfn>)</dt> |
(<dfn id=var-sss><var>sss</var></dfn>)</dt> |
178 |
<dd class=ed>@@</dd> |
<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> |
<dt>If it is a combinator (<dfn id=var-c><var>c</var></dfn>)</dt> |
187 |
<dd> |
<dd> |
188 |
<ol> |
<ol> |
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 |
<p>To |
259 |
</ol> |
</ol> |
260 |
</dd> |
</dd> |
261 |
<dt>If <var>ss</var> is an attribute selector</dt> |
<dt>If <var>ss</var> is an attribute selector</dt> |
262 |
<dd class=ed>@@</dd> |
<dd> |
263 |
|
<ol> |
264 |
|
<li>Append a <code class=char>U+005B</code> <code class=charname>LEFT |
265 |
|
SQUARE BRACKET</code> (<code class=char>[</code>) to |
266 |
|
<var>result</var>.</li> |
267 |
|
<li> |
268 |
|
Append a namespace prefix as following: |
269 |
|
<dl> |
270 |
|
<dt>If a namespace URI is specified</dt> |
271 |
|
<dd class=ed>@@</dd> |
272 |
|
<dd class=ed>@@ Current reference implementation is wrong, |
273 |
|
since its result of sorting depends on namespace prefix.</dd> |
274 |
|
<dt>If the null namespace is specified</dt> |
275 |
|
<dd>Append a <code class=char>U+007C</code> |
276 |
|
<code class=charname>VERTICAL BAR</code> character to |
277 |
|
<var>result</var>.</dd> |
278 |
|
<dt>If no namespace is specified</dt> |
279 |
|
<dd>Append a <code class=char>U+002A</code> |
280 |
|
<code class=charname>ASTERISK</code> (<code class=char>*</code>) |
281 |
|
character, followed by a <code class=char>U+007C</code> |
282 |
|
<code class=charname>VERTICAL BAR</code> (<code class=char>|</code>) |
283 |
|
character, to <var>result</var>.</dd> |
284 |
|
</dl> |
285 |
|
</li> |
286 |
|
<li>Append the <span class=ed>@@ normalized</span> local name to |
287 |
|
<var>result</var>.</li> |
288 |
|
<li>If a value is specified in <var>ss</var>: |
289 |
|
<ol> |
290 |
|
<li>Depending on the way to match, append <code>=</code>, |
291 |
|
<code>~=</code>, <code>|=</code>, <code>^=</code>, |
292 |
|
<code>$=</code>, or <code>*=</code> to <var>result</var>.</li> |
293 |
|
<li>Append the <span class=ed>@@ normalized</span> value to |
294 |
|
<var>result</var>.</li> |
295 |
|
</ol> |
296 |
|
</li> |
297 |
|
<li>Append a <code class=char>U+005D</code> <code class=charname>RIGHT |
298 |
|
SQUARE BRACKET</code> (<code class=char>]</code>) to |
299 |
|
<var>result</var>.</li> |
300 |
|
</ol> |
301 |
|
</dd> |
302 |
<dt>If <var>ss</var> is a class selector</dt> |
<dt>If <var>ss</var> is a class selector</dt> |
303 |
<dd>Append a <code class=char>U+002E</code> <code class=charname>FULL |
<dd>Append a <code class=char>U+002E</code> <code class=charname>FULL |
304 |
STOP</code> (<code class=char>.</code>) character, followed |
STOP</code> (<code class=char>.</code>) character, followed |
315 |
<li>Append a <code class=char>U+003A</code> |
<li>Append a <code class=char>U+003A</code> |
316 |
<code class=charname>COLON</code> (<code class=char>:</code>) character |
<code class=charname>COLON</code> (<code class=char>:</code>) character |
317 |
to <var>result</var>.</li> |
to <var>result</var>.</li> |
318 |
<li>Append <span class=ed>@@ normalized</span> |
<li>Append the <span class=ed>@@ normalized</span> name of the |
319 |
pseudo$B!>(Bclass name to <var>result</var>.</li> |
pseudo$B!>(Bclass to <var>result</var>.</li> |
320 |
<li>Append any arguments as following: |
<li>Append any arguments as following: |
321 |
<dl class=switch> |
<dl class=switch> |
322 |
<dt>If pseudo$B!>(Bclass name is <code>lang</code></dt> |
<dt>If the name of the pseudo$B!>(Bclass is <code>lang</code></dt> |
323 |
<dd> |
<dd> |
324 |
<ol> |
<ol> |
325 |
<li>Append a <code class=char>U+0028</code> <code class=charname>LEFT |
<li>Append a <code class=char>U+0028</code> <code class=charname>LEFT |
333 |
to <var>result</var>.</li> |
to <var>result</var>.</li> |
334 |
</ol> |
</ol> |
335 |
</dd> |
</dd> |
336 |
<dt>If pseudo$B!>(Bclass name is <code>-manakai-contains</code></dt> |
<dt>If the name of the pseudo$B!>(Bclass is |
337 |
|
<code>-manakai-contains</code></dt> |
338 |
<dd> |
<dd> |
339 |
<ol> |
<ol> |
340 |
<li>Append a <code class=char>U+0028</code> <code class=charname>LEFT |
<li>Append a <code class=char>U+0028</code> <code class=charname>LEFT |
348 |
to <var>result</var>.</li> |
to <var>result</var>.</li> |
349 |
</ol> |
</ol> |
350 |
</dd> |
</dd> |
351 |
<dt>If pseudo$B!>(Bclass name is <code>nth-child</code>, |
<dt>If name of the pseudo$B!>(Bclass is either <code>nth-child</code>, |
352 |
<code>nth-last-child</code>, <code>nth-of-type</code>, or |
<code>nth-last-child</code>, <code>nth-of-type</code>, or |
353 |
<code>nth-last-of-type</code></dt> |
<code>nth-last-of-type</code></dt> |
354 |
<dd> |
<dd> |
390 |
to <var>result</var>.</li> |
to <var>result</var>.</li> |
391 |
</ol> |
</ol> |
392 |
</dd> |
</dd> |
393 |
<dt>If pseudo$B!>(Bclass name is <code>not</code></dt> |
<dt>If the name of the pseudo$B!>(Bclass is <code>not</code></dt> |
394 |
<dd class=ed>@@</dd> |
<dd> |
395 |
|
<ol> |
396 |
|
<li>Append a string of <code class=char>U+003A</code> |
397 |
|
<code class=charname>COLON</code>, <code class=char>U+006E</code> |
398 |
|
<code class=charname>LATIN SMALL LETTER N</code>, |
399 |
|
<code class=char>U+006F</code> <code class=charname>LATIN |
400 |
|
SMALL LETTER O</code>, <code class=char>U+0074</code> |
401 |
|
<code class=charname>LATIN SMALL LETTER T</code>, and |
402 |
|
<code class=char>U+0028</code> <code class=charname>LEFT |
403 |
|
PARENTHESIS</code> (<code>:not(</code>), followed by a |
404 |
|
<a href="#newline">newline</a>, to <var>result</var>.</li> |
405 |
|
<li>Append four <code class=char>U+0020</code> |
406 |
|
<code class=charname>SPACE</code> characters to |
407 |
|
<var>result</var>.</li> |
408 |
|
<li>Append four <code class=char>U+0020</code> |
409 |
|
<code class=charname>SPACE</code> characters to |
410 |
|
<var>result</var> again.</li> |
411 |
|
<li><a href="#algorithm-serialize-a-simple-selector">Serialize |
412 |
|
the simple selector specified as the argument to the |
413 |
|
<code>not</code> pseudo$B!>(Bclass</a>.</li> |
414 |
|
<li>Append a <a href="#newline">newline</a> to |
415 |
|
<var>result</var>.</li> |
416 |
|
<li>Append four <code class=char>U+0020</code> |
417 |
|
<code class=charname>SPACE</code> characters to |
418 |
|
<var>result</var>.</li> |
419 |
|
<li>Append a <code class=char>U+0029</code> |
420 |
|
<code class=charname>RIGHT PARENTHESIS</code> |
421 |
|
(<code class=char>)</code>) character |
422 |
|
to <var>result</var>.</li> |
423 |
|
</ol> |
424 |
|
</dd> |
425 |
</dl> |
</dl> |
426 |
</li> |
</li> |
427 |
</ol> |
</ol> |
432 |
<li>Append two <code class=char>U+003A</code> |
<li>Append two <code class=char>U+003A</code> |
433 |
<code class=charname>COLON</code> characters (<code>::</code>) |
<code class=charname>COLON</code> characters (<code>::</code>) |
434 |
to <var>result</var>.</li> |
to <var>result</var>.</li> |
435 |
<li>Append <span class=ed>@@ normalized</span> |
<li>Append the <span class=ed>@@ normalized</span> name of the |
436 |
pseudo$B!>(Belement name to <var>result</var>.</li> |
pseudo$B!>(Belement to <var>result</var>.</li> |
437 |
<!-- For future version: append "(", arguments, ")", if any. --> |
<!-- For future version: append "(", arguments, ")", if any. --> |
438 |
</ol> |
</ol> |
439 |
</dd> |
</dd> |
440 |
</dl> |
</dl> |
441 |
|
|
442 |
|
|
443 |
|
<p>A <dfn id=newline title=newline>newline</dfn> |
444 |
|
<em class=rfc2119>SHOULD</em> be represented as a |
445 |
|
<code class=char>U+000A</code> <code class=charname>LINE FEED</code> |
446 |
|
character. However, depending on the context where |
447 |
|
the <abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
448 |
|
representation is in use, a sequence of |
449 |
|
<code class=char>U+000D</code> <code class=charname>CARRIAGE RETURN</code> |
450 |
|
followed by a <code class=char>U+000A</code> |
451 |
|
<code class=charname>LINE FEED</code> (i.e. a |
452 |
|
<code>CRLF</code> sequence) or a character |
453 |
|
<code class=char>U+000D</code> <code class=charname>CARRIAGE RETURN</code> |
454 |
|
<em class=rfc2119>MAY</em> be used as a <a href="#newline">newline</a> instead. |
455 |
|
<a href="#newline">Newline</a> representations |
456 |
|
<em class=rfc2119>SHOULD</em> be consistent in an |
457 |
|
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
458 |
|
representation.</p> |
459 |
|
|
460 |
|
<div class="note memo"> |
461 |
|
<p>Therefore, newlines must be normalized before |
462 |
|
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
463 |
|
representations are literally compared.</p> |
464 |
|
</div> |
465 |
|
|
466 |
</div> |
</div> |
467 |
|
|
468 |
<div class="section" id="parsing"> |
<div class="section" id="parsing"> |
469 |
<h2>Parsing |
<h2>Parsing |
470 |
<abbr title="Selectors Serialization Format for Testing">SFFT</abbr> |
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
471 |
Groups of Selectors</h2> |
Groups of Selectors</h2> |
472 |
|
|
473 |
<p>Since <a href="#serializing">the serializing algorithm</a> is |
<p>Since <a href="#serializing">the serializing algorithm</a> is |
474 |
so designed that it always output a valid |
so designed that it always output a valid |
475 |
<a href="http://www.w3.org/TR/css3-selectors/#grouping">group of |
<a href="http://www.w3.org/TR/css3-selectors/#grouping">group of |
476 |
selectors</a>, no special parser for |
selectors</a>, no special parser for the |
477 |
<abbr title="Selectors Serialization Format for Testing">SFFT</abbr> |
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
478 |
is necessary. Any conforming |
representation is necessary. Any conforming parser for |
479 |
<a href="http://www.w3.org/TR/css3-selectors/#grouping">group of |
<a href="http://www.w3.org/TR/css3-selectors/#grouping">groups of |
480 |
selectors</a> parser <em class=rfc2119>MAY</em> be used |
selectors</a> <em class=rfc2119>MAY</em> be used |
481 |
to parse <abbr title="Selectors Serialization Format for Testing">SFFT</abbr> |
to parse <abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
482 |
groups of selectors.</p> |
representations of groups of selectors.</p> |
483 |
</div> |
</div> |
484 |
|
|
485 |
<div class="section" id="examples"> |
<div class="section" id="examples"> |
557 |
<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>. |
<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>. |
558 |
The latest published version of the specification is available at |
The latest published version of the specification is available at |
559 |
<code class=URI><<a href="http://www.w3.org/TR/selectors-api/">http://www.w3.org/TR/selectors-api/</a>></code>.</dd> |
<code class=URI><<a href="http://www.w3.org/TR/selectors-api/">http://www.w3.org/TR/selectors-api/</a>></code>.</dd> |
560 |
<dt id=XBL2>XBL2</dt> |
<dt id=ref-XBL2>XBL2</dt> |
561 |
<dd><cite><a href="http://www.mozilla.org/projects/xbl/xbl2.html"><abbr>XBL</abbr> |
<dd><cite><a href="http://www.mozilla.org/projects/xbl/xbl2.html"><abbr>XBL</abbr> |
562 |
2.0</a></cite>, Mozilla.org, <time datetime=2007-03-15>15 Mar 2007</time>. |
2.0</a></cite>, Mozilla.org, <time datetime=2007-03-15>15 Mar 2007</time>. |
563 |
Work in progress. The latest |
Work in progress. The latest |