XSLT
Download
1 / 18

XSLT - PowerPoint PPT Presentation


  • 51 Views
  • Uploaded on

XSLT. Doo Soon Kim. Short tragic story. Once upon a time …. There was a handsome prince. He was traveling in Egypt, …. There, he met a beautiful woman, Cleopatra!!!. He fell in love with her. He wanted to express his love to her.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' XSLT' - athena-kinney


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
Xslt

XSLT

Doo Soon Kim


Short tragic story
Short tragic story

Once upon a time….

There was a handsome prince...

He was traveling in Egypt, …

There, he met a beautiful woman, Cleopatra!!!


Xslt

He fell in love with her

He wanted to express his love to her.

Eoifun;vun fds;ih sj;fai j;fsodij “ fisa;oinv fie fis;j ;oasidj f;asj fdasj; fiosj

Hi..I love you....Sweetheart….blah..blah….


What is xslt
What is XSLT?

  • Extensible Stylesheet Language Transformation

  • Convert XML documents into other XML documents, into HTML documents or into almost anything you like

  • defined by XML


History
History

XSL

XSLT

XPath

July, 1999

April, 1999

became Candidate Recommendation November, 2000

became Candidate Recommendation November, 2000

became Recommendation November, 1999


Use case 1
Use case #1

<name> <first_name /> <last_name /><name><job /><age />

translator(interpreter)

<name /><occupation />

schema B

schema A


Use case 2
Use case #2

Catalog.html

Catalog2HTML.xsl

Catalog.wml

Catalog.xml

Catalog2WML.xsl

Catalog2RTF.xsl

Catalog.rtf


Schema xml xslt xpath
Schema, XML, XSLT, XPATH

  • Schema : Defines the structure of XML. (grammar)

  • XML document: follows the schema. (sentence)

  • XSLT : converts a xml document of one schmeta into the other. (translation)

  • XPATH : address specific parts of an XML document. (a specific word)


Schema xslt xpath
Schema, XSLT, XPATH

<card type="simple"> <name>Doo Soon Kim</name> <title>PhD, CS Dept.</title> <email>dskim@cs.utexas.edu</email> <phone>(512) 123-4567</phone>

</card>

Schema : Top level is card. Card element has 4 children nodes – name, title, email, phone

XSLT : Converts it into HTML format (or other formats)

XPATH : card/name => name element card[@type] => the type attribute of card ...


Examples
Examples

  • example


Xslt

<card type="simple"> <name>Doo Soon Kim</name> <title>PhD, CS Dept.</title> <email>dskim@cs.utexas.edu</email> <phone>(512) 123-4567</phone>

</card>

<html xmlns="http://www.w3.org/1999/xhtml"><title>business card</title> <body><h1>Doo Soon Kim</h1><h3><i>PhD, CS Dept.</i></h3> <p>email: <a href="mailto:dskim@cs.utexas.edu"><tt>dskim@cs.utexas.edu</tt></a></p> <p>phone: (512)123-4567</p> </body></html>


Simple examples
Simple examples

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns="http://www.w3.org/1999/xhtml"> <xsl:template match="card[@type='simple']"> <html xmlns="http://www.w3.org/1999/xhtml">

<title>business card</title><body>

<xsl:apply-templates select="name"/>

<xsl:apply-templates select="title"/>

<xsl:apply-templates select="email"/>

<xsl:apply-templates select="phone"/> </body></html>

</xsl:template>

<xsl:template match="card/name">

<h1><xsl:value-of select="text()"/></h1>

</xsl:template>

<xsl:template match="email">

<p>email: <a href="mailto:{text()}"><tt>

<xsl:value-of select="text()"/>

</tt></a></p> </xsl:template>

... </xsl:stylesheet>

(ref: http://www.brics.dk/~amoeller/XML/xslt-4.1.html)


Understanding a template
Understanding a Template

  • XSLT is a list of XSL templates

  • XSL Template : If elements are satisfied by match part in a template, replace them with the body of the template

  • The match patterndetermines where this template applies

  • Match pattern is defined by XPATH


Examples1
Examples

XPATH

<xsl:template match=“title">

<H1><xsl:value-of select="text()"/></H1>

</xsl:template>

If match holds, do this part!

<title> Lord of Ring </title>

<H1> Lord of Ring </H1>

<title>

<H1>

Lord of Ring

Lord of Ring


More of xslt
More of XSLT

  • Templates can have programming features inside its bodyIf-then-else, variable, loop, function ...

  • Provides lots of built-in primitive functions.string manipulator, mathematical functions, ...


Lesson from past project
Lesson from past project

  • XFDL(eXtensible Form Description Language)

  • Built XFDL Editor/Viewer

  • Intellectual Property Office wanted to provide a patent-form service (over 150) over the internet

  • Manages patent-related documents as SGML

  • Key problem : Converting XFDL into SGML patent DTD

  • Sounds good.....But......


Project failed
Project failed!!

  • XFDL : form description language. display-oriented like HTMLPatent DTD : content-oriented. Content-oriented -> Display-oriented : EasyDisplay-oriented -> Content-oriented : Hard

  • We ended up making different 150 XSLT.

  • Lesson : You should have a well-defined schema first!


References
References

  • XSLT Processors : Saxon, XT, iXSLT, Xalan-Java, Xalan-C++, Sablotron, MSXML(ex. msxml <xsl file> <xml file>)

  • W3C Recommendation(http://www.w3.org/TR/xslt)

  • XSLT Editors(http://www.xslt.com/resources.html)