Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to XSL Hudson Ummem Veloso (huv) Luciano de Moura Silva (lms4)

Similar presentations


Presentation on theme: "Introduction to XSL Hudson Ummem Veloso (huv) Luciano de Moura Silva (lms4)"— Presentation transcript:

1 Introduction to XSL Hudson Ummem Veloso (huv) Luciano de Moura Silva (lms4)

2 12/02/2005 2 Introduction What is XSL? –XSL stands for E X tensible S tylesheet L anguage –XSL is a style sheet language applied in archives XML But what is a Style Sheet? –A list of page format specifications, including typographic and layout specifications, that, when applied to structured information, provides a particular rendering of that information. –Different style sheets may be applied to the same piece of structured information to produce different presentations of the information.

3 12/02/2005 3 Introduction How XSL will be used in the BrazilIP? –Formatting of archives XML –Create the PDF files for documentation –Create the HTML files to make use in the Internet Why to use XML and XSL? –The XML validation can be automatized –The XSL is recommended for W3C for formatting the XML files –The XSL is more powerfull than CSS

4 12/02/2005 4 Introduction XSL components –XSLT - a language for transforming XML documents –XPath - a language for navigating in XML documents –XSL-FO - a language for formatting XML documents

5 12/02/2005 5 XSLT What is XSLT? –XSLT stands for XSL Transformations –XSLT transforms an XML document into another XML document –XSLT uses XPath to navigate in XML documents

6 12/02/2005 6 XSLT How does it works –In the transformation process, XSLT uses XPath to define parts of the source document that should 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. Brazil IP...

7 12/02/2005 7 XSLT – Transformation How to create a HTML document with the following XML document? example.xml Brazil IP Fênix Configuração rgo drm 5 …

8 12/02/2005 8 XSLT - Transformation Create the XSL template example1.xsl (open the example.xml with browser) GroupName: NumberofMembers:

9 12/02/2005 9 XSLT – The element is used to extract the value of a selected node Modif link (href) in the example.xml for example2.xsl and view with browser GroupName: LeaderOne:

10 12/02/2005 10 XSLT - The element allows you to do looping in XSLT Modif link (href) in the example.xml for example3.xsl and view with browser GroupName: NumberofMembers:

11 12/02/2005 11 XSLT - The element is used to sort the output. Modif link (href) in the example.xml for example4.xsl and view with browser GroupName: NumberofMembers:

12 12/02/2005 12 XSLT - The element is used to put a conditional test against the content of the XML file. –Syntaxe: Where to put the element? –To add a conditional test, add the element inside the element in the XSL file:......some output if the expression is true......

13 12/02/2005 13 XSLT - View the example above Modif link (href) in the example.xml for example5.xsl and view with browser GroupName:

14 12/02/2005 14 XSLT - The element is used in conjunction with and to express multiple conditional tests. The element is used for simulation of if then else structure –Syntaxe : Where to put the Choose Condition? –To insert a conditional choose test against the content of the XML file, add the,, and elements to the XSL file:... some output...... some output....

15 12/02/2005 15 XSLT - Modif link (href) in the example.xml for example6.xsl and view with browser GroupName: GroupName:

16 12/02/2005 16 XSLT - The element applies a template to the current element or to the current element's child nodes. Modif link (href) in the example.xml for example7.xsl and view with browser GroupName:

17 12/02/2005 17 XPath and XSLT – basics functions Context functions: Modif link (href) in the example.xml for example8.xsl and view with browser GroupName: NumberofMembers:

18 12/02/2005 18 XPath and XSLT – basics functions Functions on Boolean values: Modif link (href) in the example.xml for example9.xsl and view with browser GroupName: NumberofMembers:

19 12/02/2005 19 XPath and XSLT – basics functions Arithmetic functions: –sum(node set) - this function sums up all the values in the set of nodes –floor(number) returns the largest integer that is not greater than number Example: floor(2.5) returns 2 –ceiling(number) returns the smallest integer that is not less than number Example. Ceiling(2.5) returns 3 –round(number) returns the integer closest to number Example. round(2.3) returns 2 NumberofMembers in the USB host project:

20 12/02/2005 20 XPath and XSLT – basics functions String functions: –string(arg) - returns the string value of the argument. The argument could be a number, boolean, or node-set Example: string(314) –Result: “314” –string-length(string) - returns the length of the specified string. Example: string-lenght(‘Brazil-IP’) –Result: 9 –concat(string,string,...) - returns the concatenation of the strings Example: concat(‘Brazil’,‘-’,’IP’,) –Result: “Brazil-IP” –translate(string1,string2,string3) – Converts string1 by replacing the characters in string2 with the characters in string3 Example: translate('12:30',‘0123',‘abcd') –Result: “bc:da”

21 12/02/2005 21 XPath and XSLT – basics functions Group Name Leader1 Leader2 Length String Modif link (href) in the example.xml for example11.xsl and view with browser

