Movatterモバイル変換


[0]ホーム

URL:


W3C

NOTE-stts2

Simple Tree Transformation Sheets 2

Submitted to W3C 17 October1997

This version:
http://www.w3.org/TR/NOTE-stts2-971017
French version:
http://www.w3.org/TR/NOTE-stts2-971017.html.fr
Author :
Daniel Glazman ,Electricité de France ,Research and Development Division

Status of this document

This document is a NOTE made available by the W3Consortium for discussion only. This indicates no endorsement of itscontent, nor that the Consortium has, is, or will be allocating anyresources to the issues addressed by the NOTE.

This document is a submission to W3C fromElectricité de France. Please seeAcknowledged Submissions toW3C regarding its disposition. This document is a proprietaryspecification developed by ELECTRICITE DE FRANCE partly based on theCascading Style Sheetsspecification. This document has been writen using a HTML 3.2 editorand then transformed byCSSize to take advantageof CSS.


  1. Status of this document
  2. Introduction
  3. Definitions and conventions
  4. Selectors
    1. Groups of selectors
    2. Hierarchical selector
    3. Sequential selector
    4. Unique hierarchical selector
    5. Direct relationship selector
    6. Attribute addressing selector
    7. Explosive selector
    8. Class addressing selector
    9. ID addressing selector
  5. Declarations
  6. Properties
    1. Change an element : transform-element
    2. Add a CSS style : add-style
    3. Add a class : add-class
    4. Add a style sheet : add-css
    5. Add a rule to a local style sheet : add-rule ouadd-unique-rule
    6. Add a HTML attribute: add-attribute
  7. Proof of concept
  8. STTS ruleset for deprecated HTML structures replacement
  9. References
  10. Acknowledgements

Introduction

The release of the Cascading Style Sheets in the World Wide Web universe the17 december 1996 is a major evolution of Web publishing. For the first time invery common software tools, it is possible to separate content and presentationin data. This old dream of SGML gurus, fighting against the rest of the world tomake them realize this is important, is now a reality. Each HTML element cancarry presentation styles.

The main effect of this evolution is the deprecation of several HTMLelements and attributes. It is then necesssary to describe the set oftransformations that should been applied to a HTML document containing thesedeprecated informations in order to make it conformant toHTML Clean and take advantage of CSS.

The current specification does not want to re-invent the wheel and it shouldnot be extended to a very large set of operations. DSSSL is recommended forlarge applications. The goal of the current specification is only providing avery simple, easy, quickly implementable of a transformation algorithm of HTMLdocuments that a HTTP server could handle on the fly for instance.

Definitions and conventions

A set of STTS transformations is made ofrules . Each rule is itself made of two parts :selectors anddeclarations .

Whenever a set of STTS rules is contained in a fileand the operating system ruling this file allows it, the common extensionassociated to this file should be*.tts

A selector is a condition attached to a HTML structure. If this condition istrue, the declarative part of the corresponding rule will be applied to thedeepest selected element in the document's structure.

A declaration is made of tho parts : aproperty and thevalue of this property. This property rules thetransformation applied to the element making the selector condition true.

The definition of each STTS property in this document contains a summarytable like the following one :

Valuepossible values or possible set of values
Applies toelements this property applies to

Selectors

A selector is conditional link between the structure of a HTML document anda set of STTS declarations.

Groups of selectors

It is possible to group selectors having the same declarative sectionseparating them with commas.

The following example

H1 { add-class : "centered" }H2 { add-class : "centered" }H3 { add-class : "centered" }

is then strictly equivalent to

H1, H2, H3 { add-class : "centered" }

Hierarchical selector

Two selectors separated by a space specify a condition on a HTML subtree (ahierarchical selector). For instance

DIV TT

specifies that the corresponding declarations are to be applied to allTT elements contained in aDIV element or in its descendance. Hierarchicalselectors are compatible with groups of selectors

P TT I, P TT EM

Sequential selector

A sequence of selectors surrounded by slashes/ indicates a sequence of conditions on acorresponding sequence of HTML elements. For instance

DIV /IMG UL/ { ... }

is to be applied toUL lists following an imageIMG and having the same parent, both of them contained in aDIV or in its descendance.

A double starting (respectively ending) slash indicates that the following(resp. preceeding) selector holds an additionnal condition : the correspondingselected element has to be the first (resp. last) child of its parent. Forinstance :

DL ~ //DT/ { ... }

is to be applied toDT elements being the first child of aDL definition list..

Unique hierarchical selector

A unique hierarchical selector is a special case of a sequential selector.

UL ~ //LI// { ... }

