Extensible Stylesheet Language - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

Extensible Stylesheet Language

Description:

DHTML CSS. DSSSL. CGI Script. XML for Information Interchange. CAD. Package. Word. Processor ... To define the regions of a page and the appearance of ... – PowerPoint PPT presentation

Number of Views:262
Avg rating:3.0/5.0
Slides: 23
Provided by: net1I
Category:

less

Transcript and Presenter's Notes

Title: Extensible Stylesheet Language


1
Extensible Stylesheet Language
Chao-Hsien Chu, Ph.D. School of Information
Sciences and Technology The Pennsylvania State
University
XSL-FO
XSLT
2
Ways of Displaying XML
Information (Document)
XSL DHTML CSS DSSSL CGI Script
Format
Structure (DTD)
3
XML for Information Interchange
Source Document
Result Document
Result Document
XML
Result Document
Result Document
4
Extensible Stylesheet Language
Formatting Objects To define the regions of a
page and the appearance of content within those
regions
XSL-FO
XSL
Transformations To specify how an XML document
be transformed from one kind of document to
another kind of document.
XSLT
5
Concepts of XSLT
XML Source Document
Resulting Document
XSL Processor
XSL Stylesheet
6
Example of XSL Processor
  • XT. www.jclark.com/xml/xt.html
  • LotusXSL. www.alphaworks.ibm.com/tech/LotusXSL
  • MSXML. www.microsoft.com/xml/xsl/
  • Xalan-Java. xml.apache.org/xalan-j/index.html
  • MDC-XSL. mdc-xsl.sourceforge.net/
  • XSL FAQ. www.dpawson.co.uk/xsl/xslfaq.html

7
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.

8
Write One Publish Many Idea
Source Document
Result Documents
XSLT
Print out CD ROM Web WAP, etc.
XML Document
9
Example of XSLT Document
Process Instruction
  • lt?xml version"1.0"?gt
  • ltxslstylesheet xmlnsxsl"http//www.w3.org/TR/WD
    -xsl"
  • xmlns"http//www.w3.org/TR/REC-html40"
  • result-ns""gt
  • ltxsltemplate match "/"gt
  • ltHTMLgt
  • ltHEADgt
  • ltTITLEgtCustomer Contactlt/TITLEgt
  • lt/HEADgt
  • ltBODYgt
  • ltxslapply-templates select"Address_Book"
    /gt
  • lt/BODYgt
  • lt/HTMLgt
  • lt/xsltemplategt

Root Element
Elements
Subroutine
10
Example of XSLT Document
  • ltxsltemplate match "Address_Book"gt
  • ltxslfor-each select"Contact"gt
  • ltULgt
  • ltLIgt ltxslvalue-of select"Name"/gtlt/LIgt
  • ltULgt
  • ltLIgtID ltxslvalue-of
    select"ID"/gtlt/LIgt
  • ltLIgtEMAIL ltxslvalue-of
    select"EMAIL"/gtlt/LIgt
  • ltLIgtPhone ltxslvalue-of
    select"Phone"/gtlt/LIgt
  • ltLIgtStreet ltxslvalue-of
    select"Address/Street"/gtlt/LIgt
  • ltLIgtCity ltxslvalue-of
    select"Address/City"/gtlt/LIgt
  • ltLIgtState ltxslvalue-of
    select"Address/State"/gtlt/LIgt
  • ltLIgtZIP ltxslvalue-of
    select"Address/ZIP"/gtlt/LIgt
  • lt/ULgt
  • lt/ULgt
  • lt/xslfor-eachgt
  • lt/xsltemplategt
  • lt/xslstylesheetgt

Producing output
Loop
Element
Attribute
11
XSL Document Tree
Root ( / )
Address_ Book
Root Element
Contact
ID
Name
E-mail
Phone
Address
Zip
State
City
Street
12
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.

13
Elements for Structure
  • ltxslstylesheetgt lt/xslstylesheetgt. The root
    element of the XSL Document.
  • ltxsloutput/gt. To specify the final format (text,
    HTML, XML, WML, etc.) of the transformations.
  • ltxsltemplategt lt/xsltemplategt. To define a
    template for producing output.
  • ltxslapply-templates/gt. To invoke other templates
    within the current template.

14
Examples of Output Element
  • ltxsloutput methodtext indentno /gt
  • ltxsloutput methodxml
  • version1.0
  • indentyes /gt
  • ltxsloutput methodxml
  • version1.0
  • indenttrue
  • doctype-systemhttp//www.wapforum.org/DTD/wml_1.
    2.xml
  • doctype-public-//WAPFORUM//DTD WML 1.2//EN /gt

15
Elements for Content
  • ltxsltextgt lt/xsltextgt. To write literal text to
    the output while preserving white space and of
    disabling output escaping.
  • ltxslvalue-of/gt. 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.

16
Looping Decision Making Elements
  • ltxslfor-eachgt lt/xslfor-eachgt. To carry out the
    transformation on each element that meets the
    criteria in select attribute.
  • ltxslifgt lt/xslifgt. Similar to the if
    statement.
  • ltxslchoosegt lt/xslchoosegt. Similar to if
    else or switch structure.
  • ltxslwhengt lt/xslwhengt and ltxslotherwisegt
    lt/xslotherwisegt. Allow us to select from one of
    several choices and to ensure that there is also
    a default action associated with this operation.

17
Elements for Manipulation
  • ltxslcopygt lt/xslcopygt. To copy elements in the
    source tree to the output.
  • ltxslcopy-of/gt. To copy the specified element in
    select attribute to the output.
  • ltxslelementgtlt/xslelementgt. To create/insert a
    new element in the result tree.
  • ltxslattributegt lt/xslattributegt. To
    create/insert a new attribute in the result tree.
  • ltxslattribute-setgt lt/xslattribute-setgt. To
    define and name a set of attributes that always
    go together.
  • ltxslsort/gt. To specify the sort order for the
    ltxslapply-templatesgt and ltxslfor-eachgt elements.

18
Notations in Xpath Expression
  • / - root node
  • .. - parent node
  • . - current context node
  • /parent/child
  • - All the child nodes of the context node
  • _at_ - attribute node
  • // - recursive descent operator (every)

19
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.

20
Top Element for Different Stylesheets
  • HTML Document
  • ltxslstylesheet xmlnsxsl" http//www.w3.org/199
    9/XSL/Transform"
  • xmlns"http//www.w3.org/TR/REC-html40"gt
  • Text File
  • ltxslstylesheet xmlnsxsl"http//www.w3.org/1999
    /XSL/Transform"gt
  • ltxsloutput method"text" indent"no"/gt
  • XML Document
  • ltxslstylesheet xmlnsxsl"http//www.w3.org/1999
    /XSL/Transform"gt
  • ltxsloutput method"xml" version"1.0"
    indent"yes"/gt
  • WML Document
  • ltxslstylesheet xmlnsxsl"http//www.w3.org/1999
    /XSL/Transform"gt
  • ltxsloutput 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" /gt

21
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 gtgt file.xxx (saved in
    file.xxx)

22
Thank You? Any Question?
Write a Comment
User Comments (0)
About PowerShow.com