71
SNU OOPSLA Lab. XML Documents 3 : processing XML Documents he ubiquitous XML(4) © copyright 2001 SNU OOPSLA Lab.

SNU OOPSLA Lab. XML Documents 3 : processing XML Documents The ubiquitous XML(4) © copyright 2001 SNU OOPSLA Lab

Embed Size (px)

Citation preview

SNUOOPSLA Lab.

XML Documents 3 : processing XML Documents

The ubiquitous XML(4)

© copyright 2001 SNU OOPSLA Lab.

2SNUOOPSLA Lab.The ubiquitous XML

Processing XML documents

Processing XML Data Document Formatting (XSL &

XSLT)

Processing XML data

3SNUOOPSLA Lab.The ubiquitous XML

Contents : processing XML data Concepts Writing XML Reading XML Event processing Tree manipulation Events or trees? Transformation tools

Processing XML data

4SNUOOPSLA Lab.The ubiquitous XML

Developing software to generate XML output is a trivial matter. However, reading an XML documents can be complicated by a number of issues and features of the language. Thus the DTD may need to be processed, either to add default information, or to compare against the document instance in order to validate it.

Concepts (1/4)

XML processor

<-->-------<-->

rules

data

errors

Application

Processing XML data

5SNUOOPSLA Lab.The ubiquitous XML

Programmers wishing to read XML data files need an XML-aware processing module, termed an XML processor.

XML processor - XML processor is responsible for marking the conten

t of the document available to the application - detect problems such as file formats that the applic

ation cannot process, or URLs that do not point to valid resources.

Concepts (2/4)

Processing XML data

6SNUOOPSLA Lab.The ubiquitous XML

Two fundamentally different approaches to reading the content of an XML document are known as the ‘event-driven’ and ‘tree-manipulation’ techniques.

Event-driven - Document is processed in strict sequence. - Each element in the data stream is

considered as event trigger, which may precipitate some special action on the part of the application.

Concepts (3/4)

Processing XML data

7SNUOOPSLA Lab.The ubiquitous XML

Tree-manipulation - The tree approach provides access to the

entire document, allowing its contents to be interrogated and manipulated in any order.

Concepts (4/4)

Processing XML data

8SNUOOPSLA Lab.The ubiquitous XML

Writing XML (1/3) To produce XML data, it is only necessary to

include XML tags in the output strings. However, one decision that has to be made is whether to output line-end codes or whether to omit them.

In many respects it is simpler and safer to omit line-end codes. But if the XML document is likely to be viewed or edited using tools that are not XML-aware, this approach makes the document very difficult to read.

Processing XML data

9SNUOOPSLA Lab.The ubiquitous XML

Some text editors will only display as much text as will fit on one line in the window

Although some editors are able to display more text by creating ‘soft’ line breaks at the right margin, the content is still not very legible.

It would seem to be more convenient to break the document into separate lines at obvious points in the text. However, there may be a problem for the recipient application in determining when line-end codes are there purely to make the XML data file more legible.

Writing XML (2/3)

Processing XML data

10SNUOOPSLA Lab.The ubiquitous XML

Writing XML (3/3)

<book><front><title>The Book Title</title><author>J. Smith</author><date>October 1917</date></front><body> <chapter><title>First Chapter</title><para>This is the first chapter in the book.</para><para>This is the …….

<book><front><title>The Book Title</title><author>J. Smith</author><date>October 1917</date></front><body> <chapter><title>First Chapter</title><para>This is the first chapter in the book.</para><para>This is the ……. …..

Processing XML data

11SNUOOPSLA Lab.The ubiquitous XML

Reading XML (1/4)

XML processor

<-->-------<-->

image

data

Application

entity manager

XML fragment

XML document

Processing XML data

12SNUOOPSLA Lab.The ubiquitous XML

Reading XML (2/4) The XML processor hides many complications

from the application.

The XML processor has at least one sub-unit, termed the entity manager, which is responsible for locating fragments of the document held in entity declarations or in order data files, and handling replacement of all references to them