is to be applied toLI list items being the unique child of aUL unordered list..

Direct relationship selector

Two selectors separated by a tilda specify a direct relationship. Forinstance

DIV ~ TT { ... }

is to be applied to allTT elements directly contained in aDIV element. Without the tilda, declarationsare to be applied to allTT contained in aDIV or any element of its descendance.

/EM ~ TT/ { ... }

is to be applied to allTT directly following aEM (they have the same parent). Without thetilda, declarations are to be applied to allTT in the chain of elements following aEM (they have the same parent).

Attribute addressing selector

An attribute addressing selector is a condition on the existence or on thevalue of an attribute carried by a HTML element. This condition is describedbetween square brackets. For instance

P[ALIGN=CENTER] { ... }

is to be applied toP elements carrying theALIGN attribute havingCENTER for value.

TABLE[BORDER]   { ... }

is to be applied toTABLES elements carrying theBORDER attribute regardless to its value.

SPAN[CLASS=="abstract"] { ... }

Important : please note the double equal sign.
Thisrule is to be applied toSPAN elements carrying theCLASS attribute,this attribute being defined ascdata-list , one of its values beingabstract .

STTS rules using an attribute adressing selector can use the selected valuesof these attributes (or the values of these attributes if no value selection isspecified) in the declarative section of the rule. These values are available asenvironment variables$$1$ $$2$ ... . Two other variables areavailable :$$N$ which contains the name of the element therule is applied to and$$P$ which contains the name of its parentelement, if any.

For instance :

BODY[BGCOLOR][TEXT] {        add-style : "background-color : $$1$";        add-style : "color : $$2$";       }[align=CENTER] { add-class : "centered" }

Warning : groups of selectors can use differentattribute addressing selectors. Using these variables may then be incompatiblewith groups of selectors.

Explosive selector

There are two kinds of explosive selectors, both specified by the circumflexaccent^ :

Explosive selectors are only meaningful on the deepest selector.

An explosive element selector indicates that the content of the element mustreplace the element itself and that the declarative part of the rule is to beapplied to the parent element. For instance :

P ~ //^CENTER//  { add-class : centered }

applied to

<P><CENTER>coucou</CENTER></P>

will result in

<P CLASS=centered>coucou</P>

while

P ~ //CENTER//  { add-class : centered }

(without^ ) will result in

<P><CENTER CLASS=centered>coucou</CENTER></P>

An explosive attribute addressing selector is an attribute addressingselector indicating that this existing attribute has to be removed from the HTMLstructure after storing internally its value and before applying the declarativepart of the rule.

P[^ALIGN]  { add-style : "text-align : $$1$ }" }

Class addressing selector

A class addressing selector is a condition on one of the values of theCLASS attribute carried by a HTML element. Thiscondition follows a dot. .Only one class addressing selector is allowed per element.For instance

DIV ~ //P.abstract// { ... }

is to be applied toP elements carrying theabstract class and being the unique content ofaDIV element.

ID addressing selector

An ID addressing selector is a condition on the existence on the value oftheID attribute carried by a HTML element. Thiscondition follows a pound# . Only one ID addressing selector is allowedper element, of course. For instance

TD#a12 { ... }

is to be applied toTD table cells having IDa12 .

Declarations

The declarative part of a STTS rule follows the selectors and is describedbetween round brackets

{ ... }

If this section contains more than one declaration, a semi-column; separator is used between declarations.

Important : order of declarations does notmatter.

Properties

Change an element :transform-element

Valuename of a HTML element, between quoted or not.
Applies toall HTML elements

This property changes the name of the element the current rule is appliedto.

For instance, the rule

P#a12 { transform-element : DIV }

applied to

<P ID=a12>bonjour à tous </P>

will result in

<DIV ID=a12>bonjour à tous </DIV>

Warning : this transformation is performedregardless to the HTML DTD.

Add a CSS style :add-style

Valuea set of CSS declarations between quotes
Applicable àall HTML elements

This property adds theSTYLE attribute to the current element ifnecessary. It adds the contents of the declared value to the contents of thisattribute.

For instance, the rule

H1[^ALIGN] { add-style : "text-align : $$1$"           }

applied to

<H1 ALIGN=CENTER>Chapitre 1</H1>

will result in

<H1 STYLE="text-align : CENTER">Chapitre 1</H1>

Add a class :add-class

Valuename of a class, or a string containing a list of classes
Applies toall HTML elements

This property changes the current element adding the declared class(es) toitsCLASS attribute, which is created if necessary.

For instance, the rule

H1[^ALIGN] { add-class : "$$1$justif"           }

applied to

