/[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.18 - (hide annotations) (download) (as text)
Sun Oct 28 07:19:15 2007 UTC (17 years, 1 month ago) by wakaba
Branch: MAIN
Changes since 1.17: +43 -31 lines
File MIME type: text/html
Introduction; namespace prefix is now namespace URI to avoid sorting problem

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

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24