Processing XML data

13SNUOOPSLA Lab.The ubiquitous XML

The XML processor delivers data to application, but there are two distinct ways in which this can be done.

(1) Event driven The simplest is to pass the data directly to the

application as a stream. The application accepts the data stream and reacts to the markup as it is encountered.

Reading XML (3/4)

Processing XML data

14SNUOOPSLA Lab.The ubiquitous XML

Reading XML (4/4)(2) Tree-walking XML processor holding onto the data on the

application’s behalf, and allowing the application to ask questions about the data and request portions of it.

- Grove A tree or group of trees can be stored in a

data structure.

Processing XML data

15SNUOOPSLA Lab.The ubiquitous XML

Event processing (1/2) The simplest method of processing an XML document is

to read the content as a stream of data, and to interpret mark up as it is encountered.

If out-of-sequence processing is required, such as needing to collect all the titles in a document for insertion at the start of the document as a table of contents, then a ‘two -pass’ processor is needed.

In the first pass, the titles are collected. In the second pass, they are inserted where they required.

Processing XML data

16SNUOOPSLA Lab.The ubiquitous XML

Event processing (2/2) Simple API for XML(SAX 1.0) To reduce the workload of the application

developer, and make it easy to replace one parser with another, a common event-driven interface has been proposed for object-oriented languages such as JAVA.

Processing XML data

17SNUOOPSLA Lab.The ubiquitous XML

Tree manipulation (1/3) Software that holds the entire document in

memory needs to organized the content so that it can be easily searched and manipulated.

There is no need for multi-pass parsing when any part of the document can be accessed instantly.

Applications that benefit from this approach include XML-aware editors, pagination engines and hypertext-enabled browsers.

Processing XML data

18SNUOOPSLA Lab.The ubiquitous XML

The abstract description of the model for SGML documents is called grove, and the grove scheme is equally applicable to XML.

The name ‘grove’ is appropriate because it mainly describes a series of trees.

A grove is a ‘directed graph of nodes’

Each node is an object of a specified type: a package of information that conforms to a pre-defined template.

Tree manipulation (2/3)

Processing XML data

19SNUOOPSLA Lab.The ubiquitous XML

A property has a name and a value, so can be compared to an attribute.

A node that describes a person mat have a property called ‘age’ which holds the value representing the age of an individual.

A node must have a type property, and name property, so that it can be identified, or referred to.

node

para

element

property

Property value type

gi

Tree manipulation (3/3)

Processing XML data

20SNUOOPSLA Lab.The ubiquitous XML

Events or trees ? (1/3) Event-driven benefits - The parser does not have to hold much

information about the documents in memory.

- The document structure does not have to be managed in memory, either by the parser or, depending on what it needs to do, by the application. This make parsing very fast.

- It does not have to do anything special in order to process the document in a simple linear fashion, from start to end.

Processing XML data

21SNUOOPSLA Lab.The ubiquitous XML

Tree-walking benefits. - With the entire document held in memory, the document str

ucture can be analyzed several times over, quickly and easily. - The data structure management module may be profitably utilized by the application to the manage the document components on its behalf.

- A documents that contains errors can be rejected before the application begins to process its contents, thereby eliminating the need for messy roll-back routines.

Events or trees ? (2/3)

Processing XML data

22SNUOOPSLA Lab.The ubiquitous XML

Other considerations- The memory usage advantage of the event-driven approach may be only theoretical.

- If the application uses an event-driven API, the parser need not build a document tree, but if the application uses a tree-walking API, it can itself use the event-driven API to build its tree model.

Events or trees ? (3/3)

Processing XML data

23SNUOOPSLA Lab.The ubiquitous XML

Transformation tools When the intent is simply to change an XML

document structure into a new structure, there are existing tools.

These tools can usually do much more advanced things, such as changing the order of elements, sorting them, and generating new content new content automatically.

It can transform XML document into another XML document, or into an HTML document.

Processing XML data

