Presentation is loading. Please wait.

Presentation is loading. Please wait.

Extensible Stylesheet Language Chao-Hsien Chu, Ph.D. School of Information Sciences and Technology The Pennsylvania State University XSL-FO XSLT.

Similar presentations


Presentation on theme: "Extensible Stylesheet Language Chao-Hsien Chu, Ph.D. School of Information Sciences and Technology The Pennsylvania State University XSL-FO XSLT."— Presentation transcript:

1

2 Extensible Stylesheet Language Chao-Hsien Chu, Ph.D. School of Information Sciences and Technology The Pennsylvania State University XSL-FO XSLT

3 Ways of Displaying XML Format Information (Document) Structure (DTD) XSL DHTML + CSS DSSSL CGI + Script

4 XML for Information Interchange CAD Package Word Processor Statistical Processing Spreadsheet Package XML Source Document Result Document Result Document Result Document Result Document

5 Extensible Stylesheet Language XSL XSLT XSL-FO Formatting Objects: To define the regions of a page and the appearance of content within those regions Transformations: To specify how an XML document be transformed from one kind of document to another kind of document.

6 Concepts of XSLT XML Source Document Resulting Document XSL Stylesheet XSL Processor

7 Example of XSL Processor  XT. www.jclark.com/xml/xt.htmlwww.jclark.com/xml/xt.html  LotusXSL. www.alphaworks.ibm.com/tech/LotusXSLwww.alphaworks.ibm.com/tech/LotusXSL  MSXML. www.microsoft.com/xml/xsl/www.microsoft.com/xml/xsl/  Xalan-Java. xml.apache.org/xalan-j/index.htmlxml.apache.org/xalan-j/index.html  MDC-XSL. mdc-xsl.sourceforge.net/mdc-xsl.sourceforge.net/  XSL FAQ. www.dpawson.co.uk/xsl/xslfaq.htmlwww.dpawson.co.uk/xsl/xslfaq.html

8 Potential Usages of XSLT  Change the styles of a document.  Add elements specifically for viewing, such as add the logo or the address of the sender to an XML invoice.  Create new contents from an existing one, such as create the table of contents.  Present information with the right level of details for the readers, such as high-level information for top managers and detailed technical information to the rest of the staffs.  Convert between different DTDs or different versions of a DTD, such as convert a company specific DTD to an industry standard.  Transform XML documents into HTML for backward compatibility with existing browsers.

9 Write One Publish Many Idea XML Document Print out CD ROM Web WAP, etc. Process Source Document Result Documents XSLT

10 Example of XSLT Document <xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" xmlns="http://www.w3.org/TR/REC-html40" result-ns=""> Customer Contact Process Instruction Root Element Elements Subroutine

11 Example of XSLT Document ID: EMAIL: Phone: Street: City: State: ZIP: Loop Producing output Element Attribute

12 XSL Document Tree Address_ Book Contact IDName E-mail PhoneAddress ZipStateCityStreet Root Element Root ( / )

13 Elements of XSLT Document  Structure. Concerned with the structure of the XSLT doc.  Content. Concerned with outputting content of the elements or attributes.  Looping and Decision Making. Used to loop and to carry out conditional operations  Manipulation. Used to manipulate, insert and copy elements from the source tree into the result tree.

14 Elements for Structure . The root element of the XSL Document. . To specify the final format (text, HTML, XML, WML, etc.) of the transformations. . To define a template for producing output. . To invoke other templates within the current template.

15 Examples of Output Element   <xsl:output method=“xml” version=“1.0” indent=“yes” />  <xsl:output method=“xml” version=“1.0” indent=“true” doctype-system=http://www.wapforum.org/DTD/wml_1.2.xml doctype-public=“-//WAPFORUM//DTD WML 1.2//EN” />

16 Elements for Content. To write literal text to the output while preserving white space and of disabling output escaping.. To output the contents of the element or attribute given in the specified node (in Xpath expression). It has an attribute called “select” to define the source of output.

17 Looping & Decision Making Elements. To carry out the transformation on each element that meets the criteria in “select” attribute.. Similar to the “if” statement.. Similar to “if … else” or “switch” structure. and. Allow us to select from one of several choices and to ensure that there is also a default action associated with this operation.

18 Elements for Manipulation. To copy elements in the source tree to the output.. To copy the specified element in “select” attribute to the output.. To create/insert a new element in the result tree.. To create/insert a new attribute in the result tree.. To define and name a set of attributes that always go together.. To specify the sort order for the and elements.

19 Notations in Xpath Expression “/” - root node “..” - parent node “.” - current context node “/parent/child” “*”- All the child nodes of the context node “@” - attribute node “//” - recursive descent operator (every)

20 Functions in Xpath Expression  name(): return the name of the node  position(): return the position of the node  count(): counts the number of occurrences of the item specified as a parameter  sum(): adds the values of the contents of the nodes passed to it.

21 Top Element for Different Stylesheets  HTML Document: <xsl:stylesheet xmlns:xsl=" http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/TR/REC-html40">  Text File:  XML Document:  WML Document: <xsl:output method="xml“ version="1.0“ indent="true" doctype-system="http://www.wapforum.org/DTD/wml_1.2.xml" doctype-public="-//WAPFORUM//DTD WML 1.2//EN" />

22 How to Use XT Processor  Copy XT.exe to the directory where your XML sources are stored. (make sure that your directory structure are simple)  Activate the DOS mode (Command Prompt).  Switch to directory where XML sources are located. Use c: (for instance), then cd xxx.  Enter: XT xxx.xml xxx.xsl (shown on screen) XT xxx.xml xxx.xsl >> file.xxx (saved in file.xxx)

23 Thank You? Any Question?


Download ppt "Extensible Stylesheet Language Chao-Hsien Chu, Ph.D. School of Information Sciences and Technology The Pennsylvania State University XSL-FO XSLT."

Similar presentations


Ads by Google