17Xsl

Uploaded from authorPOINT Lite
Download as
 PPT
Presentation Description 

No description available

Views: 54
Like it  ( Likes) Dislike it  ( Dislikes)
Added: January 15, 2008 This Presentation is Public 
Presentation Category : Education All Rights Reserved
Presentation Transcript

XSL: XSL Displaying XML


XSL Intro: XSL Intro Because XML does not use predefined tags (we can use any tags we want), the meanings of these tags are not understood: could mean an HTML table or maybe a piece of furniture. Because of the nature of XML, the browser does not know how to display an XML document.


XSL Intro – cont..: XSL Intro – cont.. In order to display XML documents, it is necessary to have a mechanism to describe how the document should be displayed. One of these mechanisms is CSS, but XSL (the eXtensible Stylesheet Language) is the preferred style sheet language of XML, and XSL is far more sophisticated than the CSS used by HTML.


XSL consists of two parts: : XSL consists of two parts: a method for transforming XML documents a method for defining XML parts and patterns If you don't understand the meaning of this, think of XSL as a language that can transform XML into HTML, a language that can filter and sort XML data, a language that can address parts of an XML document, a language that can format XML data based on the data value, like displaying negative numbers in red, and a language that can output XML data to different devices, like screen, paper or voice


XSL is Two Languages: XSL is Two Languages XSLT is a language to transform XML XPath is a language to define XML parts or patterns


XSLT: XSLT XSLT is a language for transforming XML documents into other types of documents, or into other XML documents.


XPath: XPath XPath is a language for addressing parts of an XML document. XPath was designed to be used by XSLT.


XSL-XML Transformations: XSL-XML Transformations XSLT is the most important part of the XSL Standard. It is the part of XSL that is used to transform an XML document into another XML document, or another type of document. XSLT can be used to transform an XML document into a format that is recognizable to a browser. One such format is HTML. Normally XSLT does this by transforming each XML element into an HTML element.


XML-XSL Transformations: XML-XSL Transformations XSLT can also add completely new elements into the output file, or remove elements. It can rearrange and sort the elements, and test and make decisions about which elements to display, and a lot more. XSL uses XSLT to transform an XML source tree into an XML result tree (or an XML source document into an XML result document)


How Transformation Works: How Transformation Works In the transformation process, XSLT uses XPath to define parts of the source document that match one or more predefined templates. When a match is found, XSLT will transform the matching part of the source document into the result document. The parts of the source document that do not match a template will (as a general rule) end up unmodified in the result.


Three Parts to Transformation: Three Parts to Transformation XML parser XML file XSL file You can use the built-in XML parser in IE 5.0. There are some limitations to it but it works ok. Most XML transformations are done server-side and then the transformed content is delivered to the browser. We can use CF or Java for this


XML Example: XML Example Empire Burlesque Bob Dylan USA Columbia 10.90 1985 . . . Link


XSL Example: XSL Example Title Artist Link


Beginning an XSLT StyleSheet: Beginning an XSLT StyleSheet 1   2 3 If you use IE as the processor change line 2 to:


Creating the root template: Creating the root template     If this stylesheet was processed it would turn up an empty document, because we output 2 blank lines for the root element


Outputting HTML code: Outputting HTML code   Endangered Species -   Endangered animals face numerous threats. For more information, check out the World Wildlife Federation's   pages.          


Outputting HTML code: Outputting HTML code Endangered Species Endangered animals face numerous threats. For more information, check out the World Wildlife Federation's pages. LINK


Outputting Node Content: Outputting Node Content Endangered Species- -   The mighty     faces numerous threats. For more information, check out the World Wildlife Federation's   pages .  


Outputting Node Content: Outputting Node Content Endangered Species The mighty Tiger faces numerous threats. For more information, check out the World Wildlife Federation's pages. Link


Creating and Applying Template Rules: Creating and Applying Template Rules Template rules are modules that describe how a particular part of your source XML should be output. Link – XSL Link - HTML


Another way to batch process Nodes: Another way to batch process Nodes The for-each method is usually used to build HTML tables Link – XSL Link - HTML


Conditional Processing: Conditional Processing do something Link – XSL Link - HTML


More Conditional Processing: More Conditional Processing do something do something Link – XSL Link - HTML


Sorting Nodes: Sorting Nodes Link – XSL Link - HTML