SDPL 2002Notes 4: Intro to Style Sheets1 4. Introduction to Style Sheets n Discussed recently:...
-
Upload
hugh-caldwell -
Category
Documents
-
view
212 -
download
0
Transcript of SDPL 2002Notes 4: Intro to Style Sheets1 4. Introduction to Style Sheets n Discussed recently:...
SDPL 2002 Notes 4: Intro to Style Sheets 1
4. Introduction to Style Sheets4. Introduction to Style Sheets
Discussed recently: Discussed recently: – Programmatic manipulation of documentsProgrammatic manipulation of documents
Now a more human-oriented point of view:Now a more human-oriented point of view:– How to specify formatting or rendering of How to specify formatting or rendering of
structured documents?structured documents?
Concepts, properties and requirements of Concepts, properties and requirements of style systems on a general levelstyle systems on a general level– a semantic analysis of style systemsa semantic analysis of style systems– later examples of concrete style languages later examples of concrete style languages
(CSS, XSL)(CSS, XSL)
SDPL 2002 Notes 4: Intro to Style Sheets 2
Introduction to Style SheetsIntroduction to Style Sheets
(Inspired by (Inspired by Brüggemann-Klein, A., Wood, D., Electronic Brüggemann-Klein, A., Wood, D., Electronic Style Sheets. Universität Freiburg, Institut für Informatik, Style Sheets. Universität Freiburg, Institut für Informatik, Bericht 43, Januar 1992Bericht 43, Januar 1992))
Declarative markup of structured documents Declarative markup of structured documents indicates purely syntactic structureindicates purely syntactic structure– no semantics (processing, formatting, …)no semantics (processing, formatting, …)
Electronic style sheetsElectronic style sheets– specify layout and appearance of document specify layout and appearance of document
contentcontent– e.g. FrameMaker templates, Word styles, or e.g. FrameMaker templates, Word styles, or
LaTeX style files (macros);LaTeX style files (macros);CSS and XSL style sheetsCSS and XSL style sheets
SDPL 2002 Notes 4: Intro to Style Sheets 3
Style Sheets?Style Sheets?
In traditional publishing: set of rules about In traditional publishing: set of rules about diction and language for some manuscriptdiction and language for some manuscript
Electronic style sheetsElectronic style sheets– deal with deal with graphical layoutgraphical layout of documents of documents
(In future with (In future with auralaural properties, too?) properties, too?)– setting and changing of properties controlling setting and changing of properties controlling
layout and appearance of document contentlayout and appearance of document content– define a mapping from documents define a mapping from documents
(structure+content) to external representation on a (structure+content) to external representation on a presentation medium (paper, screen, audio, …)presentation medium (paper, screen, audio, …)
SDPL 2002 Notes 4: Intro to Style Sheets 4
Why Style Sheets?Why Style Sheets?
Separation of content and presentation is a Separation of content and presentation is a basic "dogma" in structured documentingbasic "dogma" in structured documenting– supports longevity and multi-use of documentssupports longevity and multi-use of documents– (unnecessary complication for single-purpose and (unnecessary complication for single-purpose and
single-use documents)single-use documents) Relationship between documents and style sheets is Relationship between documents and style sheets is
many-to-manymany-to-many– single style for many documentssingle style for many documents
» supports manageability (of, say, consistent look and feel of a supports manageability (of, say, consistent look and feel of a corporate Web site)corporate Web site)
– many styles for a single documentmany styles for a single document» supports multiple output media (print, different Web clients, hand-supports multiple output media (print, different Web clients, hand-
held-devices, …)held-devices, …)
SDPL 2002 Notes 4: Intro to Style Sheets 5
Tasks of a Style SheetTasks of a Style Sheet
Style sheet guides the Style sheet guides the transformationtransformation of of– descriptive markup into formatter input (stream descriptive markup into formatter input (stream
of formatting commands and text)of formatting commands and text)» called called transcriptiontranscription by Brüggemann-Klein & Wood by Brüggemann-Klein & Wood
FormatterFormatter isis a device (program) capable of a device (program) capable of – hyphenation (breaking of character sequences)hyphenation (breaking of character sequences)– typeface attribution (characters into typeface attribution (characters into glyphsglyphs))
» e.g, single glyphe.g, single glyph fifi for " for "fi"fi"– line breaking (assembling glyphs into lines)line breaking (assembling glyphs into lines)– page breaking (lines into pages)page breaking (lines into pages)
SDPL 2002 Notes 4: Intro to Style Sheets 6
Process of Transcription/Transformation Process of Transcription/Transformation
doc
Structu red docum ent
sect id="sec t3 "
xre f
T ranscrip tionFormatter input
- T eX ,FO T
(X S L fo rm attingo bject tree)
S tyle sheet- Latex s tyle file ,
C S S ,X S L
SDPL 2002 Notes 4: Intro to Style Sheets 7
Process of FormattingProcess of Formatting
Creates a detailed description of presentationCreates a detailed description of presentation
Form atter
Formatter input- T eX ,FO T
(X S L fo rm attingo bject tree) TeX , FOP , ...
D escr. o fpresenta tion- DVI, PS, PDF
– > style sheet may not have total control of the final > style sheet may not have total control of the final formatted presentation!formatted presentation!
SDPL 2002 Notes 4: Intro to Style Sheets 8
Process of RenderingProcess of Rendering
Display/play the document on output mediumDisplay/play the document on output medium
Prin ter d riverDVI,PS,PDF
So me te x t lin e s So me te x t lin e s So me te x t lin e s So me te x tlin e So me te x t lin e s So me te x t lin e s So me te x t lin e s So me te x tlin e So me te x t lin e s So me te x t lin e s So me te x t lin e s So me te x tlin e So me te x t lin e s So me te x t lin e s So me te x t lin e s So me te x t
lin e So me te x t lin e s So me te x t lin e s So me te x t lin e
s So me te x t lin e So me te x t lin e s So me te x t lin e s So me te x tlin e s So me te x t lin e So me te x t lin e s So me te x t lin e s So me te x tlin e s So me te x t lin e So me te x t lin e s So me te x t lin e s So me te x tlin e s So me te x t lin e So me te x t lin e s So me te x t lin e s So me te x t
lin e s So me te x t lin e So me te x t lin e s So
me te x t lin e s So me te x t lin e s So me te x t lin e So me te x t lin e sSo me te x t lin e s So me te x t lin e s So me te x t lin e So me te x t lin e sSo me te x t lin e s So me te x t lin e s So me te x t lin e So me te x t lin e sSo me te x t lin e s So me te x t lin e s So me te x t lin e So me te x t lin e sSo me te x t lin e s So me te x t lin e s So me te x t lin e So me te x t lin e sSo me te x t lin e s So me te x t lin e s So me te x t lin e So me te x t lin e s
So me te x t lin e s So me te x t lin e s So me te x t lin e
D isp lay d river
SDPL 2002 Notes 4: Intro to Style Sheets 9
Style RulesStyle Rules
Style sheet is a set of Style sheet is a set of style rulesstyle rules– Attach transcriptions to logical elementsAttach transcriptions to logical elements
Most style rules in practiseMost style rules in practise structure-based structure-based– associated to associated to instancesinstances of element types in the of element types in the
document structure treedocument structure tree
AlsoAlso grammar-based grammar-based style rules style rules– associated to occurrences of associated to occurrences of element types inelement types in the the
document document grammargrammar
SDPL 2002 Notes 4: Intro to Style Sheets 10
Transcription typesTranscription types
Fundamental operations of style rules Fundamental operations of style rules fall into followingfall into following transcription types transcription types::1. calls of parameterised formatting tasks1. calls of parameterised formatting tasks
2. generation of text2. generation of text
3. automatic numbering3. automatic numbering
4. rearrangement of elements4. rearrangement of elements Application of transcriptions can depend on Application of transcriptions can depend on
element element contextcontext
SDPL 2002 Notes 4: Intro to Style Sheets 11
Context Specification (1)Context Specification (1)
General rule:General rule:– semantically equivalent structures (instances of the semantically equivalent structures (instances of the
same element type) should be formatted identicallysame element type) should be formatted identically Exceptions Exceptions (due to conventions, aesthetics, etc)(due to conventions, aesthetics, etc)
– all paragraphs indented, all paragraphs indented, exceptexcept for the first one for the first one– heading numbers heading numbers 1, 2,1, 2, … in … in bodybody butbut
A), B),A), B), … in … in appendixappendix– author lists in references: ‘‘author lists in references: ‘‘Aho and UllmanAho and Ullman’’ (just a ’’ (just a
few)‘ ‘vs few)‘ ‘vs Aho et al.Aho et al.’’ (’’ (ifif several authors) several authors)– indication of target element type (indication of target element type (Table, Figure, Table, Figure,
Section,Section, ...) for cross references ...) for cross references
SDPL 2002 Notes 4: Intro to Style Sheets 12
Context Specification (2)Context Specification (2)
Need access to ancestors, siblings, Need access to ancestors, siblings, descendants, targets of cross references descendants, targets of cross references
Context conditions by a Context conditions by a context predicatecontext predicate– Boolean expression built of Boolean expression built of
» a reference to the a reference to the current elementcurrent element » functions like functions like parent, leftSibling, leftMostSibling, parent, leftSibling, leftMostSibling,
children, children, andand ref ref– Rule applied if the context condition is trueRule applied if the context condition is true
Context specification orthogonal to Context specification orthogonal to transcription types transcription types (In XSL through the XPath expression language)(In XSL through the XPath expression language)
SDPL 2002 Notes 4: Intro to Style Sheets 13
Parameterised Formatting TasksParameterised Formatting Tasks
The most common transcription type:The most common transcription type: set formatting characteristics for sub-elementsset formatting characteristics for sub-elements
– typeface attribution (for strings or typeface attribution (for strings or inline-elementsinline-elements))– line breaking (for paragraphs or line breaking (for paragraphs or blocksblocks))– page breaking (for documents)page breaking (for documents)– parameterised by type size, line length, indentation, parameterised by type size, line length, indentation,
page height…page height… hierarchy of elements hierarchy of elements
hierarchy of nested formatting tasks hierarchy of nested formatting tasks hierarchy of nested presentation areas hierarchy of nested presentation areas
SDPL 2002 Notes 4: Intro to Style Sheets 14
Hierarchy in FormattingHierarchy in Formatting
Document structureDocument structure Formatting tasks / Formatting tasks / presentation areaspresentation areas
SDPL 2002 Notes 4: Intro to Style Sheets 15
Derived or Inserted ContentDerived or Inserted Content
boilerplate textboilerplate text– text not present in the source documenttext not present in the source document– e.g., letter headings, © marks, bullets, …e.g., letter headings, © marks, bullets, …
textual content inserted at the beginning textual content inserted at the beginning or at the end of the current elementor at the end of the current element
table of contents, indexestable of contents, indexes– need to specify the source of included need to specify the source of included
materialmaterial
SDPL 2002 Notes 4: Intro to Style Sheets 16
Numbering (1)Numbering (1)
Different schemesDifferent schemes– consecutively through documentconsecutively through document
» same numbering sequence, possibly common to a same numbering sequence, possibly common to a set of element types (e.g., for Theorems and set of element types (e.g., for Theorems and Examples)Examples)
– nested numbering for, say, nested listsnested numbering for, say, nested lists» relative to occurrences of another element type relative to occurrences of another element type
higher in document hierarchyhigher in document hierarchy
SDPL 2002 Notes 4: Intro to Style Sheets 17
Numbering (2)Numbering (2)
Example of different numbering schemes:Example of different numbering schemes:SectionSection 11
TheoremTheorem 11, or , or 1.11.1FigureFigure 22, or , or 11, or , or 1.11.1, or , or 1.21.2
SectionSection 22
TheoremTheorem 33, or , or 22, or , or 2.12.1 often via named often via named counterscounters with a start value with a start value
and a scope (e.g., in CSS2)and a scope (e.g., in CSS2)– In XSLT: special expressions for generating In XSLT: special expressions for generating
numbersnumbers
SDPL 2002 Notes 4: Intro to Style Sheets 18
Sub-element RearrangementSub-element Rearrangement
ExamplesExamples– reverse the order of titles and authors in reverse the order of titles and authors in
referencesreferences– sorting of the reference listsorting of the reference list
» requires functions operating on textual contentsrequires functions operating on textual contents
Sub-element Sub-element suppressionsuppression a special case a special case Not supported by the weakest style systemsNot supported by the weakest style systems
SDPL 2002 Notes 4: Intro to Style Sheets 19
Viewpoint on Style LanguagesViewpoint on Style Languages
Style systems should support traditional Style systems should support traditional stylistic design conventionsstylistic design conventions
Next a look at CSS, and later at XSLNext a look at CSS, and later at XSL– How do the discussed concepts appear in How do the discussed concepts appear in
the languages?the languages?– How do the languages support these How do the languages support these
general requirements?general requirements?