Basically, when we (i.e., Hakon and I) invent a syntax for a certain
feature, we start with the syntax for CSS2, and then simplify it for
CSS1. We're certainly not "tossing in random bits of punctuation"
(Chris Lilley). The following are probably the most important
constraints:
1. CSS2 must be general enough for a large class of DTDs, certainly
not just HTML
2. CSS1 must be simple enough not to have much overhead when used
only for HTML
3. Formatter needs a stack of elements only, no full SGML tree.
4. Readable and writable: so no nesting, no delimiters not normally
seen in prose, no constructs that invite hard-to-find
syntax errors, not too verbose, etc.
5. Easily parseable, both top-down (LL[1]) and bottom up (LALR).
(1) leads to support for arbitrary GIs, attributes and IDs. (2) leads
to shortcuts for HTML. (3) precludes Glenn's proposal to count
elements or even use full TEI xptr's (although I agree they are very
nice).
So we have [attr=val] for addressing based on attributes and a
shortcut `.val' for one designated attribute, which by default is
`class'. And yes, it *does* scale: in CSS2 there is a definition at
the top of the style sheet that declares this attribute explicitly, so
you can say `@class TYPE' at the top for TEI style sheets. (It used to
be `@archform' but `@class' may be clearer.)
1. (P [class = policy]) }
2. P.policy } all equivalent, but only 2 is in CSS1
3. (P [CLASS="policy"]) }
4. (A [HREF]) an A with a non-implied HREF
Quotes around the value are needed in the same cases as in SGML: when
`val' is not made up of only letters and digits.
To simplify CSS1, we disallow addressing based on attributes, but keep
the shortcut to address classes.
The `[]' are arbitrary delimiters. As Chris Lilley said, the ']' is
redundant, but a little redundancy is usually better for humans. I
think `[]' looks friendlier than Chris's `@', but that is a matter of
taste.
For addressing ID's we have a similar shortcut, though this one
actually needs some help from the SGML parser, since the formatter
doesn't know the DTD. Assuming attribute NAME is declared as an ID in
the DTD, you can do:
1. [NAME = "p004"] } equivalent, but only 2 is in CSS1
2. "p004" }
Note that (1) doesn't need support from the SGML parser, while (2)
does. Again, we could have used Chris's `#' instead of quotes, but I
think the `#' would scare non-programmers.
Bert
-- Bert Bos ( W 3 C ) http://www.w3.org/ bert@w3.org INRIA project RODEO/W3C http://www.w3.org/pub/WWW/People/Bos/ 2004 Rt des Lucioles / BP 93 +33 93 65 77 71 06902 Sophia Antipolis Cedex, France