128 |
2119</a> |
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 |
|
<p>Requirements phrased in the imperative as part of algorithms are to be |
132 |
|
interpreted with the meaning of the key word (<em class=rfc2119>MUST</em>) |
133 |
|
used in introducing the algorithm.</p> |
134 |
|
|
135 |
|
<p>Conformance requirements phrased as algorithms or specific steps |
136 |
|
<em class=rfc2119>MAY</em> be implemented in any manner, so long as the end |
137 |
|
result is equivalent.</p> |
138 |
|
|
139 |
<!-- Strictly speaking the paragraph below is not part of terminology. --> |
<!-- Strictly speaking the paragraph below is not part of terminology. --> |
140 |
<p>All examples and notes in this specification are non$B!>(Bnormative, |
<p>All examples and notes in this specification are non$B!>(Bnormative, |
141 |
as are all sections explicitly marked non$B!>(Bnormative. Everything |
as are all sections explicitly marked non$B!>(Bnormative. Everything |
148 |
</div> |
</div> |
149 |
|
|
150 |
<div class="section" id="serializing"> |
<div class="section" id="serializing"> |
151 |
<h2>Serializing Selectors as |
<h2>Serializing Selectors in |
152 |
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
153 |
Representation</h2> |
Representation</h2> |
154 |
|
|
155 |
|
<p>Subsections of this section define algorithms |
156 |
|
to <a href="#algorithm-serialize-a-simple-selector">serialize a simple |
157 |
|
selector</a> or <a href="#algorithm-serialize-a-group-of-selectors">serialize |
158 |
|
a group of selectors</a>.</p> |
159 |
|
|
160 |
<div class="issue ed"> |
<div class="issue ed"> |
161 |
<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 |
162 |
for now.</p> |
also the reference implementation</a> for now.</p> |
163 |
</div> |
</div> |
164 |
|
|
165 |
|
<div class="note memo"> |
166 |
|
<p>The serialized representation will not contain any comment.</p> |
167 |
|
</div> |
168 |
|
<!-- TODO: link terms to Selectors --> |
169 |
|
|
170 |
<div class=section id=serializing-tokens> |
<div class=section id=serializing-tokens> |
171 |
<h3>Serializing Tokens</h3> |
<h3>Serializing Tokens</h3> |
172 |
|
|
173 |
<p>To <dfn id=algorithm-normalize-an-ident title="normalize an IDENT">normalize |
<p>To <dfn id=algorithm-normalize-an-ident title="normalize an IDENT">normalize |
174 |
an <code>IDENT</code> (<dfn id=var-n><var>n</var></dfn>)</dfn>:</p> |
an <code>IDENT</code> (<dfn id=var-n><var>n</var></dfn>)</dfn>, |
175 |
|
the following algorithm <em class=rfc2119>MUST</em> be used:</p> |
176 |
<ol> |
<ol> |
177 |
<li>Replace the escape sequences (<code>\</code> and following |
<li>Replace the escape sequences (<code>\</code> and following |
178 |
characters) in <var>n</var> by characters represented by them |
characters) in <var>n</var> by characters represented by them |
227 |
</ol> |
</ol> |
228 |
|
|
229 |
<p>To <dfn id=algorithm-normalize-a-string title="normalize a STRING">normalize |
<p>To <dfn id=algorithm-normalize-a-string title="normalize a STRING">normalize |
230 |
a <code>STRING</code> (<dfn id=var-s><var>s</var></dfn>)</dfn>:</p> |
a <code>STRING</code> (<dfn id=var-s><var>s</var></dfn>)</dfn>, |
231 |
|
the following algorithm <em class=rfc2119>MUST</em> be used:</p> |
232 |
<ol> |
<ol> |
233 |
<li><p>Replace the escape sequences (<code>\</code> and following |
<li><p>Replace the escape sequences (<code>\</code> and following |
234 |
characters) in <var>s</var> by characters represented by them |
characters) in <var>s</var> by characters represented by them |
287 |
representations are literally compared.</p> |
representations are literally compared.</p> |
288 |
</div> |
</div> |
289 |
|
|
290 |
|
<div class="issue ed"> |
291 |
|
<p>Need to define <dfn id=lower-case>lower$B!>(Bcase</dfn>. |
292 |
|
It is tr/A-Z/a-z/ for now.</p> |
293 |
|
</div> |
294 |
|
|
295 |
</div> |
</div> |
296 |
|
|
297 |
|
|
298 |
<div class=section id=serializing-simple-selectors> |
<div class=section id=serializing-simple-selectors> |
299 |
<h3>Serializing Simple Selectors</h3> |
<h3>Serializing Simple Selectors</h3> |
300 |
|
|
301 |
|
<p>No <abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
302 |
|
representation is defined for an invalid <a href="#simple-selector">simple |
303 |
|
selector</a>.</p> |
304 |
|
|
305 |
<p>To |
<p>To |
306 |
<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 |
307 |
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>, |
308 |
|
the following algorithm <em class=rfc2119>MUST</em> be used:</p> |
309 |
|
<ol> |
310 |
|
<li>Let <dfn id=var-r><var>r</var></dfn> an empty string.</li> |
311 |
|
<li>Process <var>ss</var> as following: |
312 |
|
|
313 |
<dl class=switch> |
<dl class=switch> |
314 |
<dt>If <var>ss</var> is a type or universal selector</dt> |
<dt>If <var>ss</var> is a type or universal selector</dt> |
315 |
<dd> |
<dd> |
316 |
<ol> |
<ol> |
317 |
<li> |
<li>Append a namespace prefix as following: |
318 |
|
|
319 |
<dl class=switch> |
<dl class=switch> |
320 |
<dt>If a namespace URI is specified (via namespace prefix, or |
<dt>If a namespace URI is specified (via namespace prefix, or |
321 |
by omitting namespace prefix where a default namespace is specified)</dt> |
by omitting namespace prefix where a default namespace is specified)</dt> |
324 |
prefix)</dt> |
prefix)</dt> |
325 |
<dd>Append a <code class=char>U+007C</code> |
<dd>Append a <code class=char>U+007C</code> |
326 |
<code class=charname>VERTICAL BAR</code> (<code class=char>|</code>) |
<code class=charname>VERTICAL BAR</code> (<code class=char>|</code>) |
327 |
character to <var>result</var>.</dd> |
character to <var>r</var>.</dd> |
328 |
<dt>If no namespace is specified (by namespace prefix <code>*</code>, |
<dt>If no namespace is specified (by namespace prefix <code>*</code>, |
329 |
or by omitting namespace prefix where no default namespace is |
or by omitting namespace prefix where no default namespace is |
330 |
specified)</dt> |
specified)</dt> |
332 |
<code class=charname>ASTERISK</code> (<code class=char>*</code>) |
<code class=charname>ASTERISK</code> (<code class=char>*</code>) |
333 |
character, followed by a <code class=char>U+007C</code> |
character, followed by a <code class=char>U+007C</code> |
334 |
<code class=charname>VERTICAL BAR</code> (<code class=char>|</code>) |
<code class=charname>VERTICAL BAR</code> (<code class=char>|</code>) |
335 |
character, to <var>result</var>.</dd> |
character, to <var>r</var>.</dd> |
336 |
</dl> |
</dl> |
337 |
</li> |
</li> |
338 |
<li>If <var>ss</var> is a type selector, append the |
<li>If <var>ss</var> is a type selector, append the |
339 |
<a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
<a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
340 |
local name to <var>result</var>.</li> |
local name to <var>r</var>.</li> |
341 |
<li>If <var>ss</var> is a universal selector, append |
<li>If <var>ss</var> is a universal selector, append |
342 |
a <code class=char>U+002A</code> <code class=charname>ASTERISK</code> |
a <code class=char>U+002A</code> <code class=charname>ASTERISK</code> |
343 |
(<code class=char>*</code>) character to <var>result</var>.</li> |
(<code class=char>*</code>) character to <var>r</var>.</li> |
344 |
</ol> |
</ol> |
345 |
</dd> |
</dd> |
346 |
<dt>If <var>ss</var> is an attribute selector</dt> |
<dt>If <var>ss</var> is an attribute selector</dt> |
348 |
<ol> |
<ol> |
349 |
<li>Append a <code class=char>U+005B</code> <code class=charname>LEFT |
<li>Append a <code class=char>U+005B</code> <code class=charname>LEFT |
350 |
SQUARE BRACKET</code> (<code class=char>[</code>) to |
SQUARE BRACKET</code> (<code class=char>[</code>) to |
351 |
<var>result</var>.</li> |
<var>r</var>.</li> |
352 |
<li> |
<li> |
353 |
Append a namespace prefix as following: |
Append a namespace prefix as following: |
354 |
<dl> |
<dl> |
359 |
<dt>If the null namespace is specified</dt> |
<dt>If the null namespace is specified</dt> |
360 |
<dd>Append a <code class=char>U+007C</code> |
<dd>Append a <code class=char>U+007C</code> |
361 |
<code class=charname>VERTICAL BAR</code> character to |
<code class=charname>VERTICAL BAR</code> character to |
362 |
<var>result</var>.</dd> |
<var>r</var>.</dd> |
363 |
<dt>If no namespace is specified</dt> |
<dt>If no namespace is specified</dt> |
364 |
<dd>Append a <code class=char>U+002A</code> |
<dd>Append a <code class=char>U+002A</code> |
365 |
<code class=charname>ASTERISK</code> (<code class=char>*</code>) |
<code class=charname>ASTERISK</code> (<code class=char>*</code>) |
366 |
character, followed by a <code class=char>U+007C</code> |
character, followed by a <code class=char>U+007C</code> |
367 |
<code class=charname>VERTICAL BAR</code> (<code class=char>|</code>) |
<code class=charname>VERTICAL BAR</code> (<code class=char>|</code>) |
368 |
character, to <var>result</var>.</dd> |
character, to <var>r</var>.</dd> |
369 |
</dl> |
</dl> |
370 |
</li> |
</li> |
371 |
<li>Append the |
<li>Append the |
372 |
<a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
<a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
373 |
local name to <var>result</var>.</li> |
local name to <var>r</var>.</li> |
374 |
<li>If a value is specified in <var>ss</var>: |
<li>If a value is specified in <var>ss</var>: |
375 |
<ol> |
<ol> |
376 |
<li>Depending on the way to match, append <code>=</code>, |
<li>Depending on the way to match, append <code>=</code>, |
377 |
<code>~=</code>, <code>|=</code>, <code>^=</code>, |
<code>~=</code>, <code>|=</code>, <code>^=</code>, |
378 |
<code>$=</code>, or <code>*=</code> to <var>result</var>.</li> |
<code>$=</code>, or <code>*=</code> to <var>r</var>.</li> |
379 |
<li>Append the |
<li>Append the |
380 |
<a href="#algorithm-normalize-a-string" title="normalize a string">normalized</a> |
<a href="#algorithm-normalize-a-string" title="normalize a string">normalized</a> |
381 |
value to <var>result</var>.</li> |
value to <var>r</var>.</li> |
382 |
</ol> |
</ol> |
383 |
</li> |
</li> |
384 |
<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 |
385 |
SQUARE BRACKET</code> (<code class=char>]</code>) to |
SQUARE BRACKET</code> (<code class=char>]</code>) to |
386 |
<var>result</var>.</li> |
<var>r</var>.</li> |
387 |
</ol> |
</ol> |
388 |
</dd> |
</dd> |
389 |
<dt>If <var>ss</var> is a class selector</dt> |
<dt>If <var>ss</var> is a class selector</dt> |
390 |
<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 |
391 |
STOP</code> (<code class=char>.</code>) character, followed |
STOP</code> (<code class=char>.</code>) character, followed |
392 |
by <a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
by <a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
393 |
class name, <var>result</var>.</dd> |
class name, to <var>r</var>.</dd> |
394 |
<dt>If <var>ss</var> is an <abbr>ID</abbr> selector</dt> |
<dt>If <var>ss</var> is an <abbr>ID</abbr> selector</dt> |
395 |
<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 |
396 |
SIGN</code> (<code class=char>#</code>) character, followed |
SIGN</code> (<code class=char>#</code>) character, followed |
397 |
by <a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
by <a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
398 |
<abbr>ID</abbr>, to <var>result</var>.</dd> |
<abbr>ID</abbr>, to <var>r</var>.</dd> |
399 |
<dt>If <var>ss</var> is a pseudo$B!>(Bclass selector</dt> |
<dt>If <var>ss</var> is a pseudo$B!>(Bclass selector</dt> |
400 |
<dd> |
<dd> |
401 |
<ol> |
<ol> |
402 |
<li>Append a <code class=char>U+003A</code> |
<li>Append a <code class=char>U+003A</code> |
403 |
<code class=charname>COLON</code> (<code class=char>:</code>) character |
<code class=charname>COLON</code> (<code class=char>:</code>) character |
404 |
to <var>result</var>.</li> |
to <var>r</var>.</li> |
405 |
<li>Append the |
<li>Append the |
406 |
<a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
<a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
407 |
name of the pseudo$B!>(Bclass to <var>result</var>.</li> |
name (in <a href="#lower-case">lower$B!>(Bcase</a>) of the pseudo$B!>(Bclass to |
408 |
|
<var>r</var>.</li> |
409 |
<li>Append any arguments as following: |
<li>Append any arguments as following: |
410 |
<dl class=switch> |
<dl class=switch> |
411 |
<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> |
413 |
<ol> |
<ol> |
414 |
<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 |
415 |
PARENTHESIS</code> (<code class=char>(</code>) character |
PARENTHESIS</code> (<code class=char>(</code>) character |
416 |
to <var>result</var>.</li> |
to <var>r</var>.</li> |
417 |
<li>Append the |
<li>Append the |
418 |
<a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
<a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
419 |
language tag (the argument) to <var>result</var>.</li> |
language tag (the argument) to <var>r</var>. |
420 |
|
<span class="issue ed">Should we normalize cases?</span></li> |
421 |
<li>Append a <code class=char>U+0029</code> |
<li>Append a <code class=char>U+0029</code> |
422 |
<code class=charname>RIGHT PARENTHESIS</code> |
<code class=charname>RIGHT PARENTHESIS</code> |
423 |
(<code class=char>)</code>) character |
(<code class=char>)</code>) character |
424 |
to <var>result</var>.</li> |
to <var>r</var>.</li> |
425 |
</ol> |
</ol> |
426 |
</dd> |
</dd> |
427 |
<dt>If the name of the pseudo$B!>(Bclass is |
<dt>If the name of the pseudo$B!>(Bclass is |
430 |
<ol> |
<ol> |
431 |
<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 |
432 |
PARENTHESIS</code> (<code class=char>(</code>) character |
PARENTHESIS</code> (<code class=char>(</code>) character |
433 |
to <var>result</var>.</li> |
to <var>r</var>.</li> |
434 |
<li>Append the |
<li>Append the |
435 |
<a href="#algorithm-normalize-a-string" title="normalize a string">normalized</a> |
<a href="#algorithm-normalize-a-string" title="normalize a string">normalized</a> |
436 |
string (the argument) to <var>result</var>.</li> |
string (the argument) to <var>r</var>.</li> |
437 |
<li>Append a <code class=char>U+0029</code> |
<li>Append a <code class=char>U+0029</code> |
438 |
<code class=charname>RIGHT PARENTHESIS</code> |
<code class=charname>RIGHT PARENTHESIS</code> |
439 |
(<code class=char>)</code>) character |
(<code class=char>)</code>) character |
440 |
to <var>result</var>.</li> |
to <var>r</var>.</li> |
441 |
</ol> |
</ol> |
442 |
</dd> |
</dd> |
443 |
<dt>If name of the pseudo$B!>(Bclass is either <code>nth-child</code>, |
<dt>If name of the pseudo$B!>(Bclass is either <code>nth-child</code>, |
447 |
<ol> |
<ol> |
448 |
<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 |
449 |
PARENTHESIS</code> (<code class=char>(</code>) character |
PARENTHESIS</code> (<code class=char>(</code>) character |
450 |
to <var>result</var>.</li> |
to <var>r</var>.</li> |
451 |
<li>Append <span class=ed>@@ normalized</span> |
<li>Append <span class=ed>@@ normalized</span> |
452 |
integer <var>a</var> to <var>result</var>. |
integer <var>a</var> to <var>r</var>. |
453 |
If the argument is a keyword <code>odd</code> or <code>even</code>, |
If the argument is a keyword <code>odd</code> or <code>even</code>, |
454 |
<var>a</var> is <code>2</code>. If <var>a</var> and |
<var>a</var> is <code>2</code>. If <var>a</var> and |
455 |
<code>n</code> is omitted, <var>a</var> is assumed as |
<code>n</code> is omitted, <var>a</var> is assumed as |
460 |
character).</li> |
character).</li> |
461 |
<li>Append a <code class=char>U+006E</code> |
<li>Append a <code class=char>U+006E</code> |
462 |
<code class=charname>LATIN SMALL LETTER N</code> |
<code class=charname>LATIN SMALL LETTER N</code> |
463 |
(<code class=char>n</code>) character to <var>result</var>.</li> |
(<code class=char>n</code>) character to <var>r</var>.</li> |
464 |
<li>Append <span class=ed>@@ normalized</span> |
<li>Append <span class=ed>@@ normalized</span> |
465 |
integer <var>b</var> to <var>result</var>. |
integer <var>b</var> to <var>r</var>. |
466 |
It <em class=rfc2119>MUST</em> be preceded by a sign, |
It <em class=rfc2119>MUST</em> be preceded by a sign, |
467 |
either <code class=char>U+002B</code> <code class=charname>PLUS |
either <code class=char>U+002B</code> <code class=charname>PLUS |
468 |
SIGN</code> (<code class=char>+</code>) or |
SIGN</code> (<code class=char>+</code>) or |
479 |
<li>Append a <code class=char>U+0029</code> |
<li>Append a <code class=char>U+0029</code> |
480 |
<code class=charname>RIGHT PARENTHESIS</code> |
<code class=charname>RIGHT PARENTHESIS</code> |
481 |
(<code class=char>)</code>) character |
(<code class=char>)</code>) character |
482 |
to <var>result</var>.</li> |
to <var>r</var>.</li> |
483 |
</ol> |
</ol> |
484 |
</dd> |
</dd> |
485 |
<dt>If the name of the pseudo$B!>(Bclass is <code>not</code></dt> |
<dt>If the name of the pseudo$B!>(Bclass is <code>not</code></dt> |
493 |
<code class=charname>LATIN SMALL LETTER T</code>, and |
<code class=charname>LATIN SMALL LETTER T</code>, and |
494 |
<code class=char>U+0028</code> <code class=charname>LEFT |
<code class=char>U+0028</code> <code class=charname>LEFT |
495 |
PARENTHESIS</code> (<code>:not(</code>), followed by a |
PARENTHESIS</code> (<code>:not(</code>), followed by a |
496 |
<a href="#newline">newline</a>, to <var>result</var>.</li> |
<a href="#newline">newline</a>, to <var>r</var>.</li> |
497 |
<li>Append four <code class=char>U+0020</code> |
<li>Append four <code class=char>U+0020</code> |
498 |
<code class=charname>SPACE</code> characters to |
<code class=charname>SPACE</code> characters to |
499 |
<var>result</var>.</li> |
<var>r</var>.</li> |
500 |
<li>Append four <code class=char>U+0020</code> |
<li>Append four <code class=char>U+0020</code> |
501 |
<code class=charname>SPACE</code> characters to |
<code class=charname>SPACE</code> characters to |
502 |
<var>result</var> again.</li> |
<var>r</var> again.</li> |
503 |
<li><a href="#algorithm-serialize-a-simple-selector">Serialize |
<li><a href="#algorithm-serialize-a-simple-selector">Serialize |
504 |
the simple selector specified as the argument to the |
the simple selector specified as the argument to the |
505 |
<code>not</code> pseudo$B!>(Bclass</a>.</li> |
<code>not</code> pseudo$B!>(Bclass</a>.</li> |
506 |
<li>Append a <a href="#newline">newline</a> to |
<li>Append a <a href="#newline">newline</a> to |
507 |
<var>result</var>.</li> |
<var>r</var>.</li> |
508 |
<li>Append four <code class=char>U+0020</code> |
<li>Append four <code class=char>U+0020</code> |
509 |
<code class=charname>SPACE</code> characters to |
<code class=charname>SPACE</code> characters to |
510 |
<var>result</var>.</li> |
<var>r</var>.</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 |
514 |
to <var>result</var>.</li> |
to <var>r</var>.</li> |
515 |
</ol> |
</ol> |
516 |
</dd> |
</dd> |
517 |
|
<dt>Otherwise</dt> |
518 |
|
<dd>The pseudo$B!>(Bclass is not supported by this version of |
519 |
|
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
520 |
|
and therefore no |
521 |
|
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
522 |
|
representation is defined for <var>ss</var>. Stop the algorithm.</dd> |
523 |
</dl> |
</dl> |
524 |
</li> |
</li> |
525 |
</ol> |
</ol> |
529 |
<ol> |
<ol> |
530 |
<li>Append two <code class=char>U+003A</code> |
<li>Append two <code class=char>U+003A</code> |
531 |
<code class=charname>COLON</code> characters (<code>::</code>) |
<code class=charname>COLON</code> characters (<code>::</code>) |
532 |
to <var>result</var>.</li> |
to <var>r</var>.</li> |
533 |
<li>Append the |
<li>Append the |
534 |
<a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
<a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
535 |
name of the pseudo$B!>(Belement to <var>result</var>.</li> |
name (in <a href="#lower-case">lower$B!>(Bcase</a>) of the pseudo$B!>(Belement |
536 |
<!-- For future version: append "(", arguments, ")", if any. --> |
to <var>r</var>.</li> |
537 |
|
<li>If the pseudo$B!>(Belement has any arguments: |
538 |
|
The pseudo$B!>(Belement is not supported by this version of |
539 |
|
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
540 |
|
and therefore no |
541 |
|
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
542 |
|
representation is defined for <var>ss</var>. Stop the algorithm. |
543 |
|
</li> |
544 |
</ol> |
</ol> |
545 |
</dd> |
</dd> |
546 |
</dl> |
</dl> |
547 |
|
</li> |
548 |
|
<li>Then, <var>r</var> is the |
549 |
|
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
550 |
|
representation of <var>ss</var>.</li> |
551 |
|
</ol> |
552 |
|
|
553 |
</div> |
</div> |
554 |
|
|
556 |
<h3>Serializing Groups of Selectors</h3> |
<h3>Serializing Groups of Selectors</h3> |
557 |
|
|
558 |
<p>No <abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
<p>No <abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
559 |
representation is defined for an invalid group of selectors.</p> |
representation is defined for an invalid |
560 |
|
<a href="http://www.w3.org/TR/css3-selectors/#grouping">group of |
561 |
<div class="note memo"> |
selectors</a>.</p> |
|
<p>The serialized representation will not contain any comment.</p> |
|
|
</div> |
|
|
|
|
|
<!-- TODO: link terms to Selectors --> |
|
562 |
|
|
563 |
<p>To |
<p>To |
564 |
<dfn id=algorithm-serialize-a-group-of-selectors title="serialize a group of selectors">serialize |
<dfn id=algorithm-serialize-a-group-of-selectors title="serialize a group of selectors">serialize |
565 |
a group of selectors (<dfn id=var-gs><var>gs</var></dfn>)</dfn>:</p> |
a group of selectors (<dfn id=var-gs><var>gs</var></dfn>)</dfn>, |
566 |
|
the following algorithm <em class=rfc2119>MUST</em> be used:</p> |
567 |
<ol> |
<ol> |
568 |
<li>Let <dfn id=var-result><var>result</var></dfn> an empty string.</li> |
<li>Let <dfn id=var-result><var>result</var></dfn> an empty string.</li> |
569 |
<li>For each selector (<dfn id=var-selector><var>selector</var></dfn>) in |
<li>For each selector (<dfn id=var-selector><var>selector</var></dfn>) in |
570 |
<var>gs</var>: |
<var>gs</var>: |
571 |
<ol> |
<ol> |
572 |
<li>If <var>selector</var> is <em>not</em> the first selector |
<li>If <var>selector</var> is <em>not</em> the first selector |
573 |
in the group of selectors, then append a <code class=char>U+002C</code> |
in the <var>gs</var>, then append a <code class=char>U+002C</code> |
574 |
<code class=charname>COMMA</code> (<code class=char>,</code>) followed by a |
<code class=charname>COMMA</code> (<code class=char>,</code>) followed by a |
575 |
<a href="#newline">newline</a> to <var>result</var>.</li> |
<a href="#newline">newline</a> to <var>result</var>.</li> |
576 |
<li>Append four <code class=char>U+0020</code> |
<li>Append four <code class=char>U+0020</code> |
577 |
<code class=charname>SPACE</code> characters to <var>result</var>.</li> |
<code class=charname>SPACE</code> characters to <var>result</var>.</li> |
578 |
<li>Process each sequence of simple selectors or |
<li>Process each sequence of simple selectors or |
579 |
combinator in <var>selector</var> by following algorithm: |
combinator in <var>selector</var> as following: |
580 |
<dl class=switch> |
<dl class=switch> |
581 |
<dt>If it is a sequence of simle selector |
<dt>If it is a sequence of simle selector |
582 |
(<dfn id=var-sss><var>sss</var></dfn>)</dt> |
(<dfn id=var-sss><var>sss</var></dfn>)</dt> |
593 |
<ol> |
<ol> |
594 |
<li>Append two <code class=char>U+0020</code> |
<li>Append two <code class=char>U+0020</code> |
595 |
<code class=charname>SPACE</code> characters to <var>result</var>.</li> |
<code class=charname>SPACE</code> characters to <var>result</var>.</li> |
596 |
<li> |
<li>Process <var>c</var> as following: |
597 |
|
|
598 |
<dl class=switch> |
<dl class=switch> |
599 |
<dt>If <var>c</var> is descendant combinator (white space)</dt> |
<dt>If <var>c</var> is descendant combinator (white space)</dt> |
600 |
<dd>Append a <code class=char>U+0020</code> |
<dd>Append a <code class=char>U+0020</code> |
637 |
<div class="section" id="parsing"> |
<div class="section" id="parsing"> |
638 |
<h2>Parsing |
<h2>Parsing |
639 |
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
640 |
Groups of Selectors</h2> |
Representations of Selectors</h2> |
641 |
|
|
642 |
<p>Since <a href="#serializing">the serializing algorithm</a> is |
<p>Since <a href="#algorithm-serialize-a-group-of-selectors">the serializing |
643 |
so designed that it always output a valid |
algorithm for groups of selectors</a> is so designed that it always outputs a |
644 |
<a href="http://www.w3.org/TR/css3-selectors/#grouping">group of |
valid <a href="http://www.w3.org/TR/css3-selectors/#grouping">group of |
645 |
selectors</a>, no special parser for the |
selectors</a>, no special parser for the |
646 |
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
647 |
representation is necessary. Any conforming parser for |
representation is necessary. Any conforming parser for |
648 |
<a href="http://www.w3.org/TR/css3-selectors/#grouping">groups of |
<a href="http://www.w3.org/TR/css3-selectors/#grouping">groups of |
649 |
selectors</a> <em class=rfc2119>MAY</em> be used |
selectors</a> <em class=rfc2119>MAY</em> be used |
650 |
to parse <abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
to parse <abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
651 |
representations of groups of selectors.</p> |
representations of |
652 |
|
<a href="http://www.w3.org/TR/css3-selectors/#grouping">groups of |
653 |
|
selectors</a>.</p> |
654 |
|
|
655 |
|
<p>Likewise, <a href="#algorithm-serialize-a-simple-selector">the serializing |
656 |
|
algorithm for simple selectors</a> always outputs a valid |
657 |
|
<a href="#simple-selector">simple selector</a> and therefore any |
658 |
|
conforming parser for <a href="#simple-selector">simple selector</a> |
659 |
|
<em class=rfc2119>MAY</em> be used to parse |
660 |
|
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
661 |
|
representations of <a href="#simple-selector">simple selectors</a>.</p> |
662 |
</div> |
</div> |
663 |
|
|
664 |
<div class="section" id="examples"> |
<div class="section" id="examples"> |
694 |
<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> |
695 |
14</a>, <abbr title="Request for Comments">RFC</abbr> 2119, |
14</a>, <abbr title="Request for Comments">RFC</abbr> 2119, |
696 |
<time datetime=1997-03>March 1997</time>. |
<time datetime=1997-03>March 1997</time>. |
697 |
This version of the specification is referenced</dd> |
This version of the specification is referenced.</dd> |
698 |
<dt id=ref-SELECTORS>SELECTORS</dt> |
<dt id=ref-SELECTORS>SELECTORS</dt> |
699 |
<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>, |
700 |
<abbr title="World Wide Web Consortium">W3C</abbr> Working Draft, |
<abbr title="World Wide Web Consortium">W3C</abbr> Working Draft, |