/[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.21 - (show annotations) (download) (as text)
Mon Nov 5 11:08:05 2007 UTC (17 years ago) by wakaba
Branch: MAIN
Changes since 1.20: +5 -6 lines
File MIME type: text/html
fix duplicate IDs; remove unused SHOULD NOT keyword

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-11-05>5 November 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 <p>It is so flexible language that a conceptually same pattern
102 can be represented in inifnite numbers of instances of selectors.
103 It might be convinient for e.g. validation of a test result to
104 define a subset of the language, in which no semantically equivalent
105 selectors are contained.</p>
106
107 <p><a href="http://dev.w3.org/cvsweb/csswg/cssom/Overview.html">The
108 <abbr title="Cascading Style Sheets Object Model">CSSOM</abbr>
109 specification</a>
110 <cite class="bibref informative">[<a href="#ref-CSSOM">CSSOM</a>]</cite>
111 is trying to define an algorithm to
112 <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
113 a group of selectors</a> for the purpose of <code>selectorText</code>
114 attribute. However, the algorithm is incomplete
115 <time datetime=2007-09-25>at the time of the writing</time>.
116 Note that current Web browser implementations
117 of the <code>selectorText</code> attribute are consistently broken
118 in not escaping unsafe identifiers and therefore it is not wise
119 to deploy that format for testing.</p>
120
121 </div>
122
123 <div class="section" id="terminology">
124 <h2>Terminology</h2>
125
126 <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>,
128 <q><dfn id=should><em class="rfc2119">SHOULD</em></dfn></q>, and
129 <q><dfn id=may><em class=rfc2119>MAY</em></dfn></q> in this
130 document are to be interpreted as described in
131 <a href="urn:ietf:rfc:2119"><abbr title="Request for Comments">RFC</abbr>
132 2119</a>
133 <cite class="bibref normative">[<a href="#ref-KEYWORDS">KEYWORDS</a>]</cite>.</p>
134
135 <p>Requirements phrased in the imperative as part of algorithms are to be
136 interpreted with the meaning of the key word (<em class=rfc2119>MUST</em>)
137 used in introducing the algorithm.</p>
138
139 <p>Conformance requirements phrased as algorithms or specific steps
140 <em class=rfc2119>MAY</em> be implemented in any manner, so long as the end
141 result is equivalent.</p>
142
143 <!-- Strictly speaking the paragraph below is not part of terminology. -->
144 <p>All examples and notes in this specification are non$B!>(Bnormative,
145 as are all sections explicitly marked non$B!>(Bnormative. Everything
146 else in this specification is normative.</p>
147
148 <p>For the purpose of this specification, pseudo$B!>(Belements are also
149 referred to as <dfn title="simple selector" id=simple-selector>simple
150 selectors</dfn> and are considered as part of the last sequence of
151 simple selector in a selector.</p>
152 </div>
153
154 <div class="section" id="serializing">
155 <h2>Serializing Selectors in
156 <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
157 Representation</h2>
158
159 <p>Subsections of this section define algorithms
160 to <a href="#algorithm-serialize-a-simple-selector">serialize a simple
161 selector</a> or <a href="#algorithm-serialize-a-group-of-selectors">serialize
162 a group of selectors</a>.</p>
163
164 <div class="note memo">
165 <p>The serialized representation will not contain any comment.</p>
166 </div>
167
168 <div class="ed issue"><p>TODO: link terms to Selectors</p></div>
169
170 <div class=section id=serializing-tokens>
171 <h3>Serializing Tokens</h3>
172
173 <p>To <dfn id=algorithm-normalize-an-ident title="normalize a string as an IDENT">normalize
174 a string (<dfn id=var-n><var>n</var></dfn>) as an <code>IDENT</code></dfn>,
175 the following algorithm <em class=rfc2119>MUST</em> be used:</p>
176 <ol>
177 <li>If <var>n</var> is either an <code>IDENT</code> or a <code>HASH</code>,
178 replace the escape sequences (<code>\</code> and following characters) in
179 <var>n</var> by characters represented by them respectively.</li>
180 <li>If <var>n</var> is a <code>HASH</code>, remove the leading
181 <code class=char>U+0023</code> <code class=charname>NUMBER SIGN</code>
182 (<code class=char>#</code>) character from <var>n</var>.</li>
183 <li>If there is any character that is <em>not</em> one of
184 <code class=char>U+002D</code> <code class=charname>HYPHEN-MINUS</code>
185 (<code class=char>-</code>), <code class=char>U+0030</code>
186 <code class=charname>DIGIT ZERO</code>
187 (<code class=char>0</code>) to <code class=char>U+0039</code>
188 <code class=charname>DIGIT NINE</code> (<code class=char>9</code>),
189 <code class=char>U+0041</code> <code class=charname>LATIN CAPITAL LETTER
190 A</code> (<code class=char>A</code>) to <code class=char>U+005A</code>
191 <code class=charname>LATIN CAPITAL LETTER Z</code> (<code class=char>Z</code>),
192 <code class=char>U+005F</code> <code class=charname>LOW LINE</code>
193 (<code class=char>_</code>), <code class=char>U+0061</code>
194 <code class=charname>LATIN SMALL LETTER A</code>
195 (<code class=char>a</code>) to <code class=char>U+006A</code>
196 <code class=charname>LATIN SMALL LETTER Z</code> (<code class=char>z</code>),
197 <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
199 <var>n</var>, then replace it by string <code>\<var>HHHHHH</var></code>, where
200 <dfn id=var-ident-HHHHHH><var>HHHHHH</var></dfn> is the upper$B!>(Bcase
201 zero$B!>(Bpadded hexadecimal representation of the character. If the character
202 is outside the range of <code>[<code class=char>U+0000</code>,
203 <code class=char>U+10FFFF</code>]</code>, <var>HHHHHH</var>
204 <em class=rfc2119>MUST</em> be <code>FFFFFF</code>.</li>
205 <li>If the first character in <var>n</var> is one of
206 <code class=char>U+0030</code> <code class=charname>DIGIT ZERO</code>
207 (<code class=char>0</code>) to <code class=char>U+0039</code>
208 <code class=charname>DIGIT NINE</code> (<code class=char>9</code>),
209 then prepend a string <code>\00003</code> at the beginning of
210 <var>n</var>.</li>
211 <li>If the first character in <var>n</var> is <code class=char>U+002D</code>
212 <code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>) and
213 the second character, if any, is <em>not</em> one of
214 <code class=char>U+0041</code> <code class=charname>LATIN CAPITAL LETTER
215 A</code> (<code class=char>A</code>) to <code class=char>U+005A</code>
216 <code class=charname>LATIN CAPITAL LETTER Z</code> (<code class=char>Z</code>),
217 <code class=char>U+005F</code> <code class=charname>LOW LINE</code>
218 (<code class=char>_</code>), <code class=char>U+0061</code>
219 <code class=charname>LATIN SMALL LETTER A</code>
220 (<code class=char>a</code>) to <code class=char>U+006A</code>
221 <code class=charname>LATIN SMALL LETTER Z</code> (<code class=char>z</code>),
222 <code>U+0080</code> to <code>U+D7FF</code>, or
223 <code>U+E000</code> to <code>U+10FFFF</code>, or
224 <var>n</var> is equal to <code class=char>U+002D</code>
225 <code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>), then
226 replace the <code class=char>U+002D</code>
227 <code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>)
228 character by string <code>\00002D</code>.</li>
229 <li>Then, <var>n</var> is the result of the algorithm.</li>
230 </ol>
231
232 <p>To <dfn id=algorithm-normalize-a-string title="normalize a string (STRING or IDENT) as a STRING">normalize
233 a string (<dfn id=var-s><var>s</var></dfn>) as a <code>STRING</code></dfn>,
234 the following algorithm <em class=rfc2119>MUST</em> be used:</p>
235 <ol>
236 <li>If <var>s</var> is either an <code>IDENT</code> or a
237 <code>STRING</code>, replace the escape sequences (<code>\</code> and
238 following characters) in <var>s</var> by characters represented by them
239 (or an empty string if <code>\</code> is immediately followed by
240 newline character(s)) respectively.</li>
241 <li>If <var>s</var> is a <code>STRING</code>, remove the quotation marks
242 enclosing <var>s</var>.</li>
243 <li><p>If there is any character that is <em>not</em> one of
244 <code class=char>U+0020</code> <code class=charname>SPACE</code>,
245 <code class=char>U+0021</code> <code class=charname>EXCLAMATION MARK</code>
246 (<code class=char>!</code>), <code class=char>U+0023</code>
247 <code class=charname>NUMBER SIGN</code> (<code class=char>#</code>) to
248 <code class=char>U+005B</code> <code class=charname>LEFT SQUARE
249 BRACKET</code>, <code class=char>U+005D</code> <code class=charname>RIGHT
250 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
252 <var>s</var>, then replace it by string <code>\<var>HHHHHH</var></code>, where
253 <dfn id=var-string-HHHHHH><var>HHHHHH</var></dfn> is the upper$B!>(Bcase
254 zero$B!>(Bpadded hexadecimal representation of the character. If the character
255 is outside the range of <code>[<code class=char>U+0000</code>,
256 <code class=char>U+10FFFF</code>]</code>, <var>HHHHHH</var>
257 <em class=rfc2119>MUST</em> be <code>FFFFFF</code>.</p></li>
258 <li><p>Insert a <code class=char>U+0022</code> <code class=charname>QUOTATION
259 MARK</code> (<code class=char>"</code>) at the beginning of
260 <var>s</var>.</p></li>
261 <li><p>Insert a <code class=char>U+0022</code> <code class=charname>QUOTATION
262 MARK</code> (<code class=char>"</code>) at the end of <var>s</var>.</p></li>
263 <li><p>Then, <var>s</var> is the result of the algorithm.</p></li>
264 </ol>
265
266 <p>A <dfn id=newline title=newline>newline</dfn>
267 <em class=rfc2119>SHOULD</em> be represented as a
268 <code class=char>U+000A</code> <code class=charname>LINE FEED</code>
269 character. However, depending on the context where
270 the <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
271 representation is in use, a sequence of
272 <code class=char>U+000D</code> <code class=charname>CARRIAGE RETURN</code>
273 followed by a <code class=char>U+000A</code>
274 <code class=charname>LINE FEED</code> (i.e. a
275 <code>CRLF</code> sequence) or a character
276 <code class=char>U+000D</code> <code class=charname>CARRIAGE RETURN</code>
277 <em class=rfc2119>MAY</em> be used as a <a href="#newline">newline</a> instead.
278 <a href="#newline">Newline</a> representations
279 <em class=rfc2119>SHOULD</em> be consistent in an
280 <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
281 representation.</p>
282
283 <div class="note memo">
284 <p>Therefore, newlines must be normalized before
285 <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
286 representations are literally compared.</p>
287 </div>
288
289 <div class="issue ed">
290 <p>Need to define <dfn id=lower-case>lower$B!>(Bcase</dfn>.
291 It is tr/A-Z/a-z/ for now.</p>
292 </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>
316
317
318 <div class=section id=serializing-simple-selectors>
319 <h3>Serializing Simple Selectors</h3>
320
321 <p>No <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
322 representation is defined for an invalid <a href="#simple-selector">simple
323 selector</a>.</p>
324
325 <p>To
326 <dfn id=algorithm-serialize-a-simple-selector title="serialize a simple selector">serialize
327 a simple selector (<dfn><var id=var-ss>ss</var></dfn>)</dfn>,
328 the following algorithm <em class=rfc2119>MUST</em> be used:</p>
329 <ol>
330 <li>Let <dfn id=var-r><var>r</var></dfn> an empty string.</li>
331 <li>Process <var>ss</var> as following:
332
333 <dl class=switch>
334 <dt>If <var>ss</var> is a type or universal selector</dt>
335 <dd>
336 <ol>
337 <li>Append a namespace prefix as following:
338
339 <dl class=switch>
340 <dt>If a namespace URI is specified (via namespace prefix, or
341 by omitting namespace prefix where a default namespace is specified)</dt>
342 <dd>Append the namespace URI as a
343 <a href="#algorithm-normalize-an-ident" title="normalize a string as an IDENT">normalized
344 <code>IDENT</code></a> to <var>r</var>. Then, append a
345 <code class=char>U+007C</code>
346 <code class=charname>VERTICAL BAR</code> (<code class=char>|</code>)
347 character to <var>r</var>.</dd>
348 <dt>If the null namespace is specified (by zero$B!>(Blength namespace
349 prefix)</dt>
350 <dd>Append a <code class=char>U+007C</code>
351 <code class=charname>VERTICAL BAR</code> (<code class=char>|</code>)
352 character to <var>r</var>.</dd>
353 <dt>If no namespace is specified (by namespace prefix <code>*</code>,
354 or by omitting namespace prefix where no default namespace is
355 specified)</dt>
356 <dd>Append a <code class=char>U+002A</code>
357 <code class=charname>ASTERISK</code> (<code class=char>*</code>)
358 character, followed by a <code class=char>U+007C</code>
359 <code class=charname>VERTICAL BAR</code> (<code class=char>|</code>)
360 character, to <var>r</var>.</dd>
361 </dl>
362 </li>
363 <li>If <var>ss</var> is a type selector, append the
364 <a href="#algorithm-normalize-an-ident" title="normalize a string (IDENT) an IDENT">normalized</a>
365 local name to <var>r</var>.</li>
366 <li>If <var>ss</var> is a universal selector, append
367 a <code class=char>U+002A</code> <code class=charname>ASTERISK</code>
368 (<code class=char>*</code>) character to <var>r</var>.</li>
369 </ol>
370 </dd>
371 <dt>If <var>ss</var> is an attribute selector</dt>
372 <dd>
373 <ol>
374 <li>Append a <code class=char>U+005B</code> <code class=charname>LEFT
375 SQUARE BRACKET</code> (<code class=char>[</code>) to
376 <var>r</var>.</li>
377 <li>
378 Append a namespace prefix as following:
379 <dl>
380 <dt>If a namespace URI is specified</dt>
381 <dd>Append the namespace URI as a
382 <a href="#algorithm-normalize-an-ident" title="normalize a string as an IDENT">normalized
383 <code>IDENT</code></a> to <var>r</var>. Then, append a
384 <code class=char>U+007C</code>
385 <code class=charname>VERTICAL BAR</code> (<code class=char>|</code>)
386 character to <var>r</var>.</dd>
387 <dt>If the null namespace is specified</dt>
388 <dd>Append a <code class=char>U+007C</code>
389 <code class=charname>VERTICAL BAR</code> character to
390 <var>r</var>.</dd>
391 <dt>If no namespace is specified</dt>
392 <dd>Append a <code class=char>U+002A</code>
393 <code class=charname>ASTERISK</code> (<code class=char>*</code>)
394 character, followed by a <code class=char>U+007C</code>
395 <code class=charname>VERTICAL BAR</code> (<code class=char>|</code>)
396 character, to <var>r</var>.</dd>
397 </dl>
398 </li>
399 <li>Append the
400 <a href="#algorithm-normalize-an-ident" title="normalize a string (IDENT) as an IDENT">normalized</a>
401 local name to <var>r</var>.</li>
402 <li>If a value is specified in <var>ss</var>:
403 <ol>
404 <li>Depending on the way to match, append <code>=</code>,
405 <code>~=</code>, <code>|=</code>, <code>^=</code>,
406 <code>$=</code>, or <code>*=</code> to <var>r</var>.</li>
407 <li>Append the
408 <a href="#algorithm-normalize-a-string" title="normalize a string">normalized</a>
409 value to <var>r</var>.</li>
410 </ol>
411 </li>
412 <li>Append a <code class=char>U+005D</code> <code class=charname>RIGHT
413 SQUARE BRACKET</code> (<code class=char>]</code>) to
414 <var>r</var>.</li>
415 </ol>
416 </dd>
417 <dt>If <var>ss</var> is a class selector</dt>
418 <dd>Append a <code class=char>U+002E</code> <code class=charname>FULL
419 STOP</code> (<code class=char>.</code>) character, followed
420 by <a href="#algorithm-normalize-an-ident" title="normalize a string (IDENT) as an IDENT">normalized</a>
421 class name, to <var>r</var>.</dd>
422 <dt>If <var>ss</var> is an <abbr>ID</abbr> selector</dt>
423 <dd>Append a <code class=char>U+0023</code> <code class=charname>NUMBER
424 SIGN</code> (<code class=char>#</code>) character, followed
425 by <a href="#algorithm-normalize-an-ident" title="normalize a string (HASH except for the leading #) as an IDENT">normalized</a>
426 <abbr>ID</abbr>, to <var>r</var>.</dd>
427 <dt>If <var>ss</var> is a pseudo$B!>(Bclass selector</dt>
428 <dd>
429 <ol>
430 <li>Append a <code class=char>U+003A</code>
431 <code class=charname>COLON</code> (<code class=char>:</code>) character
432 to <var>r</var>.</li>
433 <li>Append the
434 <a href="#algorithm-normalize-an-ident" title="normalize a string (IDENT) as an IDENT">normalized</a>
435 name (in <a href="#lower-case">lower$B!>(Bcase</a>) of the pseudo$B!>(Bclass to
436 <var>r</var>.</li>
437 <li>Append any arguments as following:
438 <dl class=switch>
439 <dt>If the name of the pseudo$B!>(Bclass is <code>lang</code></dt>
440 <dd>
441 <ol>
442 <li>Append a <code class=char>U+0028</code> <code class=charname>LEFT
443 PARENTHESIS</code> (<code class=char>(</code>) character
444 to <var>r</var>.</li>
445 <li>Append the
446 <a href="#algorithm-normalize-an-ident" title="normalize a string (IDENT) as an IDENT">normalized</a>
447 language tag (the argument) to <var>r</var>.
448 <span class="issue ed">Should we normalize cases?</span></li>
449 <li>Append a <code class=char>U+0029</code>
450 <code class=charname>RIGHT PARENTHESIS</code>
451 (<code class=char>)</code>) character
452 to <var>r</var>.</li>
453 </ol>
454 </dd>
455 <dt>If the name of the pseudo$B!>(Bclass is
456 <code>-manakai-contains</code></dt>
457 <dd>
458 <ol>
459 <li>Append a <code class=char>U+0028</code> <code class=charname>LEFT
460 PARENTHESIS</code> (<code class=char>(</code>) character
461 to <var>r</var>.</li>
462 <li>Append the
463 <a href="#algorithm-normalize-a-string" title="normalize a string">normalized</a>
464 string (the argument) to <var>r</var>.</li>
465 <li>Append a <code class=char>U+0029</code>
466 <code class=charname>RIGHT PARENTHESIS</code>
467 (<code class=char>)</code>) character
468 to <var>r</var>.</li>
469 </ol>
470 </dd>
471 <dt>If name of the pseudo$B!>(Bclass is either <code>nth-child</code>,
472 <code>nth-last-child</code>, <code>nth-of-type</code>, or
473 <code>nth-last-of-type</code></dt>
474 <dd>
475 <ol>
476 <li>Append a <code class=char>U+0028</code> <code class=charname>LEFT
477 PARENTHESIS</code> (<code class=char>(</code>) character
478 to <var>r</var>.</li>
479 <li>Let <dfn id=var-a><var>a</var></dfn> be the <var>a</var>
480 part of the argument. If the argument is a keyword <code>odd</code>
481 or <code>even</code>, then let <var>a</var> be <code>2</code>.
482 If the <var>a</var> part with following <code>n</code> character
483 is omitted, then let <var>a</var> be <code>0</code>.
484 Otherwise, if only the <var>a</var> part is omitted, then
485 let <var>a</var> be <code>1</code>. Otherwise, if the <var>a</var>
486 part is <code>-</code>, then let <var>a</var> be
487 <code>-1</code>.</li>
488 <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>
493 <code class=charname>LATIN SMALL LETTER N</code>
494 (<code class=char>n</code>) character to <var>r</var>.</li>
495 <li>Let <dfn id=var-b><var>b</var></dfn> be the <var>b</var>
496 part of the argument. If the argument is a keyword <code>odd</code>,
497 then let <var>b</var> be <code>1</code>. If the argument is a
498 keyword <code>even</code>, then let <var>b</var> be <code>0</code>.
499 If the <var>b</var> part is omitted, then let <var>b</var> be
500 <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>)
507 character, then append <code class=char>U+002B</code>
508 <code class=charname>PLUS SIGN</code>
509 (<code class=char>+</code>) to <var>result</var>.</li>
510 <li>Append <var>b</var> to <var>result</var>.</li>
511 <li>Append a <code class=char>U+0029</code>
512 <code class=charname>RIGHT PARENTHESIS</code>
513 (<code class=char>)</code>) character
514 to <var>r</var>.</li>
515 </ol>
516 </dd>
517 <dt>If the name of the pseudo$B!>(Bclass is <code>not</code></dt>
518 <dd>
519 <ol>
520 <li>Append a string of <code class=char>U+003A</code>
521 <code class=charname>COLON</code>, <code class=char>U+006E</code>
522 <code class=charname>LATIN SMALL LETTER N</code>,
523 <code class=char>U+006F</code> <code class=charname>LATIN
524 SMALL LETTER O</code>, <code class=char>U+0074</code>
525 <code class=charname>LATIN SMALL LETTER T</code>, and
526 <code class=char>U+0028</code> <code class=charname>LEFT
527 PARENTHESIS</code> (<code>:not(</code>), followed by a
528 <a href="#newline">newline</a>, to <var>r</var>.</li>
529 <li>Append four <code class=char>U+0020</code>
530 <code class=charname>SPACE</code> characters to
531 <var>r</var>.</li>
532 <li>Append four <code class=char>U+0020</code>
533 <code class=charname>SPACE</code> characters to
534 <var>r</var> again.</li>
535 <li><a href="#algorithm-serialize-a-simple-selector">Serialize
536 the simple selector specified as the argument to the
537 <code>not</code> pseudo$B!>(Bclass</a>.</li>
538 <li>Append a <a href="#newline">newline</a> to
539 <var>r</var>.</li>
540 <li>Append four <code class=char>U+0020</code>
541 <code class=charname>SPACE</code> characters to
542 <var>r</var>.</li>
543 <li>Append a <code class=char>U+0029</code>
544 <code class=charname>RIGHT PARENTHESIS</code>
545 (<code class=char>)</code>) character
546 to <var>r</var>.</li>
547 </ol>
548 </dd>
549 <dt>Otherwise</dt>
550 <dd>The pseudo$B!>(Bclass is not supported by this version of
551 <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
552 and therefore no
553 <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
554 representation is defined for <var>ss</var>. Stop the algorithm.</dd>
555 </dl>
556 </li>
557 </ol>
558 </dd>
559 <dt>If <var>ss</var> is a pseudo$B!>(Belement</dt>
560 <dd>
561 <ol>
562 <li>Append two <code class=char>U+003A</code>
563 <code class=charname>COLON</code> characters (<code>::</code>)
564 to <var>r</var>.</li>
565 <li>Append the
566 <a href="#algorithm-normalize-an-ident" title="normalize a string (IDENT) as an IDENT">normalized</a>
567 name (in <a href="#lower-case">lower$B!>(Bcase</a>) of the pseudo$B!>(Belement
568 to <var>r</var>.</li>
569 <li>If the pseudo$B!>(Belement has any arguments:
570 The pseudo$B!>(Belement is not supported by this version of
571 <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
572 and therefore no
573 <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
574 representation is defined for <var>ss</var>. Stop the algorithm.
575 </li>
576 </ol>
577 </dd>
578 </dl>
579 </li>
580 <li>Then, <var>r</var> is the
581 <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
582 representation of <var>ss</var>.</li>
583 </ol>
584
585 </div>
586
587 <div class=section id=serializing-groups-of-selectors>
588 <h3>Serializing Groups of Selectors</h3>
589
590 <p>No <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
591 representation is defined for an invalid
592 <a href="http://www.w3.org/TR/css3-selectors/#grouping">group of
593 selectors</a>.</p>
594
595 <p>To
596 <dfn id=algorithm-serialize-a-group-of-selectors title="serialize a group of selectors">serialize
597 a group of selectors (<dfn id=var-gs><var>gs</var></dfn>)</dfn>,
598 the following algorithm <em class=rfc2119>MUST</em> be used:</p>
599 <ol>
600 <li>Let <dfn id=var-result><var>result</var></dfn> an empty string.</li>
601 <li>For each selector (<dfn id=var-selector><var>selector</var></dfn>) in
602 <var>gs</var>:
603 <ol>
604 <li>If <var>selector</var> is <em>not</em> the first selector
605 in the <var>gs</var>, then append a <code class=char>U+002C</code>
606 <code class=charname>COMMA</code> (<code class=char>,</code>) followed by a
607 <a href="#newline">newline</a> to <var>result</var>.</li>
608 <li>Append four <code class=char>U+0020</code>
609 <code class=charname>SPACE</code> characters to <var>result</var>.</li>
610 <li>Process each sequence of simple selectors or
611 combinator in <var>selector</var> as following:
612 <dl class=switch>
613 <dt>If it is a sequence of simle selector
614 (<dfn id=var-sss><var>sss</var></dfn>)</dt>
615 <dd>
616 <ol>
617 <li>If <var>sss</var> contains a universal or type selector, then
618 <a href="#algorithm-serialize-a-simple-selector" title="serialize a simple selector">serialize
619 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>
642 </ol>
643 </dd>
644 <dt>If it is a combinator (<dfn id=var-c><var>c</var></dfn>)</dt>
645 <dd>
646 <ol>
647 <li>Append two <code class=char>U+0020</code>
648 <code class=charname>SPACE</code> characters to <var>result</var>.</li>
649 <li>Process <var>c</var> as following:
650
651 <dl class=switch>
652 <dt>If <var>c</var> is descendant combinator (white space)</dt>
653 <dd>Append a <code class=char>U+0020</code>
654 <code class=charname>SPACE</code> character to
655 <var>result</var>.</dd>
656 <dt>If <var>c</var> is child combinator
657 (<code class=char>></code>)</dt>
658 <dd>Append a <code class=char>U+003E</code>
659 <code class=charname>GREATER-THAN SIGN</code>
660 (<code class=char>></code>) character to <var>result</var>.</dd>
661 <dt>If <var>c</var> is adjacent sibling combinator
662 (<code class=char>+</code>)</dt>
663 <dd>Append a <code class=char>U+002B</code>
664 <code class=charname>PLUS SIGN</code> (<code class=char>+</code>)
665 character to <var>result</var>.</dd>
666 <dt>If <var>c</var> is general sibling combinator
667 (<code class=char>~</code>)</dt>
668 <dd>Append a <code class=char>U+007E</code>
669 <code class=charname>TILDE</code> (<code class=char>~</code>)
670 character to <var>result</var>.</dd>
671 </dl>
672 </li>
673 <li>Append a <code class=char>U+0020</code>
674 <code class=charname>SPACE</code> character to
675 <var>result</var>.</li>
676 </ol>
677 </dd>
678 </dl>
679 </ol>
680 </li>
681 <li>Then, <var>result</var> is the
682 <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
683 representation of <var>gs</var>.</li>
684 </ol>
685
686 </div>
687
688 </div>
689
690 <div class="section" id="parsing">
691 <h2>Parsing
692 <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
693 Representations of Selectors</h2>
694
695 <p>Since <a href="#algorithm-serialize-a-group-of-selectors">the serializing
696 algorithm for groups of selectors</a> is so designed that it always outputs a
697 valid <a href="http://www.w3.org/TR/css3-selectors/#grouping">group of
698 selectors</a>, no special parser for the
699 <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
700 representation is necessary. Any conforming parser for
701 <a href="http://www.w3.org/TR/css3-selectors/#grouping">groups of
702 selectors</a> <em class=rfc2119>MAY</em> be used
703 to parse <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
704 representations of
705 <a href="http://www.w3.org/TR/css3-selectors/#grouping">groups of
706 selectors</a>.</p>
707
708 <p>Likewise, <a href="#algorithm-serialize-a-simple-selector">the serializing
709 algorithm for simple selectors</a> always outputs a valid
710 <a href="#simple-selector">simple selector</a> and therefore any
711 conforming parser for <a href="#simple-selector">simple selector</a>
712 <em class=rfc2119>MAY</em> be used to parse
713 <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
714 representations of <a href="#simple-selector">simple selectors</a>.</p>
715 </div>
716
717 <div class="section" id="examples">
718 <h2>Examples</h2>
719
720 <p class=section-info>This section is <em>non$B!>(Bnormative</em>.</p>
721
722 <div class="ed issue">
723 <p><a href="http://suika.fam.cx/gate/2007/css/parser-interface">Try demo</a>,
724 by choosing <q>Selectors</q> radio button.</p>
725
726 <div class="example figure block">
727 <div class="caption">...</div>
728
729 <pre><code>...</code></pre>
730 </div>
731
732 </div>
733
734 </div>
735
736 <div id="references" class="section reference">
737 <h2>References</h2>
738
739 <div id="normative-references" class="section normative reference">
740 <h3>Normative References</h3>
741
742 <dl>
743 <dt id="ref-KEYWORDS">KEYWORDS</dt>
744 <dd><cite><a href="urn:ietf:rfc:2119">Key words for use in
745 <abbr>RFCs</abbr> to Indicate Requirement Levels</a></cite>,
746 <abbr title="Internet Engineering Task Force">IETF</abbr>
747 <a href="urn:ietf:bcp:14"><abbr title="Best Current Practice">BCP</abbr>
748 14</a>, <abbr title="Request for Comments">RFC</abbr> 2119,
749 <time datetime=1997-03>March 1997</time>.
750 This version of the specification is referenced.</dd>
751 <dt id=ref-SELECTORS>SELECTORS</dt>
752 <dd><a href="http://www.w3.org/TR/2005/WD-css3-selectors-20051215"><cite>Selectors</cite></a>,
753 <abbr title="World Wide Web Consortium">W3C</abbr> Working Draft,
754 <time datetime=2005-12-15>15 December 2005</time>. Work in progress.
755 <a href="http://www.w3.org/TR/css3-selectors">The latest version</a>
756 of the specification is referenced.</dd>
757 </dl>
758 </div>
759
760 <div id="informative-references" class="section informative reference">
761 <h3>Non$B!>(Bnormative References</h3>
762
763 <dl>
764 <dt id=ref-CSS>CSS</dt>
765 <dd><cite><a href="http://www.w3.org/TR/2007/CR-CSS21-20070719">Cascading
766 Style Sheets Level 2 Revision 1 (<abbr>CSS</abbr> 2.1)
767 Specification</a></cite>,
768 <abbr title="World Wide Web Consortium">W3C</abbr> Candidate
769 Recommendation, <time datetime=2007-07-19>19 July 2007</time>.
770 Work in progress. The latest version of the specification is
771 available at
772 <code class=URI>&lt;<a href="http://www.w3.org/TR/CSS21">http://www.w3.org/TR/CSS21</a>></code>.</dd>
773 <dt id=ref-CSSOM>CSSOM</dt>
774 <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
775 Style Sheets Object Model (<abbr>CSSOM</abbr>)</a></cite>,
776 <abbr title="World Wide Web Consortium">W3C</abbr> Editor's Draft,
777 <time datetime=2007-06-18>18 June 2007</time>. Work in progress.
778 The latest Editor's Draft of the specification is available at
779 <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>
780 <dt id=ref-HTML5>HTML5</dt>
781 <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>
783 Working Draft, <time datetime="2007-11-03">3 November 2007</time>.
784 Work in progress.</dd>
785 <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&amp;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,
788 <time datetime=2007-08-29>29 August 2007</time>. Work in progress.
789 The latest Editor's Draft of the specification is available at
790 <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>.
791 The latest published version of the specification is available at
792 <code class=URI>&lt;<a href="http://www.w3.org/TR/selectors-api/">http://www.w3.org/TR/selectors-api/</a>></code>.</dd>
793 <dt id=ref-XBL2>XBL2</dt>
794 <dd><cite><a href="http://www.mozilla.org/projects/xbl/xbl2.html"><abbr>XBL</abbr>
795 2.0</a></cite>, Mozilla.org, <time datetime=2007-03-15>15 Mar 2007</time>.
796 Work in progress. The latest
797 <abbr title="World Wide Web Consortium">W3C</abbr>$B!>(Bpublished
798 version of the specification is available at
799 <code class=URI>&lt;<a href="http://www.w3.org/TR/xbl/">http://www.w3.org/TR/xbl/</a>></code>.</dd>
800 </dl>
801 </div>
802
803 </div>
804
805 </body>
806 </html>

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24