/[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.25 - (show annotations) (download) (as text)
Mon Nov 5 11:34:32 2007 UTC (17 years ago) by wakaba
Branch: MAIN
Changes since 1.24: +13 -10 lines
File MIME type: text/html
Make a stable version

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>First Edition <!-- Working Draft -->
14 <time datetime=2007-11-05>5 November 2007</time></h2>
15
16 <dl class="versions-uri">
17 <dt>This Version</dt>
18 <dd><code class="URI">&lt;<a href="http://suika.fam.cx/www/markup/selectors/ssft/ssft-20071105"
19 >http://suika.fam.cx/www/markup/selectors/ssft/ssft-20071105</a>&gt;</code></dd>
20 <dt>Latest Version</dt>
21 <dd><code class="URI">&lt;<a href="http://suika.fam.cx/www/markup/selectors/ssft/ssft"
22 >http://suika.fam.cx/www/markup/selectors/ssft/ssft</a>&gt;</code></dd>
23 <dt>Latest Working Draft</dt>
24 <dd><code class="URI">&lt;<a href="http://suika.fam.cx/www/markup/selectors/ssft/ssft-work"
25 >http://suika.fam.cx/www/markup/selectors/ssft/ssft-work</a>&gt;</code></dd>
26 <!-- <dt>Previous Version</dt> -->
27 <dt>Version History</dt>
28 <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>
29 </dl>
30 <dl class="authors" id="author">
31 <dt>Author</dt>
32 <dd><a href="http://suika.fam.cx/~wakaba/who?" rel="author"
33 lang=ja>Wakaba</a>
34 <code class="mail">&lt;<a href="mailto:w@suika.fam.cx" rel="author"
35 >w@suika.fam.cx</a>&gt;</code></dd>
36 </dl>
37
38 <p class="copyright" lang="en">&#xA9; <time>2007</time> <a
39 href="http://suika.fam.cx/~wakaba/who?" rel="author">Wakaba</a>.
40 Permission is granted to copy, distribute and/or modify this document
41 under the terms of the <a rel="license"
42 href="http://www.gnu.org/copyleft/fdl.html">GNU Free Documentation License</a>,
43 Version 1.2
44 or any later version published by the <a
45 href="http://www.fsf.org/">Free Software Foundation</a>;
46 with no Invariant Sections, no Front$B!>(BCover Texts, and no Back$B!>(BCover
47 Texts. A copy of the license is
48 available at <code class="URI">&lt;<a
49 href="http://www.gnu.org/copyleft/fdl.html"
50 rel="license">http://www.gnu.org/copyleft/fdl.html</a>&gt;</code>.</p>
51 </div>
52
53 <div id="abstract" class="section">
54 <h2>Abstract</h2>
55
56 <p>This document defines
57 <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>,
58 a subset of Selectors language which is suitable for describing results
59 of Selectors parsing tests.</p>
60
61 </div>
62
63 <div id="status" class="section">
64 <h2>Status of This Document</h2>
65
66 <p class=section-info><em>This section describes the status of this document
67 at the time of its publication. Other documents
68 might supersede this document.</em></p>
69
70 <p>This document is the specification
71 <!-- This document is a working draft -->
72 of <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>,
73 produced as part of the
74 <a href="http://suika.fam.cx/www/markup/html/whatpm/readme">Whatpm</a>
75 subproject
76 of the <a href="http://suika.fam.cx/www/manakai-core/doc/web/">manakai</a>
77 project.
78 <!-- It might be updated, replaced, or obsoleted by
79 other documents at any time. It is inappropriate to
80 cite this document as other than <q>work in progress</q>. --></p>
81
82 <p>Comments on this document are welcome and
83 may be sent to the <a href="#author">author</a>.</p>
84
85 <p>Translations of thie document might be available.
86 The English version of the document is the only
87 normative version.</p>
88 </div>
89
90 <div id="introduction" class="section">
91 <h2>Introduction</h2>
92
93 <p class=section-info>This section is <em>non$B!>(Bnormative</em>.</p>
94
95 <p>Selectors
96 <cite class="bibref normative">[<a href="#ref-SELECTORS">SELECTORS</a>]</cite>
97 are patterns that match against elements
98 in a tree structure and are used in Web technologies, including
99 <a href="http://www.w3.org/TR/CSS21"><abbr title="Cascading Style Sheets">CSS</abbr></a>
100 <cite class="bibref informative">[<a href="#ref-CSS">CSS</a>]</cite>,
101 <a href="http://whatwg.org/html5"><abbr title="Hypertext Markup Language">HTML</abbr>5</a>
102 <cite class="bibref informative">[<a href="#ref-HTML5">HTML5</a>]</cite>,
103 <a href="http://www.mozilla.org/projects/xbl/xbl2.html"><abbr title="XML Binding Language">XBL</abbr>2</a>
104 <cite class="bibref informative">[<a href="#ref-XBL2">XBL2</a>]</cite>, and
105 <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
106 <abbr>API</abbr></a>
107 <cite class="bibref informative">[<a href="#ref-SAPI">SAPI</a>]</cite>.</p>
108
109 <p>It is so flexible language that a conceptually same pattern
110 can be represented in inifnite numbers of instances of selectors.
111 It might be convinient for e.g. validation of a test result to
112 define a subset of the language, in which no semantically equivalent
113 selectors are contained.</p>
114
115 <p><a href="http://dev.w3.org/cvsweb/csswg/cssom/Overview.html">The
116 <abbr title="Cascading Style Sheets Object Model">CSSOM</abbr>
117 specification</a>
118 <cite class="bibref informative">[<a href="#ref-CSSOM">CSSOM</a>]</cite>
119 is trying to define an algorithm to
120 <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
121 a group of selectors</a> for the purpose of <code>selectorText</code>
122 attribute. However, the algorithm is incomplete
123 <time datetime=2007-09-25>at the time of the writing</time>.
124 Note that current Web browser implementations
125 of the <code>selectorText</code> attribute are consistently broken
126 in not escaping unsafe identifiers and therefore it is not wise
127 to deploy that format for testing.</p>
128
129 </div>
130
131 <div class="section" id="terminology">
132 <h2>Terminology</h2>
133
134 <p>The key words <q><dfn id=must><em class="rfc2119">MUST</em></dfn></q>,
135 <q><dfn id=must-not><em class="rfc2119">MUST NOT</em></dfn></q>,
136 <q><dfn id=should><em class="rfc2119">SHOULD</em></dfn></q>, and
137 <q><dfn id=may><em class=rfc2119>MAY</em></dfn></q> in this
138 document are to be interpreted as described in
139 <a href="urn:ietf:rfc:2119"><abbr title="Request for Comments">RFC</abbr>
140 2119</a>
141 <cite class="bibref normative">[<a href="#ref-KEYWORDS">KEYWORDS</a>]</cite>.</p>
142
143 <p>Requirements phrased in the imperative as part of algorithms are to be
144 interpreted with the meaning of the key word (<em class=rfc2119>MUST</em>)
145 used in introducing the algorithm.</p>
146
147 <p>Conformance requirements phrased as algorithms or specific steps
148 <em class=rfc2119>MAY</em> be implemented in any manner, so long as the end
149 result is equivalent.</p>
150
151 <!-- Strictly speaking the paragraph below is not part of terminology. -->
152 <p>All examples and notes in this specification are non$B!>(Bnormative,
153 as are all sections explicitly marked non$B!>(Bnormative. Everything
154 else in this specification is normative.</p>
155
156 <p>For the purpose of this specification, pseudo$B!>(Belements are also
157 referred to as <dfn title="simple selector" id=simple-selector>simple
158 selectors</dfn> and are considered as part of the last sequence of
159 simple selector in a selector.</p>
160 </div>
161
162 <div class="section" id="serializing">
163 <h2>Serializing Selectors in
164 <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
165 Representation</h2>
166
167 <p>Subsections of this section define algorithms
168 to <a href="#algorithm-serialize-a-simple-selector">serialize a simple
169 selector</a> or <a href="#algorithm-serialize-a-group-of-selectors">serialize
170 a group of selectors</a>.</p>
171
172 <div class="note memo">
173 <p>The serialized representation will not contain any comment.</p>
174 </div>
175
176 <div class=section id=serializing-tokens>
177 <h3>Serializing Tokens</h3>
178
179 <p>To <dfn id=algorithm-normalize-an-ident title="normalize a string as an IDENT">normalize
180 a string (<dfn id=var-n><var>n</var></dfn>) as an <code>IDENT</code></dfn>,
181 the following algorithm <em class=rfc2119>MUST</em> be used:</p>
182 <ol>
183 <li>If <var>n</var> is either an <code>IDENT</code> or a <code>HASH</code>,
184 replace the escape sequences (<code>\</code> and following characters) in
185 <var>n</var> by characters represented by them respectively.</li>
186 <li>If <var>n</var> is a <code>HASH</code>, remove the leading
187 <code class=char>U+0023</code> <code class=charname>NUMBER SIGN</code>
188 (<code class=char>#</code>) character from <var>n</var>.</li>
189 <li>If there is any character that is <em>not</em> one of
190 <code class=char>U+002D</code> <code class=charname>HYPHEN-MINUS</code>
191 (<code class=char>-</code>), <code class=char>U+0030</code>
192 <code class=charname>DIGIT ZERO</code>
193 (<code class=char>0</code>) to <code class=char>U+0039</code>
194 <code class=charname>DIGIT NINE</code> (<code class=char>9</code>),
195 <code class=char>U+0041</code> <code class=charname>LATIN CAPITAL LETTER
196 A</code> (<code class=char>A</code>) to <code class=char>U+005A</code>
197 <code class=charname>LATIN CAPITAL LETTER Z</code> (<code class=char>Z</code>),
198 <code class=char>U+005F</code> <code class=charname>LOW LINE</code>
199 (<code class=char>_</code>), <code class=char>U+0061</code>
200 <code class=charname>LATIN SMALL LETTER A</code>
201 (<code class=char>a</code>) to <code class=char>U+006A</code>
202 <code class=charname>LATIN SMALL LETTER Z</code> (<code class=char>z</code>),
203 <code class=char>U+0080</code> to <code class=char>U+D7FF</code>, or
204 <code class=char>U+E000</code> to <code class=char>U+10FFFF</code> in
205 <var>n</var>, then replace it by string <code>\<var>HHHHHH</var></code>, where
206 <dfn id=var-ident-HHHHHH><var>HHHHHH</var></dfn> is the uppercase
207 zero$B!>(Bpadded hexadecimal representation of the character. If the character
208 is outside the range of <code>[<code class=char>U+0000</code>,
209 <code class=char>U+10FFFF</code>]</code>, <var>HHHHHH</var>
210 <em class=rfc2119>MUST</em> be <code>FFFFFF</code>.</li>
211 <li>If the first character in <var>n</var> is one of
212 <code class=char>U+0030</code> <code class=charname>DIGIT ZERO</code>
213 (<code class=char>0</code>) to <code class=char>U+0039</code>
214 <code class=charname>DIGIT NINE</code> (<code class=char>9</code>),
215 then prepend a string <code>\00003</code> at the beginning of
216 <var>n</var>.</li>
217 <li>If the first character in <var>n</var> is <code class=char>U+002D</code>
218 <code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>) and
219 the second character, if any, is <em>not</em> one of
220 <code class=char>U+0041</code> <code class=charname>LATIN CAPITAL LETTER
221 A</code> (<code class=char>A</code>) to <code class=char>U+005A</code>
222 <code class=charname>LATIN CAPITAL LETTER Z</code> (<code class=char>Z</code>),
223 <code class=char>U+005F</code> <code class=charname>LOW LINE</code>
224 (<code class=char>_</code>), <code class=char>U+0061</code>
225 <code class=charname>LATIN SMALL LETTER A</code>
226 (<code class=char>a</code>) to <code class=char>U+006A</code>
227 <code class=charname>LATIN SMALL LETTER Z</code> (<code class=char>z</code>),
228 <code>U+0080</code> to <code>U+D7FF</code>, or
229 <code>U+E000</code> to <code>U+10FFFF</code>, or
230 <var>n</var> is equal to <code class=char>U+002D</code>
231 <code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>), then
232 replace the <code class=char>U+002D</code>
233 <code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>)
234 character by string <code>\00002D</code>.</li>
235 <li>Then, <var>n</var> is the result of the algorithm.</li>
236 </ol>
237
238 <p>To <dfn id=algorithm-normalize-a-string title="normalize a string (STRING or IDENT) as a STRING">normalize
239 a string (<dfn id=var-s><var>s</var></dfn>) as a <code>STRING</code></dfn>,
240 the following algorithm <em class=rfc2119>MUST</em> be used:</p>
241 <ol>
242 <li>If <var>s</var> is either an <code>IDENT</code> or a
243 <code>STRING</code>, replace the escape sequences (<code>\</code> and
244 following characters) in <var>s</var> by characters represented by them
245 (or an empty string if <code>\</code> is immediately followed by
246 newline character(s)) respectively.</li>
247 <li>If <var>s</var> is a <code>STRING</code>, remove the quotation marks
248 enclosing <var>s</var>.</li>
249 <li><p>If there is any character that is <em>not</em> one of
250 <code class=char>U+0020</code> <code class=charname>SPACE</code>,
251 <code class=char>U+0021</code> <code class=charname>EXCLAMATION MARK</code>
252 (<code class=char>!</code>), <code class=char>U+0023</code>
253 <code class=charname>NUMBER SIGN</code> (<code class=char>#</code>) to
254 <code class=char>U+005B</code> <code class=charname>LEFT SQUARE
255 BRACKET</code>, <code class=char>U+005D</code> <code class=charname>RIGHT
256 SQUARE BRACKET</code> to <code class=char>U+D7FF</code>, or
257 <code class=char>U+E000</code> to <code class=char>U+10FFFF</code> in
258 <var>s</var>, then replace it by string <code>\<var>HHHHHH</var></code>, where
259 <dfn id=var-string-HHHHHH><var>HHHHHH</var></dfn> is the uppercase
260 zero$B!>(Bpadded hexadecimal representation of the character. If the character
261 is outside the range of <code>[<code class=char>U+0000</code>,
262 <code class=char>U+10FFFF</code>]</code>, <var>HHHHHH</var>
263 <em class=rfc2119>MUST</em> be <code>FFFFFF</code>.</p></li>
264 <li><p>Insert a <code class=char>U+0022</code> <code class=charname>QUOTATION
265 MARK</code> (<code class=char>"</code>) at the beginning of
266 <var>s</var>.</p></li>
267 <li><p>Insert a <code class=char>U+0022</code> <code class=charname>QUOTATION
268 MARK</code> (<code class=char>"</code>) at the end of <var>s</var>.</p></li>
269 <li><p>Then, <var>s</var> is the result of the algorithm.</p></li>
270 </ol>
271
272 <p>A <dfn id=newline title=newline>newline</dfn>
273 <em class=rfc2119>SHOULD</em> be represented as a
274 <code class=char>U+000A</code> <code class=charname>LINE FEED</code>
275 character. However, depending on the context where
276 the <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
277 representation is in use, a sequence of
278 <code class=char>U+000D</code> <code class=charname>CARRIAGE RETURN</code>
279 followed by a <code class=char>U+000A</code>
280 <code class=charname>LINE FEED</code> (i.e. a
281 <code>CRLF</code> sequence) or a character
282 <code class=char>U+000D</code> <code class=charname>CARRIAGE RETURN</code>
283 <em class=rfc2119>MAY</em> be used as a <a href="#newline">newline</a> instead.
284 <a href="#newline">Newline</a> representations
285 <em class=rfc2119>SHOULD</em> be consistent in an
286 <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
287 representation.</p>
288
289 <div class="note memo">
290 <p>Therefore, newlines must be normalized before
291 <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
292 representations are literally compared.</p>
293 </div>
294
295 <div class="issue ed">
296 <p>In a future version of the specification, we need to define
297 <dfn id=lowercase>lowercase</dfn> (maybe by referencing some version of
298 some module of <abbr>CSS</abbr>). It is <code>tr/A-Z/a-z/</code> for now.</p>
299 </div>
300
301 <p>To
302 <dfn id=algorithm-normalize-an-integer title="normalize an integer">normalize
303 an integer (<dfn id=var-int-i><var>i</var></dfn>)</dfn>, the following
304 algorithm <em class=rfc2119>MUST</em> be used:</p>
305 <ol class=algorithm>
306 <li>If <var>i</var> is equal to zero (0), return a string with only a
307 character: <code class=char>U+0030</code>
308 <code class=charname>DIGIT ZERO</code> (<code class=char>0</code>).
309 Stop the algorithm.</li>
310 <li>Let <dfn id=var-int-result><var>result</var></dfn> be an empty string.</li>
311 <li>If <var>i</var> is less than zero (0), append a
312 <code class=char>U+002D</code> <code class=charname>HYPHEN-MINUS</code>
313 (<code class=char>-</code>) character to <var>result</var>.</li>
314 <li>Append the decimal representation of the absolute value of
315 <var>i</var> to <var>result</var>. The decimal (base$B!>(Bten) representation
316 <em class=rfc2119>MUST NOT</em> begin with a <code class=char>U+0030</code>
317 <code class=charname>DIGIT ZERO</code> (<code class=char>0</code>)
318 character.</li>
319 <li>Return <var>result</var>.</li>
320 </ol>
321
322 </div>
323
324
325 <div class=section id=serializing-simple-selectors>
326 <h3>Serializing Simple Selectors</h3>
327
328 <p>No <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
329 representation is defined for an invalid <a href="#simple-selector">simple
330 selector</a>.</p>
331
332 <p>To
333 <dfn id=algorithm-serialize-a-simple-selector title="serialize a simple selector">serialize
334 a simple selector (<dfn><var id=var-ss>ss</var></dfn>)</dfn>,
335 the following algorithm <em class=rfc2119>MUST</em> be used:</p>
336 <ol>
337 <li>Let <dfn id=var-r><var>r</var></dfn> an empty string.</li>
338 <li>Process <var>ss</var> as following:
339
340 <dl class=switch>
341 <dt>If <var>ss</var> is a type or universal selector</dt>
342 <dd>
343 <ol>
344 <li>Append a namespace prefix as following:
345
346 <dl class=switch>
347 <dt>If a namespace URI is specified (via namespace prefix, or
348 by omitting namespace prefix where a default namespace is specified)</dt>
349 <dd>Append the namespace URI as a
350 <a href="#algorithm-normalize-an-ident" title="normalize a string as an IDENT">normalized
351 <code>IDENT</code></a> to <var>r</var>. Then, append a
352 <code class=char>U+007C</code>
353 <code class=charname>VERTICAL BAR</code> (<code class=char>|</code>)
354 character to <var>r</var>.</dd>
355 <dt>If the null namespace is specified (by zero$B!>(Blength namespace
356 prefix)</dt>
357 <dd>Append a <code class=char>U+007C</code>
358 <code class=charname>VERTICAL BAR</code> (<code class=char>|</code>)
359 character to <var>r</var>.</dd>
360 <dt>If no namespace is specified (by namespace prefix <code>*</code>,
361 or by omitting namespace prefix where no default namespace is
362 specified)</dt>
363 <dd>Append a <code class=char>U+002A</code>
364 <code class=charname>ASTERISK</code> (<code class=char>*</code>)
365 character, followed by a <code class=char>U+007C</code>
366 <code class=charname>VERTICAL BAR</code> (<code class=char>|</code>)
367 character, to <var>r</var>.</dd>
368 </dl>
369 </li>
370 <li>If <var>ss</var> is a type selector, append the
371 <a href="#algorithm-normalize-an-ident" title="normalize a string (IDENT) an IDENT">normalized</a>
372 local name to <var>r</var>.</li>
373 <li>If <var>ss</var> is a universal selector, append
374 a <code class=char>U+002A</code> <code class=charname>ASTERISK</code>
375 (<code class=char>*</code>) character to <var>r</var>.</li>
376 </ol>
377 </dd>
378 <dt>If <var>ss</var> is an attribute selector</dt>
379 <dd>
380 <ol>
381 <li>Append a <code class=char>U+005B</code> <code class=charname>LEFT
382 SQUARE BRACKET</code> (<code class=char>[</code>) to
383 <var>r</var>.</li>
384 <li>
385 Append a namespace prefix as following:
386 <dl>
387 <dt>If a namespace URI is specified</dt>
388 <dd>Append the namespace URI as a
389 <a href="#algorithm-normalize-an-ident" title="normalize a string as an IDENT">normalized
390 <code>IDENT</code></a> to <var>r</var>. Then, append a
391 <code class=char>U+007C</code>
392 <code class=charname>VERTICAL BAR</code> (<code class=char>|</code>)
393 character to <var>r</var>.</dd>
394 <dt>If the null namespace is specified</dt>
395 <dd>Append a <code class=char>U+007C</code>
396 <code class=charname>VERTICAL BAR</code> character to
397 <var>r</var>.</dd>
398 <dt>If no namespace is specified</dt>
399 <dd>Append a <code class=char>U+002A</code>
400 <code class=charname>ASTERISK</code> (<code class=char>*</code>)
401 character, followed by a <code class=char>U+007C</code>
402 <code class=charname>VERTICAL BAR</code> (<code class=char>|</code>)
403 character, to <var>r</var>.</dd>
404 </dl>
405 </li>
406 <li>Append the
407 <a href="#algorithm-normalize-an-ident" title="normalize a string (IDENT) as an IDENT">normalized</a>
408 local name to <var>r</var>.</li>
409 <li>If a value is specified in <var>ss</var>:
410 <ol>
411 <li>Depending on the way to match, append <code>=</code>,
412 <code>~=</code>, <code>|=</code>, <code>^=</code>,
413 <code>$=</code>, or <code>*=</code> to <var>r</var>.</li>
414 <li>Append the
415 <a href="#algorithm-normalize-a-string" title="normalize a string">normalized</a>
416 value to <var>r</var>.</li>
417 </ol>
418 </li>
419 <li>Append a <code class=char>U+005D</code> <code class=charname>RIGHT
420 SQUARE BRACKET</code> (<code class=char>]</code>) to
421 <var>r</var>.</li>
422 </ol>
423 </dd>
424 <dt>If <var>ss</var> is a class selector</dt>
425 <dd>Append a <code class=char>U+002E</code> <code class=charname>FULL
426 STOP</code> (<code class=char>.</code>) character, followed
427 by <a href="#algorithm-normalize-an-ident" title="normalize a string (IDENT) as an IDENT">normalized</a>
428 class name, to <var>r</var>.</dd>
429 <dt>If <var>ss</var> is an <abbr>ID</abbr> selector</dt>
430 <dd>Append a <code class=char>U+0023</code> <code class=charname>NUMBER
431 SIGN</code> (<code class=char>#</code>) character, followed
432 by <a href="#algorithm-normalize-an-ident" title="normalize a string (HASH except for the leading #) as an IDENT">normalized</a>
433 <abbr>ID</abbr>, to <var>r</var>.</dd>
434 <dt>If <var>ss</var> is a pseudo$B!>(Bclass selector</dt>
435 <dd>
436 <ol>
437 <li>Append a <code class=char>U+003A</code>
438 <code class=charname>COLON</code> (<code class=char>:</code>) character
439 to <var>r</var>.</li>
440 <li>Append the
441 <a href="#algorithm-normalize-an-ident" title="normalize a string (IDENT) as an IDENT">normalized</a>
442 name (in <a href="#lowercase">lowercase</a>) of the pseudo$B!>(Bclass to
443 <var>r</var>.</li>
444 <li>Append any arguments as following:
445 <dl class=switch>
446 <dt>If the name of the pseudo$B!>(Bclass is <code>lang</code></dt>
447 <dd>
448 <ol>
449 <li>Append a <code class=char>U+0028</code> <code class=charname>LEFT
450 PARENTHESIS</code> (<code class=char>(</code>) character
451 to <var>r</var>.</li>
452 <li>Append the
453 <a href="#algorithm-normalize-an-ident" title="normalize a string (IDENT) as an IDENT">normalized</a>
454 language tag (the argument) to <var>r</var>.
455 <span class="issue ed">Should we normalize cases?</span></li>
456 <li>Append a <code class=char>U+0029</code>
457 <code class=charname>RIGHT PARENTHESIS</code>
458 (<code class=char>)</code>) character
459 to <var>r</var>.</li>
460 </ol>
461 </dd>
462 <dt>If the name of the pseudo$B!>(Bclass is
463 <code>-manakai-contains</code></dt>
464 <dd>
465 <ol>
466 <li>Append a <code class=char>U+0028</code> <code class=charname>LEFT
467 PARENTHESIS</code> (<code class=char>(</code>) character
468 to <var>r</var>.</li>
469 <li>Append the
470 <a href="#algorithm-normalize-a-string" title="normalize a string">normalized</a>
471 string (the argument) to <var>r</var>.</li>
472 <li>Append a <code class=char>U+0029</code>
473 <code class=charname>RIGHT PARENTHESIS</code>
474 (<code class=char>)</code>) character
475 to <var>r</var>.</li>
476 </ol>
477 </dd>
478 <dt>If name of the pseudo$B!>(Bclass is either <code>nth-child</code>,
479 <code>nth-last-child</code>, <code>nth-of-type</code>, or
480 <code>nth-last-of-type</code></dt>
481 <dd>
482 <ol>
483 <li>Append a <code class=char>U+0028</code> <code class=charname>LEFT
484 PARENTHESIS</code> (<code class=char>(</code>) character
485 to <var>r</var>.</li>
486 <li>Let <dfn id=var-a><var>a</var></dfn> be the <var>a</var>
487 part of the argument. If the argument is a keyword <code>odd</code>
488 or <code>even</code>, then let <var>a</var> be <code>2</code>.
489 If the <var>a</var> part with following <code>n</code> character
490 is omitted, then let <var>a</var> be <code>0</code>.
491 Otherwise, if only the <var>a</var> part is omitted, then
492 let <var>a</var> be <code>1</code>. Otherwise, if the <var>a</var>
493 part is <code>-</code>, then let <var>a</var> be
494 <code>-1</code>.</li>
495 <li>Let <var>a</var> be the
496 <a href="#algorithm-normalize-an-integer" title="normalize an integer">normalized
497 string representation</a> of integer <var>a</var>.</li>
498 <li>Append <var>a</var> to <var>r</var>.</li>
499 <li>Append a <code class=char>U+006E</code>
500 <code class=charname>LATIN SMALL LETTER N</code>
501 (<code class=char>n</code>) character to <var>r</var>.</li>
502 <li>Let <dfn id=var-b><var>b</var></dfn> be the <var>b</var>
503 part of the argument. If the argument is a keyword <code>odd</code>,
504 then let <var>b</var> be <code>1</code>. If the argument is a
505 keyword <code>even</code>, then let <var>b</var> be <code>0</code>.
506 If the <var>b</var> part is omitted, then let <var>b</var> be
507 <code>0</code>.</li>
508 <li>Let <var>b</var> be the
509 <a href="#algorithm-normalize-an-integer" title="normalize an integer">normalized
510 string representation</a> of integer <var>b</var>.</li>
511 <li>If <var>b</var> does <em>not</em> start with a
512 <code class=char>U+002D</code>
513 <code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>)
514 character, then append <code class=char>U+002B</code>
515 <code class=charname>PLUS SIGN</code>
516 (<code class=char>+</code>) to <var>r</var>.</li>
517 <li>Append <var>b</var> to <var>r</var>.</li>
518 <li>Append a <code class=char>U+0029</code>
519 <code class=charname>RIGHT PARENTHESIS</code>
520 (<code class=char>)</code>) character
521 to <var>r</var>.</li>
522 </ol>
523 </dd>
524 <dt>If the name of the pseudo$B!>(Bclass is <code>not</code></dt>
525 <dd>
526 <ol>
527 <li>Append a string of <code class=char>U+003A</code>
528 <code class=charname>COLON</code>, <code class=char>U+006E</code>
529 <code class=charname>LATIN SMALL LETTER N</code>,
530 <code class=char>U+006F</code> <code class=charname>LATIN
531 SMALL LETTER O</code>, <code class=char>U+0074</code>
532 <code class=charname>LATIN SMALL LETTER T</code>, and
533 <code class=char>U+0028</code> <code class=charname>LEFT
534 PARENTHESIS</code> (<code>:not(</code>), followed by a
535 <a href="#newline">newline</a>, to <var>r</var>.</li>
536 <li>Append four <code class=char>U+0020</code>
537 <code class=charname>SPACE</code> characters to
538 <var>r</var>.</li>
539 <li>Append four <code class=char>U+0020</code>
540 <code class=charname>SPACE</code> characters to
541 <var>r</var> again.</li>
542 <li><a href="#algorithm-serialize-a-simple-selector">Serialize
543 the simple selector specified as the argument to the
544 <code>not</code> pseudo$B!>(Bclass</a>.</li>
545 <li>Append a <a href="#newline">newline</a> to
546 <var>r</var>.</li>
547 <li>Append four <code class=char>U+0020</code>
548 <code class=charname>SPACE</code> characters to
549 <var>r</var>.</li>
550 <li>Append a <code class=char>U+0029</code>
551 <code class=charname>RIGHT PARENTHESIS</code>
552 (<code class=char>)</code>) character
553 to <var>r</var>.</li>
554 </ol>
555 </dd>
556 <dt>Otherwise</dt>
557 <dd>The pseudo$B!>(Bclass is not supported by this version of
558 <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
559 and therefore no
560 <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
561 representation is defined for <var>ss</var>. Stop the algorithm.</dd>
562 </dl>
563 </li>
564 </ol>
565 </dd>
566 <dt>If <var>ss</var> is a pseudo$B!>(Belement</dt>
567 <dd>
568 <ol>
569 <li>Append two <code class=char>U+003A</code>
570 <code class=charname>COLON</code> characters (<code>::</code>)
571 to <var>r</var>.</li>
572 <li>Append the
573 <a href="#algorithm-normalize-an-ident" title="normalize a string (IDENT) as an IDENT">normalized</a>
574 name (in <a href="#lowercase">lowercase</a>) of the pseudo$B!>(Belement
575 to <var>r</var>.</li>
576 <li>If the pseudo$B!>(Belement has any arguments:
577 The pseudo$B!>(Belement is not supported by this version of
578 <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
579 and therefore no
580 <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
581 representation is defined for <var>ss</var>. Stop the algorithm.
582 </li>
583 </ol>
584 </dd>
585 </dl>
586 </li>
587 <li>Then, <var>r</var> is the
588 <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
589 representation of <var>ss</var>.</li>
590 </ol>
591
592 </div>
593
594 <div class=section id=serializing-groups-of-selectors>
595 <h3>Serializing Groups of Selectors</h3>
596
597 <p>No <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
598 representation is defined for an invalid
599 <a href="http://www.w3.org/TR/css3-selectors/#grouping">group of
600 selectors</a>.</p>
601
602 <p>To
603 <dfn id=algorithm-serialize-a-group-of-selectors title="serialize a group of selectors">serialize
604 a group of selectors (<dfn id=var-gs><var>gs</var></dfn>)</dfn>,
605 the following algorithm <em class=rfc2119>MUST</em> be used:</p>
606 <ol>
607 <li>Let <dfn id=var-result><var>result</var></dfn> an empty string.</li>
608 <li>For each selector (<dfn id=var-selector><var>selector</var></dfn>) in
609 <var>gs</var>:
610 <ol>
611 <li>If <var>selector</var> is <em>not</em> the first selector
612 in the <var>gs</var>, then append a <code class=char>U+002C</code>
613 <code class=charname>COMMA</code> (<code class=char>,</code>) followed by a
614 <a href="#newline">newline</a> to <var>result</var>.</li>
615 <li>Append four <code class=char>U+0020</code>
616 <code class=charname>SPACE</code> characters to <var>result</var>.</li>
617 <li>Process each sequence of simple selectors or
618 combinator in <var>selector</var> as following:
619 <dl class=switch>
620 <dt>If it is a sequence of simle selector
621 (<dfn id=var-sss><var>sss</var></dfn>)</dt>
622 <dd>
623 <ol>
624 <li>If <var>sss</var> contains a universal or type selector, then
625 <a href="#algorithm-serialize-a-simple-selector" title="serialize a simple selector">serialize
626 that simple selector</a> and append the result to
627 <var>result</var>.</li>
628 <li>Otherwise, i.e. if <var>sss</var> does not contain a universal or
629 type selector, then
630 <a href="#algorithm-serialize-a-simple-selector" title="serialize a simple selector">serialize
631 a simple selector <code>*</code></a> and append the result to
632 <var>result</var>.</li>
633 <li><a href="#algorithm-serialize-a-simple-selector" title="serialize a simple selector">Serialize
634 any attribute 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 class 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 <abbr>ID</abbr> selectors</a> in <var>sss</var>, sort the results,
641 then append them to <var>result</var> in order.</li>
642 <li><a href="#algorithm-serialize-a-simple-selector" title="serialize a simple selector">Serialize
643 any pseudo$B!>(Bclass selectors</a> in <var>sss</var>, sort the results,
644 then append them to <var>result</var> in order.</li>
645 <li><a href="#algorithm-serialize-a-simple-selector" title="serialize a simple selector">Serialize
646 any pseudo elements</a> in <var>sss</var>, sort the results,
647 then append them to <var>result</var> in order.</li>
648 <li>Append a <a href="#newline">newline</a> to <var>result</var>.</li>
649 </ol>
650 </dd>
651 <dt>If it is a combinator (<dfn id=var-c><var>c</var></dfn>)</dt>
652 <dd>
653 <ol>
654 <li>Append two <code class=char>U+0020</code>
655 <code class=charname>SPACE</code> characters to <var>result</var>.</li>
656 <li>Process <var>c</var> as following:
657
658 <dl class=switch>
659 <dt>If <var>c</var> is descendant combinator (white space)</dt>
660 <dd>Append a <code class=char>U+0020</code>
661 <code class=charname>SPACE</code> character to
662 <var>result</var>.</dd>
663 <dt>If <var>c</var> is child combinator
664 (<code class=char>></code>)</dt>
665 <dd>Append a <code class=char>U+003E</code>
666 <code class=charname>GREATER-THAN SIGN</code>
667 (<code class=char>></code>) character to <var>result</var>.</dd>
668 <dt>If <var>c</var> is adjacent sibling combinator
669 (<code class=char>+</code>)</dt>
670 <dd>Append a <code class=char>U+002B</code>
671 <code class=charname>PLUS SIGN</code> (<code class=char>+</code>)
672 character to <var>result</var>.</dd>
673 <dt>If <var>c</var> is general sibling combinator
674 (<code class=char>~</code>)</dt>
675 <dd>Append a <code class=char>U+007E</code>
676 <code class=charname>TILDE</code> (<code class=char>~</code>)
677 character to <var>result</var>.</dd>
678 </dl>
679 </li>
680 <li>Append a <code class=char>U+0020</code>
681 <code class=charname>SPACE</code> character to
682 <var>result</var>.</li>
683 </ol>
684 </dd>
685 </dl>
686 </ol>
687 </li>
688 <li>Then, <var>result</var> is the
689 <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
690 representation of <var>gs</var>.</li>
691 </ol>
692
693 </div>
694
695 </div>
696
697 <div class="section" id="parsing">
698 <h2>Parsing
699 <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
700 Representations of Selectors</h2>
701
702 <p>Since <a href="#algorithm-serialize-a-group-of-selectors">the serializing
703 algorithm for groups of selectors</a> is so designed that it always outputs a
704 valid <a href="http://www.w3.org/TR/css3-selectors/#grouping">group of
705 selectors</a>, no special parser for the
706 <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
707 representation is necessary. Any conforming parser for
708 <a href="http://www.w3.org/TR/css3-selectors/#grouping">groups of
709 selectors</a> <em class=rfc2119>MAY</em> be used
710 to parse <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
711 representations of
712 <a href="http://www.w3.org/TR/css3-selectors/#grouping">groups of
713 selectors</a>.</p>
714
715 <p>Likewise, <a href="#algorithm-serialize-a-simple-selector">the serializing
716 algorithm for simple selectors</a> always outputs a valid
717 <a href="#simple-selector">simple selector</a> and therefore any
718 conforming parser for <a href="#simple-selector">simple selector</a>
719 <em class=rfc2119>MAY</em> be used to parse
720 <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
721 representations of <a href="#simple-selector">simple selectors</a>.</p>
722 </div>
723
724 <div class="section" id="examples">
725 <h2>Examples</h2>
726
727 <p class=section-info>This section is <em>non$B!>(Bnormative</em>.</p>
728
729 <div class="example figure block">
730 <p>The <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
731 representation of a selector <code>p + q</code> is:</p>
732
733 <pre><code> *|p
734 + *|q
735 </code></pre>
736 </div>
737
738 <div class="example figure block">
739 <p>The <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
740 representation of a selector <code>a#id.class1:n\ot(:Active)/*
741 comment
742 */.class2</code> is:</p>
743
744 <pre><code> *|a.class1.class2#id:not(
745 :active
746 )
747 </code></pre>
748 </div>
749
750 <div class="example figure block">
751 <p>The <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
752 representation of a
753 <a href="http://www.w3.org/TR/css3-selectors/#grouping">group of selectors</a>
754 <code>a, #b, C[d^=e], .\31 23</code> is:</p>
755
756 <pre><code> *|a
757 ,
758 *|*#b
759 ,
760 *|C[|d^="e"]
761 ,
762 *|*.\00003123
763 </code></pre>
764 </div>
765
766 </div>
767
768 <div id="references" class="section reference">
769 <h2>References</h2>
770
771 <div id="normative-references" class="section normative reference">
772 <h3>Normative References</h3>
773
774 <dl>
775 <dt id="ref-KEYWORDS">KEYWORDS</dt>
776 <dd><cite><a href="urn:ietf:rfc:2119">Key words for use in
777 <abbr>RFCs</abbr> to Indicate Requirement Levels</a></cite>,
778 <abbr title="Internet Engineering Task Force">IETF</abbr>
779 <a href="urn:ietf:bcp:14"><abbr title="Best Current Practice">BCP</abbr>
780 14</a>, <abbr title="Request for Comments">RFC</abbr> 2119,
781 <time datetime=1997-03>March 1997</time>.
782 This version of the specification is referenced.</dd>
783 <dt id=ref-SELECTORS>SELECTORS</dt>
784 <dd><a href="http://www.w3.org/TR/2005/WD-css3-selectors-20051215"><cite>Selectors</cite></a>,
785 <abbr title="World Wide Web Consortium">W3C</abbr> Working Draft,
786 <time datetime=2005-12-15>15 December 2005</time>. Work in progress.
787 <a href="http://www.w3.org/TR/css3-selectors">The latest version</a>
788 of the specification is referenced.</dd>
789 </dl>
790 </div>
791
792 <div id="informative-references" class="section informative reference">
793 <h3>Non$B!>(Bnormative References</h3>
794
795 <dl>
796 <dt id=ref-CSS>CSS</dt>
797 <dd><cite><a href="http://www.w3.org/TR/2007/CR-CSS21-20070719">Cascading
798 Style Sheets Level 2 Revision 1 (<abbr>CSS</abbr> 2.1)
799 Specification</a></cite>,
800 <abbr title="World Wide Web Consortium">W3C</abbr> Candidate
801 Recommendation, <time datetime=2007-07-19>19 July 2007</time>.
802 Work in progress. The latest version of the specification is
803 available at
804 <code class=URI>&lt;<a href="http://www.w3.org/TR/CSS21">http://www.w3.org/TR/CSS21</a>></code>.</dd>
805 <dt id=ref-CSSOM>CSSOM</dt>
806 <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
807 Style Sheets Object Model (<abbr>CSSOM</abbr>)</a></cite>,
808 <abbr title="World Wide Web Consortium">W3C</abbr> Editor's Draft,
809 <time datetime=2007-06-18>18 June 2007</time>. Work in progress.
810 The latest Editor's Draft of the specification is available at
811 <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>
812 <dt id=ref-HTML5>HTML5</dt>
813 <dd><cite><a href="http://whatwg.org/html5"><abbr>HTML</abbr> 5</a></cite>,
814 <abbr title="Web Hypertext Application Technology Working Group">WHATWG</abbr>
815 Working Draft, <time datetime="2007-11-03">3 November 2007</time>.
816 Work in progress.</dd>
817 <dt id=ref-SAPI>SAPI</dt>
818 <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>,
819 <abbr title="World Wide Web Consortium">W3C</abbr> Editor's Draft,
820 <time datetime=2007-08-29>29 August 2007</time>. Work in progress.
821 The latest Editor's Draft of the specification is available at
822 <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>.
823 The latest published version of the specification is available at
824 <code class=URI>&lt;<a href="http://www.w3.org/TR/selectors-api/">http://www.w3.org/TR/selectors-api/</a>></code>.</dd>
825 <dt id=ref-XBL2>XBL2</dt>
826 <dd><cite><a href="http://www.mozilla.org/projects/xbl/xbl2.html"><abbr>XBL</abbr>
827 2.0</a></cite>, Mozilla.org, <time datetime=2007-03-15>15 Mar 2007</time>.
828 Work in progress. The latest
829 <abbr title="World Wide Web Consortium">W3C</abbr>$B!>(Bpublished
830 version of the specification is available at
831 <code class=URI>&lt;<a href="http://www.w3.org/TR/xbl/">http://www.w3.org/TR/xbl/</a>></code>.</dd>
832 </dl>
833 </div>
834
835 </div>
836
837 </body>
838 </html>

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24