/[suikacvs]/markup/selectors/ssft/ssft-work.en.html
Suika

Contents of /markup/selectors/ssft/ssft-work.en.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.15 - (show annotations) (download) (as text)
Mon Oct 22 11:00:57 2007 UTC (17 years, 1 month ago) by wakaba
Branch: MAIN
Changes since 1.14: +24 -10 lines
File MIME type: text/html
algorithm conformance

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24