1 / 12

XML Presentation and XSL

XML Presentation and XSL. Extensible Style Sheet Language (XSL). XML application Style sheet language Components of the XML document may be rearranged or transformed One XSL document can support many media output types. Tree Transformations.

tao
Télécharger la présentation

XML Presentation and XSL

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. XML Presentation and XSL

  2. Extensible Style Sheet Language (XSL) • XML application • Style sheet language • Components of the XML document may be rearranged or transformed • One XSL document can support many media output types

  3. Tree Transformations • Performed by XSLT (Extensible Style Sheet Language Transformation) • As XML document is parsed, it is read into memory as the result tree • This tree is used by the browser to write out the formatted document (typically in HTML)

  4. Formatting the Tree • Formatting objects in the tree are considered elements • Developers have control over style and positioning elements • Patterns are applied to make the tree • XPath statements are used to describe the patterns

  5. XSLT Elements • Style sheet declaration • Value of • Template match • For each statements

  6. XSLT Style Sheet Declaration • Defines the document as a XSL Style Sheet • Points to the namespace that controls the sheet • Example for MS Explorer 5.0 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/TR/WD-xsl">

  7. XSLT Value of • Function that displays data at the current node • Only works with elements with text contained in the tags <xsl:value-of select="."/>

  8. XSL Template Match • Describes which XML elements included in result tree • Describes what to do when these elements are found • Built with XPath statements • First used should match to root • Example shows matching to root and starting an HMTL document

  9. XSL Template Examples <xsl:template match="/"> <html> <head>

  10. XSL For Each Statements • Iteratively walk through similar elements • Very useful when documents have many of the same child elements • Example will print a table of addresses

  11. For Each Example <td><b><i><xsl:value-of select="name"/></i></b></td> <xsl:for-each select="address"> <td> <xsl:value-of select="."/> </td> </xsl:for-each>

  12. Calculation with XSLT • Aggregate functions are available (sum or count) • XPath parameters describe what to calculate <xsl:value-of select="count(//Person/name)"/> • Math calculations available via function

More Related