Top Banner
MSc IT Multimedia XML & XSLT P. Muneesawang
33
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

MSc ITMultimedia

XML & XSLT

P. Muneesawang

Page 2: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

2

Outline• Why

• XML

• XSL

Page 3: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

3

World Wide Web Consortium• W3C, founded in October 1994: http://www.w3.org/

• Purpose: develop common protocols that promote WWW’s evolution and ensure its interoperability

• User Interface Domain

Hypertext Markup Language (HTML), Cascading Style Sheets (CSS), Document Object Model (DOM), Scalable Vector Graphics (SVG), SMIL

• Technology and Society Domain

Platform for Privacy Preferences (P3P), Platform for Internet Content Selection (PICS), Resource Description Framework (RDF)

• Architecture DomainHypertext Transfer Protocol (HTTP), Extensible Markup

Language (XML)

...Follow links at http://www.w3.org/ for more details…

Page 4: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

4

Why• Many XML Issues Related to Multimedia:

• XML Data Representation

• XML Schemes and MPEG

• XML and Multimedia Data Indexing

• XML and Multimedia Data Caching

• Multimedia applications and XML

• XML DTDs and Database Schemas

• Security

• But....

• We need to start with the basics….

Page 5: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

5

Why• Full Text Encoding or Mark-up allows:

• the representation of structure (original or otherwise -Headers, sections, cuts, divisions etc)

• to make explicit an interpretation or

• document searching (e.g. find by artist x, and/or by reference y)

• output in a specific format

• re-use in different formats (one document, many outputs e.g. PC, PDA, Phone, Print)

• platform & software-independence

• wide distribution

• preserve content

Page 6: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

6

Why• Particularly useful for:

• collating/providing different versions

• designing interactive multimedia editions

• recording metadata (date of creation, copyright status, change history, etc)

Page 7: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

7

Mark-up Languages• A set of rules that typically state:

• what kind of mark-up is allowed

• where it is allowed required

• how its elements relate to each other

• how to tell mark-up from content

Page 8: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

eXtensible Makeup Language (XML)

Page 9: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

9

XML• XML is a method for putting structured data in a

text file

• XML looks a bit like HTML but isn't HTML

• XML is text, can be read by humans and computers

• XML is a family of technologies

• XML is verbose, but that is less of a problem

• XML is new, but not that new

• XML is license-free, platform-independent and well-supported

Page 10: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

10

What is XML?• Interchange structured documents over the

internet

• Start and end of each logical part (elements)

• DTD formal model allows users to check validity

• Does not require presence of DTD

• A family of languages e.g. XSLT, XSL, XPath

Page 11: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

11

What is XML?• XML allows users to:

• bring multiple files together to form compound documents

• identify where images, sounds, video should be incorporated

• provide processing control information

• add editorial comments to a file

Page 12: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

12

What is XML?• XML is not

• a predefined set of tags

• a standardized template for producing particular document types

Page 13: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

13

HTML Example<! -- Price list for individual fruits --><ul><! -- Fruit --><li>Apples</li><! -- Price --><li>£1</li><! -- Fruit --><li>Oranges</li><! -- Price --><li>£2</li></ul>

Page 14: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

14

XML Example

<FruitPriceList><Fruit>Apples</Fruit>

<Price>£1</Price><Fruit>Oranges</Fruit>

<Price>£2</Price></FruitPriceList>

Page 15: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

15

XML TreeWell-formed XML treeWell-formed XML tree

Page 16: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

16

XML tree

Not well-formed XML treeNot well-formed XML tree

Page 17: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

17

XML Components

• Documents composed of entities

• Entities can contain one or more logical elements

• Each element can have certain attributes

Page 18: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

18

XML use• Elements and attributes entered between matched pairs of angle brackets <….>

• Entity references start with an ampersand and end with a semi-colon &….;

Page 19: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

19

XML Use<?xml version=“1.0” encoding=“US2” standalone=“yes”><! DOCTYPE memo SYSTEM “http://www.acme.com/memo.dtd><memo><to>All Staff</to><from>Ian Anderson</from><date>20 January</date><subject>Lottery</subject><text>The HATII syndicate has won the lottery and we can all quit tomorrow.</text></memo>

Page 20: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

20

Defining your Tag Set

Must create a DTD

