10 |
<div class="header"> |
<div class="header"> |
11 |
<h1>Selectors Serialization Format for Testing (<abbr>SSFT</abbr>) |
<h1>Selectors Serialization Format for Testing (<abbr>SSFT</abbr>) |
12 |
Specification</h1> |
Specification</h1> |
13 |
<h2>Working Draft <time datetime=2007-10-01>1 October 2007</time></h2> |
<h2>Working Draft <time datetime=2007-10-07>7 October 2007</time></h2> |
14 |
|
|
15 |
<dl class="versions-uri"> |
<dl class="versions-uri"> |
16 |
<dt>This Version</dt> |
<dt>This Version</dt> |
80 |
<div id="introduction" class="section"> |
<div id="introduction" class="section"> |
81 |
<h2>Introduction</h2> |
<h2>Introduction</h2> |
82 |
|
|
83 |
<p class=section-info>This section is <em>non-normative</em>.</p> |
<p class=section-info>This section is <em>non$B!>(Bnormative</em>.</p> |
84 |
|
|
85 |
<p>Selectors |
<p>Selectors |
86 |
<cite class="bibref normative">[<a href="#ref-SELECTORS">SELECTORS</a>]</cite> |
<cite class="bibref normative">[<a href="#ref-SELECTORS">SELECTORS</a>]</cite> |
127 |
<cite class="bibref normative">[<a href="#ref-KEYWORDS">KEYWORDS</a>]</cite>.</p> |
<cite class="bibref normative">[<a href="#ref-KEYWORDS">KEYWORDS</a>]</cite>.</p> |
128 |
|
|
129 |
<!-- Strictly speaking the paragraph below is not part of terminology. --> |
<!-- Strictly speaking the paragraph below is not part of terminology. --> |
130 |
<p>All examples and notes in this specification are non-normative, |
<p>All examples and notes in this specification are non$B!>(Bnormative, |
131 |
as are all sections explicitly marked non-normative. Everything |
as are all sections explicitly marked non$B!>(Bnormative. Everything |
132 |
else in this specification is normative.</p> |
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> |
</div> |
139 |
|
|
140 |
<div class="section" id="serializing"> |
<div class="section" id="serializing"> |
145 |
for now.</p> |
for now.</p> |
146 |
</div> |
</div> |
147 |
|
|
148 |
<p><dfn id=newline>Newline</dfn> is <code class=char>U+000A</code> |
<p><dfn id=newline title=newline>Newline</dfn> is |
149 |
<code class=charname>LINE FEED</code> <span class=ed>or |
<code class=char>U+000A</code> <code class=charname>LINE FEED</code> |
150 |
U+000D U+000A or U+000A ??</span>.</p> |
<span class=ed>or U+000D U+000A or U+000A ??</span>.</p> |
151 |
|
|
152 |
<!-- TODO: link terms to Selectors --> |
<!-- 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> |
<ol> |
158 |
<li>Let <var>result</var> an empty string.</li> |
<li>Let <dfn id=var-result><var>result</var></dfn> an empty string.</li> |
159 |
<li>For each selector (<var>selector</var>) in the group of selectors: |
<li>For each selector (<dfn id=var-selector><var>selector</var></dfn>) in |
160 |
|
<var>gs</var>: |
161 |
<ol> |
<ol> |
162 |
<li>If <var>selector</var> is <em>not</em> the first selector |
<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> |
in the group of selectors, then append a <code class=char>U+002C</code> |
164 |
<code class=charname>COMMA</code> followed by a |
<code class=charname>COMMA</code> (<code class=char>,</code>) followed by a |
165 |
<a href="#newline">newline</a> to <var>result</var>.</li> |
<a href="#newline">newline</a> to <var>result</var>.</li> |
166 |
<li>Append four <code class=char>U+0020</code> |
<li>Append four <code class=char>U+0020</code> |
167 |
<code class=charname>SPACE</code> characters to <var>result</var>.</li> |
<code class=charname>SPACE</code> characters to <var>result</var>.</li> |
168 |
<li>Process each sequence of simple selectors or |
<li>Process each sequence of simple selectors or |
169 |
combinator in <var>selector</var> by following algorithm: |
combinator in <var>selector</var> by following algorithm: |
170 |
<dl class=switch> |
<dl class=switch> |
171 |
<dt>If it is a sequence of simle selector (<var>sss</var>)</dt> |
<dt>If it is a sequence of simle selector |
172 |
|
(<dfn id=var-sss><var>sss</var></dfn>)</dt> |
173 |
<dd class=ed>@@</dd> |
<dd class=ed>@@</dd> |
174 |
<dt>If it is a combinator (<var>c</var>)</dt> |
<dt>If it is a combinator (<dfn id=var-c><var>c</var></dfn>)</dt> |
175 |
<dd> |
<dd> |
176 |
<ol> |
<ol> |
177 |
<li>Append two <code class=char>U+0020</code> |
<li>Append two <code class=char>U+0020</code> |
185 |
<dt>If <var>c</var> is child combinator |
<dt>If <var>c</var> is child combinator |
186 |
(<code class=char>></code>)</dt> |
(<code class=char>></code>)</dt> |
187 |
<dd>Append a <code class=char>U+003E</code> |
<dd>Append a <code class=char>U+003E</code> |
188 |
<code class=charname>GREATER-THAN SIGN</code> character to |
<code class=charname>GREATER-THAN SIGN</code> |
189 |
<var>result</var>.</dd> |
(<code class=char>></code>) character to <var>result</var>.</dd> |
190 |
<dt>If <var>c</var> is adjacent sibling combinator |
<dt>If <var>c</var> is adjacent sibling combinator |
191 |
(<code class=char>+</code>)</dt> |
(<code class=char>+</code>)</dt> |
192 |
<dd>Append a <code class=char>U+002B</code> |
<dd>Append a <code class=char>U+002B</code> |
193 |
<code class=charname>PLUS SIGN</code> character to |
<code class=charname>PLUS SIGN</code> (<code class=char>+</code>) |
194 |
<var>result</var>.</dd> |
character to <var>result</var>.</dd> |
195 |
<dt>If <var>c</var> is general sibling combinator |
<dt>If <var>c</var> is general sibling combinator |
196 |
(<code class=char>~</code>)</dt> |
(<code class=char>~</code>)</dt> |
197 |
<dd>Append a <code class=char>U+007E</code> |
<dd>Append a <code class=char>U+007E</code> |
198 |
<code class=charname>TILDE</code> character to |
<code class=charname>TILDE</code> (<code class=char>~</code>) |
199 |
<var>result</var>.</dd> |
character to <var>result</var>.</dd> |
200 |
</dl> |
</dl> |
201 |
</li> |
</li> |
202 |
<li>Append a <code class=char>U+0020</code> |
<li>Append a <code class=char>U+0020</code> |
212 |
representation of the group of selectors.</li> |
representation of the group of selectors.</li> |
213 |
</ol> |
</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> |
</div> |
361 |
|
|
362 |
<div class="section" id="parsing"> |
<div class="section" id="parsing"> |
379 |
<div class="section" id="examples"> |
<div class="section" id="examples"> |
380 |
<h2>Examples</h2> |
<h2>Examples</h2> |
381 |
|
|
382 |
<p class=section-info>This section is <em>non-normative</em>.</p> |
<p class=section-info>This section is <em>non$B!>(Bnormative</em>.</p> |
383 |
|
|
384 |
<div class="ed issue"> |
<div class="ed issue"> |
385 |
<p><a href="http://suika.fam.cx/gate/2007/css/parser-interface">Try demo</a>, |
<p><a href="http://suika.fam.cx/gate/2007/css/parser-interface">Try demo</a>, |
386 |
by choosing <q>Selectors</q> radio button.</a></p> |
by choosing <q>Selectors</q> radio button.</p> |
387 |
|
|
388 |
<div class="example figure block"> |
<div class="example figure block"> |
389 |
<div class="caption">...</div> |
<div class="caption">...</div> |
396 |
</div> |
</div> |
397 |
|
|
398 |
<div id="references" class="section reference"> |
<div id="references" class="section reference"> |
399 |
<h2>References</h1> |
<h2>References</h2> |
400 |
|
|
401 |
<div id="normative-references" class="section normative reference"> |
<div id="normative-references" class="section normative reference"> |
402 |
<h3>Normative References</h3> |
<h3>Normative References</h3> |
420 |
</div> |
</div> |
421 |
|
|
422 |
<div id="informative-references" class="section informative reference"> |
<div id="informative-references" class="section informative reference"> |
423 |
<h3>Non-normative References</h3> |
<h3>Non$B!>(Bnormative References</h3> |
424 |
|
|
425 |
<dl> |
<dl> |
426 |
<dt id=ref-CSS>CSS</dt> |
<dt id=ref-CSS>CSS</dt> |