24SNUOOPSLA Lab.The ubiquitous XML

Processing XML documents

Processing XML Data Document Formatting (XSL & XSLT)

25SNUOOPSLA Lab.The ubiquitous XML

Contents : Document Formatting

Concepts Selecting a style sheet XSLT Style sheet DTD issues XSL

XSL & XSLT

26SNUOOPSLA Lab.The ubiquitous XML

Concepts of XSL XML Stylesheet Language XML documents are intended to be

easily read by both people and software People don’t want to see documents

with tags It is necessary to replace the tags with

appropriate text styles

XSL & XSLT

27SNUOOPSLA Lab.The ubiquitous XML

Concepts of Style sheets (1/2)

<title>An example of style</title><intro><para>This example shows how important styleIs to material intended to be read.</para></intro><para>This is a <em>normal</em> paragraph.</para ><warning><para>Styles are important!</para><warning>

An example of style This example shows how importantstyle Is to material intended to be read. This is a normalparagraph. Styles are important!

An example of style

This example shows how important style Is to material intended to be read.

This is a normal paragraph.

Warning: Styles are important!

Removal of tag ?

Style applied

XSL & XSLT

28SNUOOPSLA Lab.The ubiquitous XML

Concepts of Style sheets (2/2)

authoring

DTD style sheet

documents

presentation

<title>This is a title</title>

<p>This paragraph contains

a <em>highlighted</em> term.</p>This is a titleThis paragraph contains a highlighted term

This is a titleThis paragraph contains a highlighted term

XSL & XSLT

29SNUOOPSLA Lab.The ubiquitous XML

Concepts of DTD and style sheet A single style sheet may be applied to a

number of documents formatted in the same way

An XML document can be associated with more than one style sheet.

Authoring

DTD Style sheet A Presentation

DocumentsStyle sheet B Presentation

XSL & XSLT

30SNUOOPSLA Lab.The ubiquitous XML

Concepts of Styling with XSL A set of formatting objects In this first version, all allowed formattin

g objects are rectangular FO DTD(Formatting Objects DTD)

Elements such as ‘block’ Attributes such as ‘text-align’

XSL & XSLT

31SNUOOPSLA Lab.The ubiquitous XML

Concepts of Transforming with XSLT(1/2)

To author XML document with FO DTD is obviously negate the entire philosophy of XML – self describing, not self formatting of HTML

An XSLT processor takes an existing XML document as input, and generates a new XML document with new DTD as output.

XSL & XSLT

32SNUOOPSLA Lab.The ubiquitous XML

Concepts of Transforming with XSLT (2/2)

XSLT style sheetSource DTD

XML document XSLT processor

New XML document

Presentation

FO DTD

XSL processor

An <emph>emphasized</emph> word.

<template match=“emph”> <fo:inline-sequence font-weight=“bold”> <apply-templates/> </fo:inline-sequence></template>

An emphasized word.

XSL & XSLT

33SNUOOPSLA Lab.The ubiquitous XML

Selecting a style sheet An XML processing instruction is used f

or selecting a style sheet.<?xml-stylesheet href=“mystyles.xsl”

type=“text/xsl”title=“default” ?>

<?xml-stylesheet href=“myBIGstyles.xsl”type=“text/xsl”title=“bigger font”alternative=“yes” ?>

XSL & XSLT

34SNUOOPSLA Lab.The ubiquitous XML

XSLT : general structure (1/3) Root element – stylesheet, transform

<stylesheet xmlns=“http://www.w3.org/XSL/Transform/1.0”>

<transform xmlns=“http://www.w3.org/XSLT/Transform/1.0”>

Another namespace – an XSLT style sheet may also contain elements that are not part of stylesheet or transform

<stylesheet xmlns=“http://www.w3.org/XSL/Transform/1.0” xmlns:X=“………….”>…… <X:my-element>…</X:my-element>…

XSL & XSLT

35SNUOOPSLA Lab.The ubiquitous XML

XSLT : general structure (2/3) Result namespace – Indicator of what the output of th