<! DOCTYPE memo [<! ELEMENT memo (to, from, date, subject?, para+) ><! ELEMENT para (#PCDATA) ><! ELEMENT to (#PCDATA) ><! ELEMENT from (#PCDATA) ><! ELEMENT data (#PCDATA) ><! ELEMENT subject (#PCDATA) >] >

Page 21: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

21

Using XML Coded Text

• XML Processing Instruction<?xml version=“1.0” encoding=“US2”

standalone=“yes”>• Document Type Declaration (internal orexternal subset)

<! DOCTYPE memo SYSTEM“http://www.myco.com/memo.dtd >

• Document InstanceElement type name must match document type name

Page 22: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

22

Using XML Coded Text

If all three components present, and document instance conforms to rules defined in document type definition, the document is valid.

If only document instance is present all XML processor can do is check document is well-formed

Page 23: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

23

Where now?• XML Multimedia Developments

• PMML - Pervasive Multimedia Markup Language

• RDF - Resource Description Framework (Multimedia specific): an infrastructure that enables the encoding, exchange, and reuse of structured metadata.

• SMIL - Synchronized Multimedia Integration Language

Page 24: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

24

Context: Informedia Digital Video Library

Page 25: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

25

Sample XML for Informedia Results Set

<?xml version="1.0" ?><?xml version="1.0" ?><IDVLResults<IDVLResults xmlns:im="x-schema:idvResSchema.xml" xmlns:im="x-schema:idvResSchema.xml">><im:doc><im:doc> <im:id><im:id>5519555195</im:id><im:pos></im:id><im:pos>00</im:pos><im:shot></im:pos><im:shot>16674991667499</im:shot></im:shot> <im:d_yr><im:d_yr>19991999</im:d_yr><im:d_mo></im:d_yr><im:d_mo>1212</im:d_mo><im:d_day></im:d_mo><im:d_day>22</im:d_day></im:d_day> <im:score><im:score>100100</im:score><im:dur></im:score><im:dur>2993029930</im:dur><im:mmss></im:dur><im:mmss>0:290:29</im:mmss></im:mmss> <im:title><im:title>The Maker of Cherry Garcia and Rainforest Crunch Ice Cream Could The Maker of Cherry Garcia and Rainforest Crunch Ice Cream Could

Soon be Scooped Up; Ice Cream Maker Didn't Name PotentialSoon be Scooped Up; Ice Cream Maker Didn't Name Potential</im:title></im:title></im:doc><im:doc></im:doc><im:doc> <im:id><im:id>5477054770</im:id><im:pos></im:id><im:pos>11</im:pos><im:shot></im:pos><im:shot>21115782111578</im:shot></im:shot> <im:d_yr><im:d_yr>19991999</im:d_yr><im:d_mo></im:d_yr><im:d_mo>1111</im:d_mo><im:d_day></im:d_mo><im:d_day>1919</im:d_day></im:d_day> <im:score><im:score>7070</im:score><im:dur></im:score><im:dur>196480196480</im:dur><im:mmss></im:dur><im:mmss>3:163:16</im:mmss></im:mmss> <im:title><im:title>So, While Ice Cream Parlor Closed, in Suite Next Door to where Tim and So, While Ice Cream Parlor Closed, in Suite Next Door to where Tim and

Heidi Manipulate Bones, Tim and Heidi now also Fill Jars Heidi Manipulate Bones, Tim and Heidi now also Fill Jars </im:title></im:title></im:doc></IDVLResults></im:doc></IDVLResults>

Page 26: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

26

Other W3C Recommendations• XSLT – Extensible Stylesheet Language

Transformations

• XPath – XML Path Language

• XML Schema

Page 27: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

27

Adding Style to XML• XML only text-based, not for visually

presentation.

• Extensible Stylesheet Language (XSL) and XSL Transformations (XSLT) available (XSL as working draft, XSLT as W3C Recommendation Nov. 16, 1999, http://www.w3.org/TR/xslt)• XSLT: a language for transforming XML

documents into other XML documents

• XPATH: a language for addressing parts of an XML document, designed to be used by both XSLT and XPointer

Page 28: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

28

XML example<?xml version="1.0" encoding="windows-874"?>

<?xml-stylesheet type="text/xsl" href="XSL_For_02-01.xsl"?>

<myfriend>

<people>

<id>001</id>

<name>น.ส. ชลธิ�ชา ศรีดา</name>

<address>กรี งเทพ</address>

<telephone>02914-6758</telephone>

<email>[email protected]</email>

<url>http://www.chon.com/</url>

</people>

<people>

<id>002</id>

<name> นายศ ภช�ย สมพาน�ช</name>

<address>กรี งเทพ</address>

<telephone>02524-1234</telephone>

<email>[email protected]</email>

<url>http://www.vbth.cjb.net/</url>

</people>

</myfriend>

Page 29: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

29

XSL example<?xml version="1.0" encoding="windows-874"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/TR/WD-xsl"><xsl:template match="/"><!-- สร้�างส�วนหัวเอกสาร้ HTML ตามปกต� --> <html><head><title> เบื้��องต�นการ้ใช้�งานภาษา XSL ร้�วมกบื้ภาษา XML </title></head> <body>

<!-- สร้�างส�วนหัวของแต�ละคอลมน� --><table width="100%" border="1" style="border-collapse: collapse"> <tr> <td width="5%" bgcolor="black"><font face="MS Sans Serif" size="2" color="white"><b>ร้หัส</b></font></td> <td width="20%" bgcolor="black"><font face="MS Sans Serif" size="2" color="white"><b>ช้��อ</b></font></td> <td width="15%" bgcolor="black"><font face="MS Sans Serif" size="2" color="white"><b>ที่!�อยู่#�</b></font></td> <td width="10%" bgcolor="black"><font face="MS Sans Serif" size="2" color="white"><b>โที่ร้ศัพที่�</b></font></td> <td width="20%" bgcolor="black"><font face="MS Sans Serif" size="2" color="white"><b>E-mail</b></font></td> <td width="30%" bgcolor="black"><font face="MS Sans Serif" size="2" color="white"><b>โอมเพจ</b></font></td> </tr>

<!-- เร้��มต�นอ�านข�อม#ลจากแหัล�งข�อม#ล 02-01_With_XSL.xml โดยู่การ้วนล#ป --><xsl:for-each select="myfriend/people"> <tr> <td><font face="MS Sans Serif" size="2"><xsl:value-of select="id"/></font></td> <td><font face="MS Sans Serif" size="2"><xsl:value-of select="name"/></font></td> <td><font face="MS Sans Serif" size="2"><xsl:value-of select="address"/></font></td> <td><font face="MS Sans Serif" size="2"><xsl:value-of select="telephone"/></font></td> <td><font face="MS Sans Serif" size="2"><xsl:value-of select="email"/></font></td> <td><font face="MS Sans Serif" size="2"><xsl:value-of select="url"/></font></td> </tr></xsl:for-each></table></body></html></xsl:template></xsl:stylesheet>

Page 30: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

30

XSLT, larger font, 1 of 2<?xml version="1.0" encoding="windows-874"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/TR/WD-xsl"><xsl:template match="/"><!-- สร้�างส�วนหัวเอกสาร้ HTML ตามปกต� --> <html><head><title> เบื้��องต�นการ้ใช้�งานภาษา XSL ร้�วมกบื้ภาษา XML </title></head> <body>

<!-- สร้�างส�วนหัวของแต�ละคอลมน� --><table width="100%" border="1" style="border-collapse: collapse"> <tr> <td width="5%" bgcolor="black"><font face="MS Sans Serif" size="2"

color="white"><b>ร้หัส</b></font></td> <td width="20%" bgcolor="black"><font face="MS Sans Serif" size="2"

color="white"><b>ช้��อ</b></font></td> <td width="15%" bgcolor="black"><font face="MS Sans Serif" size="2"

color="white"><b>ที่!�อยู่#�</b></font></td> <td width="10%" bgcolor="black"><font face="MS Sans Serif" size="2"

color="white"><b>โที่ร้ศัพที่�</b></font></td> <td width="20%" bgcolor="black"><font face="MS Sans Serif" size="2"

color="white"><b>E-mail</b></font></td> <td width="30%" bgcolor="black"><font face="MS Sans Serif" size="2"

color="white"><b>โอมเพจ</b></font></td> </tr>

Page 31: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

31

XSLT, larger font, 2 of 2<!-- เร้��มต�นอ�านข�อม#ลจากแหัล�งข�อม#ล 02-01_With_XSL.xml โดยู่การ้วนล#ป --><xsl:for-each select="myfriend/people"> <tr> <td><font face="MS Sans Serif" size="2"><xsl:value-of select="id"/></font></td> <td><font face="MS Sans Serif" size="2"><xsl:value-of select="name"/></font></td> <td><font face="MS Sans Serif" size="2"><xsl:value-of select="address"/></font></td> <td><font face="MS Sans Serif" size="2"><xsl:value-of select="telephone"/></font></td> <td><font face="MS Sans Serif" size="2"><xsl:value-of select="email"/></font></td> <td><font face="MS Sans Serif" size="2"><xsl:value-of select="url"/></font></td> </tr></xsl:for-each></table></body></html></xsl:template></xsl:stylesheet>

Page 32: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

32

XML in IE

Page 33: MSc IT Multimedia XML & XSLT P. Muneesawang. 2 Outline Why XML XSL.

33

Experiments• Install XMLSPY 5 Enterprise Edition

• Follow the online tutorial:

• Step I: making XML schema

• Step II: making XML file

• Step III: making XSLT