Introduction
¢ XSLT œ eXtensible Style sheet Language for CS 4244: Internet Programming Transformations XSLT ¢ Purpose is to transform XML documents from one format into another
¢ XSLT is an XML language
1.0
How do we use it? Two ways of using XSLT
¢ Use XSLT to convert XML documents at ¢ Server side processing
server and send to client. ¢ Server does XSLT transformations on server and sends HTML to client
Workstation XML
XSLT 1 XSLT 1 HTML Workstation
¢ Client-side processing Server
XML ¢ Laptop XSLT 2 Server sends XML and the XSLT style sheet to the client which does the transformation Server ¢ Browser support: IE 6.0 XSLT 3 XML XML XSL
Hand held computer Workstation Server XSLT 1
Using XSLT XSLT basics
¢ Multiple ways ¢ An XSLT processor merges an XML document into an XSLT style sheet ¢ From the command prompt ¢ This merging is a template-driven process ¢ java org.apache.xalan.xslt.Process -in source.xml –xsl stylesheet.xsl[t] –out ¢ An XSLT style sheet can specify page layout, out.xml page orientation, writing direction, margins, page numbering, etc ¢ Using a GUI ¢ To connect an XSLT style sheet to an XML ¢ From http://www.marchal.com document (client-side processing)
¢ An XSLT style sheet can specify page layout, page orientation, writing direction, margins, page numbering, etc
1 Examples Template matching
¢ greeting.xml, greeting.xsl and greeting.html ¢ An XSLT style sheet is an XML document with a single element,stylesheet, which defines namespaces
¢ If a style sheet matches the root element of the XML document, it is matched with the template:
XSLT basics XSLT basics
¢ A template can match any element, just by ¢ XSLT elements that represent HTML elements are naming it (in place of /) simply copied to the merged document
¢ XSLT elements include two different kinds of ¢ The XSLT value-of element
elements, those with content and those for which ¢ Has no content
the content will be merged from the XML doc ¢ Uses a select attribute to specify part of the XML data to be merged into the XSLT document ¢ Elements with content often represent HTML elements ¢
2