e XSL processor is <stylesheet xmlns=“http://www.w3.org/XSL/Transform/1.0”

xmlns:X=“……” result-ns=“X”>

Id – embedded stylesheet in a larger XML document <?xml-stylesheet type=“text/xsl” href=“#MyStyles” ?>

<X:book> <stylesheet id=“MyStyles” …> … </stylesheet> …

XSL & XSLT

36SNUOOPSLA Lab.The ubiquitous XML

XSLT : general structure (3/3) Result Version

Result Encoding – to specify which version of XML and a character set encoding scheme should be used for the output file

<stylesheet … result-version=“2.0” result-encoding=“ISO-8859-1”>

XSL & XSLT

37SNUOOPSLA Lab.The ubiquitous XML

XSLT : White space An XSLT processor creates a tree of nodes,

including nodes for each text string in and between the markup tags.

Default – all white space is preserved.Default Space – when ‘strip’ applied, it is possible to remove the white space.

<stylesheet … default-space=“strip”> <preserve-space elements=“pre poetry”/> …</stylesheet>

XSL & XSLT

38SNUOOPSLA Lab.The ubiquitous XML

XSLT : Templates The body of the style sheet consists of at least

one transformation rule, as represented by the Template element

<template match=“para”> …</template>

<template match=“warning/para”> …</template>

XSL & XSLT

39SNUOOPSLA Lab.The ubiquitous XML

XSLT : Imports and Inclusions Multiple style sheets may share some definitions.

<stylesheet …> <import href=“tables.xsl”> <import href=“colours.xsl”> <template …>…</template>

<include href=“…”>…</include> Import rules are not considered to be as

important as other rules. The include element can be used anywhere and

included rules are not considered to be less important than other rules

XSL & XSLT

40SNUOOPSLA Lab.The ubiquitous XML

XSLT : Priorities When more than one complex rule matches the

current element, it is necessary to explicitly give one rule a higher priority than the others, using the Priority attribute.

<template match=“chapter//para”><!-- priority = 1--> …</template>

<template match=“warning//para” priority = “2”> …</template>

It the priority attribute is not used, or not used correctly, an XSLT processor may choose to simply select the last rule.

XSL & XSLT

41SNUOOPSLA Lab.The ubiquitous XML

XSLT : Recursive processing If an animal element existed within the

paragraph, and there was no rule for this element, but it could contain the emphasis element, then the emphasized text would not be formatted.

<para>A <animal><emph>Giraffe</emph></animal> is an animal.</para>

To eliminate this problem, a rule is needed to act as a catch-all, representing the elements not covered by explicit formatting rules

<template match=“/|*”> <apply-templates />

XSL & XSLT

42SNUOOPSLA Lab.The ubiquitous XML

XSLT : Selective processing The Apply Templates element can take a

Select attribute, which overrides the default action of processing all children. Using Xpath patterns, it is possible to select specific children, and ignore the rest.

<template match=“names”> <apply-templates select=“name[@type=‘company’]” /></template>

The Apply Templates element can be used more than once in a template.

XSL & XSLT

43SNUOOPSLA Lab.The ubiquitous XML

XSLT : Output formats An XSLT transformation tool is expected to write

out a new XML document. One way to do this is simply to insert the appropriate elements into the templates.

<template match=“para”> <html:p><apply-templates/></html:p></template>

Comments and processing instructions can be inserted into the output document using comment and processing instruction elements

<processing-instruction name=“ACME”>INSERT_TOC</processing-instruction>

<comment>This is the HTML version</comment>

XSL & XSLT

44SNUOOPSLA Lab.The ubiquitous XML

XSLT : Sorting elements The Sort element is used within the Apply

Templates element to sort the elements it selects:

<list> <item sortcode=“1”>ZZZ</item> <item sortcode=“3”>MMM</item> <item sortcode=“2”>AAA</item></list>

<template match=“list”> <apply-templates><sort/></apply-templates></template>

<sort select=“@sortcode” />

