/[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.13 by wakaba, Mon Oct 22 10:43:33 2007 UTC revision 1.16 by wakaba, Mon Oct 22 11:16:27 2007 UTC
# Line 128  document are to be interpreted as descri Line 128  document are to be interpreted as descri
128  2119</a>  2119</a>
129  <cite class="bibref normative">[<a href="#ref-KEYWORDS">KEYWORDS</a>]</cite>.</p>  <cite class="bibref normative">[<a href="#ref-KEYWORDS">KEYWORDS</a>]</cite>.</p>
130    
131    <p>Requirements phrased in the imperative as part of algorithms are to be
132    interpreted with the meaning of the key word (<em class=rfc2119>MUST</em>)
133    used in introducing the algorithm.</p>
134    
135    <p>Conformance requirements phrased as algorithms or specific steps
136    <em class=rfc2119>MAY</em> be implemented in any manner, so long as the end
137    result is equivalent.</p>
138    
139  <!-- Strictly speaking the paragraph below is not part of terminology. -->  <!-- Strictly speaking the paragraph below is not part of terminology. -->
140  <p>All examples and notes in this specification are non$B!>(Bnormative,  <p>All examples and notes in this specification are non$B!>(Bnormative,
141  as are all sections explicitly marked non$B!>(Bnormative.  Everything  as are all sections explicitly marked non$B!>(Bnormative.  Everything
# Line 144  simple selector in a selector.</p> Line 152  simple selector in a selector.</p>
152  <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>  <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
153  Representation</h2>  Representation</h2>
154    
155    <p>Subsections of this section define algorithms
156    to <a href="#algorithm-serialize-a-simple-selector">serialize a simple
157    selector</a> or <a href="#algorithm-serialize-a-group-of-selectors">serialize
158    a group of selectors</a>.</p>
159    
160  <div class="issue ed">  <div class="issue ed">
161  <p><a href="http://suika.fam.cx/gate/cvs/*checkout*/markup/html/whatpm/Whatpm/CSS/SelectorsSerializer.pm">See the reference implementation</a>  <p><a href="http://suika.fam.cx/gate/cvs/*checkout*/markup/html/whatpm/Whatpm/CSS/SelectorsSerializer.pm">See
162  for now.</p>  also the reference implementation</a> for now.</p>
163  </div>  </div>
164    
 <div class=section id=serializing-groups-of-selectors>  
 <h3>Serializing Groups of Selectors</h3>  
   
 <p>No <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>  
 representation is defined for an invalid group of selectors.</p>  
   
165  <div class="note memo">  <div class="note memo">
166  <p>The serialized representation will not contain any comment.</p>  <p>The serialized representation will not contain any comment.</p>
167  </div>  </div>
   
168  <!-- TODO: link terms to Selectors -->  <!-- TODO: link terms to Selectors -->
169    
170  <p>To  <div class=section id=serializing-tokens>
171  <dfn id=algorithm-serialize-a-group-of-selectors title="serialize a group of selectors">serialize  <h3>Serializing Tokens</h3>
172  a group of selectors (<dfn id=var-gs><var>gs</var></dfn>)</dfn>:</p>  
173    <p>To <dfn id=algorithm-normalize-an-ident title="normalize an IDENT">normalize
174    an <code>IDENT</code> (<dfn id=var-n><var>n</var></dfn>)</dfn>,
175    the following algorithm <em class=rfc2119>MUST</em> be used:</p>
176  <ol>  <ol>
177  <li>Let <dfn id=var-result><var>result</var></dfn> an empty string.</li>  <li>Replace the escape sequences (<code>\</code> and following
178  <li>For each selector (<dfn id=var-selector><var>selector</var></dfn>) in  characters) in <var>n</var> by characters represented by them
179  <var>gs</var>:  respectively.</li>
180    <ol>  <li>If there is any character that is <em>not</em> one of
181    <li>If <var>selector</var> is <em>not</em> the first selector  <code class=char>U+002D</code> <code class=charname>HYPHEN-MINUS</code>
182    in the group of selectors, then append a <code class=char>U+002C</code>  (<code class=char>-</code>), <code class=char>U+0030</code>
183    <code class=charname>COMMA</code> (<code class=char>,</code>) followed by a  <code class=charname>DIGIT ZERO</code>
184    <a href="#newline">newline</a> to <var>result</var>.</li>  (<code class=char>0</code>) to <code class=char>U+0039</code>
185    <li>Append four <code class=char>U+0020</code>  <code class=charname>DIGIT NINE</code> (<code class=char>9</code>),
186    <code class=charname>SPACE</code> characters to <var>result</var>.</li>  <code class=char>U+0041</code> <code class=charname>LATIN CAPITAL LETTER
187    <li>Process each sequence of simple selectors or  A</code> (<code class=char>A</code>) to <code class=char>U+005A</code>
188    combinator in <var>selector</var> by following algorithm:  <code class=charname>LATIN CAPITAL LETTER Z</code> (<code class=char>Z</code>),
189      <dl class=switch>  <code class=char>U+005F</code> <code class=charname>LOW LINE</code>
190      <dt>If it is a sequence of simle selector  (<code class=char>_</code>), <code class=char>U+0061</code>
191      (<dfn id=var-sss><var>sss</var></dfn>)</dt>  <code class=charname>LATIN SMALL LETTER A</code>
192        <dd>  (<code class=char>a</code>) to <code class=char>U+006A</code>
193          <ol>  <code class=charname>LATIN SMALL LETTER Z</code> (<code class=char>z</code>),
194          <li class=ed><a href="#algorithm-serialize-a-simple-selector">Serialize  <code class=char>U+0080</code> to <code class=char>U+D7FF</code>, or
195          each simple selector</a> in <var>sss</var>.</li>  <code class=char>U+E000</code> to <code class=char>U+10FFFF</code> in
196          <li class=ed>sort</li>  <var>n</var>, then replace it by string <code>\<var>HHHHHH</var></code>, where
197          <li>Append a <a href="#newline">newline</a> to <var>result</var>.</li>  <dfn id=var-HHHHHH><var>HHHHHH</var></dfn> is the upper$B!>(Bcase zero$B!>(Bpadded
198          </ol>  hexadecimal representation of the character.  If the character
199        </dd>  is outside the range of <code>[<code class=char>U+0000</code>,
200      <dt>If it is a combinator (<dfn id=var-c><var>c</var></dfn>)</dt>  <code class=char>U+10FFFF</code>]</code>, <var>HHHHHH</var>
201        <dd>  <em class=rfc2119>MUST</em> be <code>FFFFFF</code>.</li>
202          <ol>  <li>If the first character in <var>n</var> is one of
203          <li>Append two <code class=char>U+0020</code>  <code class=char>U+0030</code> <code class=charname>DIGIT ZERO</code>
204          <code class=charname>SPACE</code> characters to <var>result</var>.</li>  (<code class=char>0</code>) to <code class=char>U+0039</code>
205          <li>  <code class=charname>DIGIT NINE</code> (<code class=char>9</code>),
206            <dl class=switch>  then prepend a string <code>\00003</code> at the beginning of
207            <dt>If <var>c</var> is descendant combinator (white space)</dt>  <var>n</var>.</li>
208              <dd>Append a <code class=char>U+0020</code>  <li>If the first character in <var>n</var> is <code class=char>U+002D</code>
209              <code class=charname>SPACE</code> character to  <code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>) and
210              <var>result</var>.</dd>  the second character, if any, is <em>not</em> one of
211            <dt>If <var>c</var> is child combinator  <code class=char>U+0041</code> <code class=charname>LATIN CAPITAL LETTER
212            (<code class=char>></code>)</dt>  A</code> (<code class=char>A</code>) to <code class=char>U+005A</code>
213              <dd>Append a <code class=char>U+003E</code>  <code class=charname>LATIN CAPITAL LETTER Z</code> (<code class=char>Z</code>),
214              <code class=charname>GREATER-THAN SIGN</code>  <code class=char>U+005F</code> <code class=charname>LOW LINE</code>
215              (<code class=char>></code>) character to <var>result</var>.</dd>  (<code class=char>_</code>), <code class=char>U+0061</code>
216            <dt>If <var>c</var> is adjacent sibling combinator  <code class=charname>LATIN SMALL LETTER A</code>
217            (<code class=char>+</code>)</dt>  (<code class=char>a</code>) to <code class=char>U+006A</code>
218              <dd>Append a <code class=char>U+002B</code>  <code class=charname>LATIN SMALL LETTER Z</code> (<code class=char>z</code>),
219              <code class=charname>PLUS SIGN</code> (<code class=char>+</code>)  <code>U+0080</code> to <code>U+D7FF</code>, or
220              character to <var>result</var>.</dd>  <code>U+E000</code> to <code>U+10FFFF</code>, or
221            <dt>If <var>c</var> is general sibling combinator  <var>n</var> is equal to <code class=char>U+002D</code>
222            (<code class=char>~</code>)</dt>  <code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>), then
223              <dd>Append a <code class=char>U+007E</code>  replace the <code class=char>U+002D</code>
224              <code class=charname>TILDE</code> (<code class=char>~</code>)  <code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>)
225              character to <var>result</var>.</dd>  character by string <code>\00002D</code>.</li>
226            </dl>  <li>Then, <var>n</var> is the result of the algorithm.</li>
227          </li>  </ol>
228          <li>Append a <code class=char>U+0020</code>  
229          <code class=charname>SPACE</code> character to  <p>To <dfn id=algorithm-normalize-a-string title="normalize a STRING">normalize
230          <var>result</var>.</li>  a <code>STRING</code> (<dfn id=var-s><var>s</var></dfn>)</dfn>,
231          </ol>  the following algorithm <em class=rfc2119>MUST</em> be used:</p>
232        </dd>  <ol>
233      </dl>  <li><p>Replace the escape sequences (<code>\</code> and following
234    </ol>  characters) in <var>s</var> by characters represented by them
235  </li>  (or an empty string if <code>\</code> is immediately followed by
236  <li>Then, <var>result</var> is the  newline character(s)) respectively.</p></li>
237  <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>  <li><p>Remove the quotation characters in <var>s</var>
238  representation of <var>gs</var>.</li>  if <var>s</var> is a <code>STRING</code>.</p>
239    
240    <div class="note memo">
241    <p>The input <var>s</var> to this algorithm may be an
242    <code>IDENT</code>.</p>
243    </div></li>
244    <li><p>If there is any character that is <em>not</em> one of
245    <code class=char>U+0020</code> <code class=charname>SPACE</code>,
246    <code class=char>U+0021</code> <code class=charname>EXCLAMATION MARK</code>
247    (<code class=char>!</code>), <code class=char>U+0023</code>
248    <code class=charname>NUMBER SIGN</code> (<code class=char>#</code>) to
249    <code class=char>U+005B</code> <code class=charname>LEFT SQUARE
250    BRACKET</code>, <code class=char>U+005D</code> <code class=charname>RIGHT
251    SQUARE BRACKET</code> to <code class=char>U+D7FF</code>, or
252    <code class=char>U+E000</code> to <code class=char>U+10FFFF</code> in
253    <var>s</var>, then replace it by string <code>\<var>HHHHHH</var></code>, where
254    <dfn id=var-HHHHHH><var>HHHHHH</var></dfn> is the upper$B!>(Bcase zero$B!>(Bpadded
255    hexadecimal representation of the character.  If the character
256    is outside the range of <code>[<code class=char>U+0000</code>,
257    <code class=char>U+10FFFF</code>]</code>, <var>HHHHHH</var>
258    <em class=rfc2119>MUST</em> be <code>FFFFFF</code>.</p></li>
259    <li><p>Insert a <code class=char>U+0022</code> <code class=charname>QUOTATION
260    MARK</code> (<code class=char>"</code>) at the beginning of
261    <var>s</var>.</p></li>
262    <li><p>Insert a <code class=char>U+0022</code> <code class=charname>QUOTATION
263    MARK</code> (<code class=char>"</code>) at the end of <var>s</var>.</p></li>
264    <li><p>Then, <var>s</var> is the result of the algorithm.</p></li>
265  </ol>  </ol>
266    
267    <p>A <dfn id=newline title=newline>newline</dfn>
268    <em class=rfc2119>SHOULD</em> be represented as a
269    <code class=char>U+000A</code> <code class=charname>LINE FEED</code>
270    character.  However, depending on the context where
271    the <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
272    representation is in use, a sequence of
273    <code class=char>U+000D</code> <code class=charname>CARRIAGE RETURN</code>
274    followed by a <code class=char>U+000A</code>
275    <code class=charname>LINE FEED</code> (i.e. a
276    <code>CRLF</code> sequence) or a character
277    <code class=char>U+000D</code> <code class=charname>CARRIAGE RETURN</code>
278    <em class=rfc2119>MAY</em> be used as a <a href="#newline">newline</a> instead.
279    <a href="#newline">Newline</a> representations
280    <em class=rfc2119>SHOULD</em> be consistent in an
281    <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
282    representation.</p>
283    
284    <div class="note memo">
285    <p>Therefore, newlines must be normalized before
286    <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
287    representations are literally compared.</p>
288  </div>  </div>
289    
290    </div>
291    
292    
293  <div class=section id=serializing-simple-selectors>  <div class=section id=serializing-simple-selectors>
294  <h3>Serializing Simple Selectors</h3>  <h3>Serializing Simple Selectors</h3>
295    
296    <p>No <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
297    representation is defined for an invalid <a href="#simple-selector">simple
298    selector</a>.</p>
299    
300  <p>To  <p>To
301  <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
302  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>,
303    the following algorithm <em class=rfc2119>MUST</em> be used:</p>
304    <ol>
305    <li>Let <dfn id=var-r><var>r</var></dfn> an empty string.</li>
306    <li>Process <var>ss</var> as following:
307    
308  <dl class=switch>  <dl class=switch>
309  <dt>If <var>ss</var> is a type or universal selector</dt>  <dt>If <var>ss</var> is a type or universal selector</dt>
310    <dd>    <dd>
# Line 250  a simple selector (<dfn><var id=var-ss>s Line 318  a simple selector (<dfn><var id=var-ss>s
318        prefix)</dt>        prefix)</dt>
319          <dd>Append a <code class=char>U+007C</code>          <dd>Append a <code class=char>U+007C</code>
320          <code class=charname>VERTICAL BAR</code> (<code class=char>|</code>)          <code class=charname>VERTICAL BAR</code> (<code class=char>|</code>)
321          character to <var>result</var>.</dd>          character to <var>r</var>.</dd>
322        <dt>If no namespace is specified (by namespace prefix <code>*</code>,        <dt>If no namespace is specified (by namespace prefix <code>*</code>,
323        or by omitting namespace prefix where no default namespace is        or by omitting namespace prefix where no default namespace is
324        specified)</dt>        specified)</dt>
# Line 258  a simple selector (<dfn><var id=var-ss>s Line 326  a simple selector (<dfn><var id=var-ss>s
326          <code class=charname>ASTERISK</code> (<code class=char>*</code>)          <code class=charname>ASTERISK</code> (<code class=char>*</code>)
327          character, followed by a <code class=char>U+007C</code>          character, followed by a <code class=char>U+007C</code>
328          <code class=charname>VERTICAL BAR</code> (<code class=char>|</code>)          <code class=charname>VERTICAL BAR</code> (<code class=char>|</code>)
329          character, to <var>result</var>.</dd>          character, to <var>r</var>.</dd>
330        </dl>        </dl>
331      </li>      </li>
332      <li>If <var>ss</var> is a type selector, append the      <li>If <var>ss</var> is a type selector, append the
333      <a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a>      <a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a>
334      local name to <var>result</var>.</li>      local name to <var>r</var>.</li>
335      <li>If <var>ss</var> is a universal selector, append      <li>If <var>ss</var> is a universal selector, append
336      a <code class=char>U+002A</code> <code class=charname>ASTERISK</code>      a <code class=char>U+002A</code> <code class=charname>ASTERISK</code>
337      (<code class=char>*</code>) character to <var>result</var>.</li>      (<code class=char>*</code>) character to <var>r</var>.</li>
338      </ol>      </ol>
339    </dd>    </dd>
340  <dt>If <var>ss</var> is an attribute selector</dt>  <dt>If <var>ss</var> is an attribute selector</dt>
# Line 274  a simple selector (<dfn><var id=var-ss>s Line 342  a simple selector (<dfn><var id=var-ss>s
342      <ol>      <ol>
343      <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
344      SQUARE BRACKET</code> (<code class=char>[</code>) to      SQUARE BRACKET</code> (<code class=char>[</code>) to
345      <var>result</var>.</li>      <var>r</var>.</li>
346      <li>      <li>
347        Append a namespace prefix as following:        Append a namespace prefix as following:
348        <dl>        <dl>
# Line 285  a simple selector (<dfn><var id=var-ss>s Line 353  a simple selector (<dfn><var id=var-ss>s
353        <dt>If the null namespace is specified</dt>        <dt>If the null namespace is specified</dt>
354          <dd>Append a <code class=char>U+007C</code>          <dd>Append a <code class=char>U+007C</code>
355          <code class=charname>VERTICAL BAR</code> character to          <code class=charname>VERTICAL BAR</code> character to
356          <var>result</var>.</dd>          <var>r</var>.</dd>
357        <dt>If no namespace is specified</dt>        <dt>If no namespace is specified</dt>
358          <dd>Append a <code class=char>U+002A</code>          <dd>Append a <code class=char>U+002A</code>
359          <code class=charname>ASTERISK</code> (<code class=char>*</code>)          <code class=charname>ASTERISK</code> (<code class=char>*</code>)
360          character, followed by a <code class=char>U+007C</code>          character, followed by a <code class=char>U+007C</code>
361          <code class=charname>VERTICAL BAR</code> (<code class=char>|</code>)          <code class=charname>VERTICAL BAR</code> (<code class=char>|</code>)
362          character, to <var>result</var>.</dd>          character, to <var>r</var>.</dd>
363        </dl>        </dl>
364      </li>      </li>
365      <li>Append the      <li>Append the
366      <a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a>      <a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a>
367      local name to <var>result</var>.</li>      local name to <var>r</var>.</li>
368      <li>If a value is specified in <var>ss</var>:      <li>If a value is specified in <var>ss</var>:
369        <ol>        <ol>
370        <li>Depending on the way to match, append <code>=</code>,        <li>Depending on the way to match, append <code>=</code>,
371        <code>~=</code>, <code>|=</code>, <code>^=</code>,        <code>~=</code>, <code>|=</code>, <code>^=</code>,
372        <code>$=</code>, or <code>*=</code> to <var>result</var>.</li>        <code>$=</code>, or <code>*=</code> to <var>r</var>.</li>
373        <li>Append the        <li>Append the
374        <a href="#algorithm-normalize-a-string" title="normalize a string">normalized</a>        <a href="#algorithm-normalize-a-string" title="normalize a string">normalized</a>
375        value to <var>result</var>.</li>        value to <var>r</var>.</li>
376        </ol>        </ol>
377      </li>      </li>
378      <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
379      SQUARE BRACKET</code> (<code class=char>]</code>) to      SQUARE BRACKET</code> (<code class=char>]</code>) to
380      <var>result</var>.</li>      <var>r</var>.</li>
381      </ol>      </ol>
382    </dd>    </dd>
383  <dt>If <var>ss</var> is a class selector</dt>  <dt>If <var>ss</var> is a class selector</dt>
384    <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
385    STOP</code> (<code class=char>.</code>) character, followed    STOP</code> (<code class=char>.</code>) character, followed
386    by <a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a>    by <a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a>
387    class name, <var>result</var>.</dd>    class name, to <var>r</var>.</dd>
388  <dt>If <var>ss</var> is an <abbr>ID</abbr> selector</dt>  <dt>If <var>ss</var> is an <abbr>ID</abbr> selector</dt>
389    <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
390    SIGN</code> (<code class=char>#</code>) character, followed    SIGN</code> (<code class=char>#</code>) character, followed
391    by <a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a>    by <a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a>
392    <abbr>ID</abbr>, to <var>result</var>.</dd>    <abbr>ID</abbr>, to <var>r</var>.</dd>
393  <dt>If <var>ss</var> is a pseudo$B!>(Bclass selector</dt>  <dt>If <var>ss</var> is a pseudo$B!>(Bclass selector</dt>
394    <dd>    <dd>
395      <ol>      <ol>
396      <li>Append a <code class=char>U+003A</code>      <li>Append a <code class=char>U+003A</code>
397      <code class=charname>COLON</code> (<code class=char>:</code>) character      <code class=charname>COLON</code> (<code class=char>:</code>) character
398      to <var>result</var>.</li>      to <var>r</var>.</li>
399      <li>Append the      <li>Append the
400      <a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a>      <a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a>
401      name of the pseudo$B!>(Bclass to <var>result</var>.</li>      name of the pseudo$B!>(Bclass to <var>r</var>.</li>
402      <li>Append any arguments as following:      <li>Append any arguments as following:
403        <dl class=switch>        <dl class=switch>
404        <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 338  a simple selector (<dfn><var id=var-ss>s Line 406  a simple selector (<dfn><var id=var-ss>s
406            <ol>            <ol>
407            <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
408            PARENTHESIS</code> (<code class=char>(</code>) character            PARENTHESIS</code> (<code class=char>(</code>) character
409            to <var>result</var>.</li>            to <var>r</var>.</li>
410            <li>Append the            <li>Append the
411            <a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a>            <a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a>
412            language tag (the argument) to <var>result</var>.</li>            language tag (the argument) to <var>r</var>.</li>
413            <li>Append a <code class=char>U+0029</code>            <li>Append a <code class=char>U+0029</code>
414            <code class=charname>RIGHT PARENTHESIS</code>            <code class=charname>RIGHT PARENTHESIS</code>
415            (<code class=char>)</code>) character            (<code class=char>)</code>) character
416            to <var>result</var>.</li>            to <var>r</var>.</li>
417            </ol>            </ol>
418          </dd>          </dd>
419        <dt>If the name of the pseudo$B!>(Bclass is        <dt>If the name of the pseudo$B!>(Bclass is
# Line 354  a simple selector (<dfn><var id=var-ss>s Line 422  a simple selector (<dfn><var id=var-ss>s
422            <ol>            <ol>
423            <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
424            PARENTHESIS</code> (<code class=char>(</code>) character            PARENTHESIS</code> (<code class=char>(</code>) character
425            to <var>result</var>.</li>            to <var>r</var>.</li>
426            <li>Append the            <li>Append the
427            <a href="#algorithm-normalize-a-string" title="normalize a string">normalized</a>            <a href="#algorithm-normalize-a-string" title="normalize a string">normalized</a>
428            string (the argument) to <var>result</var>.</li>            string (the argument) to <var>r</var>.</li>
429            <li>Append a <code class=char>U+0029</code>            <li>Append a <code class=char>U+0029</code>
430            <code class=charname>RIGHT PARENTHESIS</code>            <code class=charname>RIGHT PARENTHESIS</code>
431            (<code class=char>)</code>) character            (<code class=char>)</code>) character
432            to <var>result</var>.</li>            to <var>r</var>.</li>
433            </ol>            </ol>
434          </dd>          </dd>
435        <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 371  a simple selector (<dfn><var id=var-ss>s Line 439  a simple selector (<dfn><var id=var-ss>s
439            <ol>            <ol>
440            <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
441            PARENTHESIS</code> (<code class=char>(</code>) character            PARENTHESIS</code> (<code class=char>(</code>) character
442            to <var>result</var>.</li>            to <var>r</var>.</li>
443            <li>Append <span class=ed>@@ normalized</span>            <li>Append <span class=ed>@@ normalized</span>
444            integer <var>a</var> to <var>result</var>.            integer <var>a</var> to <var>r</var>.
445            If the argument is a keyword <code>odd</code> or <code>even</code>,            If the argument is a keyword <code>odd</code> or <code>even</code>,
446            <var>a</var> is <code>2</code>.  If <var>a</var> and            <var>a</var> is <code>2</code>.  If <var>a</var> and
447            <code>n</code> is omitted, <var>a</var> is assumed as            <code>n</code> is omitted, <var>a</var> is assumed as
# Line 384  a simple selector (<dfn><var id=var-ss>s Line 452  a simple selector (<dfn><var id=var-ss>s
452            character).</li>            character).</li>
453            <li>Append a <code class=char>U+006E</code>            <li>Append a <code class=char>U+006E</code>
454            <code class=charname>LATIN SMALL LETTER N</code>            <code class=charname>LATIN SMALL LETTER N</code>
455            (<code class=char>n</code>) character to <var>result</var>.</li>            (<code class=char>n</code>) character to <var>r</var>.</li>
456            <li>Append <span class=ed>@@ normalized</span>            <li>Append <span class=ed>@@ normalized</span>
457            integer <var>b</var> to <var>result</var>.            integer <var>b</var> to <var>r</var>.
458            It <em class=rfc2119>MUST</em> be preceded by a sign,            It <em class=rfc2119>MUST</em> be preceded by a sign,
459            either <code class=char>U+002B</code> <code class=charname>PLUS            either <code class=char>U+002B</code> <code class=charname>PLUS
460            SIGN</code> (<code class=char>+</code>) or            SIGN</code> (<code class=char>+</code>) or
# Line 403  a simple selector (<dfn><var id=var-ss>s Line 471  a simple selector (<dfn><var id=var-ss>s
471            <li>Append a <code class=char>U+0029</code>            <li>Append a <code class=char>U+0029</code>
472            <code class=charname>RIGHT PARENTHESIS</code>            <code class=charname>RIGHT PARENTHESIS</code>
473            (<code class=char>)</code>) character            (<code class=char>)</code>) character
474            to <var>result</var>.</li>            to <var>r</var>.</li>
475            </ol>            </ol>
476          </dd>          </dd>
477        <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 417  a simple selector (<dfn><var id=var-ss>s Line 485  a simple selector (<dfn><var id=var-ss>s
485              <code class=charname>LATIN SMALL LETTER T</code>, and              <code class=charname>LATIN SMALL LETTER T</code>, and
486              <code class=char>U+0028</code> <code class=charname>LEFT              <code class=char>U+0028</code> <code class=charname>LEFT
487              PARENTHESIS</code> (<code>:not(</code>), followed by a              PARENTHESIS</code> (<code>:not(</code>), followed by a
488              <a href="#newline">newline</a>, to <var>result</var>.</li>              <a href="#newline">newline</a>, to <var>r</var>.</li>
489              <li>Append four <code class=char>U+0020</code>              <li>Append four <code class=char>U+0020</code>
490              <code class=charname>SPACE</code> characters to              <code class=charname>SPACE</code> characters to
491              <var>result</var>.</li>              <var>r</var>.</li>
492              <li>Append four <code class=char>U+0020</code>              <li>Append four <code class=char>U+0020</code>
493              <code class=charname>SPACE</code> characters to              <code class=charname>SPACE</code> characters to
494              <var>result</var> again.</li>              <var>r</var> again.</li>
495              <li><a href="#algorithm-serialize-a-simple-selector">Serialize              <li><a href="#algorithm-serialize-a-simple-selector">Serialize
496              the simple selector specified as the argument to the              the simple selector specified as the argument to the
497              <code>not</code> pseudo$B!>(Bclass</a>.</li>              <code>not</code> pseudo$B!>(Bclass</a>.</li>
498              <li>Append a <a href="#newline">newline</a> to              <li>Append a <a href="#newline">newline</a> to
499              <var>result</var>.</li>              <var>r</var>.</li>
500              <li>Append four <code class=char>U+0020</code>              <li>Append four <code class=char>U+0020</code>
501              <code class=charname>SPACE</code> characters to              <code class=charname>SPACE</code> characters to
502              <var>result</var>.</li>              <var>r</var>.</li>
503              <li>Append a <code class=char>U+0029</code>              <li>Append a <code class=char>U+0029</code>
504              <code class=charname>RIGHT PARENTHESIS</code>              <code class=charname>RIGHT PARENTHESIS</code>
505              (<code class=char>)</code>) character              (<code class=char>)</code>) character
506              to <var>result</var>.</li>              to <var>r</var>.</li>
507            </ol>            </ol>
508          </dd>          </dd>
509          <dt>Otherwise</dt>
510            <dd>The pseudo$B!>(Bclass is not supported by this version of
511            <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
512            and therefore no
513            <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
514            representation is defined for <var>ss</var>.  Stop the algorithm.</dd>
515        </dl>        </dl>
516      </li>      </li>
517      </ol>      </ol>
# Line 447  a simple selector (<dfn><var id=var-ss>s Line 521  a simple selector (<dfn><var id=var-ss>s
521      <ol>      <ol>
522      <li>Append two <code class=char>U+003A</code>      <li>Append two <code class=char>U+003A</code>
523      <code class=charname>COLON</code> characters (<code>::</code>)      <code class=charname>COLON</code> characters (<code>::</code>)
524      to <var>result</var>.</li>      to <var>r</var>.</li>
525      <li>Append the      <li>Append the
526      <a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a>      <a href="#algorithm-normalize-an-ident" title="normalize an IDENT">normalized</a>
527      name of the pseudo$B!>(Belement to <var>result</var>.</li>      name of the pseudo$B!>(Belement to <var>r</var>.</li>
528      <!-- For future version: append "(", arguments, ")", if any. -->      <li>If the pseudo$B!>(Belement has any arguments:
529            The pseudo$B!>(Belement is not supported by this version of
530            <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
531            and therefore no
532            <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
533            representation is defined for <var>ss</var>.  Stop the algorithm.
534        </li>
535      </ol>      </ol>
536    </dd>    </dd>
537  </dl>  </dl>
538    </li>
539    <li>Then, <var>r</var> is the
540    <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
541    representation of <var>ss</var>.</li>
542    </ol>
543    
544  </div>  </div>
545    
546  <div class=section id=serializing-tokens>  <div class=section id=serializing-groups-of-selectors>
547  <h3>Serializing Tokens</h3>  <h3>Serializing Groups of Selectors</h3>
548    
549  <p>To <dfn id=algorithm-normalize-an-ident title="normalize an IDENT">normalize  <p>No <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
550  an <code>IDENT</code> (<dfn id=var-n><var>n</var></dfn>)</dfn>:</p>  representation is defined for an invalid group of selectors.</p>
 <ol>  
 <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>  
 </ol>  
551    
552  <p>To <dfn id=algorithm-normalize-a-string title="normalize a STRING">normalize  <p>To
553  a <code>STRING</code> (<dfn id=var-s><var>s</var></dfn>)</dfn>:</p>  <dfn id=algorithm-serialize-a-group-of-selectors title="serialize a group of selectors">serialize
554    a group of selectors (<dfn id=var-gs><var>gs</var></dfn>)</dfn>,
555    the following algorithm <em class=rfc2119>MUST</em> be used:</p>
556  <ol>  <ol>
557  <li><p>Replace the escape sequences (<code>\</code> and following  <li>Let <dfn id=var-result><var>result</var></dfn> an empty string.</li>
558  characters) in <var>s</var> by characters represented by them  <li>For each selector (<dfn id=var-selector><var>selector</var></dfn>) in
559  (or an empty string if <code>\</code> is immediately followed by  <var>gs</var>:
560  newline character(s)) respectively.</p></li>    <ol>
561  <li><p>Remove the quotation characters in <var>s</var>    <li>If <var>selector</var> is <em>not</em> the first selector
562  if <var>s</var> is a <code>STRING</code>.</p>    in the group of selectors, then append a <code class=char>U+002C</code>
563      <code class=charname>COMMA</code> (<code class=char>,</code>) followed by a
564  <div class="note memo">    <a href="#newline">newline</a> to <var>result</var>.</li>
565  <p>The input <var>s</var> to this algorithm may be an    <li>Append four <code class=char>U+0020</code>
566  <code>IDENT</code>.</p>    <code class=charname>SPACE</code> characters to <var>result</var>.</li>
567  </div></li>    <li>Process each sequence of simple selectors or
568  <li><p>If there is any character that is <em>not</em> one of    combinator in <var>selector</var> as following:
569  <code class=char>U+0020</code> <code class=charname>SPACE</code>,      <dl class=switch>
570  <code class=char>U+0021</code> <code class=charname>EXCLAMATION MARK</code>      <dt>If it is a sequence of simle selector
571  (<code class=char>!</code>), <code class=char>U+0023</code>      (<dfn id=var-sss><var>sss</var></dfn>)</dt>
572  <code class=charname>NUMBER SIGN</code> (<code class=char>#</code>) to        <dd>
573  <code class=char>U+005B</code> <code class=charname>LEFT SQUARE          <ol>
574  BRACKET</code>, <code class=char>U+005D</code> <code class=charname>RIGHT          <li class=ed><a href="#algorithm-serialize-a-simple-selector">Serialize
575  SQUARE BRACKET</code> to <code class=char>U+D7FF</code>, or          each simple selector</a> in <var>sss</var>.</li>
576  <code class=char>U+E000</code> to <code class=char>U+10FFFF</code> in          <li class=ed>sort</li>
577  <var>s</var>, then replace it by string <code>\<var>HHHHHH</var></code>, where          <li>Append a <a href="#newline">newline</a> to <var>result</var>.</li>
578  <dfn id=var-HHHHHH><var>HHHHHH</var></dfn> is the upper$B!>(Bcase zero$B!>(Bpadded          </ol>
579  hexadecimal representation of the character.  If the character        </dd>
580  is outside the range of <code>[<code class=char>U+0000</code>,      <dt>If it is a combinator (<dfn id=var-c><var>c</var></dfn>)</dt>
581  <code class=char>U+10FFFF</code>]</code>, <var>HHHHHH</var>        <dd>
582  <em class=rfc2119>MUST</em> be <code>FFFFFF</code>.</p></li>          <ol>
583  <li><p>Insert a <code class=char>U+0022</code> <code class=charname>QUOTATION          <li>Append two <code class=char>U+0020</code>
584  MARK</code> (<code class=char>"</code>) at the beginning of          <code class=charname>SPACE</code> characters to <var>result</var>.</li>
585  <var>s</var>.</p></li>          <li>Process <var>c</var> as following:
 <li><p>Insert a <code class=char>U+0022</code> <code class=charname>QUOTATION  
 MARK</code> (<code class=char>"</code>) at the end of <var>s</var>.</p></li>  
 <li><p>Then, <var>s</var> is the result of the algorithm.</p></li>  
 </ol>  
   
 <p>A <dfn id=newline title=newline>newline</dfn>  
 <em class=rfc2119>SHOULD</em> be represented as a  
 <code class=char>U+000A</code> <code class=charname>LINE FEED</code>  
 character.  However, depending on the context where  
 the <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>  
 representation is in use, a sequence of  
 <code class=char>U+000D</code> <code class=charname>CARRIAGE RETURN</code>  
 followed by a <code class=char>U+000A</code>  
 <code class=charname>LINE FEED</code> (i.e. a  
 <code>CRLF</code> sequence) or a character  
 <code class=char>U+000D</code> <code class=charname>CARRIAGE RETURN</code>  
 <em class=rfc2119>MAY</em> be used as a <a href="#newline">newline</a> instead.  
 <a href="#newline">Newline</a> representations  
 <em class=rfc2119>SHOULD</em> be consistent in an  
 <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>  
 representation.</p>  
586    
587  <div class="note memo">            <dl class=switch>
588  <p>Therefore, newlines must be normalized before            <dt>If <var>c</var> is descendant combinator (white space)</dt>
589                <dd>Append a <code class=char>U+0020</code>
590                <code class=charname>SPACE</code> character to
591                <var>result</var>.</dd>
592              <dt>If <var>c</var> is child combinator
593              (<code class=char>></code>)</dt>
594                <dd>Append a <code class=char>U+003E</code>
595                <code class=charname>GREATER-THAN SIGN</code>
596                (<code class=char>></code>) character to <var>result</var>.</dd>
597              <dt>If <var>c</var> is adjacent sibling combinator
598              (<code class=char>+</code>)</dt>
599                <dd>Append a <code class=char>U+002B</code>
600                <code class=charname>PLUS SIGN</code> (<code class=char>+</code>)
601                character to <var>result</var>.</dd>
602              <dt>If <var>c</var> is general sibling combinator
603              (<code class=char>~</code>)</dt>
604                <dd>Append a <code class=char>U+007E</code>
605                <code class=charname>TILDE</code> (<code class=char>~</code>)
606                character to <var>result</var>.</dd>
607              </dl>
608            </li>
609            <li>Append a <code class=char>U+0020</code>
610            <code class=charname>SPACE</code> character to
611            <var>result</var>.</li>
612            </ol>
613          </dd>
614        </dl>
615      </ol>
616    </li>
617    <li>Then, <var>result</var> is the
618  <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>  <abbr title="Selectors Serialization Format for Testing">SSFT</abbr>
619  representations are literally compared.</p>  representation of <var>gs</var>.</li>
620  </div>  </ol>
621    
622  </div>  </div>
623    

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.16

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24