Presentation is loading. Please wait.

Presentation is loading. Please wait.

XSLT transformations Or how to get your XML to become HMTL.

Similar presentations


Presentation on theme: "XSLT transformations Or how to get your XML to become HMTL."— Presentation transcript:

1 XSLT transformations Or how to get your XML to become HMTL

2 Agenda What is XSL and XSLT How do I use them Example usage

3 What is XSL and XSLT Recap XSL – EXtensible Stylesheet Language XSLT - EXtensible Stylesheet Language Transformation One is the mechanism to store the structuring of the document The other is the method of applying that

4 XSLT XSLT transforms an XML document into another document XSLT uses XPath to navigate in XML documents XSLT is a W3C Standard

5 Why? You might have an XML document in one format (the supplier) and it is needed in another structure by another party (the manufacturer) You might want to convert from XML to another XML type language such as HTML or WML

6 How does it work? You create the structure of the new document You find the bits of the original document that you wish to extract information from You then place the original data into the new structure by transforming the data

7 XSLT files Start with an XML declaration Then choosing the node(s) that you wish to use Then state your formatting instructions Place your data in the relevant area For example

8 Base xml file Empire Burlesque Bob Dylan USA Columbia 10.90 1985 Hide your heart Bonnie Tyler UK CBS Records 9.90 1988

9 XSL file My CD Collection Title Country HTML formatting XSL code to choose area of XML file XSL code to choose node to display

10 Output

11 How to filter the list Because you use XPATH to access nodes you can filter data e.g. Will list every cd that costs over £10

12 Templates If you want to break down the formatting of a page to individual efforts you can use templates The command is This can allow you to apply formatting to individual elements e.g

13 My CD Collection : :

14 Write an XML file using an XSL file in ASP <% 'Load XML xml = Server.CreateObject("Microsoft.XMLDOM").async = false.load(Server.MapPath("cdcatalog.xml")) 'Load XSL xsl = Server.CreateObject("Microsoft.XMLDOM").async = false.load(Server.MapPath("cdcatalog.xsl")) 'Transform file.Write(xml.transformNode(xsl)) %>

15 Or do it the easy way Drag an XML control onto the page Set the properties… You’re done

16 Server-side tips Do not need the xsl:stylesheet processing instruction in the XML file XML can come from a data source or even a dynamic request XML object properties can still be manipulated in code to deal with user-agent for example

17 System design methods Or “there is not only XML”

18 Agenda XML approach Standard system approach Benefits and drawbacks The golden key

19 Standard systems Database SQL Application server XML XSLT WAP Web ITV XSL

20 XML based systems XML datasource ASP.NET/ PHP/ CF XSLT WAP Web ITV XSL

21 Benefits Code based systems Re-use already developed skills iin PHP/SQL/ASP etc Lots of support in this area XML based systems one less area to code in consistency of data

22 Drawbacks Code based systems Extra layers of code being developed e.g. SQL/PHP etc Not most efficient use of server resources? XML based systems Not a hugely developed approach Not a widespread proven method

23 The Golden Key Take a look at http://www.dnzone.com/ShowDetail.asp?NewsId=115 http://www.dnzone.com/ShowDetail.asp?NewsId=115 http://support.microsoft.com/default.aspx?kbid=32488 9 online seminar http://support.microsoft.com/default.aspx?kbid=32488 9


Download ppt "XSLT transformations Or how to get your XML to become HMTL."

Similar presentations


Ads by Google