XSL & XSLT

45SNUOOPSLA Lab.The ubiquitous XML

XSLT : Automatic numbering In many XML documents, list items are not

physically numbered in the text, making it easy to insert, move or delete items without having to edit all the items, so the style sheet must add the required numbering.

<template match=“selection/title”> <number level=“multi” count=“chapter|section” format=“1.A” /> <apply-templates/></template>

1.A First section of Chapter One2.C Third section of Chapter Two

XSL & XSLT

46SNUOOPSLA Lab.The ubiquitous XML

XSLT : Variables and templates(1/3) A style sheet often contains a number of templates th

at produce output that is identical, or very similar, and XSLT includes some mechanisms for avoiding such redundancy.

Variable, Value Of <variable name=“Colour”>red</variable>

<html:h1> The colour is <xsl:value-of select=“$Colour”/>.<html:h1>

The colour is red.

XSL & XSLT

47SNUOOPSLA Lab.The ubiquitous XML

XSLT : Variables and templates (2/3) When the same formatting is required in a

number of places, it is possible to simply reuse the same template.

<template name=“CreateHeader”> <html:h2>*****<apply-templates/>*****</html:h2></template>

<template match=“title”> <call-template name=“CreateHeader” /></template><template match=“head”> <call-template name=“CreateHeader” /></template>

XSL & XSLT

48SNUOOPSLA Lab.The ubiquitous XML

XSLT : Variables and templates (3/3) Such a mechanism is even more useful when the action perform

ed by the named template can be modified, by passing parameters to it that override default values.

<template name=“CreateHeader”> <param name=“Prefix”>%%%</param> <html:h2><value-of select=“$Prefix”/> <apply-templates/>*****</html:h2></template>

<call-template name=“CreateHeader”> <with-param name=“Prefix”>%%%%%</with-param></call-template>

%%%Header*****

XSL & XSLT

49SNUOOPSLA Lab.The ubiquitous XML

XSLT : Creating and copying elements(1/2) An element can be created in the output

document using the Element element, with the element name specified using the Name attribute, and an optional namespace specified using the Namespace attribute

Elements can also be created that are copies of the source element, using the Copy element.

<template match=“third-header-level”> <element namespace=“html” name=“h3”> <apply-templates/> </element></template>

XSL & XSLT

50SNUOOPSLA Lab.The ubiquitous XML

XSLT: Creating and copying elements(2/2)

Source document elements can also be selected and copied out to the destination document using the Copy Of element, which uses a Select attribute to identify the document fragment or set of elements to be reproduced at the current position.

<template match=“body”> <body> <copy-of select=“//h1 | //h2” /> <apply-templates/> </body></template>

XSL & XSLT

51SNUOOPSLA Lab.The ubiquitous XML

XSLT : Repeating structures When creating tabular output from source elements, o

r some other very regular structure, a technique is available that reduces the number of templates needed significantly, and in so doing improves the clarity of the style sheet.

<template match=“countries”> <html:table> <for-each select=“country”> <html:tr> <html:th><apply-templates select=“name”/></html:th> <for-each select=“borders”> <html:td><apply-templates/></html:td> </for-each>

XSL & XSLT

52SNUOOPSLA Lab.The ubiquitous XML

XSLT : Conditions (1/2) When a template transforms a source document

element into formatted output, it is possible to vary the output depending on certain conditions.

<template match=“para”> <html:p> <if test=“not (position() mod 2 = 0)”> <attribute name=“style”>color: red</attribute> </if> <apply-templates/> </html:p></template>

XSL & XSLT

53SNUOOPSLA Lab.The ubiquitous XML

XSLT : Conditions (2/2) When an attribute can take a number of different

values, each one producing a different format. <template match=“para”>

<html:p> <choose> <when test=“@type=‘normal’”> <attribute name=“style”>color:black</attribute> </when> <otherwise> <attribute name=“style”>color:yellow</attribute> </otherwise> </choose> <apply-templates/>

XSL & XSLT

