XML%20Workshop - PowerPoint PPT Presentation

About This Presentation
Title:

XML%20Workshop

Description:

Death. Marriage. subject. Many-many resolution in XML. Photo. Image: jpeg. Description: string ... photo Example Events. Person. Event. Name: string. Date : ... – PowerPoint PPT presentation

Number of Views:27
Avg rating:3.0/5.0
Slides: 23
Provided by: wall163
Category:
Tags: 20workshop | xml | death | photos

less

Transcript and Presenter's Notes

Title: XML%20Workshop


1
XML Workshop
  • XSLT

2
XML
  • Tagged data
  • lth1gtHellolt/h1gt
  • ltmodule codeUFIE8K level3gt
  • ltreview idfredgtA really interesting course,
    well taughtlt/reviewgt
  • lt/modulegt
  • Interchange of data
  • RSS, BPEL4WS, RossettaNet
  • Structure document representation
  • Module specifications
  • Languages
  • XSLT, XSchema, Soap

3
XML a sample system
Browser
CSS process
Client
Server
XSLT process
Stores XML, XQuery,XSLCSS and binary files (JPEG)
XQuery process
Native XML Database
eXist
Java
4
Example Family History
Person
age
Photo
Name string
Id integer Image jpeg Description
string Date date Media string Inscription
string
subject
Event
Date date
Place
Birth
Death
Marriage
Address string Lat decimal Long decimal
5
Many-many resolution in XML
ltphotogt ltidgt2lt/idgt ltmediumgtB/W
photographlt/mediumgt ltdescriptiongtFamily
sitting round the fireplacelt/descriptiongt
ltsubjectgt ltpersongtRobin
Wallacelt/persongt lt/subjectgt
ltsubjectgt ltpersongtKenneth
Wallacelt/persongt lt/subjectgt
ltsubjectgt ltagegt12lt/agegt
ltpersongtFrancis Wallacelt/persongt
lt/subjectgt ltsubjectgt
ltanimalgtCatlt/animalgt lt/subjectgt
ltsubjectgt ltpersongtMiss
Whitfieldlt/persongt lt/subjectgt
ltplacegt ltaddressgtClaremont, Brows
Lane, Formbylt/addressgt
ltlonggt-3.06608lt/longgt
ltlatgt53.55555lt/latgt lt/placegt lt/photogt
Photo
Image jpeg Description string Date date Media
string Inscription string (Subject (
Person name Age integer)
Animal name ) Place (address, lat, log)
name
6
Example Events
child
Person
Birth
father
Name string
mother
lteventgt ltdategt1911-04-26lt/dategt
ltplacegt ltaddressgtNew
Brightonlt/addressgt lt/placegt
ltbirthgt ltchildgt
ltpersongtFrancis Wallacelt/persongt
lt/childgt ltfathergt
ltpersongtKenneth Wallacelt/persongt
lt/fathergt ltmothergt
ltpersongtIda Wallacelt/persongt
lt/mothergt lt/birthgt lt/eventgt
Event
Date date
Death
Marriage
7
xquery version "1.0" ( List events for a
person ) declare namespace request"http//exist
-db.org/xquery/request" declare namespace
transform "http//exist-db.org/xquery/transform"
let person requestrequest-parameter('pers
on',''), ( get the set of events in which this
person is involved ) events
document(/'db/history/events.xml')/eventList/event
.//person person, ( get the stylesheet )
ss document('/db/history/eventList.xsl'), (
set the 'focus' of the event list to the person
) params ltparametersgt ltparam
name"focus" value"person"/gt lt/parametersgt, (
order the events in ascending date order )
elist lteventListgt for e in events
order by e/date return e
lt/eventListgt return ( return the event list
transformed by the stylesheet )
transformtransform(elist,ss,params)
XQuery
8
XSLT
Matches the top-level Document
ltxslstylesheet xmlnsxsl"http//www.w3.org/1999/
XSL/Transform" version"1.0"gt ltxslparam
name"focus"/gt ltxsloutput method"html"/gt
ltxsltemplate match"/"gt lthtmlgt
ltheadgt ltlink rel"stylesheet"
href"photos.css" type"text/css"/gt
lttitlegtEvent Listlt/titlegt lt/headgt
ltbodygt lth2gt
ltxslvalue-of select"focus"/gt
lt/h2gt ltxslapply-templates/gt
lt/bodygt lt/htmlgt
lt/xsltemplategt
Elements written directly to the result
Evaluate an expression and insert the result
Apply matching templates in the given node-set
9
XSLT
Match the node named eventList
ltxsltemplate match"eventList"gt
ltxslapply-templatesgt ltxslsort
selectdate/gt lt/xslapply-templatesgt
lt/xsltemplategt ltxsltemplate
matcheventgt lth3gt ltxslvalue-of
select"date"/gt ltxslvalue-of
select"place"/gtlt/h3gt ltpgt
ltxslapply-tempates/gt lt/pgt
lt/xsltemplategt ltxsltemplate
matchbirthperson focus"gt Born
Father ltxslvalue-of select"father/person"/gt,
Mother ltxslvalue-of
select"mother/person"/gt lt/xsltemplategt
ltxsltemplate matchbirthfather/person
focus"gt Child ltxslvalue-of
select"person"/gt Mother
ltxslvalue-of select"mother/person"/gt
lt/xsltemplategt
XPath Filter conditions,
10
XSLT process
parameters
XML document
XML or plain text
XSLT process
XSLT document
Parse inputs, set context to root While nodes in
context, for each node, check if any templates
match choose the most specific and apply the
template. Set context to the node matched. Apply
this recursively
11
XSLT language
  • Multilingual
  • Output
  • Imperative Control structures
  • Procedural programming
  • Rule-based matching
  • Functional
  • XPath Functions
  • Process Control
  • Debugging

