Pseudo-classes and -elements

The formal grammer and section 2.5 say that pseudo-elements 
are only allowed in the last simple sector. However, any simple
selector may have a pseudo-class. This is not specified in the
formal grammar.

Further, there is a semantic distinction between pseudo-classes and
pseudo-elements (pseudo-classes are more like attributes while 
pseudo-elements are more like elements). IMHO there should be
a formal distinction between the two constructs. Otherwise (as I
have noted in recent postings) pseudo-classes and pseudo-elements
will be confused.

Further: Using the same syntax for both pseudo-elements and -classes
causes same (avoidable) difficulties in the specification of the
formal grammar and the implementation of the parser.

Example: Can an element be both pseudo-classed and have a 
pseudo-element? If so, how should the parser distinguish?
Pseudo-classes and -elements can be distinguished by their 
name, so the problem could be solved by using a table-lookup
in the lexical analyzer. And if a pseudo-class name is misspelled,
should the error message then be "Illegal name of pseudo-class
or maybe pseudo-element"?

I'm currently thinking about how to interpret style sheets for
arbitrary SGML documents with arbitrary DTDs. For this purpose, I
think it necessary to allow selection of elements via attribute 

Suppose one uses a construct like "foo.(bar=xyz)" to select 
foo-elements with attribute value bar equal xyz. Now, "foo.punk"
can be interpreted as "foo.(class=punk)" and "#xyz" can be 
interpreted as ".(id=xyz)" (wether this makes sense for the DTD
or not).

But the interpretation of pseudo-classes (or, more generally: 
pseudo-attributes) and pseudo-elements is open, e.g. what is
selected by "foo : bar"?

My proposal is, to use the class syntax for specification of
pseudo-classes and (to avoid name clashes), to prefix the name
of pseudo-classes with SGML RNI (reserved name indicator), i.e.
the '#'-character.

Thus, "A.#link" would be mapped to "A.(class='#link')".

For consistency, the names of pseudo-elements should be prefixed,
too. Instead of "P : first-line" you would have "P : #first-line".

Now one could think, that the '#'-character is redundant here, but
if you change the meaning of the colon-notation "A : B" from "B is
pseudo-element in A" to "B is child of A" (i.e. direct descendant), 
you are compatible with existing implementations and have a 
consistent extension of the selector syntax.

bse - Buero fuer Software-Entwicklung     Email:
                                          WWW  :
Rosenheimer Str. 214                      Phone: +49 89 497738	
80807 Munich, Germany                     Fax  : +49 89 497738

Received on Tuesday, 12 March 1996 03:49:46 UTC