54SNUOOPSLA Lab.The ubiquitous XML

XSLT : Keys XSLT allows keys to be defined and associated

with particular elements. The Name attribute provides a name for a set of

identifiers. The Match attribute specifies the elements to be

included in this set of identifiers, using an Xpath pattern.

The Use attribute is an Xpath expression that identifies the location of the identifier values.

<key name=“global” match=“*” use=“@id” /><book id=“book”> <chapter id=“chap1”>…</chapter></book>

XSL & XSLT

55SNUOOPSLA Lab.The ubiquitous XML

Style sheet DTD issues The XSLT standard includes a DTD that defines

the XSLT elements and attributes. But this DTD alone may not be sufficient. The fact that XSLT markup can be mixed with output markup means that a DTD may need to be defined that includes both sets of elements.

The DTD must, of course, also contain the definition for the elements concerned.

However, this problem can be avoided entirely, by using the Element and Attribute elements throughout the style sheet.

XSL & XSLT

56SNUOOPSLA Lab.The ubiquitous XML

XSL : Representation format Each formatting object can be represented by

an element from the FO(Formatting Objects) DTD, which is defined in an annex to the standard.

An XSL processor is expected to receive input from the XSLT processor, though in some cases an implementation may be able to receive an XML document that conforms to the FO DTD instead, created by other means.

XSL & XSLT

57SNUOOPSLA Lab.The ubiquitous XML

XSL: General presentation model (1/3) XSL creates formatting objects to hold the

content to be presented. Formatting objects create rectangular areas.

Areas are divided into four categories: area-containers, block-areas, line-areas, and inline-areas.

AB

Area-container

Block-area

Line-area

Inline-area

XSL & XSLT

58SNUOOPSLA Lab.The ubiquitous XML

XSL: General presentation model (2/3)

An area-container has a coordinate system, by which embeded objects can be placed, defining the ‘top’, ‘bottom’, ‘left’ and ‘right’ directions, and is able to contain other area-containers.

Area-containers may also contain block-areas. The placement of block-areas within area-containers depends on the ‘writing mode’.

When a block-area is too long to fit in the area-container, another block-area may be created in the next area-container.

area container

right

top

left

bottom

bottom

right

top

left

XSL & XSLT

59SNUOOPSLA Lab.The ubiquitous XML

XSL: General presentation model (3/3) A block-area may contain more block-areas. Embedded blocks may be narrower than the

enclosing block, in the non-writing-mode direction, using indent properties.

Blocks may contain line-areas, which are adjacent to each other in the line-progression direction.

Line-areas can contain inline-areas, which correspond with XML inline elements.

Inline-areas are drawn from an initial position-point, and it is possible to adjust this point upward or downward in relation to neighboring inline-areas.

XSL & XSLT

60SNUOOPSLA Lab.The ubiquitous XML

XSL – CSS-compatible formatting objects and properties

Many of the XSL formatting object types correspond with established CSS display property types.

Many of the formatting options available in XSL are derived from properties provided in CSS.

XSL & XSLT

61SNUOOPSLA Lab.The ubiquitous XML

XSL : Block-level objects The Block element is used enclose any simple block of text. Text styles can be defined, margin, border and padding attributes

may be added, text may be aligned in different ways, hyphenation can be controlled, and the whole block can be removed from the flow and positioned explicitly.

Graphics between text blocks are represented by Display Graphic elements

A rule can be drawn horizontally or vertically between text blocks, using the Display Rule element.

<fo:block>A block of text.</fo:block>

<fo:block>Another block of text.</fo:block>

A block of text.

Another vlock of text.

XSL & XSLT

62SNUOOPSLA Lab.The ubiquitous XML

XSL : Inline objects Individual characters can be represented by the

Character element. The first object inside a Block element may be a

First Line Marker element. A graphic can be presented within a line of text,

using the Inline Graphics element. Rule line can be drawn inline, as well as between

blocks The Inline Sequence element has already been

demonstrated. The current page number can be inserted into

