1 / 112

Justin Tilton instructional media + magic, inc. As presented at the JA-SIG Winter Conference: "All Java, All the T

Introduction to XSLT. Justin Tilton instructional media + magic, inc. As presented at the JA-SIG Winter Conference: "All Java, All the Time" December 8 th 2002, Orlando, Florida. The Abstract….

brinly
Télécharger la présentation

Justin Tilton instructional media + magic, inc. As presented at the JA-SIG Winter Conference: "All Java, All the T

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to XSLT Justin Tilton instructional media + magic, inc. As presented at the JA-SIG Winter Conference: "All Java, All the Time" December 8th 2002, Orlando, Florida

  2. The Abstract… Looking for a methodology to quickly and effectively create Transformations? Interested in the basics of XSLT and Xpath, and a good way to get started? If so, this workshop is for you! We will be discussing the fundamental concepts of XSLT and Xpath, and the methodologies that have emerged from months of developing stylesheet transformations for the uPortal 2.0 project. We will discuss the design aspects related to converting structured information in XML into device-dependent markup languages such as HTML, and WML, and the guidelines and best practices evolving from this experience. No prior XSLT experience is necessary.

  3. Overview • Introduction • uPortal • Basic XPath • Basic XSLT • Markup: XHTML • Cascading Style Sheets • Tools • The Creation Process • Hands-on

  4. Introduction

  5. Background • Who: W3C • What: XPath and XSLT Specs. • When: 11/16/1999 • Why: A need arose for a specification to define the syntax and semantics for transforming XML documents.

  6. References • “The” definitivereference… • Michael Kay • Wrox Press Inc • ISBN: 1861005067

  7. References • Great practicalreference… • Jeni Tennison • Hungry Minds • ISBN: 0764547763

  8. References • Practical use oftransformationsin Java code • Eric Burke • O'Reilly & Assoc. • ISBN: 0596001436

  9. JA-SIG’s uPortal

  10. What’s new in 2.x? • Abstraction of layout • Structure/theme transformations • Standard channel events • Standard CSS classes • More flexible publish/subscribe • User profile management • Groups and Permissions updates

  11. Basic Architecture Framework Structure XSLT Theme XSLT Skins - CSS

  12. Basic Architecture Permissions iPlanet LDAP authentication User preferences Channel registry Other uPortal Data Oracledb2 mySQL

  13. Channel • Elementary unit of presentation, defined by the IChannel interface User InteractionExternal Information Channel Content(Presentation) IChannel

  14. IChannel content must • Be well-formed XML such as XHTML, RSS, SVG, SMIL, or a SOAP message (HTML is not well formed XML) • Rendered by an XSL transformation using an XSL stylesheet

  15. Framework Organization User Interaction Presentation uPortal Framework Channel Channel Channel

  16. User Layout • User Layout is an abstract structure defining the overall content available to the user • userLayout is a tree structure consisting of “folders” and “channels”, the later always being the leaf nodes

  17. User Layout

  18. User Layout Tab Tab Tab Column Channel Channel Channel Column Channel Channel Channel Channel Channel Structure Transformation

  19. Theme Transformation User Layout Tab Tab Tab Jim Smith Financial Aid Library Column Column Channel Channel Channel Channel Channel Channel Dictionary.com Bookmarks Cartoon

  20. Compiling the Presentation userLayout Structuretransformation XSLT structuredLayout setRuntimeData() XSLT Channels Themetransformation renderXML() HTML, WML VoiceML...

  21. Content Transformation XML XSLT Processor XHTML: Web Browser HTML: PDA Stylesheet WML: Cell Phone

  22. Flexible Layouts • Structures • Tab / column • Tree / column • Themes • Multi-column • Multi-row • Skins • Matrix, Java

  23. Multiple Target Devices

  24. Tab / Column Layout

  25. Tree / Column Layout

  26. Skins

  27. Skin: im+m

  28. Skin: VSAC

  29. Skin: matrix

  30. User Preferences • Swappable layout and preference management modules • Profile management module • Tab-column specific prefs. module • Skin selection

  31. User Preferences

  32. Publish/Subscribe • Channel publishing document • Channel parameters • Default values • Modification permissions • Descriptions • Publish/Subscribe steps • Step sequence • Instructions, help • A complex channel with multiple XSL views

  33. Channel Types

  34. Channel Settings

  35. Channel Controls

  36. Channel Rewiew

  37. Basic XPath

  38. Nodes and Node Trees • When an application wants to operate on an XML document it builds an internal model of what the document looks like. • This model is known as a document object model or DOM. • In XPath and XSLT, it's called a node tree.

  39. Types of Nodes • Root nodes • The top of the node tree • Element nodes • XML elements • Attribute nodes • XML attributes • Text nodes • Textual content in XML elements • Comment nodes • XML comments • Processing instruction nodes • XML processing instructions • Namespace nodes • The in-scope namespaces on an element R E E E E A T

  40. document para para para note warning warning content content content Node Tree Example <document> <para type=“note”> content </para> <para type=“warning”> content </para> <para type=“warning”> content </para> </document>

  41. XPath Definition • XPath is a language for addressing parts of an XML document, designed to be used by XSLT. • Example XPath: child::para[attribute::type='warning'][position()=2] • In English: • select the second parachild of the context node that has a type attribute with a value of warning.

  42. Context node Axis Dissecting the Example child::para[attribute::type='warning'][position()=2] Axis: child::para Filter: [attribute::type='warning'] Filter: [position()=2]

  43. Dissecting the Example child::para[attribute::type='warning'][position()=2] Axis: child::para Filter: [attribute::type='warning'] Filter: [position()=2] Context node Axis Filtered

  44. Dissecting the Example child::para[attribute::type='warning'][position()=2] Axis: child::para Filter: [attribute::type='warning'] Filter: [position()=2] Context node Axis Filtered Filtered

  45. Dissecting the Example child::para[attribute::type='warning'][position()=2] Axis: child::para Filter: [attribute::type='warning'] Filter: [position()=2] Context node Axis Filtered Filtered Selected

  46. Types of XPaths • Expressions: Return a value, which might be a node set that is processed or a string that is output. <xsl:when test="@type=‘warning’"> • Patterns: Either match a particular node or don't match that node. <xsl:template match="para">

  47. XPath Expressions • Select Nodes <xsl:for-each select=“child::Z”> • Conditional <xsl:if test=“position()=2”> • Calculation <xsl:value-of select=“position()+4"> C Z Z C 1 2 3 4

  48. Node Set Expressions • The most common way that XSLT uses XPaths is to select node sets. These XPaths usually occur within a select attribute, for example on xsl:for–each or xsl:apply–templates, and are known as location paths. <xsl:for-each select=“child::para”> <xsl:apply-templates select="paragraph"/>

  49. Location Paths • The purpose of location paths is to select node sets from a node tree. • Location paths can be absolute or relative • Absolute location pathsstart from a known locationsuch as the root node <xsl:for-each select=“/R/N”> • Relative location paths start from the context node. <xsl:for-each select=“N”>note: same as “child::N” R N X Y N R N X Y C ontext N Z

  50. Steps • A location path is made up of a number of steps. • Each step takes you from a node to a node set. • Each step is separated from the one before it with a “/”.

More Related