1 / 24

Multimedia Seminar

Multimedia Seminar. XSLT Tobias Naumann. Structure. What is XSLT? Design and Concepts Practical use Examples. What is XSLT?. Popularity of XML Alternative Interfaces: Document Object Model (DOM) Simple API for XML Processing (SAX). Require knowledge of these Languages

pia
Download Presentation

Multimedia Seminar

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. Multimedia Seminar XSLT Tobias Naumann

  2. Structure • What is XSLT? • Design and Concepts • Practical use • Examples MM Seminar - XSLT

  3. What is XSLT? • Popularity of XML • Alternative Interfaces: • Document Object Model (DOM) • Simple API for XML Processing (SAX). • Require knowledge of these Languages • XSLT as simplification

  4. What is XSLT? • One of 3 parts of XSL • XSLT • XPath • XSL-FO (XSL Formatting Objects)

  5. What is XSLT? • Implemented in XML, XML Syntax • Transformation in any output file format • Developed by James Clark (XSLT 1.0, XSLT 1.1) • At the moment version 2.0 (Michael Kay )

  6. Structure • What is XSLT? • Design and Concepts • Practical use • Examples MM Seminar - XSLT

  7. Design and Concepts • XSLT Program = Stylesheet • XSLT Stylesheets using XML syntax • Parts of the stylesheet = Templates • Templates describe the rules how to transform a source document into the target format

  8. Design and Concepts • XSLT free of side effects (functional language) • Iteration and Recursion • XSLT based on Pattern Matching • XSLT and XPath since 1999 (Version 1.0) official standards of the W3C

  9. Design and Concepts • XPath: • Referencing parts of XML documents • Tree structure • Relative und absolute reference to nodes possible

  10. Design and Concepts • Illustration: <nodes> <node id="1">N1</node> <node id="2">N2</node> <supernode id="3"> <node id="4">N4</node> </supernode> <node id="5">N5</node> </nodes>

  11. Design and Concepts

  12. Structure • What is XSLT? • Design and Concepts • Practical use • Examples MM Seminar - XSLT

  13. Practical use • Webservice for stock exchange in XML • One document for different target platforms • Variable designs • Exchange of business documents

  14. Structure • What is XSLT? • Design and Concepts • Practical use • Examples MM Seminar - XSLT

  15. Examples • Functioning of XSLT Processors: • read an elemente (actual Context) • search matching template in stylesheet • If none is found, use standard template • Process data with rules of template • Read next elemente • Repeat until no elements left

  16. Examples • „Hallo Welt!“ Beispiel <?xml version="1.0"?> <greeting> Hallo Welt! </greeting>

  17. <xsl:stylesheet xmlns:xsl="http://www.w3c.org/1999/XSL/Transform" version="1.0"> <xsl:template match="/"> <html> <head> <title>Hallo Welt!</title> </head> <body> <xsl:apply-templates/> </body> </html> </xsl:template> <xsl:template name="greeting" match="greeting"> <h1>Greeting: <xsl:value-of select="."/></h1> </xsl:template> </xsl:stylesheet>

  18. Examples • output: <html> <head> <title>Hallo Welt!</title> </head> <body> <h1> Greeting: Hallo Welt! </h1> </body> </html>

  19. Examples • <xsl:if> <xsl:if test="count(titel) &gt; 0"> <xsl:value-of select="titel"/> </xsl:if>

  20. Examples • <xsl:choose>, <xsl:when> and <xsl:otherwise> <xsl:choose> <xsl:when test="count(titel) &gt; 0"> <xsl:value-of select="titel"/> </xsl:when> <xsl:otherwise> (Kein Titel) </xsl:otherwise> </xsl:choose>

  21. Examples • Iteration with <xsl:for-each> <xsl:for-each select="adressen/adresse"> <xsl:sort select="vorname"/> <xsl:call-template name="template2"/> </xsl:for-each>

  22. Examples • <xsl:param> and <xsl:variable> <xsl:param name="x„ select=„5“/> <xsl:template match="/"> <xsl:variable name="y" select="$x+1"/> x = <xsl:value-of select="$x"/><br/> y = <xsl:value-of select="$y"/><br/> </xsl:template>

  23. XSLT Processors • Xalan, Apache Project • Saxon, Java XSL Prozessor • XT, by James Clark • Sablotron, XML and XSLT Toolkit • Oracle • Micrososft XSLT Tools

  24. End… Questions? ? ? ? ? ? ?

More Related