/[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.16 - (hide annotations) (download) (as text)
Mon Oct 22 11:16:27 2007 UTC (17 years, 1 month ago) by wakaba
Branch: MAIN
Changes since 1.15: +68 -40 lines
File MIME type: text/html
Let serialize-a-simple-selector an independent algorithm

1 wakaba 1.1 <!DOCTYPE html>
2     <html lang="en" class="formal-specification status-work-in-progress">
3     <head>
4 wakaba 1.2 <title>Selectors Serialization Format for Testing (SSFT) Specification</title>
5 wakaba 1.1 <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 wakaba 1.2 <h1>Selectors Serialization Format for Testing (<abbr>SSFT</abbr>)
12     Specification</h1>
13 wakaba 1.11 <h2>Working Draft <time datetime=2007-10-22>22 October 2007</time></h2>
14 wakaba 1.1
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 wakaba 1.5 <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 wakaba 1.1 </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 wakaba 1.5 <p class="copyright" lang="en">&#xA9; <time>2007</time> <a
38 wakaba 1.1 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 wakaba 1.5 <p class=section-info><em>This section describes the status of this document
63 wakaba 1.1 at the time of its publication. Other documents
64     might supersede this document.</em></p>
65    
66 wakaba 1.10 <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 wakaba 1.5 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 wakaba 1.1 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 wakaba 1.7 <p class=section-info>This section is <em>non$B!>(Bnormative</em>.</p>
86 wakaba 1.5
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 wakaba 1.4
101 wakaba 1.1 <div class="issue ed">...</div>
102    
103 wakaba 1.4 <p><a href="http://dev.w3.org/cvsweb/csswg/cssom/Overview.html">The
104     <abbr title="Cascading Style Sheets Object Model">CSSOM</abbr>
105     specification</a>
106 wakaba 1.5 <cite class="bibref informative">[<a href="#ref-CSSOM">CSSOM</a>]</cite>
107 wakaba 1.4 is trying to define an algorithm to
108     <a href="http://dev.w3.org/cvsweb/~checkout~/csswg/cssom/Overview.html?rev=1.55&amp;content-type=text/html;%20charset=utf-8#serializing0">serialize
109     a group of selectors</a> for the purpose of <code>selectorText</code>
110     attribute. However, the algorithm is incomplete
111 wakaba 1.5 <time datetime=2007-09-25>at the time of the writing</time>.
112     Note that current Web browser implementations
113 wakaba 1.4 of the <code>selectorText</code> attribute are consistently broken
114     in not escaping unsafe identifiers.</p>
115    
116 wakaba 1.1 </div>
117    
118     <div class="section" id="terminology">
119     <h2>Terminology</h2>
120    
121 wakaba 1.10 <p>The key words <q><dfn id=must><em class="rfc2119">MUST</em></dfn></q>,
122     <q><dfn id=must-not><em class="rfc2119">MUST NOT</em></dfn></q>,
123     <q><dfn id=should><em class="rfc2119">SHOULD</em></dfn></q>,
124     <q><dfn id=should-not><em class="rfc2119">SHOULD NOT</em></dfn></q>, and
125     <q><dfn id=may><em class=rfc2119>MAY</em></dfn></q> in this
126 wakaba 1.1 document are to be interpreted as described in
127 wakaba 1.5 <a href="urn:ietf:rfc:2119"><abbr title="Request for Comments">RFC</abbr>
128     2119</a>
129 wakaba 1.1 <cite class="bibref normative">[<a href="#ref-KEYWORDS">KEYWORDS</a>]</cite>.</p>
130 wakaba 1.5
131 wakaba 1.15 <p>Requirements phrased in the imperative as part of algorithms are to be
132     interpreted with the meaning of the key word (<em class=rfc2119>MUST</em>)
133     used in introducing the algorithm.</p>
134    
135     <p>Conformance requirements phrased as algorithms or specific steps
136     <em class=rfc2119>MAY</em> be implemented in any manner, so long as the end
137     result is equivalent.</p>
138    
139 wakaba 1.5 <!-- Strictly speaking the paragraph below is not part of terminology. -->
140 wakaba 1.7 <p>All examples and notes in this specification are non$B!>(Bnormative,
141     as are all sections explicitly marked non$B!>(Bnormative. Everything
142 wakaba 1.5 else in this specification is normative.</p>
143 wakaba 1.7
144     <p>For the purpose of this specification, pseudo$B!>(Belements are also
145     referred to as <dfn title="simple selector" id=simple-selector>simple
146     selectors</dfn> and are considered as part of the last sequence of
147     simple selector in a selector.</p>
148 wakaba 1.1 </div>
149    
150     <div class="section" id="serializing">
151 wakaba 1.13 <h2>Serializing Selectors as
152 wakaba 1.12 <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
153     Representation</h2>
154 wakaba 1.1
155 wakaba 1.16 <p>Subsections of this section define algorithms
156     to <a href="#algorithm-serialize-a-simple-selector">serialize a simple
157     selector</a> or <a href="#algorithm-serialize-a-group-of-selectors">serialize
158     a group of selectors</a>.</p>
159    
160 wakaba 1.1 <div class="issue ed">
161 wakaba 1.16 <p><a href="http://suika.fam.cx/gate/cvs/*checkout*/markup/html/whatpm/Whatpm/CSS/SelectorsSerializer.pm">See
162     also the reference implementation</a> for now.</p>
163 wakaba 1.1 </div>
164 wakaba 1.3
165 wakaba 1.15 <div class="note memo">
166     <p>The serialized representation will not contain any comment.</p>
167     </div>
168     <!-- TODO: link terms to Selectors -->
169    
170 wakaba 1.14 <div class=section id=serializing-tokens>
171     <h3>Serializing Tokens</h3>
172    
173     <p>To <dfn id=algorithm-normalize-an-ident title="normalize an IDENT">normalize
174 wakaba 1.15 an <code>IDENT</code> (<dfn id=var-n><var>n</var></dfn>)</dfn>,
175     the following algorithm <em class=rfc2119>MUST</em> be used:</p>
176 wakaba 1.14 <ol>
177     <li>Replace the escape sequences (<code>\</code> and following
178     characters) in <var>n</var> by characters represented by them
179     respectively.</li>
180     <li>If there is any character that is <em>not</em> one of
181     <code class=char>U+002D</code> <code class=charname>HYPHEN-MINUS</code>
182     (<code class=char>-</code>), <code class=char>U+0030</code>
183     <code class=charname>DIGIT ZERO</code>
184     (<code class=char>0</code>) to <code class=char>U+0039</code>
185     <code class=charname>DIGIT NINE</code> (<code class=char>9</code>),
186     <code class=char>U+0041</code> <code class=charname>LATIN CAPITAL LETTER
187     A</code> (<code class=char>A</code>) to <code class=char>U+005A</code>
188     <code class=charname>LATIN CAPITAL LETTER Z</code> (<code class=char>Z</code>),
189     <code class=char>U+005F</code> <code class=charname>LOW LINE</code>
190     (<code class=char>_</code>), <code class=char>U+0061</code>
191     <code class=charname>LATIN SMALL LETTER A</code>
192     (<code class=char>a</code>) to <code class=char>U+006A</code>
193     <code class=charname>LATIN SMALL LETTER Z</code> (<code class=char>z</code>),
194     <code class=char>U+0080</code> to <code class=char>U+D7FF</code>, or
195     <code class=char>U+E000</code> to <code class=char>U+10FFFF</code> in
196     <var>n</var>, then replace it by string <code>\<var>HHHHHH</var></code>, where
197     <dfn id=var-HHHHHH><var>HHHHHH</var></dfn> is the upper$B!>(Bcase zero$B!>(Bpadded
198     hexadecimal representation of the character. If the character
199     is outside the range of <code>[<code class=char>U+0000</code>,
200     <code class=char>U+10FFFF</code>]</code>, <var>HHHHHH</var>
201     <em class=rfc2119>MUST</em> be <code>FFFFFF</code>.</li>
202     <li>If the first character in <var>n</var> is one of
203     <code class=char>U+0030</code> <code class=charname>DIGIT ZERO</code>
204     (<code class=char>0</code>) to <code class=char>U+0039</code>
205     <code class=charname>DIGIT NINE</code> (<code class=char>9</code>),
206     then prepend a string <code>\00003</code> at the beginning of
207     <var>n</var>.</li>
208     <li>If the first character in <var>n</var> is <code class=char>U+002D</code>
209     <code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>) and
210     the second character, if any, is <em>not</em> one of
211     <code class=char>U+0041</code> <code class=charname>LATIN CAPITAL LETTER
212     A</code> (<code class=char>A</code>) to <code class=char>U+005A</code>
213     <code class=charname>LATIN CAPITAL LETTER Z</code> (<code class=char>Z</code>),
214     <code class=char>U+005F</code> <code class=charname>LOW LINE</code>
215     (<code class=char>_</code>), <code class=char>U+0061</code>
216     <code class=charname>LATIN SMALL LETTER A</code>
217     (<code class=char>a</code>) to <code class=char>U+006A</code>
218     <code class=charname>LATIN SMALL LETTER Z</code> (<code class=char>z</code>),
219     <code>U+0080</code> to <code>U+D7FF</code>, or
220     <code>U+E000</code> to <code>U+10FFFF</code>, or
221     <var>n</var> is equal to <code class=char>U+002D</code>
222     <code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>), then
223     replace the <code class=char>U+002D</code>
224     <code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>)
225     character by string <code>\00002D</code>.</li>
226     <li>Then, <var>n</var> is the result of the algorithm.</li>
227     </ol>
228 wakaba 1.12
229 wakaba 1.14 <p>To <dfn id=algorithm-normalize-a-string title="normalize a STRING">normalize
230 wakaba 1.15 a <code>STRING</code> (<dfn id=var-s><var>s</var></dfn>)</dfn>,
231     the following algorithm <em class=rfc2119>MUST</em> be used:</p>
232 wakaba 1.14 <ol>
233     <li><p>Replace the escape sequences (<code>\</code> and following
234     characters) in <var>s</var> by characters represented by them
235     (or an empty string if <code>\</code> is immediately followed by
236     newline character(s)) respectively.</p></li>
237     <li><p>Remove the quotation characters in <var>s</var>
238     if <var>s</var> is a <code>STRING</code>.</p>
239 wakaba 1.8
240     <div class="note memo">
241 wakaba 1.14 <p>The input <var>s</var> to this algorithm may be an
242     <code>IDENT</code>.</p>
243     </div></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 wakaba 1.3
267 wakaba 1.14 <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 wakaba 1.4
284 wakaba 1.14 <div class="note memo">
285     <p>Therefore, newlines must be normalized before
286 wakaba 1.8 <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
287 wakaba 1.14 representations are literally compared.</p>
288     </div>
289 wakaba 1.6
290 wakaba 1.12 </div>
291    
292 wakaba 1.14
293 wakaba 1.12 <div class=section id=serializing-simple-selectors>
294     <h3>Serializing Simple Selectors</h3>
295    
296 wakaba 1.15 <p>No <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
297 wakaba 1.16 representation is defined for an invalid <a href="#simple-selector">simple
298     selector</a>.</p>
299 wakaba 1.15
300 wakaba 1.7 <p>To
301     <dfn id=algorithm-serialize-a-simple-selector title="serialize a simple selector">serialize
302 wakaba 1.15 a simple selector (<dfn><var id=var-ss>ss</var></dfn>)</dfn>,
303     the following algorithm <em class=rfc2119>MUST</em> be used:</p>
304 wakaba 1.16 <ol>
305     <li>Let <dfn id=var-r><var>r</var></dfn> an empty string.</li>
306     <li>Process <var>ss</var> as following:
307    
308 wakaba 1.6 <dl class=switch>
309     <dt>If <var>ss</var> is a type or universal selector</dt>
310 wakaba 1.7 <dd>
311     <ol>
312     <li>
313     <dl class=switch>
314     <dt>If a namespace URI is specified (via namespace prefix, or
315     by omitting namespace prefix where a default namespace is specified)</dt>
316     <dd class="ed">@@</dd>
317     <dt>If the null namespace is specified (by zero$B!>(Blength namespace
318     prefix)</dt>
319     <dd>Append a <code class=char>U+007C</code>
320     <code class=charname>VERTICAL BAR</code> (<code class=char>|</code>)
321 wakaba 1.16 character to <var>r</var>.</dd>
322 wakaba 1.7 <dt>If no namespace is specified (by namespace prefix <code>*</code>,
323     or by omitting namespace prefix where no default namespace is
324     specified)</dt>
325     <dd>Append a <code class=char>U+002A</code>
326     <code class=charname>ASTERISK</code> (<code class=char>*</code>)
327     character, followed by a <code class=char>U+007C</code>
328     <code class=charname>VERTICAL BAR</code> (<code class=char>|</code>)
329 wakaba 1.16 character, to <var>r</var>.</dd>
330 wakaba 1.7 </dl>
331     </li>
332     <li>If <var>ss</var> is a type selector, append the
333 wakaba 1.11 <a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a>
334 wakaba 1.16 local name to <var>r</var>.</li>
335 wakaba 1.7 <li>If <var>ss</var> is a universal selector, append
336     a <code class=char>U+002A</code> <code class=charname>ASTERISK</code>
337 wakaba 1.16 (<code class=char>*</code>) character to <var>r</var>.</li>
338 wakaba 1.7 </ol>
339     </dd>
340     <dt>If <var>ss</var> is an attribute selector</dt>
341 wakaba 1.9 <dd>
342     <ol>
343     <li>Append a <code class=char>U+005B</code> <code class=charname>LEFT
344     SQUARE BRACKET</code> (<code class=char>[</code>) to
345 wakaba 1.16 <var>r</var>.</li>
346 wakaba 1.9 <li>
347     Append a namespace prefix as following:
348     <dl>
349     <dt>If a namespace URI is specified</dt>
350     <dd class=ed>@@</dd>
351     <dd class=ed>@@ Current reference implementation is wrong,
352     since its result of sorting depends on namespace prefix.</dd>
353     <dt>If the null namespace is specified</dt>
354     <dd>Append a <code class=char>U+007C</code>
355     <code class=charname>VERTICAL BAR</code> character to
356 wakaba 1.16 <var>r</var>.</dd>
357 wakaba 1.9 <dt>If no namespace is specified</dt>
358     <dd>Append a <code class=char>U+002A</code>
359     <code class=charname>ASTERISK</code> (<code class=char>*</code>)
360     character, followed by a <code class=char>U+007C</code>
361     <code class=charname>VERTICAL BAR</code> (<code class=char>|</code>)
362 wakaba 1.16 character, to <var>r</var>.</dd>
363 wakaba 1.9 </dl>
364     </li>
365 wakaba 1.11 <li>Append the
366     <a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a>
367 wakaba 1.16 local name to <var>r</var>.</li>
368 wakaba 1.9 <li>If a value is specified in <var>ss</var>:
369     <ol>
370     <li>Depending on the way to match, append <code>=</code>,
371     <code>~=</code>, <code>|=</code>, <code>^=</code>,
372 wakaba 1.16 <code>$=</code>, or <code>*=</code> to <var>r</var>.</li>
373 wakaba 1.11 <li>Append the
374     <a href="#algorithm-normalize-a-string" title="normalize a string">normalized</a>
375 wakaba 1.16 value to <var>r</var>.</li>
376 wakaba 1.9 </ol>
377     </li>
378     <li>Append a <code class=char>U+005D</code> <code class=charname>RIGHT
379     SQUARE BRACKET</code> (<code class=char>]</code>) to
380 wakaba 1.16 <var>r</var>.</li>
381 wakaba 1.9 </ol>
382     </dd>
383 wakaba 1.7 <dt>If <var>ss</var> is a class selector</dt>
384     <dd>Append a <code class=char>U+002E</code> <code class=charname>FULL
385     STOP</code> (<code class=char>.</code>) character, followed
386 wakaba 1.11 by <a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a>
387 wakaba 1.16 class name, to <var>r</var>.</dd>
388 wakaba 1.7 <dt>If <var>ss</var> is an <abbr>ID</abbr> selector</dt>
389     <dd>Append a <code class=char>U+0023</code> <code class=charname>NUMBER
390     SIGN</code> (<code class=char>#</code>) character, followed
391 wakaba 1.11 by <a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a>
392 wakaba 1.16 <abbr>ID</abbr>, to <var>r</var>.</dd>
393 wakaba 1.7 <dt>If <var>ss</var> is a pseudo$B!>(Bclass selector</dt>
394     <dd>
395     <ol>
396     <li>Append a <code class=char>U+003A</code>
397     <code class=charname>COLON</code> (<code class=char>:</code>) character
398 wakaba 1.16 to <var>r</var>.</li>
399 wakaba 1.11 <li>Append the
400     <a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a>
401 wakaba 1.16 name of the pseudo$B!>(Bclass to <var>r</var>.</li>
402 wakaba 1.7 <li>Append any arguments as following:
403     <dl class=switch>
404 wakaba 1.8 <dt>If the name of the pseudo$B!>(Bclass is <code>lang</code></dt>
405 wakaba 1.7 <dd>
406     <ol>
407     <li>Append a <code class=char>U+0028</code> <code class=charname>LEFT
408     PARENTHESIS</code> (<code class=char>(</code>) character
409 wakaba 1.16 to <var>r</var>.</li>
410 wakaba 1.11 <li>Append the
411     <a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a>
412 wakaba 1.16 language tag (the argument) to <var>r</var>.</li>
413 wakaba 1.7 <li>Append a <code class=char>U+0029</code>
414     <code class=charname>RIGHT PARENTHESIS</code>
415     (<code class=char>)</code>) character
416 wakaba 1.16 to <var>r</var>.</li>
417 wakaba 1.7 </ol>
418     </dd>
419 wakaba 1.8 <dt>If the name of the pseudo$B!>(Bclass is
420     <code>-manakai-contains</code></dt>
421 wakaba 1.7 <dd>
422     <ol>
423     <li>Append a <code class=char>U+0028</code> <code class=charname>LEFT
424     PARENTHESIS</code> (<code class=char>(</code>) character
425 wakaba 1.16 to <var>r</var>.</li>
426 wakaba 1.11 <li>Append the
427     <a href="#algorithm-normalize-a-string" title="normalize a string">normalized</a>
428 wakaba 1.16 string (the argument) to <var>r</var>.</li>
429 wakaba 1.7 <li>Append a <code class=char>U+0029</code>
430     <code class=charname>RIGHT PARENTHESIS</code>
431     (<code class=char>)</code>) character
432 wakaba 1.16 to <var>r</var>.</li>
433 wakaba 1.7 </ol>
434     </dd>
435 wakaba 1.8 <dt>If name of the pseudo$B!>(Bclass is either <code>nth-child</code>,
436 wakaba 1.7 <code>nth-last-child</code>, <code>nth-of-type</code>, or
437     <code>nth-last-of-type</code></dt>
438     <dd>
439     <ol>
440     <li>Append a <code class=char>U+0028</code> <code class=charname>LEFT
441     PARENTHESIS</code> (<code class=char>(</code>) character
442 wakaba 1.16 to <var>r</var>.</li>
443 wakaba 1.7 <li>Append <span class=ed>@@ normalized</span>
444 wakaba 1.16 integer <var>a</var> to <var>r</var>.
445 wakaba 1.7 If the argument is a keyword <code>odd</code> or <code>even</code>,
446     <var>a</var> is <code>2</code>. If <var>a</var> and
447     <code>n</code> is omitted, <var>a</var> is assumed as
448     <code>0</code>. Otherwise, if <var>a</var> is omitted,
449     it is assumed as <code>1</code> (or <code>-1</code>,
450     if there is a <code class=char>U+002D</code>
451     <code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>)
452     character).</li>
453     <li>Append a <code class=char>U+006E</code>
454     <code class=charname>LATIN SMALL LETTER N</code>
455 wakaba 1.16 (<code class=char>n</code>) character to <var>r</var>.</li>
456 wakaba 1.7 <li>Append <span class=ed>@@ normalized</span>
457 wakaba 1.16 integer <var>b</var> to <var>r</var>.
458 wakaba 1.7 It <em class=rfc2119>MUST</em> be preceded by a sign,
459     either <code class=char>U+002B</code> <code class=charname>PLUS
460     SIGN</code> (<code class=char>+</code>) or
461     <code class=char>U+002D</code>
462     <code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>)
463     character. If the argument is a keyword <code>odd</code>,
464     <var>b</var> is <code>1</code>. If the argument
465     is a keyword <code>even</code>, <var>b</var> is
466     <code>0</code>. If <var>b</var> is omitted, it is assumed as
467     <code>0</code>. The sign of <code>0</code>
468     <em class=rfc2119>MUST</em> be <code class=char>U+002B</code>
469     <code class=charname>PLUS SIGN</code>
470     (<code class=char>+</code>).</li>
471     <li>Append a <code class=char>U+0029</code>
472     <code class=charname>RIGHT PARENTHESIS</code>
473     (<code class=char>)</code>) character
474 wakaba 1.16 to <var>r</var>.</li>
475 wakaba 1.7 </ol>
476     </dd>
477 wakaba 1.8 <dt>If the name of the pseudo$B!>(Bclass is <code>not</code></dt>
478     <dd>
479     <ol>
480     <li>Append a string of <code class=char>U+003A</code>
481     <code class=charname>COLON</code>, <code class=char>U+006E</code>
482     <code class=charname>LATIN SMALL LETTER N</code>,
483     <code class=char>U+006F</code> <code class=charname>LATIN
484     SMALL LETTER O</code>, <code class=char>U+0074</code>
485     <code class=charname>LATIN SMALL LETTER T</code>, and
486     <code class=char>U+0028</code> <code class=charname>LEFT
487     PARENTHESIS</code> (<code>:not(</code>), followed by a
488 wakaba 1.16 <a href="#newline">newline</a>, to <var>r</var>.</li>
489 wakaba 1.8 <li>Append four <code class=char>U+0020</code>
490     <code class=charname>SPACE</code> characters to
491 wakaba 1.16 <var>r</var>.</li>
492 wakaba 1.8 <li>Append four <code class=char>U+0020</code>
493     <code class=charname>SPACE</code> characters to
494 wakaba 1.16 <var>r</var> again.</li>
495 wakaba 1.8 <li><a href="#algorithm-serialize-a-simple-selector">Serialize
496     the simple selector specified as the argument to the
497     <code>not</code> pseudo$B!>(Bclass</a>.</li>
498     <li>Append a <a href="#newline">newline</a> to
499 wakaba 1.16 <var>r</var>.</li>
500 wakaba 1.8 <li>Append four <code class=char>U+0020</code>
501     <code class=charname>SPACE</code> characters to
502 wakaba 1.16 <var>r</var>.</li>
503 wakaba 1.8 <li>Append a <code class=char>U+0029</code>
504     <code class=charname>RIGHT PARENTHESIS</code>
505     (<code class=char>)</code>) character
506 wakaba 1.16 to <var>r</var>.</li>
507 wakaba 1.8 </ol>
508     </dd>
509 wakaba 1.16 <dt>Otherwise</dt>
510     <dd>The pseudo$B!>(Bclass is not supported by this version of
511     <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
512     and therefore no
513     <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
514     representation is defined for <var>ss</var>. Stop the algorithm.</dd>
515 wakaba 1.7 </dl>
516     </li>
517     </ol>
518     </dd>
519     <dt>If <var>ss</var> is a pseudo$B!>(Belement</dt>
520     <dd>
521     <ol>
522     <li>Append two <code class=char>U+003A</code>
523     <code class=charname>COLON</code> characters (<code>::</code>)
524 wakaba 1.16 to <var>r</var>.</li>
525 wakaba 1.11 <li>Append the
526     <a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a>
527 wakaba 1.16 name of the pseudo$B!>(Belement to <var>r</var>.</li>
528     <li>If the pseudo$B!>(Belement has any arguments:
529     The pseudo$B!>(Belement is not supported by this version of
530     <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
531     and therefore no
532     <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
533     representation is defined for <var>ss</var>. Stop the algorithm.
534     </li>
535 wakaba 1.7 </ol>
536     </dd>
537 wakaba 1.6 </dl>
538 wakaba 1.16 </li>
539     <li>Then, <var>r</var> is the
540     <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
541     representation of <var>ss</var>.</li>
542     </ol>
543 wakaba 1.1
544 wakaba 1.12 </div>
545    
546 wakaba 1.14 <div class=section id=serializing-groups-of-selectors>
547     <h3>Serializing Groups of Selectors</h3>
548 wakaba 1.12
549 wakaba 1.14 <p>No <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
550     representation is defined for an invalid group of selectors.</p>
551 wakaba 1.13
552 wakaba 1.14 <p>To
553     <dfn id=algorithm-serialize-a-group-of-selectors title="serialize a group of selectors">serialize
554 wakaba 1.15 a group of selectors (<dfn id=var-gs><var>gs</var></dfn>)</dfn>,
555     the following algorithm <em class=rfc2119>MUST</em> be used:</p>
556 wakaba 1.14 <ol>
557     <li>Let <dfn id=var-result><var>result</var></dfn> an empty string.</li>
558     <li>For each selector (<dfn id=var-selector><var>selector</var></dfn>) in
559     <var>gs</var>:
560     <ol>
561     <li>If <var>selector</var> is <em>not</em> the first selector
562     in the group of selectors, then append a <code class=char>U+002C</code>
563     <code class=charname>COMMA</code> (<code class=char>,</code>) followed by a
564     <a href="#newline">newline</a> to <var>result</var>.</li>
565     <li>Append four <code class=char>U+0020</code>
566     <code class=charname>SPACE</code> characters to <var>result</var>.</li>
567     <li>Process each sequence of simple selectors or
568 wakaba 1.16 combinator in <var>selector</var> as following:
569 wakaba 1.14 <dl class=switch>
570     <dt>If it is a sequence of simle selector
571     (<dfn id=var-sss><var>sss</var></dfn>)</dt>
572     <dd>
573     <ol>
574     <li class=ed><a href="#algorithm-serialize-a-simple-selector">Serialize
575     each simple selector</a> in <var>sss</var>.</li>
576     <li class=ed>sort</li>
577     <li>Append a <a href="#newline">newline</a> to <var>result</var>.</li>
578     </ol>
579     </dd>
580     <dt>If it is a combinator (<dfn id=var-c><var>c</var></dfn>)</dt>
581     <dd>
582     <ol>
583     <li>Append two <code class=char>U+0020</code>
584     <code class=charname>SPACE</code> characters to <var>result</var>.</li>
585 wakaba 1.16 <li>Process <var>c</var> as following:
586    
587 wakaba 1.14 <dl class=switch>
588     <dt>If <var>c</var> is descendant combinator (white space)</dt>
589     <dd>Append a <code class=char>U+0020</code>
590     <code class=charname>SPACE</code> character to
591     <var>result</var>.</dd>
592     <dt>If <var>c</var> is child combinator
593     (<code class=char>></code>)</dt>
594     <dd>Append a <code class=char>U+003E</code>
595     <code class=charname>GREATER-THAN SIGN</code>
596     (<code class=char>></code>) character to <var>result</var>.</dd>
597     <dt>If <var>c</var> is adjacent sibling combinator
598     (<code class=char>+</code>)</dt>
599     <dd>Append a <code class=char>U+002B</code>
600     <code class=charname>PLUS SIGN</code> (<code class=char>+</code>)
601     character to <var>result</var>.</dd>
602     <dt>If <var>c</var> is general sibling combinator
603     (<code class=char>~</code>)</dt>
604     <dd>Append a <code class=char>U+007E</code>
605     <code class=charname>TILDE</code> (<code class=char>~</code>)
606     character to <var>result</var>.</dd>
607     </dl>
608     </li>
609     <li>Append a <code class=char>U+0020</code>
610     <code class=charname>SPACE</code> character to
611     <var>result</var>.</li>
612     </ol>
613     </dd>
614     </dl>
615     </ol>
616     </li>
617     <li>Then, <var>result</var> is the
618 wakaba 1.8 <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
619 wakaba 1.14 representation of <var>gs</var>.</li>
620     </ol>
621 wakaba 1.12
622 wakaba 1.8 </div>
623    
624 wakaba 1.1 </div>
625    
626     <div class="section" id="parsing">
627     <h2>Parsing
628 wakaba 1.8 <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
629 wakaba 1.1 Groups of Selectors</h2>
630    
631     <p>Since <a href="#serializing">the serializing algorithm</a> is
632     so designed that it always output a valid
633     <a href="http://www.w3.org/TR/css3-selectors/#grouping">group of
634 wakaba 1.8 selectors</a>, no special parser for the
635     <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
636     representation is necessary. Any conforming parser for
637     <a href="http://www.w3.org/TR/css3-selectors/#grouping">groups of
638     selectors</a> <em class=rfc2119>MAY</em> be used
639     to parse <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
640     representations of groups of selectors.</p>
641 wakaba 1.1 </div>
642    
643     <div class="section" id="examples">
644     <h2>Examples</h2>
645    
646 wakaba 1.7 <p class=section-info>This section is <em>non$B!>(Bnormative</em>.</p>
647 wakaba 1.1
648     <div class="ed issue">
649     <p><a href="http://suika.fam.cx/gate/2007/css/parser-interface">Try demo</a>,
650 wakaba 1.7 by choosing <q>Selectors</q> radio button.</p>
651 wakaba 1.1
652     <div class="example figure block">
653     <div class="caption">...</div>
654    
655     <pre><code>...</code></pre>
656     </div>
657    
658     </div>
659    
660     </div>
661    
662     <div id="references" class="section reference">
663 wakaba 1.7 <h2>References</h2>
664 wakaba 1.1
665     <div id="normative-references" class="section normative reference">
666     <h3>Normative References</h3>
667    
668     <dl>
669     <dt id="ref-KEYWORDS">KEYWORDS</dt>
670 wakaba 1.4 <dd><cite><a href="urn:ietf:rfc:2119">Key words for use in
671     <abbr>RFCs</abbr> to Indicate Requirement Levels</a></cite>,
672     <abbr title="Internet Engineering Task Force">IETF</abbr>
673     <a href="urn:ietf:bcp:14"><abbr title="Best Current Practice">BCP</abbr>
674 wakaba 1.5 14</a>, <abbr title="Request for Comments">RFC</abbr> 2119,
675     <time datetime=1997-03>March 1997</time>.
676 wakaba 1.4 This version of the specification is referenced</dd>
677 wakaba 1.1 <dt id=ref-SELECTORS>SELECTORS</dt>
678 wakaba 1.2 <dd><a href="http://www.w3.org/TR/2005/WD-css3-selectors-20051215"><cite>Selectors</cite></a>,
679     <abbr title="World Wide Web Consortium">W3C</abbr> Working Draft,
680 wakaba 1.5 <time datetime=2005-12-15>15 December 2005</time>. Work in progress.
681 wakaba 1.2 <a href="http://www.w3.org/TR/css3-selectors">The latest version</a>
682     of the specification is referenced.</dd>
683 wakaba 1.1 </dl>
684     </div>
685    
686     <div id="informative-references" class="section informative reference">
687 wakaba 1.7 <h3>Non$B!>(Bnormative References</h3>
688 wakaba 1.1
689     <dl>
690 wakaba 1.5 <dt id=ref-CSS>CSS</dt>
691     <dd><cite><a href="http://www.w3.org/TR/2007/CR-CSS21-20070719">Cascading
692     Style Sheets Level 2 Revision 1 (<abbr>CSS</abbr> 2.1)
693     Specification</a></cite>,
694     <abbr title="World Wide Web Consortium">W3C</abbr> Candidate
695     Recommendation, <time datetime=2007-07-19>19 July 2007</time>.
696     Work in progress. The latest version of the specification is
697     available at
698     <code class=URI>&lt;<a href="http://www.w3.org/TR/CSS21">http://www.w3.org/TR/CSS21</a>></code>.</dd>
699 wakaba 1.4 <dt id=ref-CSSOM>CSSOM</dt>
700     <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
701     Style Sheets Object Model (<abbr>CSSOM</abbr>)</a></cite>,
702     <abbr title="World Wide Web Consortium">W3C</abbr> Editor's Draft,
703 wakaba 1.5 <time datetime=2007-06-18>18 June 2007</time>. Work in progress.
704     The latest Editor's Draft of the specification is available at
705     <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>
706     <dt id=ref-HTML5>HTML5</dt>
707     <dd><cite><a href="http://whatwg.org/html5"><abbr>HTML</abbr> 5</a></cite>,
708     <abbr title="Web Hypertext Application Technology Working Group">WHATWG</abbr>
709     Working Draft. Work in progress.</dd>
710     <dt id=ref-SAPI>SAPI</dt>
711     <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>,
712     <abbr title="World Wide Web Consortium">W3C</abbr> Editor's Draft,
713     <time datetime=2007-08-29>29 August 2007</time>. Work in progress.
714     The latest Editor's Draft of the specification is available at
715     <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>.
716     The latest published version of the specification is available at
717     <code class=URI>&lt;<a href="http://www.w3.org/TR/selectors-api/">http://www.w3.org/TR/selectors-api/</a>></code>.</dd>
718 wakaba 1.10 <dt id=ref-XBL2>XBL2</dt>
719 wakaba 1.5 <dd><cite><a href="http://www.mozilla.org/projects/xbl/xbl2.html"><abbr>XBL</abbr>
720     2.0</a></cite>, Mozilla.org, <time datetime=2007-03-15>15 Mar 2007</time>.
721     Work in progress. The latest
722     <abbr title="World Wide Web Consortium">W3C</abbr>$B!>(Bpublished
723     version of the specification is available at
724     <code class=URI>&lt;<a href="http://www.w3.org/TR/xbl/">http://www.w3.org/TR/xbl/</a>></code>.</dd>
725 wakaba 1.1 </dl>
726     </div>
727    
728     </div>
729    
730     </body>
731     </html>

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24