/[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.19 - (show annotations) (download) (as text)
Mon Nov 5 10:59:48 2007 UTC (17 years ago) by wakaba
Branch: MAIN
Changes since 1.18: +76 -34 lines
File MIME type: text/html
integer normalization; sss serialization

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