Selectors Serialization Format for Testing (SSFT) Specification

Working Draft

This Version
<http://suika.fam.cx/www/markup/selectors/ssft/ssft>
Latest Version
<http://suika.fam.cx/www/markup/selectors/ssft/ssft>
Version History
<http://suika.fam.cx/gate/cvs/markup/selectors/ssft/ssft.en.html>
Author
<>

Abstract

...

Status of This Document

This section describes the status of this document at the time of its publication. Other documents might supersede this document.

This document is a working draft, produced as part of the manakai project. It might be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.

Comments on this document are welcome and may be sent to the author.

Translations of thie document might be available. The English version of the document is the only normative version.

Introduction

This section is non-normative.

Selectors [SELECTORS] are patterns that match against elements in a tree structure and are used in Web technologies, including CSS [CSS], HTML5 [HTML5], XBL2 [XBL2], and Selectors API [SAPI].

...

The CSSOM specification [CSSOM] is trying to define an algorithm to serialize a group of selectors for the purpose of selectorText attribute. However, the algorithm is incomplete . Note that current Web browser implementations of the selectorText attribute are consistently broken in not escaping unsafe identifiers.

Terminology

The key words MUST, MUST NOT, SHOULD, SHOULD NOT, and MAY in this document are to be interpreted as described in RFC 2119 [KEYWORDS].

All examples and notes in this specification are non-normative, as are all sections explicitly marked non-normative. Everything else in this specification is normative.

Serializing Groups of Selectors

See the reference implementation for now.

Newline is U+000A LINE FEED or U+000D U+000A or U+000A ??.

To serialize a group of selectors (gs):

  1. Let result an empty string.
  2. For each selector (selector) in gs:
    1. If selector is not the first selector in the group of selectors, then append a U+002C COMMA followed by a newline to result.
    2. Append four U+0020 SPACE characters to result.
    3. Process each sequence of simple selectors or combinator in selector by following algorithm:
      If it is a sequence of simle selector (sss)
      @@
      If it is a combinator (c)
      1. Append two U+0020 SPACE characters to result.
      2. If c is descendant combinator (white space)
        Append a U+0020 SPACE character to result.
        If c is child combinator (>)
        Append a U+003E GREATER-THAN SIGN character to result.
        If c is adjacent sibling combinator (+)
        Append a U+002B PLUS SIGN character to result.
        If c is general sibling combinator (~)
        Append a U+007E TILDE character to result.
      3. Append a U+0020 SPACE character to result.
  3. Then, result is the SFFT representation of the group of selectors.

To serialize a simple selector (ss):

If ss is a type or universal selector
If a namespace URI is specified (via namespace prefix, or by omitting namespace prefix where a default namespace is specified)
@@
If the null namespace is specified (by zero‐length namespace prefix)
Return a U+007C VERTICAL BAR character, followed by either local name (if ss is a type selector) or a U+002A ASTERISK character (if ss is a universal selector).
If no namespace is specified (by namespace prefix *, or by omitting namespace prefix where no default namespace is specified)
Return a U+002A ASTERISK character, followed by a U+007C VERTICAL BAR character, followed by either local name (if ss is a type selector) or a U+002A ASTERISK character (if ss is a universal selector).
@@

Parsing SFFT Groups of Selectors

Since the serializing algorithm is so designed that it always output a valid group of selectors, no special parser for SFFT is necessary. Any conforming group of selectors parser MAY be used to parse SFFT groups of selectors.

Examples

This section is non-normative.

Try demo, by choosing Selectors radio button.

...
...

References

Normative References

KEYWORDS
Key words for use in RFCs to Indicate Requirement Levels, IETF BCP 14, RFC 2119, . This version of the specification is referenced
SELECTORS
Selectors, W3C Working Draft, . Work in progress. The latest version of the specification is referenced.

Non-normative References

CSS
Cascading Style Sheets Level 2 Revision 1 (CSS 2.1) Specification, W3C Candidate Recommendation, . Work in progress. The latest version of the specification is available at <http://www.w3.org/TR/CSS21>.
CSSOM
Cascading Style Sheets Object Model (CSSOM), W3C Editor's Draft, . Work in progress. The latest Editor's Draft of the specification is available at <http://dev.w3.org/csswg/cssom/Overview.html>.
HTML5
HTML 5, WHATWG Working Draft. Work in progress.
SAPI
Selectors API, W3C Editor's Draft, . Work in progress. The latest Editor's Draft of the specification is available at <http://dev.w3.org/2006/webapi/selectors-api/Overview.html>. The latest published version of the specification is available at <http://www.w3.org/TR/selectors-api/>.
XBL2
XBL 2.0, Mozilla.org, . Work in progress. The latest W3C‐published version of the specification is available at <http://www.w3.org/TR/xbl/>.