<H1 ALIGN=CENTER>Chapitre 1</H1>

will result in

<H1 CLASS=CENTERjustif>Chapitre 1</H1>

Add a style sheet :add-css

Valuevalue is made of two data :
  • a keyword
    • link if aLINK reference to an external CSS style sheetis to be added to the current document
    • style if the contents of the declared style sheet is to be integrated in theHTML document in a newSTYLE element
  • a character string between quotes containing the URL or path to a filecontaining the style sheet
Applies toHEAD only

This property adds toHEAD aLINK to a CSS style sheet or a newSTYLE containing the contents of the stylesheet.

For instance, the rule

HEAD { add-css : link "http://www.edf.fr/styles/default.css" }

applied to

...<HEAD><TITLE>title of this document</TITLE></HEAD>...

will result in

...<HEAD><TITLE>title of this document</TITLE><LINK REL=stylesheet TYPE="text/css"      HREF="http://www.edf.fr/styles/default.css"></HEAD>...

Add a rule to a local style sheet :add-rule andadd-unique-rule

Valuethe definition of a CSS rule
Applies toall HTML elements

This property adds to the current document, in an existing or createdSTYLE element inHEAD document's header, the specified CSS rule.If its definition contains double-quotes" , these quotes have to be preceeded by abackslash\ .

For instance :

BODY[^LINK] {     add-rule : "A:LINK { color : $$1$ } "    }

Important warning : this rule will be added eachtime selectors are matching the internal HTML structure. Replaceadd-rule byadd-unique-rule if you want this declaration tobe applied only once over the whole document. For instance, if you want todefine a CSS rule only if a certain CLASS exists in the document :

.thisClass {    add-unique-rule : ".otherClass { color : red }"}

Note : factorization of CSS rules if they have the sameselector, and factorization of CSS rules having the same declarative part butdifferent selectors is a more complex job, but is implementable. The wayadd-rule andadd-unique-rule add CSS rules to the documentdepends only on the implementation of the User Agent.

Add a HTML attribute:add-attribute

Valuedefinition of a HTML attribute
Applies toall HTML elements

This property adds to the selected element the attribute defined inproperty's value. If this value has to contain quotes", they should be preceeded by a backslash\. For instance : dynamic association of a CLASSto a language

.french { add-attribute : "LANG=fr" }

applied to

<H1 CLASS=french>Titre de la section</H1>

will result in

<H1 LANG=fr CLASS=french>Titre de la section</H1>

Warning : this transformation is performedregardless to the HTML DTD.

Proof of concept

STTS 2 are implemented in CSSize, proof of concept. CSSize is a new softwaredeveloped by theauthor of the current document at theResearch and Development Division of ELECTRICITE DE FRANCE, which is a W3Cmember.

For more information about CSSize, please contact

<cssize-t@cli51ak.der.edf.fr >

or consult the on-line data

<URL:http://lara0.exp.edf.fr/glazman/cssize.en.htm >

(after 1st November 1997).

A version of CSSize based on CSS 1 selectors (STTS 1) is already available.

STTS ruleset for deprecated HTML structuresreplacement

Here is an example of a set of STTS rules one can apply to a HTML 3.2document in order to replace some deprecated or old attributes and elements byCSS rules.Warning : this set is provided as is without anygaranty of any kind !.

XMP, PLAINTEXT, LISTING { transform-element : PRE }APPLET { transform-element : OBJECT }CENTER { transform-element : DIV ;         add-class         : centered       }TT     { transform-element : SPAN ;         add-class         : monospace       }I      { transform-element : SPAN ;         add-class         : italicized       }DIR, MENU { transform-element : UL }HEAD { add-css : style "standard.css" }BODY[^BGCOLOR][^TEXT][^LINK][^ALINK][^VLINK] {         add-style    : "background-color : $$1$" ;         add-style    : "color : $$2$" ;         add-unique-rule : "A:link     { color : $$3$ }" ;         add-unique-rule : "A:actived  { color : $$4$ }" ;         add-unique-rule : "A:visited  { color : $$5$ }"       }

thestandard.css file contains the following CSSrules :

.centered    { text-align     : center }.monospace   { font-family    : monospace }.italicized  { font-style     : italic }

References

Acknowledgements

Special thanks to

I also wish to thank the HTML Working Group and CSS+FP Working Groupchairmen and members who welcomed me in their Ali-Baba magic cave on behalf ofElectricité de France. The permanent brainstorming and discussionshappening there are the best seeds for imagination and creativity.


Daniel Glazman

Logo EDFmade with CSSThis document has been CSSized


[8]
ページ先頭

©2009-2025 Movatter.jp