1 |
<!DOCTYPE html> |
<!DOCTYPE html> |
2 |
<html lang="en" class="formal-specification status-work-in-progress"> |
<html lang="en" class="formal-specification"><!-- work-in-progress --> |
3 |
<head> |
<head> |
4 |
<title>Selectors Serialization Format for Testing (SSFT) Specification</title> |
<title>Selectors Serialization Format for Testing (SSFT) Specification</title> |
5 |
<link rel="stylesheet" href="http://suika.fam.cx/www/style/html/spec"> |
<link rel="stylesheet" href="http://suika.fam.cx/www/style/html/spec"> |
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-22>22 October 2007</time></h2> |
<h2>First Edition <!-- Working Draft --> |
14 |
|
<time datetime=2007-11-05>5 November 2007</time></h2> |
15 |
|
|
16 |
<dl class="versions-uri"> |
<dl class="versions-uri"> |
17 |
<dt>This Version</dt> |
<dt>This Version</dt> |
18 |
<dd><code class="URI"><<a href="http://suika.fam.cx/www/markup/selectors/ssft/ssft" |
<dd><code class="URI"><<a href="http://suika.fam.cx/www/markup/selectors/ssft/ssft-20071105" |
19 |
>http://suika.fam.cx/www/markup/selectors/ssft/ssft</a>></code></dd> |
>http://suika.fam.cx/www/markup/selectors/ssft/ssft-20071105</a>></code></dd> |
20 |
<dt>Latest Version</dt> |
<dt>Latest Version</dt> |
21 |
<dd><code class="URI"><<a href="http://suika.fam.cx/www/markup/selectors/ssft/ssft" |
<dd><code class="URI"><<a href="http://suika.fam.cx/www/markup/selectors/ssft/ssft" |
22 |
>http://suika.fam.cx/www/markup/selectors/ssft/ssft</a>></code></dd> |
>http://suika.fam.cx/www/markup/selectors/ssft/ssft</a>></code></dd> |
|
<!-- |
|
23 |
<dt>Latest Working Draft</dt> |
<dt>Latest Working Draft</dt> |
24 |
--> |
<dd><code class="URI"><<a href="http://suika.fam.cx/www/markup/selectors/ssft/ssft-work" |
25 |
|
>http://suika.fam.cx/www/markup/selectors/ssft/ssft-work</a>></code></dd> |
26 |
<!-- <dt>Previous Version</dt> --> |
<!-- <dt>Previous Version</dt> --> |
27 |
<dt>Version History</dt> |
<dt>Version History</dt> |
28 |
<dd><code class=URI><<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>></code></dd> |
<dd><code class=URI><<a href="http://suika.fam.cx/gate/cvs/markup/selectors/ssft/ssft-work.en.html">http://suika.fam.cx/gate/cvs/markup/selectors/ssft/ssft-work.en.html</a>></code></dd> |
29 |
</dl> |
</dl> |
30 |
<dl class="authors" id="author"> |
<dl class="authors" id="author"> |
31 |
<dt>Author</dt> |
<dt>Author</dt> |
53 |
<div id="abstract" class="section"> |
<div id="abstract" class="section"> |
54 |
<h2>Abstract</h2> |
<h2>Abstract</h2> |
55 |
|
|
56 |
<div class="ed issue">...</div> |
<p>This document defines |
57 |
|
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr>, |
58 |
|
a subset of Selectors language which is suitable for describing results |
59 |
|
of Selectors parsing tests.</p> |
60 |
|
|
61 |
</div> |
</div> |
62 |
|
|
67 |
at the time of its publication. Other documents |
at the time of its publication. Other documents |
68 |
might supersede this document.</em></p> |
might supersede this document.</em></p> |
69 |
|
|
70 |
<p>This document is a working draft, produced as part of the |
<p>This document is the specification |
71 |
|
<!-- This document is a working draft --> |
72 |
|
of <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>, |
73 |
|
produced as part of the |
74 |
<a href="http://suika.fam.cx/www/markup/html/whatpm/readme">Whatpm</a> |
<a href="http://suika.fam.cx/www/markup/html/whatpm/readme">Whatpm</a> |
75 |
subproject |
subproject |
76 |
of the <a href="http://suika.fam.cx/www/manakai-core/doc/web/">manakai</a> |
of the <a href="http://suika.fam.cx/www/manakai-core/doc/web/">manakai</a> |
77 |
project. It might be updated, replaced, or obsoleted by |
project. |
78 |
|
<!-- It might be updated, replaced, or obsoleted by |
79 |
other documents at any time. It is inappropriate to |
other documents at any time. It is inappropriate to |
80 |
cite this document as other than <q>work in progress</q>.</p> |
cite this document as other than <q>work in progress</q>. --></p> |
81 |
|
|
82 |
<p>Comments on this document are welcome and |
<p>Comments on this document are welcome and |
83 |
may be sent to the <a href="#author">author</a>.</p> |
may be sent to the <a href="#author">author</a>.</p> |
106 |
<abbr>API</abbr></a> |
<abbr>API</abbr></a> |
107 |
<cite class="bibref informative">[<a href="#ref-SAPI">SAPI</a>]</cite>.</p> |
<cite class="bibref informative">[<a href="#ref-SAPI">SAPI</a>]</cite>.</p> |
108 |
|
|
109 |
<div class="issue ed">...</div> |
<p>It is so flexible language that a conceptually same pattern |
110 |
|
can be represented in inifnite numbers of instances of selectors. |
111 |
|
It might be convinient for e.g. validation of a test result to |
112 |
|
define a subset of the language, in which no semantically equivalent |
113 |
|
selectors are contained.</p> |
114 |
|
|
115 |
<p><a href="http://dev.w3.org/cvsweb/csswg/cssom/Overview.html">The |
<p><a href="http://dev.w3.org/cvsweb/csswg/cssom/Overview.html">The |
116 |
<abbr title="Cascading Style Sheets Object Model">CSSOM</abbr> |
<abbr title="Cascading Style Sheets Object Model">CSSOM</abbr> |
123 |
<time datetime=2007-09-25>at the time of the writing</time>. |
<time datetime=2007-09-25>at the time of the writing</time>. |
124 |
Note that current Web browser implementations |
Note that current Web browser implementations |
125 |
of the <code>selectorText</code> attribute are consistently broken |
of the <code>selectorText</code> attribute are consistently broken |
126 |
in not escaping unsafe identifiers.</p> |
in not escaping unsafe identifiers and therefore it is not wise |
127 |
|
to deploy that format for testing.</p> |
128 |
|
|
129 |
</div> |
</div> |
130 |
|
|
133 |
|
|
134 |
<p>The key words <q><dfn id=must><em class="rfc2119">MUST</em></dfn></q>, |
<p>The key words <q><dfn id=must><em class="rfc2119">MUST</em></dfn></q>, |
135 |
<q><dfn id=must-not><em class="rfc2119">MUST NOT</em></dfn></q>, |
<q><dfn id=must-not><em class="rfc2119">MUST NOT</em></dfn></q>, |
136 |
<q><dfn id=should><em class="rfc2119">SHOULD</em></dfn></q>, |
<q><dfn id=should><em class="rfc2119">SHOULD</em></dfn></q>, and |
|
<q><dfn id=should-not><em class="rfc2119">SHOULD NOT</em></dfn></q>, and |
|
137 |
<q><dfn id=may><em class=rfc2119>MAY</em></dfn></q> in this |
<q><dfn id=may><em class=rfc2119>MAY</em></dfn></q> in this |
138 |
document are to be interpreted as described in |
document are to be interpreted as described in |
139 |
<a href="urn:ietf:rfc:2119"><abbr title="Request for Comments">RFC</abbr> |
<a href="urn:ietf:rfc:2119"><abbr title="Request for Comments">RFC</abbr> |
160 |
</div> |
</div> |
161 |
|
|
162 |
<div class="section" id="serializing"> |
<div class="section" id="serializing"> |
163 |
<h2>Serializing Selectors as |
<h2>Serializing Selectors in |
164 |
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
165 |
Representation</h2> |
Representation</h2> |
166 |
|
|
169 |
selector</a> or <a href="#algorithm-serialize-a-group-of-selectors">serialize |
selector</a> or <a href="#algorithm-serialize-a-group-of-selectors">serialize |
170 |
a group of selectors</a>.</p> |
a group of selectors</a>.</p> |
171 |
|
|
|
<div class="issue ed"> |
|
|
<p><a href="http://suika.fam.cx/gate/cvs/*checkout*/markup/html/whatpm/Whatpm/CSS/SelectorsSerializer.pm">See |
|
|
also the reference implementation</a> for now.</p> |
|
|
</div> |
|
|
|
|
172 |
<div class="note memo"> |
<div class="note memo"> |
173 |
<p>The serialized representation will not contain any comment.</p> |
<p>The serialized representation will not contain any comment.</p> |
174 |
</div> |
</div> |
|
<!-- TODO: link terms to Selectors --> |
|
175 |
|
|
176 |
<div class=section id=serializing-tokens> |
<div class=section id=serializing-tokens> |
177 |
<h3>Serializing Tokens</h3> |
<h3>Serializing Tokens</h3> |
178 |
|
|
179 |
<p>To <dfn id=algorithm-normalize-an-ident title="normalize an IDENT">normalize |
<p>To <dfn id=algorithm-normalize-an-ident title="normalize a string as an IDENT">normalize |
180 |
an <code>IDENT</code> (<dfn id=var-n><var>n</var></dfn>)</dfn>, |
a string (<dfn id=var-n><var>n</var></dfn>) as an <code>IDENT</code></dfn>, |
181 |
the following algorithm <em class=rfc2119>MUST</em> be used:</p> |
the following algorithm <em class=rfc2119>MUST</em> be used:</p> |
182 |
<ol> |
<ol> |
183 |
<li>Replace the escape sequences (<code>\</code> and following |
<li>If <var>n</var> is either an <code>IDENT</code> or a <code>HASH</code>, |
184 |
characters) in <var>n</var> by characters represented by them |
replace the escape sequences (<code>\</code> and following characters) in |
185 |
respectively.</li> |
<var>n</var> by characters represented by them respectively.</li> |
186 |
|
<li>If <var>n</var> is a <code>HASH</code>, remove the leading |
187 |
|
<code class=char>U+0023</code> <code class=charname>NUMBER SIGN</code> |
188 |
|
(<code class=char>#</code>) character from <var>n</var>.</li> |
189 |
<li>If there is any character that is <em>not</em> one of |
<li>If there is any character that is <em>not</em> one of |
190 |
<code class=char>U+002D</code> <code class=charname>HYPHEN-MINUS</code> |
<code class=char>U+002D</code> <code class=charname>HYPHEN-MINUS</code> |
191 |
(<code class=char>-</code>), <code class=char>U+0030</code> |
(<code class=char>-</code>), <code class=char>U+0030</code> |
203 |
<code class=char>U+0080</code> to <code class=char>U+D7FF</code>, or |
<code class=char>U+0080</code> to <code class=char>U+D7FF</code>, or |
204 |
<code class=char>U+E000</code> to <code class=char>U+10FFFF</code> in |
<code class=char>U+E000</code> to <code class=char>U+10FFFF</code> in |
205 |
<var>n</var>, then replace it by string <code>\<var>HHHHHH</var></code>, where |
<var>n</var>, then replace it by string <code>\<var>HHHHHH</var></code>, where |
206 |
<dfn id=var-HHHHHH><var>HHHHHH</var></dfn> is the upper$B!>(Bcase zero$B!>(Bpadded |
<dfn id=var-ident-HHHHHH><var>HHHHHH</var></dfn> is the uppercase |
207 |
hexadecimal representation of the character. If the character |
zero$B!>(Bpadded hexadecimal representation of the character. If the character |
208 |
is outside the range of <code>[<code class=char>U+0000</code>, |
is outside the range of <code>[<code class=char>U+0000</code>, |
209 |
<code class=char>U+10FFFF</code>]</code>, <var>HHHHHH</var> |
<code class=char>U+10FFFF</code>]</code>, <var>HHHHHH</var> |
210 |
<em class=rfc2119>MUST</em> be <code>FFFFFF</code>.</li> |
<em class=rfc2119>MUST</em> be <code>FFFFFF</code>.</li> |
235 |
<li>Then, <var>n</var> is the result of the algorithm.</li> |
<li>Then, <var>n</var> is the result of the algorithm.</li> |
236 |
</ol> |
</ol> |
237 |
|
|
238 |
<p>To <dfn id=algorithm-normalize-a-string title="normalize a STRING">normalize |
<p>To <dfn id=algorithm-normalize-a-string title="normalize a string (STRING or IDENT) as a STRING">normalize |
239 |
a <code>STRING</code> (<dfn id=var-s><var>s</var></dfn>)</dfn>, |
a string (<dfn id=var-s><var>s</var></dfn>) as a <code>STRING</code></dfn>, |
240 |
the following algorithm <em class=rfc2119>MUST</em> be used:</p> |
the following algorithm <em class=rfc2119>MUST</em> be used:</p> |
241 |
<ol> |
<ol> |
242 |
<li><p>Replace the escape sequences (<code>\</code> and following |
<li>If <var>s</var> is either an <code>IDENT</code> or a |
243 |
characters) in <var>s</var> by characters represented by them |
<code>STRING</code>, replace the escape sequences (<code>\</code> and |
244 |
|
following characters) in <var>s</var> by characters represented by them |
245 |
(or an empty string if <code>\</code> is immediately followed by |
(or an empty string if <code>\</code> is immediately followed by |
246 |
newline character(s)) respectively.</p></li> |
newline character(s)) respectively.</li> |
247 |
<li><p>Remove the quotation characters in <var>s</var> |
<li>If <var>s</var> is a <code>STRING</code>, remove the quotation marks |
248 |
if <var>s</var> is a <code>STRING</code>.</p> |
enclosing <var>s</var>.</li> |
|
|
|
|
<div class="note memo"> |
|
|
<p>The input <var>s</var> to this algorithm may be an |
|
|
<code>IDENT</code>.</p> |
|
|
</div></li> |
|
249 |
<li><p>If there is any character that is <em>not</em> one of |
<li><p>If there is any character that is <em>not</em> one of |
250 |
<code class=char>U+0020</code> <code class=charname>SPACE</code>, |
<code class=char>U+0020</code> <code class=charname>SPACE</code>, |
251 |
<code class=char>U+0021</code> <code class=charname>EXCLAMATION MARK</code> |
<code class=char>U+0021</code> <code class=charname>EXCLAMATION MARK</code> |
256 |
SQUARE BRACKET</code> to <code class=char>U+D7FF</code>, or |
SQUARE BRACKET</code> to <code class=char>U+D7FF</code>, or |
257 |
<code class=char>U+E000</code> to <code class=char>U+10FFFF</code> in |
<code class=char>U+E000</code> to <code class=char>U+10FFFF</code> in |
258 |
<var>s</var>, then replace it by string <code>\<var>HHHHHH</var></code>, where |
<var>s</var>, then replace it by string <code>\<var>HHHHHH</var></code>, where |
259 |
<dfn id=var-HHHHHH><var>HHHHHH</var></dfn> is the upper$B!>(Bcase zero$B!>(Bpadded |
<dfn id=var-string-HHHHHH><var>HHHHHH</var></dfn> is the uppercase |
260 |
hexadecimal representation of the character. If the character |
zero$B!>(Bpadded hexadecimal representation of the character. If the character |
261 |
is outside the range of <code>[<code class=char>U+0000</code>, |
is outside the range of <code>[<code class=char>U+0000</code>, |
262 |
<code class=char>U+10FFFF</code>]</code>, <var>HHHHHH</var> |
<code class=char>U+10FFFF</code>]</code>, <var>HHHHHH</var> |
263 |
<em class=rfc2119>MUST</em> be <code>FFFFFF</code>.</p></li> |
<em class=rfc2119>MUST</em> be <code>FFFFFF</code>.</p></li> |
292 |
representations are literally compared.</p> |
representations are literally compared.</p> |
293 |
</div> |
</div> |
294 |
|
|
295 |
|
<div class="issue ed"> |
296 |
|
<p>In a future version of the specification, we need to define |
297 |
|
<dfn id=lowercase>lowercase</dfn> (maybe by referencing some version of |
298 |
|
some module of <abbr>CSS</abbr>). It is <code>tr/A-Z/a-z/</code> for now.</p> |
299 |
|
</div> |
300 |
|
|
301 |
|
<p>To |
302 |
|
<dfn id=algorithm-normalize-an-integer title="normalize an integer">normalize |
303 |
|
an integer (<dfn id=var-int-i><var>i</var></dfn>)</dfn>, the following |
304 |
|
algorithm <em class=rfc2119>MUST</em> be used:</p> |
305 |
|
<ol class=algorithm> |
306 |
|
<li>If <var>i</var> is equal to zero (0), return a string with only a |
307 |
|
character: <code class=char>U+0030</code> |
308 |
|
<code class=charname>DIGIT ZERO</code> (<code class=char>0</code>). |
309 |
|
Stop the algorithm.</li> |
310 |
|
<li>Let <dfn id=var-int-result><var>result</var></dfn> be an empty string.</li> |
311 |
|
<li>If <var>i</var> is less than zero (0), append a |
312 |
|
<code class=char>U+002D</code> <code class=charname>HYPHEN-MINUS</code> |
313 |
|
(<code class=char>-</code>) character to <var>result</var>.</li> |
314 |
|
<li>Append the decimal representation of the absolute value of |
315 |
|
<var>i</var> to <var>result</var>. The decimal (base$B!>(Bten) representation |
316 |
|
<em class=rfc2119>MUST NOT</em> begin with a <code class=char>U+0030</code> |
317 |
|
<code class=charname>DIGIT ZERO</code> (<code class=char>0</code>) |
318 |
|
character.</li> |
319 |
|
<li>Return <var>result</var>.</li> |
320 |
|
</ol> |
321 |
|
|
322 |
</div> |
</div> |
323 |
|
|
324 |
|
|
341 |
<dt>If <var>ss</var> is a type or universal selector</dt> |
<dt>If <var>ss</var> is a type or universal selector</dt> |
342 |
<dd> |
<dd> |
343 |
<ol> |
<ol> |
344 |
<li> |
<li>Append a namespace prefix as following: |
345 |
|
|
346 |
<dl class=switch> |
<dl class=switch> |
347 |
<dt>If a namespace URI is specified (via namespace prefix, or |
<dt>If a namespace URI is specified (via namespace prefix, or |
348 |
by omitting namespace prefix where a default namespace is specified)</dt> |
by omitting namespace prefix where a default namespace is specified)</dt> |
349 |
<dd class="ed">@@</dd> |
<dd>Append the namespace URI as a |
350 |
|
<a href="#algorithm-normalize-an-ident" title="normalize a string as an IDENT">normalized |
351 |
|
<code>IDENT</code></a> to <var>r</var>. Then, append a |
352 |
|
<code class=char>U+007C</code> |
353 |
|
<code class=charname>VERTICAL BAR</code> (<code class=char>|</code>) |
354 |
|
character to <var>r</var>.</dd> |
355 |
<dt>If the null namespace is specified (by zero$B!>(Blength namespace |
<dt>If the null namespace is specified (by zero$B!>(Blength namespace |
356 |
prefix)</dt> |
prefix)</dt> |
357 |
<dd>Append a <code class=char>U+007C</code> |
<dd>Append a <code class=char>U+007C</code> |
368 |
</dl> |
</dl> |
369 |
</li> |
</li> |
370 |
<li>If <var>ss</var> is a type selector, append the |
<li>If <var>ss</var> is a type selector, append the |
371 |
<a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
<a href="#algorithm-normalize-an-ident" title="normalize a string (IDENT) an IDENT">normalized</a> |
372 |
local name to <var>r</var>.</li> |
local name to <var>r</var>.</li> |
373 |
<li>If <var>ss</var> is a universal selector, append |
<li>If <var>ss</var> is a universal selector, append |
374 |
a <code class=char>U+002A</code> <code class=charname>ASTERISK</code> |
a <code class=char>U+002A</code> <code class=charname>ASTERISK</code> |
385 |
Append a namespace prefix as following: |
Append a namespace prefix as following: |
386 |
<dl> |
<dl> |
387 |
<dt>If a namespace URI is specified</dt> |
<dt>If a namespace URI is specified</dt> |
388 |
<dd class=ed>@@</dd> |
<dd>Append the namespace URI as a |
389 |
<dd class=ed>@@ Current reference implementation is wrong, |
<a href="#algorithm-normalize-an-ident" title="normalize a string as an IDENT">normalized |
390 |
since its result of sorting depends on namespace prefix.</dd> |
<code>IDENT</code></a> to <var>r</var>. Then, append a |
391 |
|
<code class=char>U+007C</code> |
392 |
|
<code class=charname>VERTICAL BAR</code> (<code class=char>|</code>) |
393 |
|
character to <var>r</var>.</dd> |
394 |
<dt>If the null namespace is specified</dt> |
<dt>If the null namespace is specified</dt> |
395 |
<dd>Append a <code class=char>U+007C</code> |
<dd>Append a <code class=char>U+007C</code> |
396 |
<code class=charname>VERTICAL BAR</code> character to |
<code class=charname>VERTICAL BAR</code> character to |
404 |
</dl> |
</dl> |
405 |
</li> |
</li> |
406 |
<li>Append the |
<li>Append the |
407 |
<a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
<a href="#algorithm-normalize-an-ident" title="normalize a string (IDENT) as an IDENT">normalized</a> |
408 |
local name to <var>r</var>.</li> |
local name to <var>r</var>.</li> |
409 |
<li>If a value is specified in <var>ss</var>: |
<li>If a value is specified in <var>ss</var>: |
410 |
<ol> |
<ol> |
424 |
<dt>If <var>ss</var> is a class selector</dt> |
<dt>If <var>ss</var> is a class selector</dt> |
425 |
<dd>Append a <code class=char>U+002E</code> <code class=charname>FULL |
<dd>Append a <code class=char>U+002E</code> <code class=charname>FULL |
426 |
STOP</code> (<code class=char>.</code>) character, followed |
STOP</code> (<code class=char>.</code>) character, followed |
427 |
by <a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
by <a href="#algorithm-normalize-an-ident" title="normalize a string (IDENT) as an IDENT">normalized</a> |
428 |
class name, to <var>r</var>.</dd> |
class name, to <var>r</var>.</dd> |
429 |
<dt>If <var>ss</var> is an <abbr>ID</abbr> selector</dt> |
<dt>If <var>ss</var> is an <abbr>ID</abbr> selector</dt> |
430 |
<dd>Append a <code class=char>U+0023</code> <code class=charname>NUMBER |
<dd>Append a <code class=char>U+0023</code> <code class=charname>NUMBER |
431 |
SIGN</code> (<code class=char>#</code>) character, followed |
SIGN</code> (<code class=char>#</code>) character, followed |
432 |
by <a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
by <a href="#algorithm-normalize-an-ident" title="normalize a string (HASH except for the leading #) as an IDENT">normalized</a> |
433 |
<abbr>ID</abbr>, to <var>r</var>.</dd> |
<abbr>ID</abbr>, to <var>r</var>.</dd> |
434 |
<dt>If <var>ss</var> is a pseudo$B!>(Bclass selector</dt> |
<dt>If <var>ss</var> is a pseudo$B!>(Bclass selector</dt> |
435 |
<dd> |
<dd> |
438 |
<code class=charname>COLON</code> (<code class=char>:</code>) character |
<code class=charname>COLON</code> (<code class=char>:</code>) character |
439 |
to <var>r</var>.</li> |
to <var>r</var>.</li> |
440 |
<li>Append the |
<li>Append the |
441 |
<a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
<a href="#algorithm-normalize-an-ident" title="normalize a string (IDENT) as an IDENT">normalized</a> |
442 |
name of the pseudo$B!>(Bclass to <var>r</var>.</li> |
name (in <a href="#lowercase">lowercase</a>) of the pseudo$B!>(Bclass to |
443 |
|
<var>r</var>.</li> |
444 |
<li>Append any arguments as following: |
<li>Append any arguments as following: |
445 |
<dl class=switch> |
<dl class=switch> |
446 |
<dt>If the name of the pseudo$B!>(Bclass is <code>lang</code></dt> |
<dt>If the name of the pseudo$B!>(Bclass is <code>lang</code></dt> |
450 |
PARENTHESIS</code> (<code class=char>(</code>) character |
PARENTHESIS</code> (<code class=char>(</code>) character |
451 |
to <var>r</var>.</li> |
to <var>r</var>.</li> |
452 |
<li>Append the |
<li>Append the |
453 |
<a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
<a href="#algorithm-normalize-an-ident" title="normalize a string (IDENT) as an IDENT">normalized</a> |
454 |
language tag (the argument) to <var>r</var>.</li> |
language tag (the argument) to <var>r</var>. |
455 |
|
<span class="issue ed">Should we normalize cases?</span></li> |
456 |
<li>Append a <code class=char>U+0029</code> |
<li>Append a <code class=char>U+0029</code> |
457 |
<code class=charname>RIGHT PARENTHESIS</code> |
<code class=charname>RIGHT PARENTHESIS</code> |
458 |
(<code class=char>)</code>) character |
(<code class=char>)</code>) character |
483 |
<li>Append a <code class=char>U+0028</code> <code class=charname>LEFT |
<li>Append a <code class=char>U+0028</code> <code class=charname>LEFT |
484 |
PARENTHESIS</code> (<code class=char>(</code>) character |
PARENTHESIS</code> (<code class=char>(</code>) character |
485 |
to <var>r</var>.</li> |
to <var>r</var>.</li> |
486 |
<li>Append <span class=ed>@@ normalized</span> |
<li>Let <dfn id=var-a><var>a</var></dfn> be the <var>a</var> |
487 |
integer <var>a</var> to <var>r</var>. |
part of the argument. If the argument is a keyword <code>odd</code> |
488 |
If the argument is a keyword <code>odd</code> or <code>even</code>, |
or <code>even</code>, then let <var>a</var> be <code>2</code>. |
489 |
<var>a</var> is <code>2</code>. If <var>a</var> and |
If the <var>a</var> part with following <code>n</code> character |
490 |
<code>n</code> is omitted, <var>a</var> is assumed as |
is omitted, then let <var>a</var> be <code>0</code>. |
491 |
<code>0</code>. Otherwise, if <var>a</var> is omitted, |
Otherwise, if only the <var>a</var> part is omitted, then |
492 |
it is assumed as <code>1</code> (or <code>-1</code>, |
let <var>a</var> be <code>1</code>. Otherwise, if the <var>a</var> |
493 |
if there is a <code class=char>U+002D</code> |
part is <code>-</code>, then let <var>a</var> be |
494 |
<code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>) |
<code>-1</code>.</li> |
495 |
character).</li> |
<li>Let <var>a</var> be the |
496 |
|
<a href="#algorithm-normalize-an-integer" title="normalize an integer">normalized |
497 |
|
string representation</a> of integer <var>a</var>.</li> |
498 |
|
<li>Append <var>a</var> to <var>r</var>.</li> |
499 |
<li>Append a <code class=char>U+006E</code> |
<li>Append a <code class=char>U+006E</code> |
500 |
<code class=charname>LATIN SMALL LETTER N</code> |
<code class=charname>LATIN SMALL LETTER N</code> |
501 |
(<code class=char>n</code>) character to <var>r</var>.</li> |
(<code class=char>n</code>) character to <var>r</var>.</li> |
502 |
<li>Append <span class=ed>@@ normalized</span> |
<li>Let <dfn id=var-b><var>b</var></dfn> be the <var>b</var> |
503 |
integer <var>b</var> to <var>r</var>. |
part of the argument. If the argument is a keyword <code>odd</code>, |
504 |
It <em class=rfc2119>MUST</em> be preceded by a sign, |
then let <var>b</var> be <code>1</code>. If the argument is a |
505 |
either <code class=char>U+002B</code> <code class=charname>PLUS |
keyword <code>even</code>, then let <var>b</var> be <code>0</code>. |
506 |
SIGN</code> (<code class=char>+</code>) or |
If the <var>b</var> part is omitted, then let <var>b</var> be |
507 |
<code class=char>U+002D</code> |
<code>0</code>.</li> |
508 |
|
<li>Let <var>b</var> be the |
509 |
|
<a href="#algorithm-normalize-an-integer" title="normalize an integer">normalized |
510 |
|
string representation</a> of integer <var>b</var>.</li> |
511 |
|
<li>If <var>b</var> does <em>not</em> start with a |
512 |
|
<code class=char>U+002D</code> |
513 |
<code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>) |
<code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>) |
514 |
character. If the argument is a keyword <code>odd</code>, |
character, then append <code class=char>U+002B</code> |
515 |
<var>b</var> is <code>1</code>. If the argument |
<code class=charname>PLUS SIGN</code> |
516 |
is a keyword <code>even</code>, <var>b</var> is |
(<code class=char>+</code>) to <var>r</var>.</li> |
517 |
<code>0</code>. If <var>b</var> is omitted, it is assumed as |
<li>Append <var>b</var> to <var>r</var>.</li> |
|
<code>0</code>. The sign of <code>0</code> |
|
|
<em class=rfc2119>MUST</em> be <code class=char>U+002B</code> |
|
|
<code class=charname>PLUS SIGN</code> |
|
|
(<code class=char>+</code>).</li> |
|
518 |
<li>Append a <code class=char>U+0029</code> |
<li>Append a <code class=char>U+0029</code> |
519 |
<code class=charname>RIGHT PARENTHESIS</code> |
<code class=charname>RIGHT PARENTHESIS</code> |
520 |
(<code class=char>)</code>) character |
(<code class=char>)</code>) character |
570 |
<code class=charname>COLON</code> characters (<code>::</code>) |
<code class=charname>COLON</code> characters (<code>::</code>) |
571 |
to <var>r</var>.</li> |
to <var>r</var>.</li> |
572 |
<li>Append the |
<li>Append the |
573 |
<a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a> |
<a href="#algorithm-normalize-an-ident" title="normalize a string (IDENT) as an IDENT">normalized</a> |
574 |
name of the pseudo$B!>(Belement to <var>r</var>.</li> |
name (in <a href="#lowercase">lowercase</a>) of the pseudo$B!>(Belement |
575 |
|
to <var>r</var>.</li> |
576 |
<li>If the pseudo$B!>(Belement has any arguments: |
<li>If the pseudo$B!>(Belement has any arguments: |
577 |
The pseudo$B!>(Belement is not supported by this version of |
The pseudo$B!>(Belement is not supported by this version of |
578 |
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
595 |
<h3>Serializing Groups of Selectors</h3> |
<h3>Serializing Groups of Selectors</h3> |
596 |
|
|
597 |
<p>No <abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
<p>No <abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
598 |
representation is defined for an invalid group of selectors.</p> |
representation is defined for an invalid |
599 |
|
<a href="http://www.w3.org/TR/css3-selectors/#grouping">group of |
600 |
|
selectors</a>.</p> |
601 |
|
|
602 |
<p>To |
<p>To |
603 |
<dfn id=algorithm-serialize-a-group-of-selectors title="serialize a group of selectors">serialize |
<dfn id=algorithm-serialize-a-group-of-selectors title="serialize a group of selectors">serialize |
609 |
<var>gs</var>: |
<var>gs</var>: |
610 |
<ol> |
<ol> |
611 |
<li>If <var>selector</var> is <em>not</em> the first selector |
<li>If <var>selector</var> is <em>not</em> the first selector |
612 |
in the group of selectors, then append a <code class=char>U+002C</code> |
in the <var>gs</var>, then append a <code class=char>U+002C</code> |
613 |
<code class=charname>COMMA</code> (<code class=char>,</code>) followed by a |
<code class=charname>COMMA</code> (<code class=char>,</code>) followed by a |
614 |
<a href="#newline">newline</a> to <var>result</var>.</li> |
<a href="#newline">newline</a> to <var>result</var>.</li> |
615 |
<li>Append four <code class=char>U+0020</code> |
<li>Append four <code class=char>U+0020</code> |
621 |
(<dfn id=var-sss><var>sss</var></dfn>)</dt> |
(<dfn id=var-sss><var>sss</var></dfn>)</dt> |
622 |
<dd> |
<dd> |
623 |
<ol> |
<ol> |
624 |
<li class=ed><a href="#algorithm-serialize-a-simple-selector">Serialize |
<li>If <var>sss</var> contains a universal or type selector, then |
625 |
each simple selector</a> in <var>sss</var>.</li> |
<a href="#algorithm-serialize-a-simple-selector" title="serialize a simple selector">serialize |
626 |
<li class=ed>sort</li> |
that simple selector</a> and append the result to |
627 |
|
<var>result</var>.</li> |
628 |
|
<li>Otherwise, i.e. if <var>sss</var> does not contain a universal or |
629 |
|
type selector, then |
630 |
|
<a href="#algorithm-serialize-a-simple-selector" title="serialize a simple selector">serialize |
631 |
|
a simple selector <code>*</code></a> and append the result to |
632 |
|
<var>result</var>.</li> |
633 |
|
<li><a href="#algorithm-serialize-a-simple-selector" title="serialize a simple selector">Serialize |
634 |
|
any attribute selectors</a> in <var>sss</var>, sort the results, |
635 |
|
then append them to <var>result</var> in order.</li> |
636 |
|
<li><a href="#algorithm-serialize-a-simple-selector" title="serialize a simple selector">Serialize |
637 |
|
any class selectors</a> in <var>sss</var>, sort the results, |
638 |
|
then append them to <var>result</var> in order.</li> |
639 |
|
<li><a href="#algorithm-serialize-a-simple-selector" title="serialize a simple selector">Serialize |
640 |
|
any <abbr>ID</abbr> selectors</a> in <var>sss</var>, sort the results, |
641 |
|
then append them to <var>result</var> in order.</li> |
642 |
|
<li><a href="#algorithm-serialize-a-simple-selector" title="serialize a simple selector">Serialize |
643 |
|
any pseudo$B!>(Bclass selectors</a> in <var>sss</var>, sort the results, |
644 |
|
then append them to <var>result</var> in order.</li> |
645 |
|
<li><a href="#algorithm-serialize-a-simple-selector" title="serialize a simple selector">Serialize |
646 |
|
any pseudo elements</a> in <var>sss</var>, sort the results, |
647 |
|
then append them to <var>result</var> in order.</li> |
648 |
<li>Append a <a href="#newline">newline</a> to <var>result</var>.</li> |
<li>Append a <a href="#newline">newline</a> to <var>result</var>.</li> |
649 |
</ol> |
</ol> |
650 |
</dd> |
</dd> |
697 |
<div class="section" id="parsing"> |
<div class="section" id="parsing"> |
698 |
<h2>Parsing |
<h2>Parsing |
699 |
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
700 |
Groups of Selectors</h2> |
Representations of Selectors</h2> |
701 |
|
|
702 |
<p>Since <a href="#serializing">the serializing algorithm</a> is |
<p>Since <a href="#algorithm-serialize-a-group-of-selectors">the serializing |
703 |
so designed that it always output a valid |
algorithm for groups of selectors</a> is so designed that it always outputs a |
704 |
<a href="http://www.w3.org/TR/css3-selectors/#grouping">group of |
valid <a href="http://www.w3.org/TR/css3-selectors/#grouping">group of |
705 |
selectors</a>, no special parser for the |
selectors</a>, no special parser for the |
706 |
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
707 |
representation is necessary. Any conforming parser for |
representation is necessary. Any conforming parser for |
708 |
<a href="http://www.w3.org/TR/css3-selectors/#grouping">groups of |
<a href="http://www.w3.org/TR/css3-selectors/#grouping">groups of |
709 |
selectors</a> <em class=rfc2119>MAY</em> be used |
selectors</a> <em class=rfc2119>MAY</em> be used |
710 |
to parse <abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
to parse <abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
711 |
representations of groups of selectors.</p> |
representations of |
712 |
|
<a href="http://www.w3.org/TR/css3-selectors/#grouping">groups of |
713 |
|
selectors</a>.</p> |
714 |
|
|
715 |
|
<p>Likewise, <a href="#algorithm-serialize-a-simple-selector">the serializing |
716 |
|
algorithm for simple selectors</a> always outputs a valid |
717 |
|
<a href="#simple-selector">simple selector</a> and therefore any |
718 |
|
conforming parser for <a href="#simple-selector">simple selector</a> |
719 |
|
<em class=rfc2119>MAY</em> be used to parse |
720 |
|
<abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
721 |
|
representations of <a href="#simple-selector">simple selectors</a>.</p> |
722 |
</div> |
</div> |
723 |
|
|
724 |
<div class="section" id="examples"> |
<div class="section" id="examples"> |
726 |
|
|
727 |
<p class=section-info>This section is <em>non$B!>(Bnormative</em>.</p> |
<p class=section-info>This section is <em>non$B!>(Bnormative</em>.</p> |
728 |
|
|
|
<div class="ed issue"> |
|
|
<p><a href="http://suika.fam.cx/gate/2007/css/parser-interface">Try demo</a>, |
|
|
by choosing <q>Selectors</q> radio button.</p> |
|
|
|
|
729 |
<div class="example figure block"> |
<div class="example figure block"> |
730 |
<div class="caption">...</div> |
<p>The <abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
731 |
|
representation of a selector <code>p + q</code> is:</p> |
732 |
|
|
733 |
<pre><code>...</code></pre> |
<pre><code> *|p |
734 |
|
+ *|q |
735 |
|
</code></pre> |
736 |
</div> |
</div> |
737 |
|
|
738 |
|
<div class="example figure block"> |
739 |
|
<p>The <abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
740 |
|
representation of a selector <code>a#id.class1:n\ot(:Active)/* |
741 |
|
comment |
742 |
|
*/.class2</code> is:</p> |
743 |
|
|
744 |
|
<pre><code> *|a.class1.class2#id:not( |
745 |
|
:active |
746 |
|
) |
747 |
|
</code></pre> |
748 |
|
</div> |
749 |
|
|
750 |
|
<div class="example figure block"> |
751 |
|
<p>The <abbr title="Selectors Serialization Format for Testing">SSFT</abbr> |
752 |
|
representation of a |
753 |
|
<a href="http://www.w3.org/TR/css3-selectors/#grouping">group of selectors</a> |
754 |
|
<code>a, #b, C[d^=e], .\31 23</code> is:</p> |
755 |
|
|
756 |
|
<pre><code> *|a |
757 |
|
, |
758 |
|
*|*#b |
759 |
|
, |
760 |
|
*|C[|d^="e"] |
761 |
|
, |
762 |
|
*|*.\00003123 |
763 |
|
</code></pre> |
764 |
</div> |
</div> |
765 |
|
|
766 |
</div> |
</div> |
779 |
<a href="urn:ietf:bcp:14"><abbr title="Best Current Practice">BCP</abbr> |
<a href="urn:ietf:bcp:14"><abbr title="Best Current Practice">BCP</abbr> |
780 |
14</a>, <abbr title="Request for Comments">RFC</abbr> 2119, |
14</a>, <abbr title="Request for Comments">RFC</abbr> 2119, |
781 |
<time datetime=1997-03>March 1997</time>. |
<time datetime=1997-03>March 1997</time>. |
782 |
This version of the specification is referenced</dd> |
This version of the specification is referenced.</dd> |
783 |
<dt id=ref-SELECTORS>SELECTORS</dt> |
<dt id=ref-SELECTORS>SELECTORS</dt> |
784 |
<dd><a href="http://www.w3.org/TR/2005/WD-css3-selectors-20051215"><cite>Selectors</cite></a>, |
<dd><a href="http://www.w3.org/TR/2005/WD-css3-selectors-20051215"><cite>Selectors</cite></a>, |
785 |
<abbr title="World Wide Web Consortium">W3C</abbr> Working Draft, |
<abbr title="World Wide Web Consortium">W3C</abbr> Working Draft, |
812 |
<dt id=ref-HTML5>HTML5</dt> |
<dt id=ref-HTML5>HTML5</dt> |
813 |
<dd><cite><a href="http://whatwg.org/html5"><abbr>HTML</abbr> 5</a></cite>, |
<dd><cite><a href="http://whatwg.org/html5"><abbr>HTML</abbr> 5</a></cite>, |
814 |
<abbr title="Web Hypertext Application Technology Working Group">WHATWG</abbr> |
<abbr title="Web Hypertext Application Technology Working Group">WHATWG</abbr> |
815 |
Working Draft. Work in progress.</dd> |
Working Draft, <time datetime="2007-11-03">3 November 2007</time>. |
816 |
|
Work in progress.</dd> |
817 |
<dt id=ref-SAPI>SAPI</dt> |
<dt id=ref-SAPI>SAPI</dt> |
818 |
<dd><cite><a href="http://dev.w3.org/cvsweb/~checkout~/2006/webapi/selectors-api/Overview.html?rev=1.28&content-type=text/html;%20charset=utf-8">Selectors <abbr>API</abbr></a></cite>, |
<dd><cite><a href="http://dev.w3.org/cvsweb/~checkout~/2006/webapi/selectors-api/Overview.html?rev=1.28&content-type=text/html;%20charset=utf-8">Selectors <abbr>API</abbr></a></cite>, |
819 |
<abbr title="World Wide Web Consortium">W3C</abbr> Editor's Draft, |
<abbr title="World Wide Web Consortium">W3C</abbr> Editor's Draft, |