1 / 20

Using XSLT To Transform XML Brian E. Travis Architag International Corp btravis@architag 9-333

Using XSLT To Transform XML Brian E. Travis Architag International Corp btravis@architag.com 9-333. XSL Extensible Stylesheet Language. HTML: "Format without Structure" Typesetting language Not extensible CSS: "Enhanced Format, No Structure" Stylesheet language

blaze
Download Presentation

Using XSLT To Transform XML Brian E. Travis Architag International Corp btravis@architag 9-333

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. Using XSLT To Transform XMLBrian E. TravisArchitag International Corpbtravis@architag.com9-333

  2. XSLExtensible Stylesheet Language • HTML: "Format without Structure" • Typesetting language • Not extensible • CSS: "Enhanced Format, No Structure" • Stylesheet language • Overrides default formatting for HTML, but annot change basic structure of the document • XML: "Structure Without Format" • Defines "elements" using "tags" • Creates hierarchical structure of information set

  3. XSLT"Adding Format to Structure" • Transforms XML to XML • Declarative programming language • Creates formatted output • Does limited processing

  4. May 5, 2000 <I>May 5, 2000</I> <birthday>May 5, 2000</birthday> Quiz

  5. XSLT Operation Source Tree (your XML) XSLT Output (x) XSL Transformer Stylesheet xmlns:xsl

  6. Example In XRay

  7. <xsl:stylesheet version="1.0"xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> ... </xsl:stylesheet> Start tag for stylesheet document, containing XSL Namespace indicator Template rules and other stuff End of stylesheet XSLT Stylesheet Architecture

  8. XSLT Template Rule <xsl:template match="chapter/title"> <DIV STYLE="font-family:sans-serif; font-weight:bold; color:blue;"> <xsl:apply-templates/> </DIV> </xsl:template>

  9. Patterns

  10. XSLT Template Rule <xsl:template match=“something”/> <xsl:apply-templates/> <xsl:value-of/>

  11. XSLT Stylesheet <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="weather"> <H1><xsl:value-of select="@type"/></H1> <xsl:apply-templates/> <HR/> </xsl:template> <xsl:template match="temp"> <LI>Temperature <xsl:apply-templates/>&#x00B0;F</LI> </xsl:template> <xsl:template match="wind"> <LI>Wind: <xsl:apply-templates/>mph</LI> </xsl:template> <xsl:template match="text()"> <xsl:value-of select="."/> </xsl:template> </xsl:stylesheet>

  12. XSLT Transformation <weather type="Current conditions"> <temp>76</temp> <wind>5</wind> </weather> <wind>5</wind> <temp>76</temp> 8 76 1 5 3 5 10 6 2 7 4 13 9 11 12 <H1>Current conditions</H1> <LI>Temperature: 76 °F</LI> <LI>Wind: 5 mph</LI> <HR/>

  13. Demonstration: XSL for Documents • Create stylesheet for complex document • Run in browser

  14. Demonstration: XSL On The Server • Get XML document from server • Article.xml • Apply stylesheet, transform, and deliver HTML to the browser • Article.asp • Article.xsl

  15. XSL(Abstract) XSL (Full) XSL (TOC) XML XSL Processor (HTML) XSLT Operation HTML (TOC) HTML (Abstract) HTML (Full)

  16. Demonstration: XML Data Islands • Create HTML document with XML data islands • Article.xml • Article-toc.xsl • Article-abstract.xsl • Article-full.xsl • Article-wtoc.xsl • Switch stylesheet under script control • ApplyStyle.htm

  17. Case Study: <TAG> Newsletter XML-enabled Web Site http://tagnewsletter.com

  18. </Tutorial> • Tech Ed 2000 Materials • http://architag.com/r/TechEd2000 • XML and XSL • http://msdn.microsoft.com/xml • http://www.w3.org/Style/XSL/

More Related