/[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.7 - (show annotations) (download) (as text)
Sun Oct 7 08:50:13 2007 UTC (16 years, 7 months ago) by wakaba
Branch: MAIN
Changes since 1.6: +167 -44 lines
File MIME type: text/html
Define algorithms for class, ID, pseudo-class, and pseudo-element selectors

1 <!DOCTYPE html>
2 <html lang="en" class="formal-specification status-work-in-progress">
3 <head>
4 <title>Selectors Serialization Format for Testing (SSFT) Specification</title>
5 <link rel="stylesheet" href="http://suika.fam.cx/www/style/html/spec">
6 <link rel="license" href="http://suika.fam.cx/c/gnu/fdl">
7 </head>
8 <body class="has-abstract">
9
10 <div class="header">
11 <h1>Selectors Serialization Format for Testing (<abbr>SSFT</abbr>)
12 Specification</h1>
13 <h2>Working Draft <time datetime=2007-10-07>7 October 2007</time></h2>
14
15 <dl class="versions-uri">
16 <dt>This Version</dt>
17 <dd><code class="URI">&lt;<a href="http://suika.fam.cx/www/markup/selectors/ssft/ssft"
18 >http://suika.fam.cx/www/markup/selectors/ssft/ssft</a>&gt;</code></dd>
19 <dt>Latest Version</dt>
20 <dd><code class="URI">&lt;<a href="http://suika.fam.cx/www/markup/selectors/ssft/ssft"
21 >http://suika.fam.cx/www/markup/selectors/ssft/ssft</a>&gt;</code></dd>
22 <!--
23 <dt>Latest Working Draft</dt>
24 -->
25 <!-- <dt>Previous Version</dt> -->
26 <dt>Version History</dt>
27 <dd><code class=URI>&lt;<a href="http://suika.fam.cx/gate/cvs/markup/selectors/ssft/ssft.en.html">http://suika.fam.cx/gate/cvs/markup/selectors/ssft/ssft.en.html</a>&gt;</code></dd>
28 </dl>
29 <dl class="authors" id="author">
30 <dt>Author</dt>
31 <dd><a href="http://suika.fam.cx/~wakaba/who?" rel="author"
32 lang=ja>Wakaba</a>
33 <code class="mail">&lt;<a href="mailto:w@suika.fam.cx" rel="author"
34 >w@suika.fam.cx</a>&gt;</code></dd>
35 </dl>
36
37 <p class="copyright" lang="en">&#xA9; <time>2007</time> <a
38 href="http://suika.fam.cx/~wakaba/who?" rel="author">Wakaba</a>.
39 Permission is granted to copy, distribute and/or modify this document
40 under the terms of the <a rel="license"
41 href="http://www.gnu.org/copyleft/fdl.html">GNU Free Documentation License</a>,
42 Version 1.2
43 or any later version published by the <a
44 href="http://www.fsf.org/">Free Software Foundation</a>;
45 with no Invariant Sections, no Front$B!>(BCover Texts, and no Back$B!>(BCover
46 Texts. A copy of the license is
47 available at <code class="URI">&lt;<a
48 href="http://www.gnu.org/copyleft/fdl.html"
49 rel="license">http://www.gnu.org/copyleft/fdl.html</a>&gt;</code>.</p>
50 </div>
51
52 <div id="abstract" class="section">
53 <h2>Abstract</h2>
54
55 <div class="ed issue">...</div>
56
57 </div>
58
59 <div id="status" class="section">
60 <h2>Status of This Document</h2>
61
62 <p class=section-info><em>This section describes the status of this document
63 at the time of its publication. Other documents
64 might supersede this document.</em></p>
65
66 <p>This document is a working draft, produced as part
67 of the <a href="http://suika.fam.cx/www/manakai-core/doc/web/">manakai</a>
68 project. It might be updated, replaced, or obsoleted by
69 other documents at any time. It is inappropriate to
70 cite this document as other than <q>work in progress</q>.</p>
71
72 <p>Comments on this document are welcome and
73 may be sent to the <a href="#author">author</a>.</p>
74
75 <p>Translations of thie document might be available.
76 The English version of the document is the only
77 normative version.</p>
78 </div>
79
80 <div id="introduction" class="section">
81 <h2>Introduction</h2>
82
83 <p class=section-info>This section is <em>non$B!>(Bnormative</em>.</p>
84
85 <p>Selectors
86 <cite class="bibref normative">[<a href="#ref-SELECTORS">SELECTORS</a>]</cite>
87 are patterns that match against elements
88 in a tree structure and are used in Web technologies, including
89 <a href="http://www.w3.org/TR/CSS21"><abbr title="Cascading Style Sheets">CSS</abbr></a>
90 <cite class="bibref informative">[<a href="#ref-CSS">CSS</a>]</cite>,
91 <a href="http://whatwg.org/html5"><abbr title="Hypertext Markup Language">HTML</abbr>5</a>
92 <cite class="bibref informative">[<a href="#ref-HTML5">HTML5</a>]</cite>,
93 <a href="http://www.mozilla.org/projects/xbl/xbl2.html"><abbr title="XML Binding Language">XBL</abbr>2</a>
94 <cite class="bibref informative">[<a href="#ref-XBL2">XBL2</a>]</cite>, and
95 <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
96 <abbr>API</abbr></a>
97 <cite class="bibref informative">[<a href="#ref-SAPI">SAPI</a>]</cite>.</p>
98
99 <div class="issue ed">...</div>
100
101 <p><a href="http://dev.w3.org/cvsweb/csswg/cssom/Overview.html">The
102 <abbr title="Cascading Style Sheets Object Model">CSSOM</abbr>
103 specification</a>
104 <cite class="bibref informative">[<a href="#ref-CSSOM">CSSOM</a>]</cite>
105 is trying to define an algorithm to
106 <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
107 a group of selectors</a> for the purpose of <code>selectorText</code>
108 attribute. However, the algorithm is incomplete
109 <time datetime=2007-09-25>at the time of the writing</time>.
110 Note that current Web browser implementations
111 of the <code>selectorText</code> attribute are consistently broken
112 in not escaping unsafe identifiers.</p>
113
114 </div>
115
116 <div class="section" id="terminology">
117 <h2>Terminology</h2>
118
119 <p>The key words <q><em class="rfc2119">MUST</em></q>,
120 <q><em class="rfc2119">MUST NOT</em></q>,
121 <q><em class="rfc2119">SHOULD</em></q>,
122 <q><em class="rfc2119">SHOULD NOT</em></q>, and
123 <q><em class=rfc2119>MAY</em></q> in this
124 document are to be interpreted as described in
125 <a href="urn:ietf:rfc:2119"><abbr title="Request for Comments">RFC</abbr>
126 2119</a>
127 <cite class="bibref normative">[<a href="#ref-KEYWORDS">KEYWORDS</a>]</cite>.</p>
128
129 <!-- Strictly speaking the paragraph below is not part of terminology. -->
130 <p>All examples and notes in this specification are non$B!>(Bnormative,
131 as are all sections explicitly marked non$B!>(Bnormative. Everything
132 else in this specification is normative.</p>
133
134 <p>For the purpose of this specification, pseudo$B!>(Belements are also
135 referred to as <dfn title="simple selector" id=simple-selector>simple
136 selectors</dfn> and are considered as part of the last sequence of
137 simple selector in a selector.</p>
138 </div>
139
140 <div class="section" id="serializing">
141 <h2>Serializing Groups of Selectors</h2>
142
143 <div class="issue ed">
144 <p><a href="http://suika.fam.cx/gate/cvs/*checkout*/markup/html/whatpm/Whatpm/CSS/SelectorsSerializer.pm">See the reference implementation</a>
145 for now.</p>
146 </div>
147
148 <p><dfn id=newline title=newline>Newline</dfn> is
149 <code class=char>U+000A</code> <code class=charname>LINE FEED</code>
150 <span class=ed>or U+000D U+000A or U+000A ??</span>.</p>
151
152 <!-- TODO: link terms to Selectors -->
153
154 <p>To
155 <dfn id=algorithm-serialize-a-group-of-selectors title="serialize a group of selectors">serialize
156 a group of selectors (<dfn id=var-gs><var>gs</var></dfn>)</dfn>:</p>
157 <ol>
158 <li>Let <dfn id=var-result><var>result</var></dfn> an empty string.</li>
159 <li>For each selector (<dfn id=var-selector><var>selector</var></dfn>) in
160 <var>gs</var>:
161 <ol>
162 <li>If <var>selector</var> is <em>not</em> the first selector
163 in the group of selectors, then append a <code class=char>U+002C</code>
164 <code class=charname>COMMA</code> (<code class=char>,</code>) followed by a
165 <a href="#newline">newline</a> to <var>result</var>.</li>
166 <li>Append four <code class=char>U+0020</code>
167 <code class=charname>SPACE</code> characters to <var>result</var>.</li>
168 <li>Process each sequence of simple selectors or
169 combinator in <var>selector</var> by following algorithm:
170 <dl class=switch>
171 <dt>If it is a sequence of simle selector
172 (<dfn id=var-sss><var>sss</var></dfn>)</dt>
173 <dd class=ed>@@</dd>
174 <dt>If it is a combinator (<dfn id=var-c><var>c</var></dfn>)</dt>
175 <dd>
176 <ol>
177 <li>Append two <code class=char>U+0020</code>
178 <code class=charname>SPACE</code> characters to <var>result</var>.</li>
179 <li>
180 <dl class=switch>
181 <dt>If <var>c</var> is descendant combinator (white space)</dt>
182 <dd>Append a <code class=char>U+0020</code>
183 <code class=charname>SPACE</code> character to
184 <var>result</var>.</dd>
185 <dt>If <var>c</var> is child combinator
186 (<code class=char>></code>)</dt>
187 <dd>Append a <code class=char>U+003E</code>
188 <code class=charname>GREATER-THAN SIGN</code>
189 (<code class=char>></code>) character to <var>result</var>.</dd>
190 <dt>If <var>c</var> is adjacent sibling combinator
191 (<code class=char>+</code>)</dt>
192 <dd>Append a <code class=char>U+002B</code>
193 <code class=charname>PLUS SIGN</code> (<code class=char>+</code>)
194 character to <var>result</var>.</dd>
195 <dt>If <var>c</var> is general sibling combinator
196 (<code class=char>~</code>)</dt>
197 <dd>Append a <code class=char>U+007E</code>
198 <code class=charname>TILDE</code> (<code class=char>~</code>)
199 character to <var>result</var>.</dd>
200 </dl>
201 </li>
202 <li>Append a <code class=char>U+0020</code>
203 <code class=charname>SPACE</code> character to
204 <var>result</var>.</li>
205 </ol>
206 </dd>
207 </dl>
208 </ol>
209 </li>
210 <li>Then, <var>result</var> is the
211 <abbr title="Selectors Serialization Format for Testing">SFFT</abbr>
212 representation of the group of selectors.</li>
213 </ol>
214
215 <p>To
216 <dfn id=algorithm-serialize-a-simple-selector title="serialize a simple selector">serialize
217 a simple selector (<dfn><var id=var-ss>ss</var></dfn>)</dfn>:</p>
218 <dl class=switch>
219 <dt>If <var>ss</var> is a type or universal selector</dt>
220 <dd>
221 <ol>
222 <li>
223 <dl class=switch>
224 <dt>If a namespace URI is specified (via namespace prefix, or
225 by omitting namespace prefix where a default namespace is specified)</dt>
226 <dd class="ed">@@</dd>
227 <dt>If the null namespace is specified (by zero$B!>(Blength namespace
228 prefix)</dt>
229 <dd>Append a <code class=char>U+007C</code>
230 <code class=charname>VERTICAL BAR</code> (<code class=char>|</code>)
231 character to <var>result</var>.</dd>
232 <dt>If no namespace is specified (by namespace prefix <code>*</code>,
233 or by omitting namespace prefix where no default namespace is
234 specified)</dt>
235 <dd>Append a <code class=char>U+002A</code>
236 <code class=charname>ASTERISK</code> (<code class=char>*</code>)
237 character, followed by a <code class=char>U+007C</code>
238 <code class=charname>VERTICAL BAR</code> (<code class=char>|</code>)
239 character, to <var>result</var>.</dd>
240 </dl>
241 </li>
242 <li>If <var>ss</var> is a type selector, append the
243 <span class=ed>@@ normalized</span> local name to <var>result</var>.</li>
244 <li>If <var>ss</var> is a universal selector, append
245 a <code class=char>U+002A</code> <code class=charname>ASTERISK</code>
246 (<code class=char>*</code>) character to <var>result</var>.</li>
247 </ol>
248 </dd>
249 <dt>If <var>ss</var> is an attribute selector</dt>
250 <dd class=ed>@@</dd>
251 <dt>If <var>ss</var> is a class selector</dt>
252 <dd>Append a <code class=char>U+002E</code> <code class=charname>FULL
253 STOP</code> (<code class=char>.</code>) character, followed
254 by <span class=ed>@@ normalized</span> class name,
255 <var>result</var>.</dd>
256 <dt>If <var>ss</var> is an <abbr>ID</abbr> selector</dt>
257 <dd>Append a <code class=char>U+0023</code> <code class=charname>NUMBER
258 SIGN</code> (<code class=char>#</code>) character, followed
259 by <span class=ed>@@ normalized</span> <abbr>ID</abbr>,
260 to <var>result</var>.</dd>
261 <dt>If <var>ss</var> is a pseudo$B!>(Bclass selector</dt>
262 <dd>
263 <ol>
264 <li>Append a <code class=char>U+003A</code>
265 <code class=charname>COLON</code> (<code class=char>:</code>) character
266 to <var>result</var>.</li>
267 <li>Append <span class=ed>@@ normalized</span>
268 pseudo$B!>(Bclass name to <var>result</var>.</li>
269 <li>Append any arguments as following:
270 <dl class=switch>
271 <dt>If pseudo$B!>(Bclass name is <code>lang</code></dt>
272 <dd>
273 <ol>
274 <li>Append a <code class=char>U+0028</code> <code class=charname>LEFT
275 PARENTHESIS</code> (<code class=char>(</code>) character
276 to <var>result</var>.</li>
277 <li>Append <span class=ed>@@ normalized</span>
278 language tag (the argument) to <var>result</var>.</li>
279 <li>Append a <code class=char>U+0029</code>
280 <code class=charname>RIGHT PARENTHESIS</code>
281 (<code class=char>)</code>) character
282 to <var>result</var>.</li>
283 </ol>
284 </dd>
285 <dt>If pseudo$B!>(Bclass name is <code>-manakai-contains</code></dt>
286 <dd>
287 <ol>
288 <li>Append a <code class=char>U+0028</code> <code class=charname>LEFT
289 PARENTHESIS</code> (<code class=char>(</code>) character
290 to <var>result</var>.</li>
291 <li>Append <span class=ed>@@ normalized</span>
292 string (the argument) to <var>result</var>.</li>
293 <li>Append a <code class=char>U+0029</code>
294 <code class=charname>RIGHT PARENTHESIS</code>
295 (<code class=char>)</code>) character
296 to <var>result</var>.</li>
297 </ol>
298 </dd>
299 <dt>If pseudo$B!>(Bclass name is <code>nth-child</code>,
300 <code>nth-last-child</code>, <code>nth-of-type</code>, or
301 <code>nth-last-of-type</code></dt>
302 <dd>
303 <ol>
304 <li>Append a <code class=char>U+0028</code> <code class=charname>LEFT
305 PARENTHESIS</code> (<code class=char>(</code>) character
306 to <var>result</var>.</li>
307 <li>Append <span class=ed>@@ normalized</span>
308 integer <var>a</var> to <var>result</var>.
309 If the argument is a keyword <code>odd</code> or <code>even</code>,
310 <var>a</var> is <code>2</code>. If <var>a</var> and
311 <code>n</code> is omitted, <var>a</var> is assumed as
312 <code>0</code>. Otherwise, if <var>a</var> is omitted,
313 it is assumed as <code>1</code> (or <code>-1</code>,
314 if there is a <code class=char>U+002D</code>
315 <code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>)
316 character).</li>
317 <li>Append a <code class=char>U+006E</code>
318 <code class=charname>LATIN SMALL LETTER N</code>
319 (<code class=char>n</code>) character to <var>result</var>.</li>
320 <li>Append <span class=ed>@@ normalized</span>
321 integer <var>b</var> to <var>result</var>.
322 It <em class=rfc2119>MUST</em> be preceded by a sign,
323 either <code class=char>U+002B</code> <code class=charname>PLUS
324 SIGN</code> (<code class=char>+</code>) or
325 <code class=char>U+002D</code>
326 <code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>)
327 character. If the argument is a keyword <code>odd</code>,
328 <var>b</var> is <code>1</code>. If the argument
329 is a keyword <code>even</code>, <var>b</var> is
330 <code>0</code>. If <var>b</var> is omitted, it is assumed as
331 <code>0</code>. The sign of <code>0</code>
332 <em class=rfc2119>MUST</em> be <code class=char>U+002B</code>
333 <code class=charname>PLUS SIGN</code>
334 (<code class=char>+</code>).</li>
335 <li>Append a <code class=char>U+0029</code>
336 <code class=charname>RIGHT PARENTHESIS</code>
337 (<code class=char>)</code>) character
338 to <var>result</var>.</li>
339 </ol>
340 </dd>
341 <dt>If pseudo$B!>(Bclass name is <code>not</code></dt>
342 <dd class=ed>@@</dd>
343 </dl>
344 </li>
345 </ol>
346 </dd>
347 <dt>If <var>ss</var> is a pseudo$B!>(Belement</dt>
348 <dd>
349 <ol>
350 <li>Append two <code class=char>U+003A</code>
351 <code class=charname>COLON</code> characters (<code>::</code>)
352 to <var>result</var>.</li>
353 <li>Append <span class=ed>@@ normalized</span>
354 pseudo$B!>(Belement name to <var>result</var>.</li>
355 <!-- For future version: append "(", arguments, ")", if any. -->
356 </ol>
357 </dd>
358 </dl>
359
360 </div>
361
362 <div class="section" id="parsing">
363 <h2>Parsing
364 <abbr title="Selectors Serialization Format for Testing">SFFT</abbr>
365 Groups of Selectors</h2>
366
367 <p>Since <a href="#serializing">the serializing algorithm</a> is
368 so designed that it always output a valid
369 <a href="http://www.w3.org/TR/css3-selectors/#grouping">group of
370 selectors</a>, no special parser for
371 <abbr title="Selectors Serialization Format for Testing">SFFT</abbr>
372 is necessary. Any conforming
373 <a href="http://www.w3.org/TR/css3-selectors/#grouping">group of
374 selectors</a> parser <em class=rfc2119>MAY</em> be used
375 to parse <abbr title="Selectors Serialization Format for Testing">SFFT</abbr>
376 groups of selectors.</p>
377 </div>
378
379 <div class="section" id="examples">
380 <h2>Examples</h2>
381
382 <p class=section-info>This section is <em>non$B!>(Bnormative</em>.</p>
383
384 <div class="ed issue">
385 <p><a href="http://suika.fam.cx/gate/2007/css/parser-interface">Try demo</a>,
386 by choosing <q>Selectors</q> radio button.</p>
387
388 <div class="example figure block">
389 <div class="caption">...</div>
390
391 <pre><code>...</code></pre>
392 </div>
393
394 </div>
395
396 </div>
397
398 <div id="references" class="section reference">
399 <h2>References</h2>
400
401 <div id="normative-references" class="section normative reference">
402 <h3>Normative References</h3>
403
404 <dl>
405 <dt id="ref-KEYWORDS">KEYWORDS</dt>
406 <dd><cite><a href="urn:ietf:rfc:2119">Key words for use in
407 <abbr>RFCs</abbr> to Indicate Requirement Levels</a></cite>,
408 <abbr title="Internet Engineering Task Force">IETF</abbr>
409 <a href="urn:ietf:bcp:14"><abbr title="Best Current Practice">BCP</abbr>
410 14</a>, <abbr title="Request for Comments">RFC</abbr> 2119,
411 <time datetime=1997-03>March 1997</time>.
412 This version of the specification is referenced</dd>
413 <dt id=ref-SELECTORS>SELECTORS</dt>
414 <dd><a href="http://www.w3.org/TR/2005/WD-css3-selectors-20051215"><cite>Selectors</cite></a>,
415 <abbr title="World Wide Web Consortium">W3C</abbr> Working Draft,
416 <time datetime=2005-12-15>15 December 2005</time>. Work in progress.
417 <a href="http://www.w3.org/TR/css3-selectors">The latest version</a>
418 of the specification is referenced.</dd>
419 </dl>
420 </div>
421
422 <div id="informative-references" class="section informative reference">
423 <h3>Non$B!>(Bnormative References</h3>
424
425 <dl>
426 <dt id=ref-CSS>CSS</dt>
427 <dd><cite><a href="http://www.w3.org/TR/2007/CR-CSS21-20070719">Cascading
428 Style Sheets Level 2 Revision 1 (<abbr>CSS</abbr> 2.1)
429 Specification</a></cite>,
430 <abbr title="World Wide Web Consortium">W3C</abbr> Candidate
431 Recommendation, <time datetime=2007-07-19>19 July 2007</time>.
432 Work in progress. The latest version of the specification is
433 available at
434 <code class=URI>&lt;<a href="http://www.w3.org/TR/CSS21">http://www.w3.org/TR/CSS21</a>></code>.</dd>
435 <dt id=ref-CSSOM>CSSOM</dt>
436 <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
437 Style Sheets Object Model (<abbr>CSSOM</abbr>)</a></cite>,
438 <abbr title="World Wide Web Consortium">W3C</abbr> Editor's Draft,
439 <time datetime=2007-06-18>18 June 2007</time>. Work in progress.
440 The latest Editor's Draft of the specification is available at
441 <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>
442 <dt id=ref-HTML5>HTML5</dt>
443 <dd><cite><a href="http://whatwg.org/html5"><abbr>HTML</abbr> 5</a></cite>,
444 <abbr title="Web Hypertext Application Technology Working Group">WHATWG</abbr>
445 Working Draft. Work in progress.</dd>
446 <dt id=ref-SAPI>SAPI</dt>
447 <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>,
448 <abbr title="World Wide Web Consortium">W3C</abbr> Editor's Draft,
449 <time datetime=2007-08-29>29 August 2007</time>. Work in progress.
450 The latest Editor's Draft of the specification is available at
451 <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>.
452 The latest published version of the specification is available at
453 <code class=URI>&lt;<a href="http://www.w3.org/TR/selectors-api/">http://www.w3.org/TR/selectors-api/</a>></code>.</dd>
454 <dt id=XBL2>XBL2</dt>
455 <dd><cite><a href="http://www.mozilla.org/projects/xbl/xbl2.html"><abbr>XBL</abbr>
456 2.0</a></cite>, Mozilla.org, <time datetime=2007-03-15>15 Mar 2007</time>.
457 Work in progress. The latest
458 <abbr title="World Wide Web Consortium">W3C</abbr>$B!>(Bpublished
459 version of the specification is available at
460 <code class=URI>&lt;<a href="http://www.w3.org/TR/xbl/">http://www.w3.org/TR/xbl/</a>></code>.</dd>
461 </dl>
462 </div>
463
464 </div>
465
466 </body>
467 </html>

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24