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-28>28 October 2007</time></h2> |
<h2>Working Draft <time datetime=2007-11-05>5 November 2007</time></h2> |
14 |
|
|
15 |
<dl class="versions-uri"> |
<dl class="versions-uri"> |
16 |
<dt>This Version</dt> |
<dt>This Version</dt> |
125 |
|
|
126 |
<p>The key words <q><dfn id=must><em class="rfc2119">MUST</em></dfn></q>, |
<p>The key words <q><dfn id=must><em class="rfc2119">MUST</em></dfn></q>, |
127 |
<q><dfn id=must-not><em class="rfc2119">MUST NOT</em></dfn></q>, |
<q><dfn id=must-not><em class="rfc2119">MUST NOT</em></dfn></q>, |
128 |
<q><dfn id=should><em class="rfc2119">SHOULD</em></dfn></q>, |
<q><dfn id=should><em class="rfc2119">SHOULD</em></dfn></q>, and |
|
<q><dfn id=should-not><em class="rfc2119">SHOULD NOT</em></dfn></q>, and |
|
129 |
<q><dfn id=may><em class=rfc2119>MAY</em></dfn></q> in this |
<q><dfn id=may><em class=rfc2119>MAY</em></dfn></q> in this |
130 |
document are to be interpreted as described in |
document are to be interpreted as described in |
131 |
<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> |
161 |
selector</a> or <a href="#algorithm-serialize-a-group-of-selectors">serialize |
selector</a> or <a href="#algorithm-serialize-a-group-of-selectors">serialize |
162 |
a group of selectors</a>.</p> |
a group of selectors</a>.</p> |
163 |
|
|
|
<div class="issue ed"> |
|
|
<p><a href="http://suika.fam.cx/gate/cvs/*checkout*/markup/html/whatpm/Whatpm/CSS/SelectorsSerializer.pm">See |
|
|
also the reference implementation</a> for now.</p> |
|
|
</div> |
|
|
|
|
164 |
<div class="note memo"> |
<div class="note memo"> |
165 |
<p>The serialized representation will not contain any comment.</p> |
<p>The serialized representation will not contain any comment.</p> |
166 |
</div> |
</div> |
167 |
<!-- TODO: link terms to Selectors --> |
|
168 |
|
<div class="ed issue"><p>TODO: link terms to Selectors</p></div> |
169 |
|
|
170 |
<div class=section id=serializing-tokens> |
<div class=section id=serializing-tokens> |
171 |
<h3>Serializing Tokens</h3> |
<h3>Serializing Tokens</h3> |
197 |
<code class=char>U+0080</code> to <code class=char>U+D7FF</code>, or |
<code class=char>U+0080</code> to <code class=char>U+D7FF</code>, or |
198 |
<code class=char>U+E000</code> to <code class=char>U+10FFFF</code> in |
<code class=char>U+E000</code> to <code class=char>U+10FFFF</code> in |
199 |
<var>n</var>, then replace it by string <code>\<var>HHHHHH</var></code>, where |
<var>n</var>, then replace it by string <code>\<var>HHHHHH</var></code>, where |
200 |
<dfn id=var-HHHHHH><var>HHHHHH</var></dfn> is the upper$B!>(Bcase zero$B!>(Bpadded |
<dfn id=var-ident-HHHHHH><var>HHHHHH</var></dfn> is the upper$B!>(Bcase |
201 |
hexadecimal representation of the character. If the character |
zero$B!>(Bpadded hexadecimal representation of the character. If the character |
202 |
is outside the range of <code>[<code class=char>U+0000</code>, |
is outside the range of <code>[<code class=char>U+0000</code>, |
203 |
<code class=char>U+10FFFF</code>]</code>, <var>HHHHHH</var> |
<code class=char>U+10FFFF</code>]</code>, <var>HHHHHH</var> |
204 |
<em class=rfc2119>MUST</em> be <code>FFFFFF</code>.</li> |
<em class=rfc2119>MUST</em> be <code>FFFFFF</code>.</li> |
250 |
SQUARE BRACKET</code> to <code class=char>U+D7FF</code>, or |
SQUARE BRACKET</code> to <code class=char>U+D7FF</code>, or |
251 |
<code class=char>U+E000</code> to <code class=char>U+10FFFF</code> in |
<code class=char>U+E000</code> to <code class=char>U+10FFFF</code> in |
252 |
<var>s</var>, then replace it by string <code>\<var>HHHHHH</var></code>, where |
<var>s</var>, then replace it by string <code>\<var>HHHHHH</var></code>, where |
253 |
<dfn id=var-HHHHHH><var>HHHHHH</var></dfn> is the upper$B!>(Bcase zero$B!>(Bpadded |
<dfn id=var-string-HHHHHH><var>HHHHHH</var></dfn> is the upper$B!>(Bcase |
254 |
hexadecimal representation of the character. If the character |
zero$B!>(Bpadded hexadecimal representation of the character. If the character |
255 |
is outside the range of <code>[<code class=char>U+0000</code>, |
is outside the range of <code>[<code class=char>U+0000</code>, |
256 |
<code class=char>U+10FFFF</code>]</code>, <var>HHHHHH</var> |
<code class=char>U+10FFFF</code>]</code>, <var>HHHHHH</var> |
257 |
<em class=rfc2119>MUST</em> be <code>FFFFFF</code>.</p></li> |
<em class=rfc2119>MUST</em> be <code>FFFFFF</code>.</p></li> |
291 |
It is tr/A-Z/a-z/ for now.</p> |
It is tr/A-Z/a-z/ for now.</p> |
292 |
</div> |
</div> |
293 |
|
|
294 |
|
<p>To |
295 |
|
<dfn id=algorithm-normalize-an-integer title="normalize an integer">normalize |
296 |
|
an integer (<dfn id=var-int-i><var>i</var></dfn>)</dfn>, the following |
297 |
|
algorithm <em class=rfc2119>MUST</em> be run:</p> |
298 |
|
<ol class=algorithm> |
299 |
|
<li>If <var>i</var> is equal to zero (0), return a string with only a |
300 |
|
character: <code class=char>U+0030</code> |
301 |
|
<code class=charname>DIGIT ZERO</code> (<code class=char>0</code>). |
302 |
|
Stop the algorithm.</li> |
303 |
|
<li>Let <dfn id=var-int-result><var>result</var></dfn> be an empty string.</li> |
304 |
|
<li>If <var>i</var> is less than zero (0), append a |
305 |
|
<code class=char>U+002D</code> <code class=charname>HYPHEN-MINUS</code> |
306 |
|
(<code class=char>-</code>) character to <var>result</var>.</li> |
307 |
|
<li>Append the decimal representation of the absolute value of |
308 |
|
<var>i</var> to <var>result</var>. The decimal (base$B!>(Bten) representation |
309 |
|
<em class=rfc2119>MUST NOT</em> begin with a <code class=char>U+0030</code> |
310 |
|
<code class=charname>DIGIT ZERO</code> (<code class=char>0</code>) |
311 |
|
character.</li> |
312 |
|
<li>Return <var>result</var>.</li> |
313 |
|
</ol> |
314 |
|
|
315 |
</div> |
</div> |
316 |
|
|
317 |
|
|
476 |
<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 |
477 |
PARENTHESIS</code> (<code class=char>(</code>) character |
PARENTHESIS</code> (<code class=char>(</code>) character |
478 |
to <var>r</var>.</li> |
to <var>r</var>.</li> |
479 |
<li>Append <span class=ed>@@ normalized</span> |
<li>Let <dfn id=var-a><var>a</var></dfn> be the <var>a</var> |
480 |
integer <var>a</var> to <var>r</var>. |
part of the argument. If the argument is a keyword <code>odd</code> |
481 |
If the argument is a keyword <code>odd</code> or <code>even</code>, |
or <code>even</code>, then let <var>a</var> be <code>2</code>. |
482 |
<var>a</var> is <code>2</code>. If <var>a</var> and |
If the <var>a</var> part with following <code>n</code> character |
483 |
<code>n</code> is omitted, <var>a</var> is assumed as |
is omitted, then let <var>a</var> be <code>0</code>. |
484 |
<code>0</code>. Otherwise, if <var>a</var> is omitted, |
Otherwise, if only the <var>a</var> part is omitted, then |
485 |
it is assumed as <code>1</code> (or <code>-1</code>, |
let <var>a</var> be <code>1</code>. Otherwise, if the <var>a</var> |
486 |
if there is a <code class=char>U+002D</code> |
part is <code>-</code>, then let <var>a</var> be |
487 |
<code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>) |
<code>-1</code>.</li> |
488 |
character).</li> |
<li>Let <var>a</var> be the |
489 |
|
<a href="#algorithm-normalize-an-integer" title="normalize an integer">normalized |
490 |
|
string representation</a> of integer <var>a</var>.</li> |
491 |
|
<li>Append <var>a</var> to <var>result</var>.</li> |
492 |
<li>Append a <code class=char>U+006E</code> |
<li>Append a <code class=char>U+006E</code> |
493 |
<code class=charname>LATIN SMALL LETTER N</code> |
<code class=charname>LATIN SMALL LETTER N</code> |
494 |
(<code class=char>n</code>) character to <var>r</var>.</li> |
(<code class=char>n</code>) character to <var>r</var>.</li> |
495 |
<li>Append <span class=ed>@@ normalized</span> |
<li>Let <dfn id=var-b><var>b</var></dfn> be the <var>b</var> |
496 |
integer <var>b</var> to <var>r</var>. |
part of the argument. If the argument is a keyword <code>odd</code>, |
497 |
It <em class=rfc2119>MUST</em> be preceded by a sign, |
then let <var>b</var> be <code>1</code>. If the argument is a |
498 |
either <code class=char>U+002B</code> <code class=charname>PLUS |
keyword <code>even</code>, then let <var>b</var> be <code>0</code>. |
499 |
SIGN</code> (<code class=char>+</code>) or |
If the <var>b</var> part is omitted, then let <var>b</var> be |
500 |
<code class=char>U+002D</code> |
<code>0</code>.</li> |
501 |
|
<li>Let <var>b</var> be the |
502 |
|
<a href="#algorithm-normalize-an-integer" title="normalize an integer">normalized |
503 |
|
string representation</a> of integer <var>b</var>.</li> |
504 |
|
<li>If <var>b</var> does <em>not</em> start with a |
505 |
|
<code class=char>U+002D</code> |
506 |
<code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>) |
<code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>) |
507 |
character. If the argument is a keyword <code>odd</code>, |
character, then append <code class=char>U+002B</code> |
508 |
<var>b</var> is <code>1</code>. If the argument |
<code class=charname>PLUS SIGN</code> |
509 |
is a keyword <code>even</code>, <var>b</var> is |
(<code class=char>+</code>) to <var>result</var>.</li> |
510 |
<code>0</code>. If <var>b</var> is omitted, it is assumed as |
<li>Append <var>b</var> to <var>result</var>.</li> |
|
<code>0</code>. The sign of <code>0</code> |
|
|
<em class=rfc2119>MUST</em> be <code class=char>U+002B</code> |
|
|
<code class=charname>PLUS SIGN</code> |
|
|
(<code class=char>+</code>).</li> |
|
511 |
<li>Append a <code class=char>U+0029</code> |
<li>Append a <code class=char>U+0029</code> |
512 |
<code class=charname>RIGHT PARENTHESIS</code> |
<code class=charname>RIGHT PARENTHESIS</code> |
513 |
(<code class=char>)</code>) character |
(<code class=char>)</code>) character |
614 |
(<dfn id=var-sss><var>sss</var></dfn>)</dt> |
(<dfn id=var-sss><var>sss</var></dfn>)</dt> |
615 |
<dd> |
<dd> |
616 |
<ol> |
<ol> |
617 |
<li class=ed><a href="#algorithm-serialize-a-simple-selector">Serialize |
<li>If <var>sss</var> contains a universal or type selector, then |
618 |
each simple selector</a> in <var>sss</var>.</li> |
<a href="#algorithm-serialize-a-simple-selector" title="serialize a simple selector">serialize |
619 |
<li class=ed>sort</li> |
that simple selector</a> and append the result to |
620 |
|
<var>result</var>.</li> |
621 |
|
<li>Otherwise, i.e. if <var>sss</var> does not contain a universal or |
622 |
|
type selector, then |
623 |
|
<a href="#algorithm-serialize-a-simple-selector" title="serialize a simple selector">serialize |
624 |
|
a simple selector <code>*</code></a> and append the result to |
625 |
|
<var>result</var>.</li> |
626 |
|
<li><a href="#algorithm-serialize-a-simple-selector" title="serialize a simple selector">Serialize |
627 |
|
any attribute selectors</a> in <var>sss</var>, sort the results, |
628 |
|
then append them to <var>result</var> in order.</li> |
629 |
|
<li><a href="#algorithm-serialize-a-simple-selector" title="serialize a simple selector">Serialize |
630 |
|
any class selectors</a> in <var>sss</var>, sort the results, |
631 |
|
then append them to <var>result</var> in order.</li> |
632 |
|
<li><a href="#algorithm-serialize-a-simple-selector" title="serialize a simple selector">Serialize |
633 |
|
any <abbr>ID</abbr> selectors</a> in <var>sss</var>, sort the results, |
634 |
|
then append them to <var>result</var> in order.</li> |
635 |
|
<li><a href="#algorithm-serialize-a-simple-selector" title="serialize a simple selector">Serialize |
636 |
|
any pseudo$B!>(Bclass selectors</a> in <var>sss</var>, sort the results, |
637 |
|
then append them to <var>result</var> in order.</li> |
638 |
|
<li><a href="#algorithm-serialize-a-simple-selector" title="serialize a simple selector">Serialize |
639 |
|
any pseudo elements</a> in <var>sss</var>, sort the results, |
640 |
|
then append them to <var>result</var> in order.</li> |
641 |
<li>Append a <a href="#newline">newline</a> to <var>result</var>.</li> |
<li>Append a <a href="#newline">newline</a> to <var>result</var>.</li> |
642 |
</ol> |
</ol> |
643 |
</dd> |
</dd> |
780 |
<dt id=ref-HTML5>HTML5</dt> |
<dt id=ref-HTML5>HTML5</dt> |
781 |
<dd><cite><a href="http://whatwg.org/html5"><abbr>HTML</abbr> 5</a></cite>, |
<dd><cite><a href="http://whatwg.org/html5"><abbr>HTML</abbr> 5</a></cite>, |
782 |
<abbr title="Web Hypertext Application Technology Working Group">WHATWG</abbr> |
<abbr title="Web Hypertext Application Technology Working Group">WHATWG</abbr> |
783 |
Working Draft. Work in progress.</dd> |
Working Draft, <time datetime="2007-11-03">3 November 2007</time>. |
784 |
|
Work in progress.</dd> |
785 |
<dt id=ref-SAPI>SAPI</dt> |
<dt id=ref-SAPI>SAPI</dt> |
786 |
<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>, |
<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>, |
787 |
<abbr title="World Wide Web Consortium">W3C</abbr> Editor's Draft, |
<abbr title="World Wide Web Consortium">W3C</abbr> Editor's Draft, |