the text using the Page Number element

XSL & XSLT

63SNUOOPSLA Lab.The ubiquitous XML

XSL : Lists The items are a sequence of List Item

elements. <fo:list-block>

<fo:list-item>…</fo:list-item> <fo:list-item>…</fo:list-item></fo:list-block>

The block may directly contain a sequence of labels followed by contents, using the List Item Label and List Item Body elements.

<fo:list-item-label><fo:block>LABEL</fo:block></fo:list-i …<fo:list-item-body> <fo:block>First Block In Content</fo:block>

XSL & XSLT

64SNUOOPSLA Lab.The ubiquitous XML

XSL : Tables When a table has a caption, the main element is called Table an

d Caption. The Table element contains the actual table grid. The model follo

ws the HTML approach <fo:table>

<fo:table-header>…</fo:table-header> <fo:table-footer>…</fo:table-footer> <fo:table-body>…</fo:table-body></fo:table><fo:table-body> <fo:table-row>…</fo:table-row></fo:table-body><fo:table-row> <fo:table-cell>…</fo:table-cell></fo:table-row>

XSL & XSLT

65SNUOOPSLA Lab.The ubiquitous XML

XSL : Hypertext links A range of text can be enclosed in a Simple

Link element, which is used to provide a mechanism for hypertext linking to another object

See <fo:simple-link internal-destination=“chap9”>Chapter 9</fo:simple-link> for details.See <fo:simple-link external-destination=“file:///book3.xml”>Book 3</fo:simple-link> for details.

XSL & XSLT

66SNUOOPSLA Lab.The ubiquitous XML

XSL: Alternative document fragments When publishing electronically, it is possible to

hide and reveal portions of the document depending on user actions.

<fo:multi-case name=“closed” initial=“true”> <fo:block>Heading <fo:multi-toggle switch-to=“opened”> [+] </fo:multi-toggle> …<fo:multi-case name=“opened”> <fo:block>Heading <fo:multi-toggle switch-to=“closed”> [-]

XSL & XSLT

67SNUOOPSLA Lab.The ubiquitous XML

XSL : Alternative properties The Multi Properties element contains a number of ini

tial, empty Multi Property Set elements, each one providing the style to apply under a given circumstance, identified using the State attribute.

<fo:multi-properties><fo:multi-property-set state=“visited” color=“#FF0000” /><fo:multi-property-set state=“active” color=“#00FF00” />This text to be coloured depending on the state</fo:multi-properties>

XSL & XSLT

68SNUOOPSLA Lab.The ubiquitous XML

XSL: Floating objects and footnotes

The Float element is used to contain such items, indicating to the pagination engine that it may move the content as appropriate.

<fo:float><fo:table>…</fo:table></fo:float> The Footnote element contains the footnote text, whic

h will float to the base of the page, and may also contain a reference to the footnote.

Here is a reference<fo:footnote><fo:footnote-citation>*</fo:footnote-citation><fo:block>* The footnote</fo:block></fo:footnote> to a footnote

XSL & XSLT

69SNUOOPSLA Lab.The ubiquitous XML

XSL : Building pages (1/2) The Flow element contains all the block-level

objects that constitute the main text flow content of the document.

The Page Sequence element may contain the Flow element and any number of objects that are to be repeated in the same place on each page in the sequence, which is termed static content.

A page sequence must include information on how different page master templates are to be used in the sequence.

XSL & XSLT

70SNUOOPSLA Lab.The ubiquitous XML

XSL : Building pages (2/2)

Xml camp oopslaXml camp

Binding margins

Writing mode

extents

XSL & XSLT

71SNUOOPSLA Lab.The ubiquitous XML

XSL : Hyphenation The ‘hyphenate’ property defaults to ‘false’,

but can be set to ‘true’, so enabling the hyphenation or words.

<fo:block hyphenate=“true” hyphenation-char=“-” hyphenation-push-char-count=“2” hyphenation-remain-char-count=“2”>…

XSL & XSLT