Академический Документы
Профессиональный Документы
Культура Документы
Deborah Aleyne Lapeyre and B. Tommie Usdin Mulberry Technologies, Inc. 17 West Jefferson St., Suite 207 Rockville, MD 20850 Phone: 301/315-9631 Fax: 301/315-8285 info@mulberrytech.com
http://www.mulberrytech.com
Page i
Single Source and Reuse Publishing...........................................................................25 Construct the Output for Publishing.........................................................................25 What You Want in the Order You Want It...............................................................26 There is Not Just One Print Product..........................................................................26 Some of the Text is Added by the Transform...........................................................27 Large Structures Can be Built and Inserted as Well..................................................27 XSLT is Also Useful During Production..................................................................28 XML for Interchange and Archiving.......................................................................30 XSLT as the Middle Component in XSL-FO...........................................................30 How XSL-FO Works.................................................................................................31 Architecture of a Full XSL System (XSLT + XSL-FO)............................................32 Formatting Objects Describe Page Layout................................................................32 Applying Styles through XSL FOs.........................................................................33 XSL-FO is a Great Report Writer..........................................................................33 The Last Bits.....................................................................................................................34 What is XPath................................................................................................................34 XPath Has Two Main Uses..........................................................................................35 Youve Seen XPath in match Expressions ..................................................................35 XPath Can Be Very Complex......................................................................................35 Another Complexity: Push-me Pull-you Stylesheets What is a Pull Stylesheet?........................................................................................37 Why Pull Can Be a Problem.......................................................................................40 Heads UP: XSLT and XPath 1.0, 1.1, 2.0.......................................................................41 What Was Wrong with XSLT 1.0................................................................................41 XSLT 2.0: More Power; More Programmer Responsibility............................................42 How to Deal with XSLT 1.0 and 2.0 (November 2005).................................................42 How to Make XSLT Programmers.................................................................................43 XSLT is Also Really Easy But........................................................................................43 How to Learn XSLT........................................................................................................45 Debbie's XSLT Programming Pearls (Optional).............................................................45
Page ii
Now Lets Look at Some Real Stylesheets......................................................................46 End Speech; Start References For Further Information..................................................................................................47 XSLT Technical Reference Book...................................................................................47 Useful XSLT Reference Website: Zvon..........................................................................48 XSLT Concept/Syntax Books.........................................................................................48 XSLT Syntax+ for Programmers.....................................................................................48 Colophon.........................................................................................................................49
Appendixes
Appendix 1: Representative XSLT Tools.......................................................................49 Appendix 2: Acronyms Used in This Talk.....................................................................50
Page iii
Administrivia
C Start, end, break C Ask questions any time (please!) C Who we are C Why this class C Why more publishing examples C Anything else?
slide 2
Page 1
slide 3
slide 4
WARNING!
We are going to show code! Youll understand the examples even if you ignore the code We are going to act as if you never heard of XSLT and start from scratch
Page 2
slide 5
Page 3
slide 6
slide 7
What is XSLT
Extensible Stylesheet Language Transformation
C Name is misleading C Stylesheet C implies it makes things look like something C not necessarily or usually true C Name should have been The XML Transformation Language
Page 4
slide 8
slide 9
Page 5
slide 10
Page 6
slide 12
slide 13
Sasparilla Usdin
17 West Jefferson Street Suite 207 Rockville, MD 20850 Phone: 301/315-9631 Fax: 301/315-9634 sassy@mulberrytech.com
Page 7
slide 14
C XML elements rolled into form letter C Something (perhaps employee-id) linked to photo
slide 15
Page 8
slide 16
INTO
<contrib>Deborah A. Lapeyre</contrib>
INTO
<h2>Lawns and Gardens</h2>
C <bold>Tall</bold>... INTO
:G46Helvetica-ExtraBold;Tall
slide 17
XML file
XSLT processor
output file
Page 9
slide 18
Page 10
slide 19
slide 20
Page 11
slide 21
slide 22
Page 12
slide 23
Page 13
slide 24
slide 25
Page 14
slide 26
<xsl:stylesheet>... </xsl:stylesheet>
...<z>XSL is <e>fun</e></z>... ...<t>XSL is </t>"fun"...
Page 15
Source Tree
T r a n s f o r m e r
Result Tree
slide 27
Page 16
slide 29
slide 31
Page 17
slide 32
slide 33
slide 34
Page 18
slide 35
slide 36
Page 19
slide 37
slide 38
The Requirement was to put the name of the state before every section title
<title>Texas Large Animals</title>
Page 20
slide 39
slide 40
Page 21
slide 41
Presentation Layer
Other Device
XSLT
<XML/>
XSLT XSLT
<XML/>
format engine
XSLT
XSLT
XSL <XML/> Processing XSLT Layer <XML/>
<XML/>
<XML/>
DOM
<XML/>
File system
Relational DB
Object DB
Storage Layer
Partner system
Page 22
slide 42
slide 43
Page 23
slide 44
slide 45
Which Displays As
Page 24
slide 46
Page 25
slide 48
Page 26
slide 50
Page 27
slide 52
Page 28
slide 53
Page 29
slide 54
slide 55
Page 30
slide 56
Source Tree
T r a n s f o r m e r
Result Tree
slide 58
slide 59
Page 32
...XSL is fun...
Source Tree
T r a n s f o r m e r
Result Tree
F o r m a t t e r
slide 60
slide 61
Page 33
slide 62
slide 63
slide 64
What is XPath
C The tree-walking part of XSLT C So named because it uses a path notation with slashes like UNIX directories and URLs
play/act/scecne/speech invoice/customer_data/customer_name
C C
XPath 1.0 W3C Recommendation in 1999 XPath 2.0 W3C Recommendation Draft 2005 (more complex, more powerful, harder to learn)
Page 34
slide 65
Page 35
XSLT is
C By design and default, driven by the XML input file C That means you tell it what to do, not how or when C Automatically recursive through the use of templates
slide 69
Page 36
slide 71
slide 72
Page 37
<h2>Fish</h2> <ul> <li> <xsl:value-of select="//spec-fish"/> </li> </ul> <h2>Pasta</h2> <ul> <li> <xsl:value-of select ="//spec-pasta"/> </li> </ul> <h2>Entree</h2> <ul> <li> <xsl:value-of select ="//spec-meat"/> </li> </ul> <h2>Dessert</h2> <ul> <li> <xsl:value-of select ="//spec-sweet"/> </li> </ul> <br/> <h3>Specials are available every day from opening until exhaustion.</h3> <p>Come see us anytime!</p> </html>
Page 38
slide 73
Page 39
slide 74
Page 40
slide 76
Page 41
slide 78
Page 42
slide 80
Page 43
slide 82
slide 83
Page 44
slide 84
Page 45
slide 86
Page 46
C See http://www.mulberrytech.com/xsl/xsl-list
C The W3C Recommendations (programmers only!)
slide 88 XSLT Technical Reference Book (XSLT programmer ought to have access to a copy)
Page 47
slide 89
Useful XSLT Reference Website: Zvon http://www.zvon.org
C If you feel you must read the XSLT 1.0 and XPath 1.0, at least read them indexed and
hyperlinked on this site.http://www.zvon.org/xxl/XSLTreference/Output/index.html C Also online tutorials for XPath 1.0, etc.
slide 90
XSLT Concept/Syntax Books
C ISBN: 0-7645-4819-0 (Hungry Minds) C [ Only a couple of chapters cover XSLT, but very good, and available online]
slide 91
XSLT Syntax+ for Programmers
C XSLT and XPath: A Guide to XML Transformations by John Robert Gardner and
Zarella L. Rendon C ISBN: 0-13-040446-2 (Prentice Hall PTR) [tutorial. XSLT and XPath 1.0]
C Practical Transformation using XSLT and XPath by Ken Holman C Eleventh Edition - ISBN 1-894049-12-8 - 2004-02-03. Available from his
website: http://www.CraneSoftwrights.com (tutorial)
C ISBN: 0-7645-4776-3 (OReilly) [XSLT 1.0 Code samples plus; good for parameters, variables, named templates; a bit fond of pull]
Page 48
slide 92
Colophon C Slides and handouts created from single XML source C Slides projected from HTML which was created from XML using XSLT C Handouts created from XML: C Source XML transformed to Open Office XML C Open Office XML opened in Open Office C Pagination normally adjusted C Saved as PDF C Slideshow materials available at: http://www.mulberrytech.com/slideshow
Appendix 1
Representative XSLT Tools
XSLT processors
Commonly used free tools:
Page 49
Appendix 2
Acronyms Used in This Talk aka CME CSS DTD EDI GUI HTML OO MIF PDA PDF RDF RTF SGML SVG URL W3C WWW WYSIROTS XML XSL XSL-FO XSLT also known as Continuing Medical Education Cascading Style Sheets Document Type Definition Electronic Data Interchange Graphical User Interface Hypertext Markup Language Object Oriented (applied to database) FrameMaker internal format Personal Digital Assistant Portable Document Format Resource Description Framework Rich Text Format (Microsoft interchange format for Word) Standard Generalized Markup Language Scalable Vector Graphics Uniform (Universal) Resource Indicator World Wide Web Consortium World Wide Web What You See Is Representative Of The Structure Extensible Markup Language Extensible Stylesheet Language XSL Formatting Objects XSL Transformations
Page 50