12
Multi-lingual
  • Plain text and plain xml
  • xsl (identified by the xslnamespace)
  • XPath to define node-sets
  • Filter conditions to select subsets
  • XPath functions to manipulate the nodes
  • Comments
  • lt!-- comment --gt

13
Result output
  • Insert evaluated expression
  • ltxslvalue-of selectexp/gt
  • Insert plain text
  • ltxsltextgt. lt/xslgt
  • Insert processing instruction
  • ltxslprocessing-instructiongt
  • Insert a number like a level number
  • ltxslnumbergt
  • Copy nodes into the output
  • ltxslcopy-ofgt
  • ltxslcopygt
  • Create a node
  • ltxslelementgt
  • ltxslattributegt

14
Two programming styles
  • Pull structured programming (imperative)
  • XSL models output structure and pulls parts of
    the XML input into the output

output
XML
  • Push rule-based programming (declarative)
  • XML is pushed through a set of matching rules

output
XML
15
Imperative Control Structures
  • Imperative Control structures
  • Sequence of data and instructions
  • Selection
  • One option
  • ltxslif gt
  • Multiple options
  • ltxslchoosegt
  • ltxslwhengt
  • ltxslotherwisegt
  • Iteration
  • Iterate over nodes in a sequence
  • ltxslfor-eachgt
  • Order nodes in the iteration
  • ltxslsortgt

16
Procedural programming
  • Procedure call -
  • ltxslcall-template nameprocgt..
  • Call Parameters
  • ltxslwith-param namex select30gt
  • Procedure definition
  • ltxsltemplate nameprocgt..
  • Procedure parameters
  • ltxslparam namexgt

17
Rule-based matching
  • Template definition
  • ltxsltemplates matchpathgt
  • Template application
  • ltxslapply-templates selectnodesetgt
  • Recursive
  • Apply most specific template to a node
  • only one rule can match

18
Functional
  • variables can be defined but they are constants
  • Variable declaration
  • ltxslvariable namea valueexp/gt
  • Variable value
  • ltxslvalue-of selecta/gt

19
XPath Functions
  • Boolean Functions
  • String functions
  • Numeric Functions
  • Node sequence functions

20
Modular Programming
  • Inclusion of another stylesheet
  • ltxslincludegt
  • Inclusion of tempates from a stylesheet
  • ltxslimportgt

21
Process control
  • Stylesheet declaration
  • ltstylesheetgt
  • Output control
  • ltxsloutput methodtext/gt
  • Serialisation
  • ltxslpreserve-spacegt
  • ltxslstrip-spacegt
  • Key
  • ltxslkeygt
  • Define attributes
  • ltxslattribute-setgt

22
Debugging
  • Output Debug message
  • ltxslmessagegt
Write a Comment
User Comments (0)
About PowerShow.com