/[suikacvs]/markup/selectors/ssft/ssft-work.en.html
Suika

Diff of /markup/selectors/ssft/ssft-work.en.html

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.11 by wakaba, Mon Oct 22 10:30:53 2007 UTC revision 1.22 by wakaba, Mon Nov 5 11:20:10 2007 UTC
# Line 10  Line 10 
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>Working Draft <time datetime=2007-11-05>5 November 2007</time></h2>
14    
15  <dl class="versions-uri">  <dl class="versions-uri">
16  <dt>This Version</dt>  <dt>This Version</dt>
# Line 52  available at <code class="URI">&lt;<a Line 52  available at <code class="URI">&lt;<a
52  <div id="abstract" class="section">  <div id="abstract" class="section">
53  <h2>Abstract</h2>  <h2>Abstract</h2>
54    
55  <div class="ed issue">...</div>  <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    
60  </div>  </div>
61    
# Line 98  in a tree structure and are used in Web Line 101  in a tree structure and are used in Web
101  <abbr>API</abbr></a>  <abbr>API</abbr></a>
102  <cite class="bibref informative">[<a href="#ref-SAPI">SAPI</a>]</cite>.</p>  <cite class="bibref informative">[<a href="#ref-SAPI">SAPI</a>]</cite>.</p>
103    
104  <div class="issue ed">...</div>  <p>It is so flexible language that a conceptually same pattern
105    can be represented in inifnite numbers of instances of selectors.
106    It might be convinient for e.g. validation of a test result to
107    define a subset of the language, in which no semantically equivalent
108    selectors are contained.</p>
109    
110  <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
111  <abbr title="Cascading Style Sheets Object Model">CSSOM</abbr>  <abbr title="Cascading Style Sheets Object Model">CSSOM</abbr>
# Line 111  attribute.  However, the algorithm is in Line 118  attribute.  However, the algorithm is in
118  <time datetime=2007-09-25>at the time of the writing</time>.    <time datetime=2007-09-25>at the time of the writing</time>.  
119  Note that current Web browser implementations  Note that current Web browser implementations
120  of the <code>selectorText</code> attribute are consistently broken  of the <code>selectorText</code> attribute are consistently broken
121  in not escaping unsafe identifiers.</p>  in not escaping unsafe identifiers and therefore it is not wise
122    to deploy that format for testing.</p>
123    
124  </div>  </div>
125    
# Line 120  in not escaping unsafe identifiers.</p> Line 128  in not escaping unsafe identifiers.</p>
128    
129  <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>,
130  <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>,
131  <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  
132  <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
133  document are to be interpreted as described in  document are to be interpreted as described in
134  <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>
135  2119</a>  2119</a>
136  <cite class="bibref normative">[<a href="#ref-KEYWORDS">KEYWORDS</a>]</cite>.</p>  <cite class="bibref normative">[<a href="#ref-KEYWORDS">KEYWORDS</a>]</cite>.</p>
137    
138    <p>Requirements phrased in the imperative as part of algorithms are to be
139    interpreted with the meaning of the key word (<em class=rfc2119>MUST</em>)
140    used in introducing the algorithm.</p>
141    
142    <p>Conformance requirements phrased as algorithms or specific steps
143    <em class=rfc2119>MAY</em> be implemented in any manner, so long as the end
144    result is equivalent.</p>
145    
146  <!-- Strictly speaking the paragraph below is not part of terminology. -->  <!-- Strictly speaking the paragraph below is not part of terminology. -->
147  <p>All examples and notes in this specification are non$B!>(Bnormative,  <p>All examples and notes in this specification are non$B!>(Bnormative,
148  as are all sections explicitly marked non$B!>(Bnormative.  Everything  as are all sections explicitly marked non$B!>(Bnormative.  Everything
# Line 140  simple selector in a selector.</p> Line 155  simple selector in a selector.</p>
155  </div>  </div>
156    
157  <div class="section" id="serializing">  <div class="section" id="serializing">
158  <h2>Serializing Groups of Selectors</h2>  <h2>Serializing Selectors in
159    <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
160  <div class="issue ed">  Representation</h2>
 <p><a href="http://suika.fam.cx/gate/cvs/*checkout*/markup/html/whatpm/Whatpm/CSS/SelectorsSerializer.pm">See the reference implementation</a>  
 for now.</p>  
 </div>  
161    
162  <p>No <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>  <p>Subsections of this section define algorithms
163  representation is defined for an invalid group of selectors.</p>  to <a href="#algorithm-serialize-a-simple-selector">serialize a simple
164    selector</a> or <a href="#algorithm-serialize-a-group-of-selectors">serialize
165    a group of selectors</a>.</p>
166    
167  <div class="note memo">  <div class="note memo">
168  <p>The serialized representation will not contain any comment.</p>  <p>The serialized representation will not contain any comment.</p>
169  </div>  </div>
170    
171  <!-- TODO: link terms to Selectors -->  <div class="ed issue"><p>TODO: link terms to Selectors</p></div>
172    
173  <p>To  <div class=section id=serializing-tokens>
174  <dfn id=algorithm-serialize-a-group-of-selectors title="serialize a group of selectors">serialize  <h3>Serializing Tokens</h3>
175  a group of selectors (<dfn id=var-gs><var>gs</var></dfn>)</dfn>:</p>  
176    <p>To <dfn id=algorithm-normalize-an-ident title="normalize a string as an IDENT">normalize
177    a string (<dfn id=var-n><var>n</var></dfn>) as an <code>IDENT</code></dfn>,
178    the following algorithm <em class=rfc2119>MUST</em> be used:</p>
179  <ol>  <ol>
180  <li>Let <dfn id=var-result><var>result</var></dfn> an empty string.</li>  <li>If <var>n</var> is either an <code>IDENT</code> or a <code>HASH</code>,
181  <li>For each selector (<dfn id=var-selector><var>selector</var></dfn>) in  replace the escape sequences (<code>\</code> and following characters) in
182  <var>gs</var>:  <var>n</var> by characters represented by them respectively.</li>
183    <ol>  <li>If <var>n</var> is a <code>HASH</code>, remove the leading
184    <li>If <var>selector</var> is <em>not</em> the first selector  <code class=char>U+0023</code> <code class=charname>NUMBER SIGN</code>
185    in the group of selectors, then append a <code class=char>U+002C</code>  (<code class=char>#</code>) character from <var>n</var>.</li>
186    <code class=charname>COMMA</code> (<code class=char>,</code>) followed by a  <li>If there is any character that is <em>not</em> one of
187    <a href="#newline">newline</a> to <var>result</var>.</li>  <code class=char>U+002D</code> <code class=charname>HYPHEN-MINUS</code>
188    <li>Append four <code class=char>U+0020</code>  (<code class=char>-</code>), <code class=char>U+0030</code>
189    <code class=charname>SPACE</code> characters to <var>result</var>.</li>  <code class=charname>DIGIT ZERO</code>
190    <li>Process each sequence of simple selectors or  (<code class=char>0</code>) to <code class=char>U+0039</code>
191    combinator in <var>selector</var> by following algorithm:  <code class=charname>DIGIT NINE</code> (<code class=char>9</code>),
192      <dl class=switch>  <code class=char>U+0041</code> <code class=charname>LATIN CAPITAL LETTER
193      <dt>If it is a sequence of simle selector  A</code> (<code class=char>A</code>) to <code class=char>U+005A</code>
194      (<dfn id=var-sss><var>sss</var></dfn>)</dt>  <code class=charname>LATIN CAPITAL LETTER Z</code> (<code class=char>Z</code>),
195        <dd>  <code class=char>U+005F</code> <code class=charname>LOW LINE</code>
196          <ol>  (<code class=char>_</code>), <code class=char>U+0061</code>
197          <li class=ed><a href="#algorithm-serialize-a-simple-selector">Serialize  <code class=charname>LATIN SMALL LETTER A</code>
198          each simple selector</a> in <var>sss</var>.</li>  (<code class=char>a</code>) to <code class=char>U+006A</code>
199          <li class=ed>sort</li>  <code class=charname>LATIN SMALL LETTER Z</code> (<code class=char>z</code>),
200          <li>Append a <a href="#newline">newline</a> to <var>result</var>.</li>  <code class=char>U+0080</code> to <code class=char>U+D7FF</code>, or
201          </ol>  <code class=char>U+E000</code> to <code class=char>U+10FFFF</code> in
202        </dd>  <var>n</var>, then replace it by string <code>\<var>HHHHHH</var></code>, where
203      <dt>If it is a combinator (<dfn id=var-c><var>c</var></dfn>)</dt>  <dfn id=var-ident-HHHHHH><var>HHHHHH</var></dfn> is the upper$B!>(Bcase
204        <dd>  zero$B!>(Bpadded hexadecimal representation of the character.  If the character
205          <ol>  is outside the range of <code>[<code class=char>U+0000</code>,
206          <li>Append two <code class=char>U+0020</code>  <code class=char>U+10FFFF</code>]</code>, <var>HHHHHH</var>
207          <code class=charname>SPACE</code> characters to <var>result</var>.</li>  <em class=rfc2119>MUST</em> be <code>FFFFFF</code>.</li>
208          <li>  <li>If the first character in <var>n</var> is one of
209            <dl class=switch>  <code class=char>U+0030</code> <code class=charname>DIGIT ZERO</code>
210            <dt>If <var>c</var> is descendant combinator (white space)</dt>  (<code class=char>0</code>) to <code class=char>U+0039</code>
211              <dd>Append a <code class=char>U+0020</code>  <code class=charname>DIGIT NINE</code> (<code class=char>9</code>),
212              <code class=charname>SPACE</code> character to  then prepend a string <code>\00003</code> at the beginning of
213              <var>result</var>.</dd>  <var>n</var>.</li>
214            <dt>If <var>c</var> is child combinator  <li>If the first character in <var>n</var> is <code class=char>U+002D</code>
215            (<code class=char>></code>)</dt>  <code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>) and
216              <dd>Append a <code class=char>U+003E</code>  the second character, if any, is <em>not</em> one of
217              <code class=charname>GREATER-THAN SIGN</code>  <code class=char>U+0041</code> <code class=charname>LATIN CAPITAL LETTER
218              (<code class=char>></code>) character to <var>result</var>.</dd>  A</code> (<code class=char>A</code>) to <code class=char>U+005A</code>
219            <dt>If <var>c</var> is adjacent sibling combinator  <code class=charname>LATIN CAPITAL LETTER Z</code> (<code class=char>Z</code>),
220            (<code class=char>+</code>)</dt>  <code class=char>U+005F</code> <code class=charname>LOW LINE</code>
221              <dd>Append a <code class=char>U+002B</code>  (<code class=char>_</code>), <code class=char>U+0061</code>
222              <code class=charname>PLUS SIGN</code> (<code class=char>+</code>)  <code class=charname>LATIN SMALL LETTER A</code>
223              character to <var>result</var>.</dd>  (<code class=char>a</code>) to <code class=char>U+006A</code>
224            <dt>If <var>c</var> is general sibling combinator  <code class=charname>LATIN SMALL LETTER Z</code> (<code class=char>z</code>),
225            (<code class=char>~</code>)</dt>  <code>U+0080</code> to <code>U+D7FF</code>, or
226              <dd>Append a <code class=char>U+007E</code>  <code>U+E000</code> to <code>U+10FFFF</code>, or
227              <code class=charname>TILDE</code> (<code class=char>~</code>)  <var>n</var> is equal to <code class=char>U+002D</code>
228              character to <var>result</var>.</dd>  <code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>), then
229            </dl>  replace the <code class=char>U+002D</code>
230          </li>  <code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>)
231          <li>Append a <code class=char>U+0020</code>  character by string <code>\00002D</code>.</li>
232          <code class=charname>SPACE</code> character to  <li>Then, <var>n</var> is the result of the algorithm.</li>
233          <var>result</var>.</li>  </ol>
234          </ol>  
235        </dd>  <p>To <dfn id=algorithm-normalize-a-string title="normalize a string (STRING or IDENT) as a STRING">normalize
236      </dl>  a string (<dfn id=var-s><var>s</var></dfn>) as a <code>STRING</code></dfn>,
237    </ol>  the following algorithm <em class=rfc2119>MUST</em> be used:</p>
238  </li>  <ol>
239  <li>Then, <var>result</var> is the  <li>If <var>s</var> is either an <code>IDENT</code> or a
240    <code>STRING</code>, replace the escape sequences (<code>\</code> and
241    following characters) in <var>s</var> by characters represented by them
242    (or an empty string if <code>\</code> is immediately followed by
243    newline character(s)) respectively.</li>
244    <li>If <var>s</var> is a <code>STRING</code>, remove the quotation marks
245    enclosing <var>s</var>.</li>
246    <li><p>If there is any character that is <em>not</em> one of
247    <code class=char>U+0020</code> <code class=charname>SPACE</code>,
248    <code class=char>U+0021</code> <code class=charname>EXCLAMATION MARK</code>
249    (<code class=char>!</code>), <code class=char>U+0023</code>
250    <code class=charname>NUMBER SIGN</code> (<code class=char>#</code>) to
251    <code class=char>U+005B</code> <code class=charname>LEFT SQUARE
252    BRACKET</code>, <code class=char>U+005D</code> <code class=charname>RIGHT
253    SQUARE BRACKET</code> to <code class=char>U+D7FF</code>, or
254    <code class=char>U+E000</code> to <code class=char>U+10FFFF</code> in
255    <var>s</var>, then replace it by string <code>\<var>HHHHHH</var></code>, where
256    <dfn id=var-string-HHHHHH><var>HHHHHH</var></dfn> is the upper$B!>(Bcase
257    zero$B!>(Bpadded hexadecimal representation of the character.  If the character
258    is outside the range of <code>[<code class=char>U+0000</code>,
259    <code class=char>U+10FFFF</code>]</code>, <var>HHHHHH</var>
260    <em class=rfc2119>MUST</em> be <code>FFFFFF</code>.</p></li>
261    <li><p>Insert a <code class=char>U+0022</code> <code class=charname>QUOTATION
262    MARK</code> (<code class=char>"</code>) at the beginning of
263    <var>s</var>.</p></li>
264    <li><p>Insert a <code class=char>U+0022</code> <code class=charname>QUOTATION
265    MARK</code> (<code class=char>"</code>) at the end of <var>s</var>.</p></li>
266    <li><p>Then, <var>s</var> is the result of the algorithm.</p></li>
267    </ol>
268    
269    <p>A <dfn id=newline title=newline>newline</dfn>
270    <em class=rfc2119>SHOULD</em> be represented as a
271    <code class=char>U+000A</code> <code class=charname>LINE FEED</code>
272    character.  However, depending on the context where
273    the <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
274    representation is in use, a sequence of
275    <code class=char>U+000D</code> <code class=charname>CARRIAGE RETURN</code>
276    followed by a <code class=char>U+000A</code>
277    <code class=charname>LINE FEED</code> (i.e. a
278    <code>CRLF</code> sequence) or a character
279    <code class=char>U+000D</code> <code class=charname>CARRIAGE RETURN</code>
280    <em class=rfc2119>MAY</em> be used as a <a href="#newline">newline</a> instead.
281    <a href="#newline">Newline</a> representations
282    <em class=rfc2119>SHOULD</em> be consistent in an
283  <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>  <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
284  representation of <var>gs</var>.</li>  representation.</p>
285    
286    <div class="note memo">
287    <p>Therefore, newlines must be normalized before
288    <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
289    representations are literally compared.</p>
290    </div>
291    
292    <div class="issue ed">
293    <p>Need to define <dfn id=lower-case>lower$B!>(Bcase</dfn>.
294    It is tr/A-Z/a-z/ for now.</p>
295    </div>
296    
297    <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    algorithm <em class=rfc2119>MUST</em> be used:</p>
301    <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>  </ol>
317    
318    </div>
319    
320    
321    <div class=section id=serializing-simple-selectors>
322    <h3>Serializing Simple Selectors</h3>
323    
324    <p>No <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
325    representation is defined for an invalid <a href="#simple-selector">simple
326    selector</a>.</p>
327    
328  <p>To  <p>To
329  <dfn id=algorithm-serialize-a-simple-selector title="serialize a simple selector">serialize  <dfn id=algorithm-serialize-a-simple-selector title="serialize a simple selector">serialize
330  a simple selector (<dfn><var id=var-ss>ss</var></dfn>)</dfn>:</p>  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    <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  <dl class=switch>  <dl class=switch>
337  <dt>If <var>ss</var> is a type or universal selector</dt>  <dt>If <var>ss</var> is a type or universal selector</dt>
338    <dd>    <dd>
339      <ol>      <ol>
340      <li>      <li>Append a namespace prefix as following:
341    
342        <dl class=switch>        <dl class=switch>
343        <dt>If a namespace URI is specified (via namespace prefix, or        <dt>If a namespace URI is specified (via namespace prefix, or
344        by omitting namespace prefix where a default namespace is specified)</dt>        by omitting namespace prefix where a default namespace is specified)</dt>
345          <dd class="ed">@@</dd>          <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        <dt>If the null namespace is specified (by zero$B!>(Blength namespace        <dt>If the null namespace is specified (by zero$B!>(Blength namespace
352        prefix)</dt>        prefix)</dt>
353          <dd>Append a <code class=char>U+007C</code>          <dd>Append a <code class=char>U+007C</code>
354          <code class=charname>VERTICAL BAR</code> (<code class=char>|</code>)          <code class=charname>VERTICAL BAR</code> (<code class=char>|</code>)
355          character to <var>result</var>.</dd>          character to <var>r</var>.</dd>
356        <dt>If no namespace is specified (by namespace prefix <code>*</code>,        <dt>If no namespace is specified (by namespace prefix <code>*</code>,
357        or by omitting namespace prefix where no default namespace is        or by omitting namespace prefix where no default namespace is
358        specified)</dt>        specified)</dt>
# Line 248  a simple selector (<dfn><var id=var-ss>s Line 360  a simple selector (<dfn><var id=var-ss>s
360          <code class=charname>ASTERISK</code> (<code class=char>*</code>)          <code class=charname>ASTERISK</code> (<code class=char>*</code>)
361          character, followed by a <code class=char>U+007C</code>          character, followed by a <code class=char>U+007C</code>
362          <code class=charname>VERTICAL BAR</code> (<code class=char>|</code>)          <code class=charname>VERTICAL BAR</code> (<code class=char>|</code>)
363          character, to <var>result</var>.</dd>          character, to <var>r</var>.</dd>
364        </dl>        </dl>
365      </li>      </li>
366      <li>If <var>ss</var> is a type selector, append the      <li>If <var>ss</var> is a type selector, append the
367      <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>
368      local name to <var>result</var>.</li>      local name to <var>r</var>.</li>
369      <li>If <var>ss</var> is a universal selector, append      <li>If <var>ss</var> is a universal selector, append
370      a <code class=char>U+002A</code> <code class=charname>ASTERISK</code>      a <code class=char>U+002A</code> <code class=charname>ASTERISK</code>
371      (<code class=char>*</code>) character to <var>result</var>.</li>      (<code class=char>*</code>) character to <var>r</var>.</li>
372      </ol>      </ol>
373    </dd>    </dd>
374  <dt>If <var>ss</var> is an attribute selector</dt>  <dt>If <var>ss</var> is an attribute selector</dt>
# Line 264  a simple selector (<dfn><var id=var-ss>s Line 376  a simple selector (<dfn><var id=var-ss>s
376      <ol>      <ol>
377      <li>Append a <code class=char>U+005B</code> <code class=charname>LEFT      <li>Append a <code class=char>U+005B</code> <code class=charname>LEFT
378      SQUARE BRACKET</code> (<code class=char>[</code>) to      SQUARE BRACKET</code> (<code class=char>[</code>) to
379      <var>result</var>.</li>      <var>r</var>.</li>
380      <li>      <li>
381        Append a namespace prefix as following:        Append a namespace prefix as following:
382        <dl>        <dl>
383        <dt>If a namespace URI is specified</dt>        <dt>If a namespace URI is specified</dt>
384          <dd class=ed>@@</dd>          <dd>Append the namespace URI as a
385          <dd class=ed>@@ Current reference implementation is wrong,          <a href="#algorithm-normalize-an-ident" title="normalize a string as an IDENT">normalized
386          since its result of sorting depends on namespace prefix.</dd>          <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        <dt>If the null namespace is specified</dt>        <dt>If the null namespace is specified</dt>
391          <dd>Append a <code class=char>U+007C</code>          <dd>Append a <code class=char>U+007C</code>
392          <code class=charname>VERTICAL BAR</code> character to          <code class=charname>VERTICAL BAR</code> character to
393          <var>result</var>.</dd>          <var>r</var>.</dd>
394        <dt>If no namespace is specified</dt>        <dt>If no namespace is specified</dt>
395          <dd>Append a <code class=char>U+002A</code>          <dd>Append a <code class=char>U+002A</code>
396          <code class=charname>ASTERISK</code> (<code class=char>*</code>)          <code class=charname>ASTERISK</code> (<code class=char>*</code>)
397          character, followed by a <code class=char>U+007C</code>          character, followed by a <code class=char>U+007C</code>
398          <code class=charname>VERTICAL BAR</code> (<code class=char>|</code>)          <code class=charname>VERTICAL BAR</code> (<code class=char>|</code>)
399          character, to <var>result</var>.</dd>          character, to <var>r</var>.</dd>
400        </dl>        </dl>
401      </li>      </li>
402      <li>Append the      <li>Append the
403      <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>
404      local name to <var>result</var>.</li>      local name to <var>r</var>.</li>
405      <li>If a value is specified in <var>ss</var>:      <li>If a value is specified in <var>ss</var>:
406        <ol>        <ol>
407        <li>Depending on the way to match, append <code>=</code>,        <li>Depending on the way to match, append <code>=</code>,
408        <code>~=</code>, <code>|=</code>, <code>^=</code>,        <code>~=</code>, <code>|=</code>, <code>^=</code>,
409        <code>$=</code>, or <code>*=</code> to <var>result</var>.</li>        <code>$=</code>, or <code>*=</code> to <var>r</var>.</li>
410        <li>Append the        <li>Append the
411        <a href="#algorithm-normalize-a-string" title="normalize a string">normalized</a>        <a href="#algorithm-normalize-a-string" title="normalize a string">normalized</a>
412        value to <var>result</var>.</li>        value to <var>r</var>.</li>
413        </ol>        </ol>
414      </li>      </li>
415      <li>Append a <code class=char>U+005D</code> <code class=charname>RIGHT      <li>Append a <code class=char>U+005D</code> <code class=charname>RIGHT
416      SQUARE BRACKET</code> (<code class=char>]</code>) to      SQUARE BRACKET</code> (<code class=char>]</code>) to
417      <var>result</var>.</li>      <var>r</var>.</li>
418      </ol>      </ol>
419    </dd>    </dd>
420  <dt>If <var>ss</var> is a class selector</dt>  <dt>If <var>ss</var> is a class selector</dt>
421    <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
422    STOP</code> (<code class=char>.</code>) character, followed    STOP</code> (<code class=char>.</code>) character, followed
423    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>
424    class name, <var>result</var>.</dd>    class name, to <var>r</var>.</dd>
425  <dt>If <var>ss</var> is an <abbr>ID</abbr> selector</dt>  <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    <dd>Append a <code class=char>U+0023</code> <code class=charname>NUMBER
427    SIGN</code> (<code class=char>#</code>) character, followed    SIGN</code> (<code class=char>#</code>) character, followed
428    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>
429    <abbr>ID</abbr>, to <var>result</var>.</dd>    <abbr>ID</abbr>, to <var>r</var>.</dd>
430  <dt>If <var>ss</var> is a pseudo$B!>(Bclass selector</dt>  <dt>If <var>ss</var> is a pseudo$B!>(Bclass selector</dt>
431    <dd>    <dd>
432      <ol>      <ol>
433      <li>Append a <code class=char>U+003A</code>      <li>Append a <code class=char>U+003A</code>
434      <code class=charname>COLON</code> (<code class=char>:</code>) character      <code class=charname>COLON</code> (<code class=char>:</code>) character
435      to <var>result</var>.</li>      to <var>r</var>.</li>
436      <li>Append the      <li>Append the
437      <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>
438      name of the pseudo$B!>(Bclass to <var>result</var>.</li>      name (in <a href="#lower-case">lower$B!>(Bcase</a>) of the pseudo$B!>(Bclass to
439        <var>r</var>.</li>
440      <li>Append any arguments as following:      <li>Append any arguments as following:
441        <dl class=switch>        <dl class=switch>
442        <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>
# Line 328  a simple selector (<dfn><var id=var-ss>s Line 444  a simple selector (<dfn><var id=var-ss>s
444            <ol>            <ol>
445            <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
446            PARENTHESIS</code> (<code class=char>(</code>) character            PARENTHESIS</code> (<code class=char>(</code>) character
447            to <var>result</var>.</li>            to <var>r</var>.</li>
448            <li>Append the            <li>Append the
449            <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>
450            language tag (the argument) to <var>result</var>.</li>            language tag (the argument) to <var>r</var>.
451              <span class="issue ed">Should we normalize cases?</span></li>
452            <li>Append a <code class=char>U+0029</code>            <li>Append a <code class=char>U+0029</code>
453            <code class=charname>RIGHT PARENTHESIS</code>            <code class=charname>RIGHT PARENTHESIS</code>
454            (<code class=char>)</code>) character            (<code class=char>)</code>) character
455            to <var>result</var>.</li>            to <var>r</var>.</li>
456            </ol>            </ol>
457          </dd>          </dd>
458        <dt>If the name of the pseudo$B!>(Bclass is        <dt>If the name of the pseudo$B!>(Bclass is
# Line 344  a simple selector (<dfn><var id=var-ss>s Line 461  a simple selector (<dfn><var id=var-ss>s
461            <ol>            <ol>
462            <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
463            PARENTHESIS</code> (<code class=char>(</code>) character            PARENTHESIS</code> (<code class=char>(</code>) character
464            to <var>result</var>.</li>            to <var>r</var>.</li>
465            <li>Append the            <li>Append the
466            <a href="#algorithm-normalize-a-string" title="normalize a string">normalized</a>            <a href="#algorithm-normalize-a-string" title="normalize a string">normalized</a>
467            string (the argument) to <var>result</var>.</li>            string (the argument) to <var>r</var>.</li>
468            <li>Append a <code class=char>U+0029</code>            <li>Append a <code class=char>U+0029</code>
469            <code class=charname>RIGHT PARENTHESIS</code>            <code class=charname>RIGHT PARENTHESIS</code>
470            (<code class=char>)</code>) character            (<code class=char>)</code>) character
471            to <var>result</var>.</li>            to <var>r</var>.</li>
472            </ol>            </ol>
473          </dd>          </dd>
474        <dt>If name of the pseudo$B!>(Bclass is either <code>nth-child</code>,        <dt>If name of the pseudo$B!>(Bclass is either <code>nth-child</code>,
# Line 361  a simple selector (<dfn><var id=var-ss>s Line 478  a simple selector (<dfn><var id=var-ss>s
478            <ol>            <ol>
479            <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
480            PARENTHESIS</code> (<code class=char>(</code>) character            PARENTHESIS</code> (<code class=char>(</code>) character
481            to <var>result</var>.</li>            to <var>r</var>.</li>
482            <li>Append <span class=ed>@@ normalized</span>            <li>Let <dfn id=var-a><var>a</var></dfn> be the <var>a</var>
483            integer <var>a</var> to <var>result</var>.            part of the argument.  If the argument is a keyword <code>odd</code>
484            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>.
485            <var>a</var> is <code>2</code>.  If <var>a</var> and            If the <var>a</var> part with following <code>n</code> character
486            <code>n</code> is omitted, <var>a</var> is assumed as            is omitted, then let <var>a</var> be <code>0</code>.
487            <code>0</code>.  Otherwise, if <var>a</var> is omitted,            Otherwise, if only the <var>a</var> part is omitted, then
488            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>
489            if there is a <code class=char>U+002D</code>            part is <code>-</code>, then let <var>a</var> be
490            <code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>)            <code>-1</code>.</li>
491            character).</li>            <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              <li>Append <var>a</var> to <var>result</var>.</li>
495            <li>Append a <code class=char>U+006E</code>            <li>Append a <code class=char>U+006E</code>
496            <code class=charname>LATIN SMALL LETTER N</code>            <code class=charname>LATIN SMALL LETTER N</code>
497            (<code class=char>n</code>) character to <var>result</var>.</li>            (<code class=char>n</code>) character to <var>r</var>.</li>
498            <li>Append <span class=ed>@@ normalized</span>            <li>Let <dfn id=var-b><var>b</var></dfn> be the <var>b</var>
499            integer <var>b</var> to <var>result</var>.            part of the argument.  If the argument is a keyword <code>odd</code>,
500            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
501            either <code class=char>U+002B</code> <code class=charname>PLUS            keyword <code>even</code>, then let <var>b</var> be <code>0</code>.
502            SIGN</code> (<code class=char>+</code>) or            If the <var>b</var> part is omitted, then let <var>b</var> be
503            <code class=char>U+002D</code>            <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            <code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>)            <code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>)
510            character.  If the argument is a keyword <code>odd</code>,            character, then append <code class=char>U+002B</code>
511            <var>b</var> is <code>1</code>.  If the argument            <code class=charname>PLUS SIGN</code>
512            is a keyword <code>even</code>, <var>b</var> is            (<code class=char>+</code>) to <var>result</var>.</li>
513            <code>0</code>.  If <var>b</var> is omitted, it is assumed as            <li>Append <var>b</var> to <var>result</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>  
514            <li>Append a <code class=char>U+0029</code>            <li>Append a <code class=char>U+0029</code>
515            <code class=charname>RIGHT PARENTHESIS</code>            <code class=charname>RIGHT PARENTHESIS</code>
516            (<code class=char>)</code>) character            (<code class=char>)</code>) character
517            to <var>result</var>.</li>            to <var>r</var>.</li>
518            </ol>            </ol>
519          </dd>          </dd>
520        <dt>If the name of the pseudo$B!>(Bclass is <code>not</code></dt>        <dt>If the name of the pseudo$B!>(Bclass is <code>not</code></dt>
# Line 407  a simple selector (<dfn><var id=var-ss>s Line 528  a simple selector (<dfn><var id=var-ss>s
528              <code class=charname>LATIN SMALL LETTER T</code>, and              <code class=charname>LATIN SMALL LETTER T</code>, and
529              <code class=char>U+0028</code> <code class=charname>LEFT              <code class=char>U+0028</code> <code class=charname>LEFT
530              PARENTHESIS</code> (<code>:not(</code>), followed by a              PARENTHESIS</code> (<code>:not(</code>), followed by a
531              <a href="#newline">newline</a>, to <var>result</var>.</li>              <a href="#newline">newline</a>, to <var>r</var>.</li>
532              <li>Append four <code class=char>U+0020</code>              <li>Append four <code class=char>U+0020</code>
533              <code class=charname>SPACE</code> characters to              <code class=charname>SPACE</code> characters to
534              <var>result</var>.</li>              <var>r</var>.</li>
535              <li>Append four <code class=char>U+0020</code>              <li>Append four <code class=char>U+0020</code>
536              <code class=charname>SPACE</code> characters to              <code class=charname>SPACE</code> characters to
537              <var>result</var> again.</li>              <var>r</var> again.</li>
538              <li><a href="#algorithm-serialize-a-simple-selector">Serialize              <li><a href="#algorithm-serialize-a-simple-selector">Serialize
539              the simple selector specified as the argument to the              the simple selector specified as the argument to the
540              <code>not</code> pseudo$B!>(Bclass</a>.</li>              <code>not</code> pseudo$B!>(Bclass</a>.</li>
541              <li>Append a <a href="#newline">newline</a> to              <li>Append a <a href="#newline">newline</a> to
542              <var>result</var>.</li>              <var>r</var>.</li>
543              <li>Append four <code class=char>U+0020</code>              <li>Append four <code class=char>U+0020</code>
544              <code class=charname>SPACE</code> characters to              <code class=charname>SPACE</code> characters to
545              <var>result</var>.</li>              <var>r</var>.</li>
546              <li>Append a <code class=char>U+0029</code>              <li>Append a <code class=char>U+0029</code>
547              <code class=charname>RIGHT PARENTHESIS</code>              <code class=charname>RIGHT PARENTHESIS</code>
548              (<code class=char>)</code>) character              (<code class=char>)</code>) character
549              to <var>result</var>.</li>              to <var>r</var>.</li>
550            </ol>            </ol>
551          </dd>          </dd>
552          <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        </dl>        </dl>
559      </li>      </li>
560      </ol>      </ol>
# Line 437  a simple selector (<dfn><var id=var-ss>s Line 564  a simple selector (<dfn><var id=var-ss>s
564      <ol>      <ol>
565      <li>Append two <code class=char>U+003A</code>      <li>Append two <code class=char>U+003A</code>
566      <code class=charname>COLON</code> characters (<code>::</code>)      <code class=charname>COLON</code> characters (<code>::</code>)
567      to <var>result</var>.</li>      to <var>r</var>.</li>
568      <li>Append the      <li>Append the
569      <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>
570      name of the pseudo$B!>(Belement to <var>result</var>.</li>      name (in <a href="#lower-case">lower$B!>(Bcase</a>) of the pseudo$B!>(Belement
571      <!-- For future version: append "(", arguments, ")", if any. -->      to <var>r</var>.</li>
572        <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      </ol>      </ol>
580    </dd>    </dd>
581  </dl>  </dl>
582    </li>
583  <p>To <dfn id=algorithm-normalize-an-ident title="normalize an IDENT">normalize  <li>Then, <var>r</var> is the
584  an <code>IDENT</code> (<dfn id=var-n><var>n</var></dfn>)</dfn>:</p>  <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
585  <ol>  representation of <var>ss</var>.</li>
 <li>Replace the escape sequences (<code>\</code> and following  
 characters) in <var>n</var> by characters represented by them  
 respectively.</li>  
 <li>If there is any character that is <em>not</em> one of  
 <code class=char>U+002D</code> <code class=charname>HYPHEN-MINUS</code>  
 (<code class=char>-</code>), <code class=char>U+0030</code>  
 <code class=charname>DIGIT ZERO</code>  
 (<code class=char>0</code>) to <code class=char>U+0039</code>  
 <code class=charname>DIGIT NINE</code> (<code class=char>9</code>),  
 <code class=char>U+0041</code> <code class=charname>LATIN CAPITAL LETTER  
 A</code> (<code class=char>A</code>) to <code class=char>U+005A</code>  
 <code class=charname>LATIN CAPITAL LETTER Z</code> (<code class=char>Z</code>),  
 <code class=char>U+005F</code> <code class=charname>LOW LINE</code>  
 (<code class=char>_</code>), <code class=char>U+0061</code>  
 <code class=charname>LATIN SMALL LETTER A</code>  
 (<code class=char>a</code>) to <code class=char>U+006A</code>  
 <code class=charname>LATIN SMALL LETTER Z</code> (<code class=char>z</code>),  
 <code class=char>U+0080</code> to <code class=char>U+D7FF</code>, or  
 <code class=char>U+E000</code> to <code class=char>U+10FFFF</code> in  
 <var>n</var>, then replace it by string <code>\<var>HHHHHH</var></code>, where  
 <dfn id=var-HHHHHH><var>HHHHHH</var></dfn> is the upper$B!>(Bcase zero$B!>(Bpadded  
 hexadecimal representation of the character.  If the character  
 is outside the range of <code>[<code class=char>U+0000</code>,  
 <code class=char>U+10FFFF</code>]</code>, <var>HHHHHH</var>  
 <em class=rfc2119>MUST</em> be <code>FFFFFF</code>.</li>  
 <li>If the first character in <var>n</var> is one of  
 <code class=char>U+0030</code> <code class=charname>DIGIT ZERO</code>  
 (<code class=char>0</code>) to <code class=char>U+0039</code>  
 <code class=charname>DIGIT NINE</code> (<code class=char>9</code>),  
 then prepend a string <code>\00003</code> at the beginning of  
 <var>n</var>.</li>  
 <li>If the first character in <var>n</var> is <code class=char>U+002D</code>  
 <code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>) and  
 the second character, if any, is <em>not</em> one of  
 <code class=char>U+0041</code> <code class=charname>LATIN CAPITAL LETTER  
 A</code> (<code class=char>A</code>) to <code class=char>U+005A</code>  
 <code class=charname>LATIN CAPITAL LETTER Z</code> (<code class=char>Z</code>),  
 <code class=char>U+005F</code> <code class=charname>LOW LINE</code>  
 (<code class=char>_</code>), <code class=char>U+0061</code>  
 <code class=charname>LATIN SMALL LETTER A</code>  
 (<code class=char>a</code>) to <code class=char>U+006A</code>  
 <code class=charname>LATIN SMALL LETTER Z</code> (<code class=char>z</code>),  
 <code>U+0080</code> to <code>U+D7FF</code>, or  
 <code>U+E000</code> to <code>U+10FFFF</code>, or  
 <var>n</var> is equal to <code class=char>U+002D</code>  
 <code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>), then  
 replace the <code class=char>U+002D</code>  
 <code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>)  
 character by string <code>\00002D</code>.</li>  
 <li>Then, <var>n</var> is the result of the algorithm.</li>  
586  </ol>  </ol>
587    
588  <p>To <dfn id=algorithm-normalize-a-string title="normalize a STRING">normalize  </div>
589  a <code>STRING</code> (<dfn id=var-s><var>s</var></dfn>)</dfn>:</p>  
590    <div class=section id=serializing-groups-of-selectors>
591    <h3>Serializing Groups of Selectors</h3>
592    
593    <p>No <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
594    representation is defined for an invalid
595    <a href="http://www.w3.org/TR/css3-selectors/#grouping">group of
596    selectors</a>.</p>
597    
598    <p>To
599    <dfn id=algorithm-serialize-a-group-of-selectors title="serialize a group of selectors">serialize
600    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  <ol>  <ol>
603  <li>Replace the escape sequences (<code>\</code> and following  <li>Let <dfn id=var-result><var>result</var></dfn> an empty string.</li>
604  characters) in <var>s</var> by characters represented by them  <li>For each selector (<dfn id=var-selector><var>selector</var></dfn>) in
605  (or an empty string if <code>\</code> is immediately followed by  <var>gs</var>:
606  newline character(s)) respectively.</li>    <ol>
607  <li>Remove the quotation characters in <var>s</var>    <li>If <var>selector</var> is <em>not</em> the first selector
608  if <var>s</var> is a <code>STRING</code>.</li>    in the <var>gs</var>, then append a <code class=char>U+002C</code>
609  <li>If there is any character that is <em>not</em> one of    <code class=charname>COMMA</code> (<code class=char>,</code>) followed by a
610  <code class=char>U+0020</code> <code class=charname>SPACE</code>,    <a href="#newline">newline</a> to <var>result</var>.</li>
611  <code class=char>U+0021</code> <code class=charname>EXCLAMATION MARK</code>    <li>Append four <code class=char>U+0020</code>
612  (<code class=char>!</code>), <code class=char>U+0023</code>    <code class=charname>SPACE</code> characters to <var>result</var>.</li>
613  <code class=charname>NUMBER SIGN</code> (<code class=char>#</code>) to    <li>Process each sequence of simple selectors or
614  <code class=char>U+005B</code> <code class=charname>LEFT SQUARE    combinator in <var>selector</var> as following:
615  BRACKET</code>, <code class=char>U+005D</code> <code class=charname>RIGHT      <dl class=switch>
616  SQUARE BRACKET</code> to <code class=char>U+D7FF</code>, or      <dt>If it is a sequence of simle selector
617  <code class=char>U+E000</code> to <code class=char>U+10FFFF</code> in      (<dfn id=var-sss><var>sss</var></dfn>)</dt>
618  <var>s</var>, then replace it by string <code>\<var>HHHHHH</var></code>, where        <dd>
619  <dfn id=var-HHHHHH><var>HHHHHH</var></dfn> is the upper$B!>(Bcase zero$B!>(Bpadded          <ol>
620  hexadecimal representation of the character.  If the character          <li>If <var>sss</var> contains a universal or type selector, then
621  is outside the range of <code>[<code class=char>U+0000</code>,          <a href="#algorithm-serialize-a-simple-selector" title="serialize a simple selector">serialize
622  <code class=char>U+10FFFF</code>]</code>, <var>HHHHHH</var>          that simple selector</a> and append the result to
623  <em class=rfc2119>MUST</em> be <code>FFFFFF</code>.</li>          <var>result</var>.</li>
624  <li>Insert a <code class=char>U+0022</code> <code class=charname>QUOTATION          <li>Otherwise, i.e. if <var>sss</var> does not contain a universal or
625  MARK</code> (<code class=char>"</code>) at the beginning of <var>s</var>.</li>          type selector, then
626  <li>Insert a <code class=char>U+0022</code> <code class=charname>QUOTATION          <a href="#algorithm-serialize-a-simple-selector" title="serialize a simple selector">serialize
627  MARK</code> (<code class=char>"</code>) at the end of <var>s</var>.</li>          a simple selector <code>*</code></a> and append the result to
628  <li>Then, <var>s</var> is the result of the algorithm.</li>          <var>result</var>.</li>
629  </ol>          <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            <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            <li>Process <var>c</var> as following:
653    
654  <p>A <dfn id=newline title=newline>newline</dfn>            <dl class=switch>
655  <em class=rfc2119>SHOULD</em> be represented as a            <dt>If <var>c</var> is descendant combinator (white space)</dt>
656  <code class=char>U+000A</code> <code class=charname>LINE FEED</code>              <dd>Append a <code class=char>U+0020</code>
657  character.  However, depending on the context where              <code class=charname>SPACE</code> character to
658  the <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>              <var>result</var>.</dd>
659  representation is in use, a sequence of            <dt>If <var>c</var> is child combinator
660  <code class=char>U+000D</code> <code class=charname>CARRIAGE RETURN</code>            (<code class=char>></code>)</dt>
661  followed by a <code class=char>U+000A</code>              <dd>Append a <code class=char>U+003E</code>
662  <code class=charname>LINE FEED</code> (i.e. a              <code class=charname>GREATER-THAN SIGN</code>
663  <code>CRLF</code> sequence) or a character              (<code class=char>></code>) character to <var>result</var>.</dd>
664  <code class=char>U+000D</code> <code class=charname>CARRIAGE RETURN</code>            <dt>If <var>c</var> is adjacent sibling combinator
665  <em class=rfc2119>MAY</em> be used as a <a href="#newline">newline</a> instead.            (<code class=char>+</code>)</dt>
666  <a href="#newline">Newline</a> representations              <dd>Append a <code class=char>U+002B</code>
667  <em class=rfc2119>SHOULD</em> be consistent in an              <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  <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>  <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
686  representation.</p>  representation of <var>gs</var>.</li>
687    </ol>
688    
 <div class="note memo">  
 <p>Therefore, newlines must be normalized before  
 <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>  
 representations are literally compared.</p>  
689  </div>  </div>
690    
691  </div>  </div>
# Line 560  representations are literally compared.< Line 693  representations are literally compared.<
693  <div class="section" id="parsing">  <div class="section" id="parsing">
694  <h2>Parsing  <h2>Parsing
695  <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>  <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
696  Groups of Selectors</h2>  Representations of Selectors</h2>
697    
698  <p>Since <a href="#serializing">the serializing algorithm</a> is  <p>Since <a href="#algorithm-serialize-a-group-of-selectors">the serializing
699  so designed that it always output a valid  algorithm for groups of selectors</a> is so designed that it always outputs a
700  <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
701  selectors</a>, no special parser for the  selectors</a>, no special parser for the
702  <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>  <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
703  representation is necessary.  Any conforming parser for  representation is necessary.  Any conforming parser for
704  <a href="http://www.w3.org/TR/css3-selectors/#grouping">groups of  <a href="http://www.w3.org/TR/css3-selectors/#grouping">groups of
705  selectors</a> <em class=rfc2119>MAY</em> be used  selectors</a> <em class=rfc2119>MAY</em> be used
706  to parse <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>  to parse <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
707  representations of groups of selectors.</p>  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  </div>  </div>
719    
720  <div class="section" id="examples">  <div class="section" id="examples">
# Line 579  representations of groups of selectors.< Line 722  representations of groups of selectors.<
722    
723  <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>
724    
 <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>  
   
725  <div class="example figure block">  <div class="example figure block">
726  <div class="caption">...</div>  <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>...</code></pre>  <pre><code>    *|p
730      + *|q
731    </code></pre>
732  </div>  </div>
733    
734    <div class="example figure block">
735    <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    </div>
745    
746    <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  </div>  </div>
761    
762  </div>  </div>
# Line 607  by choosing <q>Selectors</q> radio butto Line 775  by choosing <q>Selectors</q> radio butto
775    <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>
776    14</a>, <abbr title="Request for Comments">RFC</abbr> 2119,    14</a>, <abbr title="Request for Comments">RFC</abbr> 2119,
777    <time datetime=1997-03>March 1997</time>.    <time datetime=1997-03>March 1997</time>.
778    This version of the specification is referenced</dd>    This version of the specification is referenced.</dd>
779  <dt id=ref-SELECTORS>SELECTORS</dt>  <dt id=ref-SELECTORS>SELECTORS</dt>
780    <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>,
781    <abbr title="World Wide Web Consortium">W3C</abbr> Working Draft,    <abbr title="World Wide Web Consortium">W3C</abbr> Working Draft,
# Line 640  by choosing <q>Selectors</q> radio butto Line 808  by choosing <q>Selectors</q> radio butto
808  <dt id=ref-HTML5>HTML5</dt>  <dt id=ref-HTML5>HTML5</dt>
809    <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>,
810    <abbr title="Web Hypertext Application Technology Working Group">WHATWG</abbr>    <abbr title="Web Hypertext Application Technology Working Group">WHATWG</abbr>
811    Working Draft.  Work in progress.</dd>    Working Draft, <time datetime="2007-11-03">3 November 2007</time>.
812      Work in progress.</dd>
813  <dt id=ref-SAPI>SAPI</dt>  <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&amp;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&amp;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,    <abbr title="World Wide Web Consortium">W3C</abbr> Editor's Draft,

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.22

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24