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-15>15 October 2007</time></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> |
140 |
</div> |
</div> |
141 |
|
|
142 |
<div class="section" id="serializing"> |
<div class="section" id="serializing"> |
143 |
<h2>Serializing Groups of Selectors</h2> |
<h2>Serializing in |
144 |
|
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
145 |
|
Representation</h2> |
146 |
|
|
147 |
<div class="issue ed"> |
<div class="issue ed"> |
148 |
<p><a href="http://suika.fam.cx/gate/cvs/*checkout*/markup/html/whatpm/Whatpm/CSS/SelectorsSerializer.pm">See the reference implementation</a> |
<p><a href="http://suika.fam.cx/gate/cvs/*checkout*/markup/html/whatpm/Whatpm/CSS/SelectorsSerializer.pm">See the reference implementation</a> |
149 |
for now.</p> |
for now.</p> |
150 |
</div> |
</div> |
151 |
|
|
152 |
|
<div class=section id=serializing-groups-of-selectors> |
153 |
|
<h3>Serializing Groups of Selectors</h3> |
154 |
|
|
155 |
<p>No <abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
<p>No <abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
156 |
representation is defined for an invalid group of selectors.</p> |
representation is defined for an invalid group of selectors.</p> |
157 |
|
|
229 |
representation of <var>gs</var>.</li> |
representation of <var>gs</var>.</li> |
230 |
</ol> |
</ol> |
231 |
|
|
232 |
|
</div> |
233 |
|
|
234 |
|
<div class=section id=serializing-simple-selectors> |
235 |
|
<h3>Serializing Simple Selectors</h3> |
236 |
|
|
237 |
<p>To |
<p>To |
238 |
<dfn id=algorithm-serialize-a-simple-selector title="serialize a simple selector">serialize |
<dfn id=algorithm-serialize-a-simple-selector title="serialize a simple selector">serialize |
239 |
a simple selector (<dfn><var id=var-ss>ss</var></dfn>)</dfn>:</p> |
a simple selector (<dfn><var id=var-ss>ss</var></dfn>)</dfn>:</p> |
262 |
</dl> |
</dl> |
263 |
</li> |
</li> |
264 |
<li>If <var>ss</var> is a type selector, append the |
<li>If <var>ss</var> is a type selector, append the |
265 |
<span class=ed>@@ normalized</span> local name to <var>result</var>.</li> |
<a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
266 |
|
local name to <var>result</var>.</li> |
267 |
<li>If <var>ss</var> is a universal selector, append |
<li>If <var>ss</var> is a universal selector, append |
268 |
a <code class=char>U+002A</code> <code class=charname>ASTERISK</code> |
a <code class=char>U+002A</code> <code class=charname>ASTERISK</code> |
269 |
(<code class=char>*</code>) character to <var>result</var>.</li> |
(<code class=char>*</code>) character to <var>result</var>.</li> |
294 |
character, to <var>result</var>.</dd> |
character, to <var>result</var>.</dd> |
295 |
</dl> |
</dl> |
296 |
</li> |
</li> |
297 |
<li>Append the <span class=ed>@@ normalized</span> local name to |
<li>Append the |
298 |
<var>result</var>.</li> |
<a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
299 |
|
local name to <var>result</var>.</li> |
300 |
<li>If a value is specified in <var>ss</var>: |
<li>If a value is specified in <var>ss</var>: |
301 |
<ol> |
<ol> |
302 |
<li>Depending on the way to match, append <code>=</code>, |
<li>Depending on the way to match, append <code>=</code>, |
303 |
<code>~=</code>, <code>|=</code>, <code>^=</code>, |
<code>~=</code>, <code>|=</code>, <code>^=</code>, |
304 |
<code>$=</code>, or <code>*=</code> to <var>result</var>.</li> |
<code>$=</code>, or <code>*=</code> to <var>result</var>.</li> |
305 |
<li>Append the <span class=ed>@@ normalized</span> value to |
<li>Append the |
306 |
<var>result</var>.</li> |
<a href="#algorithm-normalize-a-string" title="normalize a string">normalized</a> |
307 |
|
value to <var>result</var>.</li> |
308 |
</ol> |
</ol> |
309 |
</li> |
</li> |
310 |
<li>Append a <code class=char>U+005D</code> <code class=charname>RIGHT |
<li>Append a <code class=char>U+005D</code> <code class=charname>RIGHT |
315 |
<dt>If <var>ss</var> is a class selector</dt> |
<dt>If <var>ss</var> is a class selector</dt> |
316 |
<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 |
317 |
STOP</code> (<code class=char>.</code>) character, followed |
STOP</code> (<code class=char>.</code>) character, followed |
318 |
by <span class=ed>@@ normalized</span> class name, |
by <a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
319 |
<var>result</var>.</dd> |
class name, <var>result</var>.</dd> |
320 |
<dt>If <var>ss</var> is an <abbr>ID</abbr> selector</dt> |
<dt>If <var>ss</var> is an <abbr>ID</abbr> selector</dt> |
321 |
<dd>Append a <code class=char>U+0023</code> <code class=charname>NUMBER |
<dd>Append a <code class=char>U+0023</code> <code class=charname>NUMBER |
322 |
SIGN</code> (<code class=char>#</code>) character, followed |
SIGN</code> (<code class=char>#</code>) character, followed |
323 |
by <span class=ed>@@ normalized</span> <abbr>ID</abbr>, |
by <a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
324 |
to <var>result</var>.</dd> |
<abbr>ID</abbr>, to <var>result</var>.</dd> |
325 |
<dt>If <var>ss</var> is a pseudo$B!>(Bclass selector</dt> |
<dt>If <var>ss</var> is a pseudo$B!>(Bclass selector</dt> |
326 |
<dd> |
<dd> |
327 |
<ol> |
<ol> |
328 |
<li>Append a <code class=char>U+003A</code> |
<li>Append a <code class=char>U+003A</code> |
329 |
<code class=charname>COLON</code> (<code class=char>:</code>) character |
<code class=charname>COLON</code> (<code class=char>:</code>) character |
330 |
to <var>result</var>.</li> |
to <var>result</var>.</li> |
331 |
<li>Append the <span class=ed>@@ normalized</span> name of the |
<li>Append the |
332 |
pseudo$B!>(Bclass to <var>result</var>.</li> |
<a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
333 |
|
name of the pseudo$B!>(Bclass to <var>result</var>.</li> |
334 |
<li>Append any arguments as following: |
<li>Append any arguments as following: |
335 |
<dl class=switch> |
<dl class=switch> |
336 |
<dt>If the name of the pseudo$B!>(Bclass is <code>lang</code></dt> |
<dt>If the name of the pseudo$B!>(Bclass is <code>lang</code></dt> |
339 |
<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 |
340 |
PARENTHESIS</code> (<code class=char>(</code>) character |
PARENTHESIS</code> (<code class=char>(</code>) character |
341 |
to <var>result</var>.</li> |
to <var>result</var>.</li> |
342 |
<li>Append <span class=ed>@@ normalized</span> |
<li>Append the |
343 |
|
<a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
344 |
language tag (the argument) to <var>result</var>.</li> |
language tag (the argument) to <var>result</var>.</li> |
345 |
<li>Append a <code class=char>U+0029</code> |
<li>Append a <code class=char>U+0029</code> |
346 |
<code class=charname>RIGHT PARENTHESIS</code> |
<code class=charname>RIGHT PARENTHESIS</code> |
355 |
<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 |
356 |
PARENTHESIS</code> (<code class=char>(</code>) character |
PARENTHESIS</code> (<code class=char>(</code>) character |
357 |
to <var>result</var>.</li> |
to <var>result</var>.</li> |
358 |
<li>Append <span class=ed>@@ normalized</span> |
<li>Append the |
359 |
|
<a href="#algorithm-normalize-a-string" title="normalize a string">normalized</a> |
360 |
string (the argument) to <var>result</var>.</li> |
string (the argument) to <var>result</var>.</li> |
361 |
<li>Append a <code class=char>U+0029</code> |
<li>Append a <code class=char>U+0029</code> |
362 |
<code class=charname>RIGHT PARENTHESIS</code> |
<code class=charname>RIGHT PARENTHESIS</code> |
448 |
<li>Append two <code class=char>U+003A</code> |
<li>Append two <code class=char>U+003A</code> |
449 |
<code class=charname>COLON</code> characters (<code>::</code>) |
<code class=charname>COLON</code> characters (<code>::</code>) |
450 |
to <var>result</var>.</li> |
to <var>result</var>.</li> |
451 |
<li>Append the <span class=ed>@@ normalized</span> name of the |
<li>Append the |
452 |
pseudo$B!>(Belement to <var>result</var>.</li> |
<a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
453 |
|
name of the pseudo$B!>(Belement to <var>result</var>.</li> |
454 |
<!-- For future version: append "(", arguments, ")", if any. --> |
<!-- For future version: append "(", arguments, ")", if any. --> |
455 |
</ol> |
</ol> |
456 |
</dd> |
</dd> |
457 |
</dl> |
</dl> |
458 |
|
|
459 |
|
</div> |
460 |
|
|
461 |
|
<div class=section id=serializing-tokens> |
462 |
|
<h3>Serializing Tokens</h3> |
463 |
|
|
464 |
|
<p>To <dfn id=algorithm-normalize-an-ident title="normalize an IDENT">normalize |
465 |
|
an <code>IDENT</code> (<dfn id=var-n><var>n</var></dfn>)</dfn>:</p> |
466 |
|
<ol> |
467 |
|
<li>Replace the escape sequences (<code>\</code> and following |
468 |
|
characters) in <var>n</var> by characters represented by them |
469 |
|
respectively.</li> |
470 |
|
<li>If there is any character that is <em>not</em> one of |
471 |
|
<code class=char>U+002D</code> <code class=charname>HYPHEN-MINUS</code> |
472 |
|
(<code class=char>-</code>), <code class=char>U+0030</code> |
473 |
|
<code class=charname>DIGIT ZERO</code> |
474 |
|
(<code class=char>0</code>) to <code class=char>U+0039</code> |
475 |
|
<code class=charname>DIGIT NINE</code> (<code class=char>9</code>), |
476 |
|
<code class=char>U+0041</code> <code class=charname>LATIN CAPITAL LETTER |
477 |
|
A</code> (<code class=char>A</code>) to <code class=char>U+005A</code> |
478 |
|
<code class=charname>LATIN CAPITAL LETTER Z</code> (<code class=char>Z</code>), |
479 |
|
<code class=char>U+005F</code> <code class=charname>LOW LINE</code> |
480 |
|
(<code class=char>_</code>), <code class=char>U+0061</code> |
481 |
|
<code class=charname>LATIN SMALL LETTER A</code> |
482 |
|
(<code class=char>a</code>) to <code class=char>U+006A</code> |
483 |
|
<code class=charname>LATIN SMALL LETTER Z</code> (<code class=char>z</code>), |
484 |
|
<code class=char>U+0080</code> to <code class=char>U+D7FF</code>, or |
485 |
|
<code class=char>U+E000</code> to <code class=char>U+10FFFF</code> in |
486 |
|
<var>n</var>, then replace it by string <code>\<var>HHHHHH</var></code>, where |
487 |
|
<dfn id=var-HHHHHH><var>HHHHHH</var></dfn> is the upper$B!>(Bcase zero$B!>(Bpadded |
488 |
|
hexadecimal representation of the character. If the character |
489 |
|
is outside the range of <code>[<code class=char>U+0000</code>, |
490 |
|
<code class=char>U+10FFFF</code>]</code>, <var>HHHHHH</var> |
491 |
|
<em class=rfc2119>MUST</em> be <code>FFFFFF</code>.</li> |
492 |
|
<li>If the first character in <var>n</var> is one of |
493 |
|
<code class=char>U+0030</code> <code class=charname>DIGIT ZERO</code> |
494 |
|
(<code class=char>0</code>) to <code class=char>U+0039</code> |
495 |
|
<code class=charname>DIGIT NINE</code> (<code class=char>9</code>), |
496 |
|
then prepend a string <code>\00003</code> at the beginning of |
497 |
|
<var>n</var>.</li> |
498 |
|
<li>If the first character in <var>n</var> is <code class=char>U+002D</code> |
499 |
|
<code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>) and |
500 |
|
the second character, if any, is <em>not</em> one of |
501 |
|
<code class=char>U+0041</code> <code class=charname>LATIN CAPITAL LETTER |
502 |
|
A</code> (<code class=char>A</code>) to <code class=char>U+005A</code> |
503 |
|
<code class=charname>LATIN CAPITAL LETTER Z</code> (<code class=char>Z</code>), |
504 |
|
<code class=char>U+005F</code> <code class=charname>LOW LINE</code> |
505 |
|
(<code class=char>_</code>), <code class=char>U+0061</code> |
506 |
|
<code class=charname>LATIN SMALL LETTER A</code> |
507 |
|
(<code class=char>a</code>) to <code class=char>U+006A</code> |
508 |
|
<code class=charname>LATIN SMALL LETTER Z</code> (<code class=char>z</code>), |
509 |
|
<code>U+0080</code> to <code>U+D7FF</code>, or |
510 |
|
<code>U+E000</code> to <code>U+10FFFF</code>, or |
511 |
|
<var>n</var> is equal to <code class=char>U+002D</code> |
512 |
|
<code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>), then |
513 |
|
replace the <code class=char>U+002D</code> |
514 |
|
<code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>) |
515 |
|
character by string <code>\00002D</code>.</li> |
516 |
|
<li>Then, <var>n</var> is the result of the algorithm.</li> |
517 |
|
</ol> |
518 |
|
|
519 |
|
<p>To <dfn id=algorithm-normalize-a-string title="normalize a STRING">normalize |
520 |
|
a <code>STRING</code> (<dfn id=var-s><var>s</var></dfn>)</dfn>:</p> |
521 |
|
<ol> |
522 |
|
<li>Replace the escape sequences (<code>\</code> and following |
523 |
|
characters) in <var>s</var> by characters represented by them |
524 |
|
(or an empty string if <code>\</code> is immediately followed by |
525 |
|
newline character(s)) respectively.</li> |
526 |
|
<li>Remove the quotation characters in <var>s</var> |
527 |
|
if <var>s</var> is a <code>STRING</code>.</li> |
528 |
|
<li>If there is any character that is <em>not</em> one of |
529 |
|
<code class=char>U+0020</code> <code class=charname>SPACE</code>, |
530 |
|
<code class=char>U+0021</code> <code class=charname>EXCLAMATION MARK</code> |
531 |
|
(<code class=char>!</code>), <code class=char>U+0023</code> |
532 |
|
<code class=charname>NUMBER SIGN</code> (<code class=char>#</code>) to |
533 |
|
<code class=char>U+005B</code> <code class=charname>LEFT SQUARE |
534 |
|
BRACKET</code>, <code class=char>U+005D</code> <code class=charname>RIGHT |
535 |
|
SQUARE BRACKET</code> to <code class=char>U+D7FF</code>, or |
536 |
|
<code class=char>U+E000</code> to <code class=char>U+10FFFF</code> in |
537 |
|
<var>s</var>, then replace it by string <code>\<var>HHHHHH</var></code>, where |
538 |
|
<dfn id=var-HHHHHH><var>HHHHHH</var></dfn> is the upper$B!>(Bcase zero$B!>(Bpadded |
539 |
|
hexadecimal representation of the character. If the character |
540 |
|
is outside the range of <code>[<code class=char>U+0000</code>, |
541 |
|
<code class=char>U+10FFFF</code>]</code>, <var>HHHHHH</var> |
542 |
|
<em class=rfc2119>MUST</em> be <code>FFFFFF</code>.</li> |
543 |
|
<li>Insert a <code class=char>U+0022</code> <code class=charname>QUOTATION |
544 |
|
MARK</code> (<code class=char>"</code>) at the beginning of <var>s</var>.</li> |
545 |
|
<li>Insert a <code class=char>U+0022</code> <code class=charname>QUOTATION |
546 |
|
MARK</code> (<code class=char>"</code>) at the end of <var>s</var>.</li> |
547 |
|
<li>Then, <var>s</var> is the result of the algorithm.</li> |
548 |
|
</ol> |
549 |
|
|
550 |
<p>A <dfn id=newline title=newline>newline</dfn> |
<p>A <dfn id=newline title=newline>newline</dfn> |
551 |
<em class=rfc2119>SHOULD</em> be represented as a |
<em class=rfc2119>SHOULD</em> be represented as a |
571 |
</div> |
</div> |
572 |
|
|
573 |
</div> |
</div> |
574 |
|
|
575 |
|
</div> |
576 |
|
|
577 |
<div class="section" id="parsing"> |
<div class="section" id="parsing"> |
578 |
<h2>Parsing |
<h2>Parsing |