22 12/02/2005 22 XSLT - elements –The element is used to add attributes to elements. yellow Modif link (href) in the example.xml for example12.xsl and view with browser

23 12/02/2005 23 XSLT - elements –The element writes a message to the output. This element is primarily used to report errors This line is pair Modif link (href) in the example.xml for example13.xsl and view with browser

24 12/02/2005 24 XSLT XSLT Processors –Saxon (http://saxon.sourceforge.net/) is a free processor written in Javahttp://saxon.sourceforge.net/ –Xalan (http://xml.apache.org/xalan-j/index.html) is part of the Apache XML Project. It has versions written in both Java and C++, both of them freehttp://xml.apache.org/xalan-j/index.html –xsltproc (http://xmlsoft.org/XSLT/) processor is written in C. It is free and is considered the fastest of the processorshttp://xmlsoft.org/XSLT/ –Microsoft's MSXML (http://msdn.microsoft.com/xml/) engine includes an XSLT processor. It is reported to be fast, but only runs on Windowshttp://msdn.microsoft.com/xml/

25 12/02/2005 25 XSLT How to generate a HTML file from a XML and a XSL files –First we have to get the fop.zip from Apache.orgApache.org –Then use the xalan command xalan -in inputFile.xml -out outputFile.html

26 12/02/2005 26 XSL-FO What is XSL-FO? –XSL-FO stands for Extensible Stylesheet Language Formatting Objects –XSL-FO is an XML-based markup language describing the formatting of XML data for output to screen, paper or other media.

27 12/02/2005 27 XSL-FO XSL-FO document structure

28 12/02/2005 28 XSL-FO XSL-FO Areas –XSL-FO uses rectangules boxes (areas) to display output Pages Regions Block areas Line areas Inline areas

29 12/02/2005 29 XSL-FO XSL-FO Areas –Pages contain margin-top margin-bottom margin-left margin-right Regions –Regions contain region-body region-before region-after region-start region-end Block areas

30 12/02/2005 30 XSL-FO

31 12/02/2005 31 XSL-FO XSL-FO Areas –Block Areas Block areas defines small block elements like paragraphs, tables and lists Can contain other Block areas, but most often they contain Line areas –Line Areas Define text lines inside Block areas Contain Inline areas –Inline Areas Define text inside Lines (bullets, single character, graphics)

32 12/02/2005 32 XSL-FO A real XSL-FO example Hello Brazil_IP

33 12/02/2005 33 XSL-FO Templates <fo:simple-page-master master-name="capa" page-width="297mm" page-height="210mm" margin-top="3cm" margin-bottom="3cm" margin-left="2cm" margin-right="2cm"> <fo:simple-page-master master-name="A4" page-width="297mm" page-height="210mm" margin-top="1cm" margin-bottom="1cm" margin-left="1cm" margin-right="1cm">

34 12/02/2005 34 XSL-FO XSL-FO Processors –XSL Formatter (http://www.antennahouse.com/)http://www.antennahouse.com/ –Xinc Beta Release (http://www.lunasil.com/) A Swing based XSL-FO viewer allows you to view and print XSL-FO files as well as generate PDF files with the click of a button.http://www.lunasil.com/ –FOP (http://xmlgraphics.apache.org/fop/) It is a free Java application that reads a formatting object (FO) tree and renders the resulting pages to a specified output.http://xmlgraphics.apache.org/fop/

35 12/02/2005 35 XSL-FO How to generate a PDF file from a XML and a XSL files –Use the xalan command to create the FO file –Then use the fop comand to generate the PDF xalan -in inputFile.xml -out outputFile.fo fop -fo inputFile.fo -pdf outputFile.pdf

36 12/02/2005 36 XSL-FO You also can generate a PS file –Use the xalan command to create the FO file –Then use the fop comand to generate the PS xalan -in inputFile.xml -out outputFile.fo fop -fo inputFile.fo -ps outputFile.ps

37 12/02/2005 37 Study Bibliography –http://www.w3schools.comhttp://www.w3schools.com This site have some tutorials about XML, HTML, CSS and XSL for beginners. –http://www.dpawson.co.uk/xsl/http://www.dpawson.co.uk/xsl/ A reference guide about XSL. –http://www.antennahouse.com/XSLsample/XSLsample.htmhttp://www.antennahouse.com/XSLsample/XSLsample.htm A guide to generate PDF files from a XSL-FO. –http://www.zvon.org/xxl/http://www.zvon.org/xxl/ A complete source with tutorials an reference guides about XML, XSLT, XSL-FO, CSS and others. –http://xmlgraphics.apache.org/fop/download.htmlhttp://xmlgraphics.apache.org/fop/download.html Where to download the FOP XSL-FO Processor.


Download ppt "Introduction to XSL Hudson Ummem Veloso (huv) Luciano de Moura Silva (lms4)"

Similar presentations


Ads by Google