/[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.17 by wakaba, Mon Oct 22 11:33:15 2007 UTC revision 1.19 by wakaba, Mon Nov 5 10:59:48 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 98  in a tree structure and are used in Web Line 98  in a tree structure and are used in Web
98  <abbr>API</abbr></a>  <abbr>API</abbr></a>
99  <cite class="bibref informative">[<a href="#ref-SAPI">SAPI</a>]</cite>.</p>  <cite class="bibref informative">[<a href="#ref-SAPI">SAPI</a>]</cite>.</p>
100    
101  <div class="issue ed">...</div>  <p>It is so flexible language that a conceptually same pattern
102    can be represented in inifnite numbers of instances of selectors.
103    It might be convinient for e.g. validation of a test result to
104    define a subset of the language, in which no semantically equivalent
105    selectors are contained.</p>
106    
107  <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
108  <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 115  attribute.  However, the algorithm is in
115  <time datetime=2007-09-25>at the time of the writing</time>.    <time datetime=2007-09-25>at the time of the writing</time>.  
116  Note that current Web browser implementations  Note that current Web browser implementations
117  of the <code>selectorText</code> attribute are consistently broken  of the <code>selectorText</code> attribute are consistently broken
118  in not escaping unsafe identifiers.</p>  in not escaping unsafe identifiers and therefore it is not wise
119    to deploy that format for testing.</p>
120    
121  </div>  </div>
122    
# Line 157  to <a href="#algorithm-serialize-a-simpl Line 162  to <a href="#algorithm-serialize-a-simpl
162  selector</a> or <a href="#algorithm-serialize-a-group-of-selectors">serialize  selector</a> or <a href="#algorithm-serialize-a-group-of-selectors">serialize
163  a group of selectors</a>.</p>  a group of selectors</a>.</p>
164    
 <div class="issue ed">  
 <p><a href="http://suika.fam.cx/gate/cvs/*checkout*/markup/html/whatpm/Whatpm/CSS/SelectorsSerializer.pm">See  
 also the reference implementation</a> for now.</p>  
 </div>  
   
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 -->  
169    <div class="ed issue"><p>TODO: link terms to Selectors</p></div>
170    
171  <div class=section id=serializing-tokens>  <div class=section id=serializing-tokens>
172  <h3>Serializing Tokens</h3>  <h3>Serializing Tokens</h3>
173    
174  <p>To <dfn id=algorithm-normalize-an-ident title="normalize an IDENT">normalize  <p>To <dfn id=algorithm-normalize-an-ident title="normalize a string as an IDENT">normalize
175  an <code>IDENT</code> (<dfn id=var-n><var>n</var></dfn>)</dfn>,  a string (<dfn id=var-n><var>n</var></dfn>) as an <code>IDENT</code></dfn>,
176  the following algorithm <em class=rfc2119>MUST</em> be used:</p>  the following algorithm <em class=rfc2119>MUST</em> be used:</p>
177  <ol>  <ol>
178  <li>Replace the escape sequences (<code>\</code> and following  <li>If <var>n</var> is either an <code>IDENT</code> or a <code>HASH</code>,
179  characters) in <var>n</var> by characters represented by them  replace the escape sequences (<code>\</code> and following characters) in
180  respectively.</li>  <var>n</var> by characters represented by them respectively.</li>
181    <li>If <var>n</var> is a <code>HASH</code>, remove the leading
182    <code class=char>U+0023</code> <code class=charname>NUMBER SIGN</code>
183    (<code class=char>#</code>) character from <var>n</var>.</li>
184  <li>If there is any character that is <em>not</em> one of  <li>If there is any character that is <em>not</em> one of
185  <code class=char>U+002D</code> <code class=charname>HYPHEN-MINUS</code>  <code class=char>U+002D</code> <code class=charname>HYPHEN-MINUS</code>
186  (<code class=char>-</code>), <code class=char>U+0030</code>  (<code class=char>-</code>), <code class=char>U+0030</code>
# Line 226  character by string <code>\00002D</code> Line 230  character by string <code>\00002D</code>
230  <li>Then, <var>n</var> is the result of the algorithm.</li>  <li>Then, <var>n</var> is the result of the algorithm.</li>
231  </ol>  </ol>
232    
233  <p>To <dfn id=algorithm-normalize-a-string title="normalize a STRING">normalize  <p>To <dfn id=algorithm-normalize-a-string title="normalize a string (STRING or IDENT) as a STRING">normalize
234  a <code>STRING</code> (<dfn id=var-s><var>s</var></dfn>)</dfn>,  a string (<dfn id=var-s><var>s</var></dfn>) as a <code>STRING</code></dfn>,
235  the following algorithm <em class=rfc2119>MUST</em> be used:</p>  the following algorithm <em class=rfc2119>MUST</em> be used:</p>
236  <ol>  <ol>
237  <li><p>Replace the escape sequences (<code>\</code> and following  <li>If <var>s</var> is either an <code>IDENT</code> or a
238  characters) in <var>s</var> by characters represented by them  <code>STRING</code>, replace the escape sequences (<code>\</code> and
239    following characters) in <var>s</var> by characters represented by them
240  (or an empty string if <code>\</code> is immediately followed by  (or an empty string if <code>\</code> is immediately followed by
241  newline character(s)) respectively.</p></li>  newline character(s)) respectively.</li>
242  <li><p>Remove the quotation characters in <var>s</var>  <li>If <var>s</var> is a <code>STRING</code>, remove the quotation marks
243  if <var>s</var> is a <code>STRING</code>.</p>  enclosing <var>s</var>.</li>
   
 <div class="note memo">  
 <p>The input <var>s</var> to this algorithm may be an  
 <code>IDENT</code>.</p>  
 </div></li>  
244  <li><p>If there is any character that is <em>not</em> one of  <li><p>If there is any character that is <em>not</em> one of
245  <code class=char>U+0020</code> <code class=charname>SPACE</code>,  <code class=char>U+0020</code> <code class=charname>SPACE</code>,
246  <code class=char>U+0021</code> <code class=charname>EXCLAMATION MARK</code>  <code class=char>U+0021</code> <code class=charname>EXCLAMATION MARK</code>
# Line 292  representations are literally compared.< Line 292  representations are literally compared.<
292  It is tr/A-Z/a-z/ for now.</p>  It is tr/A-Z/a-z/ for now.</p>
293  </div>  </div>
294    
295    <p>To
296    <dfn id=algorithm-normalize-an-integer title="normalize an integer">normalize
297    an integer (<dfn id=var-int-i><var>i</var></dfn>)</dfn>, the following
298    algorithm <em class=rfc2119>MUST</em> be run:</p>
299    <ol class=algorithm>
300    <li>If <var>i</var> is equal to zero (0), return a string with only a
301    character: <code class=char>U+0030</code>
302    <code class=charname>DIGIT ZERO</code> (<code class=char>0</code>).
303    Stop the algorithm.</li>
304    <li>Let <dfn id=var-int-result><var>result</var></dfn> be an empty string.</li>
305    <li>If <var>i</var> is less than zero (0), append a
306    <code class=char>U+002D</code> <code class=charname>HYPHEN-MINUS</code>
307    (<code class=char>-</code>) character to <var>result</var>.</li>
308    <li>Append the decimal representation of the absolute value of
309    <var>i</var> to <var>result</var>.  The decimal (base$B!>(Bten) representation
310    <em class=rfc2119>MUST NOT</em> begin with a <code class=char>U+0030</code>
311    <code class=charname>DIGIT ZERO</code> (<code class=char>0</code>)
312    character.</li>
313    <li>Return <var>result</var>.</li>
314    </ol>
315    
316  </div>  </div>
317    
318    
# Line 319  the following algorithm <em class=rfc211 Line 340  the following algorithm <em class=rfc211
340        <dl class=switch>        <dl class=switch>
341        <dt>If a namespace URI is specified (via namespace prefix, or        <dt>If a namespace URI is specified (via namespace prefix, or
342        by omitting namespace prefix where a default namespace is specified)</dt>        by omitting namespace prefix where a default namespace is specified)</dt>
343          <dd class="ed">@@</dd>          <dd>Append the namespace URI as a
344            <a href="#algorithm-normalize-an-ident" title="normalize a string as an IDENT">normalized
345            <code>IDENT</code></a> to <var>r</var>.  Then, append a
346            <code class=char>U+007C</code>
347            <code class=charname>VERTICAL BAR</code> (<code class=char>|</code>)
348            character to <var>r</var>.</dd>
349        <dt>If the null namespace is specified (by zero$B!>(Blength namespace        <dt>If the null namespace is specified (by zero$B!>(Blength namespace
350        prefix)</dt>        prefix)</dt>
351          <dd>Append a <code class=char>U+007C</code>          <dd>Append a <code class=char>U+007C</code>
# Line 336  the following algorithm <em class=rfc211 Line 362  the following algorithm <em class=rfc211
362        </dl>        </dl>
363      </li>      </li>
364      <li>If <var>ss</var> is a type selector, append the      <li>If <var>ss</var> is a type selector, append the
365      <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>
366      local name to <var>r</var>.</li>      local name to <var>r</var>.</li>
367      <li>If <var>ss</var> is a universal selector, append      <li>If <var>ss</var> is a universal selector, append
368      a <code class=char>U+002A</code> <code class=charname>ASTERISK</code>      a <code class=char>U+002A</code> <code class=charname>ASTERISK</code>
# Line 353  the following algorithm <em class=rfc211 Line 379  the following algorithm <em class=rfc211
379        Append a namespace prefix as following:        Append a namespace prefix as following:
380        <dl>        <dl>
381        <dt>If a namespace URI is specified</dt>        <dt>If a namespace URI is specified</dt>
382          <dd class=ed>@@</dd>          <dd>Append the namespace URI as a
383          <dd class=ed>@@ Current reference implementation is wrong,          <a href="#algorithm-normalize-an-ident" title="normalize a string as an IDENT">normalized
384          since its result of sorting depends on namespace prefix.</dd>          <code>IDENT</code></a> to <var>r</var>.  Then, append a
385            <code class=char>U+007C</code>
386            <code class=charname>VERTICAL BAR</code> (<code class=char>|</code>)
387            character to <var>r</var>.</dd>
388        <dt>If the null namespace is specified</dt>        <dt>If the null namespace is specified</dt>
389          <dd>Append a <code class=char>U+007C</code>          <dd>Append a <code class=char>U+007C</code>
390          <code class=charname>VERTICAL BAR</code> character to          <code class=charname>VERTICAL BAR</code> character to
# Line 369  the following algorithm <em class=rfc211 Line 398  the following algorithm <em class=rfc211
398        </dl>        </dl>
399      </li>      </li>
400      <li>Append the      <li>Append the
401      <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>
402      local name to <var>r</var>.</li>      local name to <var>r</var>.</li>
403      <li>If a value is specified in <var>ss</var>:      <li>If a value is specified in <var>ss</var>:
404        <ol>        <ol>
# Line 389  the following algorithm <em class=rfc211 Line 418  the following algorithm <em class=rfc211
418  <dt>If <var>ss</var> is a class selector</dt>  <dt>If <var>ss</var> is a class selector</dt>
419    <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
420    STOP</code> (<code class=char>.</code>) character, followed    STOP</code> (<code class=char>.</code>) character, followed
421    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>
422    class name, to <var>r</var>.</dd>    class name, to <var>r</var>.</dd>
423  <dt>If <var>ss</var> is an <abbr>ID</abbr> selector</dt>  <dt>If <var>ss</var> is an <abbr>ID</abbr> selector</dt>
424    <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
425    SIGN</code> (<code class=char>#</code>) character, followed    SIGN</code> (<code class=char>#</code>) character, followed
426    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>
427    <abbr>ID</abbr>, to <var>r</var>.</dd>    <abbr>ID</abbr>, to <var>r</var>.</dd>
428  <dt>If <var>ss</var> is a pseudo$B!>(Bclass selector</dt>  <dt>If <var>ss</var> is a pseudo$B!>(Bclass selector</dt>
429    <dd>    <dd>
# Line 403  the following algorithm <em class=rfc211 Line 432  the following algorithm <em class=rfc211
432      <code class=charname>COLON</code> (<code class=char>:</code>) character      <code class=charname>COLON</code> (<code class=char>:</code>) character
433      to <var>r</var>.</li>      to <var>r</var>.</li>
434      <li>Append the      <li>Append the
435      <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>
436      name (in <a href="#lower-case">lower$B!>(Bcase</a>) of the pseudo$B!>(Bclass to      name (in <a href="#lower-case">lower$B!>(Bcase</a>) of the pseudo$B!>(Bclass to
437      <var>r</var>.</li>      <var>r</var>.</li>
438      <li>Append any arguments as following:      <li>Append any arguments as following:
# Line 415  the following algorithm <em class=rfc211 Line 444  the following algorithm <em class=rfc211
444            PARENTHESIS</code> (<code class=char>(</code>) character            PARENTHESIS</code> (<code class=char>(</code>) character
445            to <var>r</var>.</li>            to <var>r</var>.</li>
446            <li>Append the            <li>Append the
447            <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>
448            language tag (the argument) to <var>r</var>.            language tag (the argument) to <var>r</var>.
449            <span class="issue ed">Should we normalize cases?</span></li>            <span class="issue ed">Should we normalize cases?</span></li>
450            <li>Append a <code class=char>U+0029</code>            <li>Append a <code class=char>U+0029</code>
# Line 448  the following algorithm <em class=rfc211 Line 477  the following algorithm <em class=rfc211
477            <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
478            PARENTHESIS</code> (<code class=char>(</code>) character            PARENTHESIS</code> (<code class=char>(</code>) character
479            to <var>r</var>.</li>            to <var>r</var>.</li>
480            <li>Append <span class=ed>@@ normalized</span>            <li>Let <dfn id=var-a><var>a</var></dfn> be the <var>a</var>
481            integer <var>a</var> to <var>r</var>.            part of the argument.  If the argument is a keyword <code>odd</code>
482            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>.
483            <var>a</var> is <code>2</code>.  If <var>a</var> and            If the <var>a</var> part with following <code>n</code> character
484            <code>n</code> is omitted, <var>a</var> is assumed as            is omitted, then let <var>a</var> be <code>0</code>.
485            <code>0</code>.  Otherwise, if <var>a</var> is omitted,            Otherwise, if only the <var>a</var> part is omitted, then
486            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>
487            if there is a <code class=char>U+002D</code>            part is <code>-</code>, then let <var>a</var> be
488            <code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>)            <code>-1</code>.</li>
489            character).</li>            <li>Let <var>a</var> be the
490              <a href="#algorithm-normalize-an-integer" title="normalize an integer">normalized
491              string representation</a> of integer <var>a</var>.</li>
492              <li>Append <var>a</var> to <var>result</var>.</li>
493            <li>Append a <code class=char>U+006E</code>            <li>Append a <code class=char>U+006E</code>
494            <code class=charname>LATIN SMALL LETTER N</code>            <code class=charname>LATIN SMALL LETTER N</code>
495            (<code class=char>n</code>) character to <var>r</var>.</li>            (<code class=char>n</code>) character to <var>r</var>.</li>
496            <li>Append <span class=ed>@@ normalized</span>            <li>Let <dfn id=var-b><var>b</var></dfn> be the <var>b</var>
497            integer <var>b</var> to <var>r</var>.            part of the argument.  If the argument is a keyword <code>odd</code>,
498            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
499            either <code class=char>U+002B</code> <code class=charname>PLUS            keyword <code>even</code>, then let <var>b</var> be <code>0</code>.
500            SIGN</code> (<code class=char>+</code>) or            If the <var>b</var> part is omitted, then let <var>b</var> be
501            <code class=char>U+002D</code>            <code>0</code>.</li>
502              <li>Let <var>b</var> be the
503              <a href="#algorithm-normalize-an-integer" title="normalize an integer">normalized
504              string representation</a> of integer <var>b</var>.</li>
505              <li>If <var>b</var> does <em>not</em> start with a
506              <code class=char>U+002D</code>
507            <code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>)            <code class=charname>HYPHEN-MINUS</code> (<code class=char>-</code>)
508            character.  If the argument is a keyword <code>odd</code>,            character, then append <code class=char>U+002B</code>
509            <var>b</var> is <code>1</code>.  If the argument            <code class=charname>PLUS SIGN</code>
510            is a keyword <code>even</code>, <var>b</var> is            (<code class=char>+</code>) to <var>result</var>.</li>
511            <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>  
512            <li>Append a <code class=char>U+0029</code>            <li>Append a <code class=char>U+0029</code>
513            <code class=charname>RIGHT PARENTHESIS</code>            <code class=charname>RIGHT PARENTHESIS</code>
514            (<code class=char>)</code>) character            (<code class=char>)</code>) character
# Line 531  the following algorithm <em class=rfc211 Line 564  the following algorithm <em class=rfc211
564      <code class=charname>COLON</code> characters (<code>::</code>)      <code class=charname>COLON</code> characters (<code>::</code>)
565      to <var>r</var>.</li>      to <var>r</var>.</li>
566      <li>Append the      <li>Append the
567      <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>
568      name (in <a href="#lower-case">lower$B!>(Bcase</a>) of the pseudo$B!>(Belement      name (in <a href="#lower-case">lower$B!>(Bcase</a>) of the pseudo$B!>(Belement
569      to <var>r</var>.</li>      to <var>r</var>.</li>
570      <li>If the pseudo$B!>(Belement has any arguments:      <li>If the pseudo$B!>(Belement has any arguments:
# Line 582  the following algorithm <em class=rfc211 Line 615  the following algorithm <em class=rfc211
615      (<dfn id=var-sss><var>sss</var></dfn>)</dt>      (<dfn id=var-sss><var>sss</var></dfn>)</dt>
616        <dd>        <dd>
617          <ol>          <ol>
618          <li class=ed><a href="#algorithm-serialize-a-simple-selector">Serialize          <li>If <var>sss</var> contains a universal or type selector, then
619          each simple selector</a> in <var>sss</var>.</li>          <a href="#algorithm-serialize-a-simple-selector" title="serialize a simple selector">serialize
620          <li class=ed>sort</li>          that simple selector</a> and append the result to
621            <var>result</var>.</li>
622            <li>Otherwise, i.e. if <var>sss</var> does not contain a universal or
623            type selector, then
624            <a href="#algorithm-serialize-a-simple-selector" title="serialize a simple selector">serialize
625            a simple selector <code>*</code></a> and append the result to
626            <var>result</var>.</li>
627            <li><a href="#algorithm-serialize-a-simple-selector" title="serialize a simple selector">Serialize
628            any attribute selectors</a> in <var>sss</var>, sort the results,
629            then append them to <var>result</var> in order.</li>
630            <li><a href="#algorithm-serialize-a-simple-selector" title="serialize a simple selector">Serialize
631            any class selectors</a> in <var>sss</var>, sort the results,
632            then append them to <var>result</var> in order.</li>
633            <li><a href="#algorithm-serialize-a-simple-selector" title="serialize a simple selector">Serialize
634            any <abbr>ID</abbr> selectors</a> in <var>sss</var>, sort the results,
635            then append them to <var>result</var> in order.</li>
636            <li><a href="#algorithm-serialize-a-simple-selector" title="serialize a simple selector">Serialize
637            any pseudo$B!>(Bclass selectors</a> in <var>sss</var>, sort the results,
638            then append them to <var>result</var> in order.</li>
639            <li><a href="#algorithm-serialize-a-simple-selector" title="serialize a simple selector">Serialize
640            any pseudo elements</a> in <var>sss</var>, sort the results,
641            then append them to <var>result</var> in order.</li>
642          <li>Append a <a href="#newline">newline</a> to <var>result</var>.</li>          <li>Append a <a href="#newline">newline</a> to <var>result</var>.</li>
643          </ol>          </ol>
644        </dd>        </dd>

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.19

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24