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