XML Technologies in action, XSLT/XPath/FO/MathML/SVG
XML Technologies in action, XSLT/XPath/FO/MathML/SVG
Contents
Principles of XSLT
Examples of usage:
Various output formats
server transforms vs. browser transforms
XML Formats: standard
XHTML
XSLT and XML for Content Management
XSLT and XML for Content Management
...
SVG
Example arcs01 - arc commands in path data
Picture of a pie chart with two pie wedges and
a picture of a line with arc blips
XML Formats: custom
SCENE II. The same. Another street.
Enter the corpse of KING HENRY the Sixth, Gentlemen
with halberds to guard it; LADY ANNE being the mourner
LADY ANNE
Set down, set down your honourable load,
If honour may be shrouded in a hearse,
Whilst I awhile obsequiously lament
The untimely fall of virtuous Lancaster.
...
From one to the other
In order to make data available on the Web, one can use HTML:
CD stocks
CD stocks
Artist Title Price In-store
Supertramp Even in The Quietest Moments... 12.99 EUR 4
Runrig The Big Wheel 5.99 EUR 12
Queen The Miracle 5.99 EUR 1
ArtistTitlePriceIn-store
SupertrampEven in The Quietest Moments...12.99 EUR4
RunrigThe Big Wheel5.99 EUR12
QueenThe Miracle5.99 EUR1
Or one can design custom XML markup
CD stocks
Supertramp
Even in The Quietest Moments...
12.99
Runrig
The Big Wheel
5.99
Queen
The Miracle
5.99
Because, as the custom XML markup provides better information on
what it describes it makes it easier to manipulate the data. And it's
easier to read. HTML markup is attached to the way the documents is
going to be displayed (table) and indeed makes it harder to process
for other purposes.
However HTML has the advantage that is displays on your
browser. The custom markup can't be displayed as is. This is where
stylesheets come into the picture. Here will describe one method of
doing it: XSLT, a language to transform XML documents.
Display your data using XSLT
Uses:
Transform custom XML into "displayable" XML
More generally, transform anyXML into anyOtherXML
XSLT works by defining templates. In our example,
becomes
Template:
Full recordML to HTML transform:
We will not go much further into the syntax of XSLT, as it
is not really the point of this presentation. Rather we will
concentrate on applications of XSLT.
Many output formats
XSLT allows any type of output markup in the stylesheet
Example: record database
record in database in XML and XSLT transforms, make it
easy to process the database in different ways:
Output the data: HTML
(music2html.xsl)
XSL-FO (PDF) (music2fo.xsl). Many things shown: sorting, grouping, indexing, etc.
Query the data:
returns
Genesis
Aphrodite's Child
Emerson, Lake and Palmer
Pink Floyd
Example: ChessGML
XSLT transforms custom XML to text, XHTML or SVG.
ChessGML describes chess games
Is produced by chess software, and is not easily readable
Not unserstood by browsers
XSLT transforms make it possible to display in various formats
The Immortal Game
London
Anderssen
Adolf
Kieseritzky
Lionel
...
ChessGML to text
The Immortal Game
London - 1851
White: Anderssen, Adolf
Black: Kieseritzky, Lionel
1. e4 e5
2. f4 exf4
3. Bc4 Qh4+
4. Kf1 b5
5. Bxb5 Nf6
6. Nf3 Qh6
7. d3 Nh5
8. Nh4 Qg5
9. Nf5 c6
10. g4 Nf6
11. Rg1 cxb5
12. h4 Qg6
13. h5 Qg5
14. Qf3 Ng8
15. Bxf4 Qf6
16. Nc3 Bc5
17. Nd5 Qxb2
18. Bd6 Bxg1
19. e5 Qxa1+
20. Ke2 Na6
21. Nxg7+ Kd8
22. Qf6+ Nxf6
23. Be7 1-0
ChessGML to readable text (or audio devices)
The Immortal Game, played in London in 1851, between Adolf Anderssen
(white) and Lionel Kieseritzyky, Lionel.
One, white pawn to e 4, black pawn to e 5.
Two, white pawn to f 4, black pawn takes wite pawn at f 4.
Three, white bishop to c 4, black queen to h 4, check.
Four, white king to f 1, black pawn to b 5
...
Twenty-three, white bishop to e 7, black resigns.
ChessGML to HTML
The Immortal Game
The Immortal Game
Anderssen, Adolf
vs.
Kieseritzky, Lionel
London, 1851
1. e4
1. ... e5
2. f4
ChessGML to SVG
(full screen SVG, project page)
Example: Slide Generator
Variant: these slides have been generated from a single
HTML source file (using Amaya to edit text and mathematics)
and made into smaller html files: one for each slide
XSLT transforms XHTML to XHTML
Single XHTML source
XSLT stylesheet makes XHTML slides, splitting at each
common style (using CSS)
Automatic TOC, forward/back buttons, notes, etc.
Easily customisable: display notes or not...
Easily extensible: just add more templates to handle more XHTML tags
Similar stylesheets could produce text, SVG or XSL-FO
from same source.
Get Real
This is all very nice, but talk to us about production uses. Chess
is a niche market, what about myBigCorp's thousands of pages of
documentation?
Production uses of XSLT within W3C:
Many W3C specs: XMLSpec DTD with stylesheets to generate various
formats, e.g. MathML
2.0: HTML, XHTML, PDF (2)
Math, XSL, SVG: public pages
RDF: RDF/XML parser, RDF picture description using SVG
Issues management: XML Protocols, WS Architecture, XSLT, XPath
Publications: on-line pubrules validator
RSS Feeds: W3C home page, MathML, XSL, SVG, Internal WDs
DOM: test suite framework
WAI: stylesheets used to add ToC to specs
TAG: meeting minutes formatting
QA: generating the Matrix
Get real 2: docbook
docbook is probably the most
widely used XML Document Management system
One source DTD. Example instance:
My First Book
Jane Doe
1998 Jane Doe
Foreword ...
...
...
...
...
...
...
Many XSLT stylesheets for:
Formatting for print publication (heavily used by O'reily publishers): PS, PDF output
Formatting for Web sites: HTML, XHTML
Formatting for computer documentation (GNOME, FreeBSD, PHP, etc.)
Formatting slides
Documenting code
Formal specifications
Theses/dissertations
and so on...
XSLT in your browser
XSLT is supported in browsers
Browsers receives XML + XSLT and produces HTML
Transformation is done on the spot
Browser-side: XSL Page at W3C
http://www.w3.org/Style/XSL: XSL page at W3C (source)
Source is XML, can be viewed directly
HTML version produced off-line (for old browsers)
RSS version for news service
Browser-side: The Pan-Galactic MathML stylesheet
This "hack" shows another use of XSLT in a
browser
XML: MathML
1
1
+
e
-
2
π
1
+
e
-
4
π
1
+
e
-
6
π
1
+
...
=
(
5
+
5
2
-
5
+
1
2
)
e
2
π
5
1
1
+
e
-
...
The problem with MathML: native support vs. plug-in
two syntaxes:
Inline (Amaya, Mozilla, Netscape 7):...
Here's how to include MathML the right way
x + 2
...
Embed (IE plug-ins):...
Here's how to include MathML for plug-ins
...
Both syntaxes are incompatible
However...
The Pan-Galactic MathML stylesheet: solution
XSLT can transform one syntax into the other
Use the inline syntax
Add a stylesheet processing instruction at the beginning of the file:
This invokes an XSLT stylesheet that will transform the markup into something the browser understands
One standard syntax will work in all the browsers that support MathML
Mozilla, Amaya, Netscape 7, IE 5.5/6.0 with plug-ins (or not)
XSLT and other XML-related technologies
XSLT complies with other XML standards, Therefore it is
interoperable with many other technologies
A transform can be performed on a DOM
XSLT can be part of a chain of processes: Java, Javascript, ASP,
PHPetc.
Examples: Project management systems, application servers
(Cocoon, 4Suite Server, Austin PM, E-speak, Krysalis, etc.)
A little bit of history
The Past: XSL
In the beginning was XSL
XSL became XSLT 1.0 and XSL(FO) 1.0
XSLT 1.0 produced XPath 1.0
The present:
XSLT quite successful:
25 books, according to Amazon
9 implementation, according to me
122 messages a day on xsl-list (avg. on last 30 days)
The Future: XSLT 2.0
New requirements:
More functionality
Simplify the language
Support for new W3C specs: XML Schema, XQuery
Remember...
XSLT can simplify XML processing
It is open technology
Specifications available on the Web (w3.org/TR)
Royalty-Free material
Many Open Source implementations
All the tools and specifications used to produce this
presentation (Amaya, Mathplayer plug-in, Emacs, Saxon, Adobe SVG,
DocBook, etc.) are freely available.
Links
This presentation: http://www.w3.org/2002/Talks/05-Interop-MaxF/
The XSL page at W3C: http://www.w3.org/Style/XSL
This Presenter: mf@w3.org