8 xml (extensible markup lan- guage) - uni-due.de · 8 xml (extensible markup lan-guage) •...
TRANSCRIPT
XML (Extensible Markup Language) 1
8 XML (Extensible Markup Lan-guage)
• Introduction
• XML namespaces
• Document Type Definitions (DTDs)
• XML Schema
• XPath locator language
• XSLT (Extensible Style Sheet Language Transfor-mations)
• XLink (XML Linking Language)
• XPointer (XML Pointer Language)
• XML Query Languages
Norbert Fuhr
XML (Extensible Markup Language) 2
8.1 Introduction
basic ideas:
• markup of logical structure of documents
• separation of logical structure and layout(in contrast to HTML)
• support interoperability of Web services and XML-based applications
Norbert Fuhr
XML (Extensible Markup Language) 3
Example XML document
<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE book SYSTEM
"/services/dtds/book.dtd"><book class="H.3.3">
<author>John Smith</author><title>XML Retrieval</title><chapter>
<heading>Introduction</heading>This text explains all about XML and IR.
</chapter><chapter>
<heading>XML Query Language XQL
</heading><section>
<heading>Examples</heading></section><section>
<heading>Syntax</heading>Now we describe the XQL syntax.
</section></chapter>
</book>
Norbert Fuhr
XML (Extensible Markup Language) 4
• hierarchical structure: nesting of elements
• element: start-tag – content – end tag<tag-name> content </tag-name>
• tag-name: logical name of element
• content: data or other elements(nesting of elements)
<author><first>John</first><last>Smith</last></author>
• attributes: assigned to elements(specified in start tag)pair of (attribute name, attribute value),e.g. <date format="ISO">2000-05-01</date>
Norbert Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
5
8.2
XM
Lna
mes
pace
s
allo
wfo
rco
mbi
natio
nof
elem
ent
nam
esde
fined
inde
pend
ently
(in
diffe
rent
reso
urce
s)
<?xm
lve
rsio
n="1
.0"?
><!
--bo
thna
mesp
ace
pref
ixes
are
avai
labl
eth
roug
hout
-->
<bk:
book
xmln
s:bk
=’ur
n:lo
c.go
v:bo
oks’
xmln
s:is
bn=’
urn:
ISBN
:0-3
95-3
6341
-6’>
<bk:
titl
e>Ch
eape
rby
the
Doze
n</b
k:ti
tle>
<isb
n:nu
mber
>156
8491
379<
/isb
n:nu
mber
></
bk:b
ook>
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
6
nam
espa
cing
with
defa
ult:
<?xm
lve
rsio
n="1
.0"?
><!
--un
pref
ixed
elem
ent
type
sar
efr
om"b
ooks
"--
><b
ook
xmln
s=’u
rn:l
oc.g
ov:b
ooks
’xm
lns:
isbn
=’ur
n:IS
BN:0
-395
-363
41-6
’><t
itle
>Che
aper
byth
eDo
zen<
/tit
le>
<isb
n:nu
mber
>156
8491
379<
/isb
n:nu
mber
></
book
>
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
7
8.3
Doc
umen
tTyp
eD
efini
tion
s
wel
l-for
med
XM
L:pr
oper
nest
ing
ofel
emen
ts(e
.g.
<a>
<b>
</a
><
/b>
isfo
rbid
den
valid
XM
L:do
cum
ent
iswel
l-for
med
and
conf
orm
sto
docu
men
tty
pede
finiti
on
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
8
Dec
lara
tion
ofD
ocum
ent
Typ
e
doct
yped
ecl
::=
’<!D
OCTY
PE’
SNa
me(S
Exte
rnal
ID)?
S?(’
[’(m
arku
pdec
l|
Decl
Sep)
*’]
’S?
)?’>
’De
clSe
p::
=PE
Refe
renc
e|
Sma
rkup
decl
::=
elem
entd
ecl
|At
tlis
tDec
l|
Enti
tyDe
cl|
Nota
tion
Decl
|PI
|Co
mmen
tEx
tern
alID
::=
’SYS
TEM’
SSy
stem
Lite
ral
|’P
UBLI
C’S
Pubi
dLit
eral
SSy
stem
Lite
ral
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
9
Dec
lara
tion
ofD
TD
:Exa
mpl
es
exte
rnal
DT
D:
<?xm
lve
rsio
n="1
.0"?
><!
DOCT
YPE
gree
ting
SYST
EM"h
ello
.dtd
"><g
reet
ing>
Hell
o,wo
rld!
</gr
eeti
ng>
inte
rnal
DT
D:
<?xm
lve
rsio
n="1
.0"
enco
ding
="UT
F-8"
?><!
DOCT
YPE
gree
ting
[<!
ELEM
ENT
gree
ting
(#PC
DATA
)>]>
<gre
etin
g>He
llo,
worl
d!</
gree
ting
>
Nor
bert
Fuhr
XML (Extensible Markup Language) 10
DTD Specification
• element definitions
• definition of element attributes
• entity definitions
Norbert Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
11
Ele
men
tD
efini
tion
s
elem
entd
ecl
::=
’<!E
LEME
NT’
SNa
meS
cont
ents
pec
S?’>
’co
nten
tspe
c::
=’E
MPTY
’|
’ANY
’|
Mixe
d|
chil
dren
Mixe
d::
=’(
’S?
’#PC
DATA
’(S
?’|
’S?
Name
)*S?
’)*’
|’(
’S?
’#PC
DATA
’S?
’)’
Nor
bert
Fuhr
XML (Extensible Markup Language) 12
Element Definition: Examples
<!ELEMENT br EMPTY><!ELEMENT p (#PCDATA|emph)* ><!ELEMENT %name.para; %content.para; ><!ELEMENT container ANY><!ELEMENT book (author,title, chapter+)><!ELEMENT author (#PCDATA)><!ELEMENT title (#PCDATA)><!ELEMENT chapter (heading, #PCDATA?, section*)><!ELEMENT section (heading, #PCDATA)>
Norbert Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
13
Defi
nition
ofel
emen
tat
trib
utes
Attl
istD
ecl
::=
’<!A
TTLI
ST’
SNa
meAt
tDef
*S?
’>’
AttD
ef::
=S
Name
SAt
tTyp
eS
Defa
ultD
ecl
AttT
ype
::=
Stri
ngTy
pe|
Toke
nize
dTyp
e|
Enum
erat
edTy
peSt
ring
Type
::=
’CDA
TA’
Toke
nize
dTyp
e::
=’I
D’|
’IDR
EF’
|’I
DREF
S’|
’ENT
ITY’
|’E
NTIT
IES’
|’N
MTOK
EN’
|’N
MTOK
ENS’
Enum
erat
edTy
pe::
=No
tati
onTy
pe|
Enum
erat
ion
Enum
erat
ion
::=
’(’
S?Nm
toke
n(S
?’|
’S?
Nmto
ken)
*S?
’)’
Defa
ultD
ecl
::=
’#RE
QUIR
ED’
|’#
IMPL
IED’
|((
’#FI
XED’
S)?
AttV
alue
)
Nor
bert
Fuhr
XML (Extensible Markup Language) 14
Entity Declaration
EntityDecl ::= GEDecl | PEDeclGEDecl ::= ’<!ENTITY’ S Name S
EntityDef S? ’>’PEDecl ::= ’<!ENTITY’ S ’%’ S Name S
PEDef S? ’>’EntityDef ::= EntityValue |
(ExternalID NDataDecl?)PEDef ::= EntityValue | ExternalIDNDataDecl ::= S ’NDATA’ S Name
Example of an internal entity declaration:
<!ENTITY Pub-Status "This is a pre-releaseof the specification.">
Examples of external entity declarations:
<!ENTITY open-hatch SYSTEM"http://www.texty.com/boilerp/OpenHatch.xml"><!ENTITY open-hatch PUBLIC"-//Texty//TEXT Standard open-hatch boilerp//EN""http://www.textuality.com/boilerplate/OpenHatch.xml">
<!ENTITY hatch-picSYSTEM "../grafix/OpenHatch.gif"NDATA gif >
Norbert Fuhr
XML (Extensible Markup Language) 15
Example DTD
<!ELEMENT article (title, abstract, section+)><!ELEMENT title (#PCDATA)><!ELEMENT abstract (#PCDATA)><!ELEMENT section((title, body+) | (title, body*, subsectn+))><!ELEMENT subsectn (title, body+)><!ELEMENT body (figure | paragr)><!ELEMENT figure EMPTY><!ELEMENT paragr (#PCDATA)>
<!ATTLIST article author CDATA #REQUIREDstatus (final | draft) "draft">
<!ATTLIST figure file ENTITY #IMPLIED>
<!ENTITY file SYSTEM "/tmp/picture.ps")NDATA postscript>
<!ENTITY amp "&">
Norbert Fuhr
XML (Extensible Markup Language) 16
Example document
<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE article SYSTEM
"/services/dtds/article.dtd"><article status = draft"
author = "Cluet Christophides"><title>From Structured Documents to ...</title><abstract>Structured Documents (e.g SGML) canbenefit from... </abstract><section><title>Introduction</title><body><paragr>This Paper is organized as follows....</body></section><section><title>SGML preliminaries</title><body><figure/></body></section></article>
Norbert Fuhr
XML (Extensible Markup Language) 17
8.4 XML Schema
types of XML applications:
1. structured documentsDTDs for documents in specific application areas,e.g.
• MathML: mathematics
• CML: chemistry
• SMIL: multimedia documents
2. formatted data(e.g. spreadsheets, document metadata, databases,. . . )
Norbert Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
18
<?xm
lve
rsio
n="1
.0"?
><r
df:R
DFxm
lns:
rdf
="h
ttp:
//ww
w.w3
.org
/199
9/02
/22-
rdf-
synt
ax-n
s#"
xmln
s:vC
ard
="h
ttp:
//ww
w.w3
.org
/200
1/vc
ard-
rdf/
3.0#
"><r
df:D
escr
ipti
onrd
f:ab
out
="h
ttp:
//ls
6-ww
w.cs
.uni
-dor
tmun
d/~f
uhr"
><v
Card
:FN>
Norb
ert
Fuhr
</vC
ard:
FN>
<vCa
rd:N
rdf:
pars
eTyp
e="R
esou
rce"
><v
Card
:Fam
ily>
Fuhr
</vC
ard:
Fami
ly>
<vCa
rd:G
iven
>No
rber
t</
vCar
d:Gi
ven>
</vC
ard:
N><v
Card
:TIT
LE>
Univ
ersi
tyPr
ofes
sor
</vC
ard:
TITL
E><v
Card
:TEL
rdf:
pars
eTyp
e="R
esou
rce"
><r
df:v
alue
>+4
923
175
520
45</
rdf:
valu
e><r
df:t
ype
rdf:
reso
urce
="ht
tp:/
/www
.w3.
org/
2001
/vca
rd-r
df/3
.0#w
ork"
/><r
df:t
ype
rdf:
reso
urce
="ht
tp:/
/www
.w3.
org/
2001
/vca
rd-r
df/3
.0#v
oice
"/>
</vC
ard:
TEL>
</vC
ard:
ADR>
</rd
f:De
scri
ptio
n></
rdf:
RDF>
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
19
XM
LSc
hem
a
missing
feat
ures
ofD
TD
sw
rt.
form
atte
dda
ta:
•su
ppor
tfo
rda
taty
pes
(onl
ych
ildel
emen
ts,P
CD
ATA,m
ixed
cont
ent
and
EMPT
Y)
•sp
ecifi
catio
nof
stru
ctur
edda
ta(e
.g.ar
rays
with
lower
/upp
erbo
unds
)
•re
use
ofda
taty
pes
(exp
licit
supp
ort
for
elem
ents
only,bu
tno
tfo
rat
trib
utes
)
•ex
tens
ible
type
syst
em(u
ser-
defin
edty
pes
/su
btyp
es)
•su
ppor
tfo
rna
mes
pace
s
•su
ppor
tfo
rre
fere
nce
mec
hani
sm(ID
,ID
REF
(S))
supp
orts
loca
lref
eren
ces
only
)
•D
TD
synt
axin
XM
LN
orbe
rtFu
hr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
20
XM
LSc
hem
afe
atur
es
•de
fines
44pr
imiti
veda
taty
pes
•su
ppor
tsth
ede
finiti
onof
aggr
egat
edty
pes
•al
low
sfo
rre
use
ofda
taty
pes
•pr
ovid
esm
echa
nism
for
spec
ifyin
gus
er-d
efine
dty
pes,
(der
ived
from
pred
efine
dty
pes)
•su
ppor
tsna
mes
pace
s
•lo
cal(
(ID
,ID
REF
(S))
and
non-
loca
l(U
RI)
refe
renc
es
•XM
Lsy
ntax
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
21
Cla
ssifi
cation
ofX
SDty
pes
•at
omic
vs.
aggr
egat
ed:
–at
omic
:at
omic
valu
es,c
onte
ntno
tfu
rthe
rin
terp
rete
d
–ag
greg
ated
:lis
ts,u
nion
(ofdi
ffere
ntty
pes)
•pr
imiti
vevs
.de
rived
:
–pr
imiti
ve:
inde
pend
ent
ofot
her
type
s
–de
rived
:su
btyp
eof
othe
rty
pe
•pr
edefi
ned
vs.
user
-defi
ned
–XM
LSc
hem
aPa
rt2
defin
es44
type
s
–us
ers
may
defin
ead
ditio
nalt
ypes
byag
greg
atio
nor
assu
btyp
esof
existin
gty
pes
Nor
bert
Fuhr
XML (Extensible Markup Language) 22
XSD Type System
Norbert Fuhr
XML (Extensible Markup Language) 23
string (any UNICODE string)
normalizedString (UNICODE except CR, LF, TAB)
token (normalizedString without multiple / leading/trailing blanks)
byte -1, 126
unsignedByte 0, 126
base64Binary GpM7
hexBinary 0FB7
integer -126789, -1, 0, 1, 126789
positiveInteger 1, 126789
negativeInteger -126789, -1
nonNegativeInteger 0, 1, 126789
nonPositiveInteger -126789, -1, 0
int -1, 126789675
unsignedInt 0, 1267896754
long -1, 12678967543233
unsignedLong 0, 12678967543233
short -1, 12678
unsignedShort 0, 12678
Norbert Fuhr
XML (Extensible Markup Language) 24
decimal -1.23, 0, 123.4, 1000.00
float -INF, -1E4, -0, 0, 12.78E-2, 12, INF, NaN
double -INF, -1E4, -0, 0, 12.78E-2, 12, INF, NaN
boolean true, false<br> 1, 0
time 13:20:00.000, 13:20:00.000-05:00
dateTime 1999-05-31T13:20:00.000-05:00
duration P1Y2M3DT10H30M12.3S
date 1999-05-31
gMonth –05–
gYear 1999
gYearMonth 1999-02
gDay —31
gMonthDay –05-31
Name shipTo
QName po:USAddress
NCName USAddress
anyURI http://www.example.com/,http://www.example.com/doc.html#ID5
language en-GB, en-US, fr
Norbert Fuhr
XML (Extensible Markup Language) 25
ID
IDREF
IDREFS
ENTITY
ENTITIES
NOTATION
NMTOKEN US, Brésil
NMTOKENS US, UK <br> Brésil CanadaMexique
Norbert Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
26
Exa
mpl
ety
pede
finitio
ns
<xsd
:com
plex
Type
name
="US
Addr
ess"
><x
sd:s
eque
nce>
<xsd
:ele
ment
name
="na
me"
type
="xs
d:st
ring
"/>
<xsd
:ele
ment
name
="st
reet
"ty
pe="
xsd:
stri
ng"/
><x
sd:e
leme
ntna
me="
city
"ty
pe="
xsd:
stri
ng"/
><x
sd:e
leme
ntna
me="
stat
e"ty
pe="
xsd:
stri
ng"/
><x
sd:e
leme
ntna
me="
zip"
type
="xs
d:de
cima
l"/>
</xs
d:se
quen
ce>
<xsd
:att
ribu
tena
me="
coun
try"
type
="xs
d:NM
TOKE
N"fi
xed=
"US"
/></
xsd:
comp
lexT
ype>
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
27
<xsd
:com
plex
Type
name
="Pu
rcha
seOr
derT
ype"
><x
sd:s
eque
nce>
<xsd
:ele
ment
name
="sh
ipTo
"ty
pe="
USAd
dres
s"/>
<xsd
:ele
ment
name
="bi
llTo
"ty
pe="
USAd
dres
s"/>
<xsd
:ele
ment
ref=
"com
ment
"mi
nOcc
urs=
"0"/
><x
sd:e
leme
ntna
me="
item
s"ty
pe="
Item
s"/>
</xs
d:se
quen
ce>
<xsd
:att
ribu
tena
me="
orde
rDat
e"ty
pe="
xsd:
date
"/>
</xs
d:co
mple
xTyp
e>
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
28
Subt
ypin
g
•re
stric
tion
–va
lue
rest
rictio
n(s
trin
gle
ngth
,ran
ge,s
trin
gpa
tter
n)
–ca
rdin
ality
rest
rictio
n(m
in,m
axbo
unds
)of
arra
ys
•ex
tens
ion
(add
ing
elem
ents
toa
type
,lik
ety
peat
trib
utes
inO
OD
Bs)
•re
defin
ition
(red
efine
type
sof
agi
ven
sche
ma
defin
ition
)
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
29
num
eric
rang
ere
stric
tion
:
<xsd
:sim
pleT
ype
name
="my
Inte
ger"
><x
sd:r
estr
icti
onba
se="
xsd:
inte
ger"
><x
sd:m
inIn
clus
ive
valu
e="1
0000
"/>
<xsd
:max
Incl
usiv
eva
lue=
"999
99"/
></
xsd:
rest
rict
ion>
</xs
d:si
mple
Type
>
patt
ern
rest
riction
<xsd
:sim
pleT
ype
name
="SK
U">
<xsd
:res
tric
tion
base
="xs
d:st
ring
"><x
sd:p
atte
rnva
lue=
"\d{
3}-[
A-Z]
{2}"
/></
xsd:
rest
rict
ion>
</xs
d:si
mple
Type
>
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
30
rest
riction
byen
umer
atio
n
<xsd
:sim
pleT
ype
name
="US
Stat
e">
<xsd
:res
tric
tion
base
="xs
d:st
ring
"><x
sd:e
nume
rati
onva
lue=
"AK"
/><x
sd:e
nume
rati
onva
lue=
"AL"
/><x
sd:e
nume
rati
onva
lue=
"AR"
/><!
--an
dso
on..
.--
></
xsd:
rest
rict
ion>
</xs
d:si
mple
Type
>
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
31
List
type
sim
ple
exam
ple
<xsd
:sim
pleT
ype
name
="li
stOf
MyIn
tTyp
e">
<xsd
:lis
tit
emTy
pe="
myIn
tege
r"/>
</xs
d:si
mple
Type
>
<lis
tOfM
yInt
>200
0315
037
9597
795
945<
/lis
tOfM
yInt
>
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
32
list
offix
edle
ngth
<xsd
:sim
pleT
ype
name
="US
Stat
eLis
t">
<xsd
:lis
tit
emTy
pe="
USSt
ate"
/></
xsd:
simp
leTy
pe>
<xsd
:sim
pleT
ype
name
="Si
xUSS
tate
s">
<xsd
:res
tric
tion
base
="US
Stat
eLis
t">
<xsd
:len
gth
valu
e="6
"/>
</xs
d:re
stri
ctio
n></
xsd:
simp
leTy
pe>
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
33
Uni
onty
pe
<xsd
:sim
pleT
ype
name
="zi
pUni
on">
<xsd
:uni
onme
mber
Type
s="U
SSta
teli
stOf
MyIn
tTyp
e"/>
</xs
d:si
mple
Type
>
<xsd
:ele
ment
name
="zi
ps"
type
="zi
pUni
on">
<zip
s>CA
</zi
ps>
<zip
s>95
630
9597
795
945<
/zip
s><z
ips>
AK</
zips
>
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
34
8.5
XPat
hlo
cato
rla
ngua
ge
rest
ricte
dXM
Lqu
ery
lang
uage
retr
ieve
sco
mpl
ete
elem
ents
(sub
tree
s)of
XM
Ldo
cum
ents
used
in
XSL
T(E
xten
sibl
eSt
yle
Shee
tLa
ngua
geTr
ansf
orm
atio
ns)
for
spec
ifyin
gar
gum
ent
ofa
tran
sfor
mat
ion
XPoi
nter
(XM
LPo
inte
r)fo
rde
finin
gso
urce
s/
targ
ets
oflin
ks
XQ
uery
(XM
LQ
uery
Lang
uage
)fo
rse
lect
ing
elem
ents
that
are
argu
men
tsof
furt
her
oper
atio
ns(v
alue
join
s,re
stru
ctur
ing,
aggr
egat
ion)
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
35
Pat
hex
pres
sion
s
•se
arch
for
sing
leel
emen
ts:
head
ing
•pa
rent
-chi
ld:
chap
ter/
head
ing
•an
cest
or-d
esce
ndan
t:ch
apte
r//h
eadi
ng
•do
cum
ent
root
:/b
ook/
*
•fil
ter
wrt
.st
ruct
ure:
//ch
apte
r[he
adin
g]
•fil
ter
wrt
cont
ent:
/doc
umen
t[@c
lass
="H.
3.3"
$and
$au
thor
="Jo
hnSm
ith"
]
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
36
Axe
s
gene
raliz
atio
nof
loca
tor
oper
ator
s
child
::ch
ildre
nof
the
cont
ext
node
desc
enda
nt::
desc
enda
nts
ofth
eco
ntex
tno
de
pare
nt::
pare
ntof
the
cont
ext
node
ance
stor
::an
cest
ors
ofth
eco
ntex
tno
de
follo
win
g-sibl
ing:
:al
lthe
follo
win
gsibl
ings
ofth
eco
ntex
tno
de
prec
edin
g-sibl
ing:
:al
lthe
prec
edin
gsibl
ings
ofth
eco
ntex
tno
de
follo
win
g::
alln
odes
inth
esa
me
docu
men
tas
the
cont
ext
node
that
are
afte
rth
eco
ntex
tno
dein
docu
men
tor
der
prec
edin
g::
alln
odes
inth
esa
me
docu
men
tas
the
cont
ext
node
that
are
befo
reth
eco
ntex
tno
dein
docu
men
tor
der,
attr
ibut
e::
attr
ibut
esof
the
cont
ext
node
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
37
nam
espa
ce::
nam
espa
ceno
des
ofth
eco
ntex
tno
de
self:
:ju
stth
eco
ntex
tno
deits
elf
desc
enda
nt-o
r-se
lf::
cont
ext
node
and
the
desc
enda
nts
ofth
eco
ntex
tno
de
ance
stor
-or-
self:
:co
ntex
tno
dean
dth
ean
cest
ors
ofth
eco
ntex
tno
de
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
38
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
39
XPat
hax
esex
ampl
es
•ch
ild:
:par
apa
rael
emen
tch
ildre
nof
the
cont
ext
node
•ch
ild:
:*el
emen
tch
ildre
nof
the
cont
ext
node
•ch
ild:
:tex
t()
text
node
child
ren
ofth
eco
ntex
tno
de
•ch
ild:
:nod
e()
child
ren
ofth
eco
ntex
tno
de,w
hate
ver
thei
rno
dety
pe
•at
trib
ute:
:nam
ena
me
attr
ibut
eof
the
cont
ext
node
•at
trib
ute:
:*th
eat
trib
utes
ofth
eco
ntex
tno
de
•de
scen
dant
::pa
rapa
rael
emen
tde
scen
dant
sof
the
cont
ext
node
•an
cest
or::
div
div
ance
stor
sof
the
cont
ext
node
•an
cest
or-o
r-se
lf::
div
div
ance
stor
sof
the
cont
ext
node
and,
ifth
eco
ntex
tno
deis
adi
vel
emen
t,th
eco
ntex
tno
deas
wel
l
•de
scen
dant
-or-
self
::pa
rapa
rael
emen
tde
scen
dant
sof
the
cont
ext
node
and,
ifth
eco
ntex
tno
deis
apa
rael
emen
t,th
eco
ntex
tno
deas
wel
lN
orbe
rtFu
hr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
40
•se
lf::
para
cont
extno
deif
itis
apa
rael
emen
t,an
dot
herw
ise
sele
ctsno
thin
g
•ch
ild:
:cha
pter
/des
cend
ant:
:par
apa
rael
emen
tde
scen
dant
sof
the
chap
ter
elem
ent
child
ren
ofth
eco
ntex
tno
de
•ch
ild:
:*/c
hild
::pa
rapa
ragr
andc
hild
ren
ofth
eco
ntex
tno
de
•/
docu
men
tro
ot(w
hich
isal
way
sth
epa
rent
ofth
edo
cum
ent
elem
ent)
•/d
esce
ndan
t::p
ara
para
elem
ents
inth
esa
me
docu
men
tas
the
cont
ext
node
•/d
esce
ndan
t::o
list
/chi
ld::
item
item
elem
ents
that
have
anol
ist
pare
ntan
dth
atar
ein
the
sam
edo
cum
ent
asth
eco
ntex
tno
de
Nor
bert
Fuhr
XML (Extensible Markup Language) 41
8.6 XSLT
transformation of XML documents(e.g. from XML into HTML)
XSLT-Stylesheet =frame + set of transformation rules
<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"xmlns="http://www.w3.org/TR/REC-html40">
<xsl:output method="html"/>
<xsl:template match="...">...</xsl:template>...
</xsl:stylesheet>
Norbert Fuhr
XML (Extensible Markup Language) 42
Some XSLT elements
<xsl:template>specifies a template rulematch attribute identifies source node(s) to which ruleapplies
<xsl:if>test attribute specifies an expression:if true, content template is instantiated
<xsl:choose>selects one among a number of possible alternative childelements <xsl:when> and <xsl:otherwise>
<xsl:when>if expression specified by test attribute is true, contenttemplate is instantiated
<xsl:text>contains literal data to be included in the output
Norbert Fuhr
XML (Extensible Markup Language) 43
A small example
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE brief SYSTEM "brief.dtd">
<brief>
<anrede geschlecht="f" sozial="du">Nora</anrede>
<text>habe gerade den Ulysses beendet. Mal sehen,wann der in den USA gedruckt werden darf...</text>
<gruss>J</gruss>
</brief>
Norbert Fuhr
XML (Extensible Markup Language) 44
Stylesheet
<xsl:template match="/"><html>
<body><xsl:apply-templates/>
</body></html></xsl:template>
<xsl:template match="anrede"><p><xsl:choose>
<xsl:when test="@sozial=’du’"><xsl:text>Liebe</xsl:text><xsl:if test="@geschlecht=’m’">
<xsl:text>r</xsl:text></xsl:if><xsl:text> </xsl:text>
</xsl:when>
<xsl:when test="@sozial=’sie’"><xsl:choose><xsl:when test="@geschlecht=’m’">
<xsl:text>Sehr geehrter Herr </xsl:text></xsl:when>
Norbert Fuhr
XML (Extensible Markup Language) 45
<xsl:when test="@geschlecht=’m’"><xsl:text>Sehr geehrte Frau </xsl:text>
</xsl:when></xsl:choose>
</xsl:when></xsl:choose><xsl:apply-templates/><xsl:text>,</xsl:text>
</p></xsl:template>
<xsl:template match="text | gruss"><p>
<xsl:apply-templates/></p>
</xsl:template>
Norbert Fuhr
XML (Extensible Markup Language) 46
HTML output:
<html><body><p>Liebe Nora,</p><p>habe gerade den Ulysses beendet. Mal sehen,wann der in den USA gedruckt werden darf...</p><p>J</p></body>
</html>
Norbert Fuhr
XML (Extensible Markup Language) 47
Example DTD
<!ENTITY % xhtml SYSTEM "xhtml-1.0-strict.dtd" >%xhtml;
<!ELEMENT project (projecttitle,shortdesc,logo*,fieldofoperation,timeperiod?,contactpersons,involvedpersons?,sponsoredby?,participatinginstitutes?,description,publicationlist?,notes?,doccreator) >
<!ELEMENT projecttitle (langtext+) ><!ATTLIST projecttitle state (work|closed) "closed"><!ATTLIST projecttitle workgroup (ir|issi) #REQUIRED><!ELEMENT shortdesc (langtext+) ><!ELEMENT logo (#PCDATA) > <!-- image file name --><!ATTLIST logo align (left|right) #IMPLIED
width %Length; #IMPLIEDheight %Length; #IMPLIED >
<!ELEMENT referenceno (#PCDATA) ><!ELEMENT fieldofoperation (langtext+) >
Norbert Fuhr
XML (Extensible Markup Language) 48
<!ELEMENT sponsoredby (sponsor+) ><!ELEMENT sponsor (langtext+ | weblink) ><!ELEMENT timeperiod (langtext+ |
(startdate, enddate)) ><!ELEMENT startdate (day, month, year) ><!ELEMENT enddate (day, month, year) ><!ELEMENT day (#PCDATA) ><!ELEMENT month (#PCDATA) ><!ELEMENT year (#PCDATA) ><!ELEMENT contactpersons (personnel+) ><!ELEMENT involvedpersons (personnel+) ><!ELEMENT personnel (langtext+) ><!ELEMENT participatinginstitutes (institute+) ><!ELEMENT institute (langtext+ | weblink) ><!ELEMENT description (langflow+) ><!ELEMENT publicationlist (publication+) ><!ELEMENT publication (langtext+) ><!ELEMENT notes (langflow+) ><!ELEMENT doccreator EMPTY>
<!ELEMENT weblink (url, linkdescription, langtext*)><!ELEMENT url (#PCDATA) ><!ELEMENT linkdescription (langtext+) >
<!ELEMENT langtext %Inline; ><!ELEMENT langflow %Flow; >
Norbert Fuhr
XML (Extensible Markup Language) 49
Example document
<?xml version="1.0" encoding="ISO-8859-1" ?><!DOCTYPE project SYSTEM
"/services/www/xml/dtd/project.dtd"><project>
<projecttitle state="work" workgroup="ir"><langtext>
MIND</langtext>
</projecttitle>
<shortdesc><langtext>
Resource Selection and Data Fusion forMultimedia International Digital Libraries
</langtext></shortdesc>
<logo align="right">mast2_sm.gif</logo><fieldofoperation>
<langtext>Information Retrieval</langtext></fieldofoperation><timeperiod>
<startdate><day>01</day><month>02</month><year>2001</year>
Norbert Fuhr
XML (Extensible Markup Language) 50
</startdate><enddate>
<day>31</day><month>07</month><year>2003</year>
</enddate></timeperiod><contactpersons>
<personnel><langtext><a href="/staff/members/nottelma.html">Dipl.-Inform. Henrik Nottelmann</a></langtext>
</personnel></contactpersons><sponsoredby>
<sponsor><langtext>EU FP5</langtext>
</sponsor></sponsoredby><participatinginstitutes>
<institute><weblink>
<url>http://www.strath.ac.uk/</url><linkdescription>
<langtext>University of Strathclyde
Norbert Fuhr
XML (Extensible Markup Language) 51
</langtext></linkdescription>
</weblink></institute><institute>
<weblink><url>http://ls6-www.informatik.uni-dortmund.de</url>
<linkdescription> <langtext>University of Dortmund
</langtext></linkdescription>
</weblink></institute>
</participatinginstitutes><description>
<langflow><p> This research addresses problems associated
with the emergence of thousands ofheterogeneous multimedia Digital libraries...
</p></langflow>
</description><notes>
<langflow >
Norbert Fuhr
XML (Extensible Markup Language) 52
<ul><li><a href="internal/index.html">
Internal pages</a></li></ul>
</langflow></notes><publicationlist>
<publication><langtext>
<a href="overview/mind-overview.html">MIND Overview slides
</a></langtext>
</publication></publicationlist><doccreator/>
</project>
Norbert Fuhr
XML (Extensible Markup Language) 53
XSL stylesheet for project page
<?xml version="1.0" encoding="ISO-8859-1" ?><xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"xmlns="http://www.w3.org/TR/REC-html40"result-ns=""version="1.0"default-space="strip"indent-result="yes">
<xsl:output method="html" encoding="iso-8859-1"/><xsl:param name="mailto"/><xsl:param name="fullname"/><xsl:param name="date"/><xsl:param name="lang"/><xsl:param name="url"/>
<xsl:include href="ls6common.xsl"/>
<xsl:template match="/"><html>
<head><xsl:apply-templates
select="/project/projecttitle" mode="head"/><meta name="description"><xsl:attribute name="content">University of Dortmund,
Norbert Fuhr
XML (Extensible Markup Language) 54
Department of Computer Science (Chair VI):<xsl:value-ofselect="/project/projecttitle/langtext"/>,
<xsl:value-ofselect="/project/shortdesc/langtext"/>
</xsl:attribute></meta>
</head><body bgcolor="white">
<xsl:apply-templates/></body>
</html></xsl:template>
<xsl:template match="project"><xsl:if test="//projecttitle[@workgroup=’ir’]">
<xsl:call-template name="navbar-top"><xsl:with-param name="upurl">/ir/projects.html.en</xsl:with-param><xsl:with-param name="upname">IR Projects</xsl:with-param>
</xsl:call-template></xsl:if><xsl:if test="//projecttitle[@workgroup=’issi’]">
<xsl:call-template name="navbar-top"><xsl:with-param name="upurl">/issi/projects.html.en</xsl:with-param>
Norbert Fuhr
XML (Extensible Markup Language) 55
<xsl:with-param name="upname">ISSI Projects</xsl:with-param>
</xsl:call-template></xsl:if>
<xsl:apply-templates/></xsl:template>
<xsl:template match="projecttitle" mode="head"><title>
<xsl:apply-templates select="langtext" mode="head"/></title>
</xsl:template>
<xsl:template match="projecttitle"><h1>
<xsl:apply-templates select="langtext"/></h1><xsl:call-template name="hrule"/>
</xsl:template>
<xsl:template match="shortdesc"><em><xsl:apply-templates/></em><br/>
</xsl:template>
<xsl:template match="logo"><img src="{.}">
Norbert Fuhr
XML (Extensible Markup Language) 56
<xsl:if test="@width"><xsl:attribute name="width"><xsl:value-of select="@width"/></xsl:attribute>
</xsl:if><xsl:if test="@height">
<xsl:attribute name="height"><xsl:value-of select="@height"/></xsl:attribute>
</xsl:if><xsl:if test="@align">
<xsl:attribute name="align"><xsl:value-of select="@align"/></xsl:attribute>
</xsl:if></img>
</xsl:template>
<xsl:template match="referenceno"><p> <h3>Reference Number</h3>
<xsl:apply-templates/></p>
</xsl:template>
<xsl:template match="fieldofoperation"><p> <h3>Field of operation</h3>
<xsl:apply-templates/></p>
</xsl:template>
Norbert Fuhr
XML (Extensible Markup Language) 57
<xsl:template match="timeperiod"><p> <h3>Project Duration</h3>
From <xsl:apply-templates select="startdate"/>until <xsl:apply-templates select="enddate"/>
</p></xsl:template>
<xsl:template match="startdate|enddate"><xsl:apply-templates select="day"/>.<xsl:apply-templates select="month"/>.<xsl:apply-templates select="year"/>
</xsl:template>
<xsl:template match="day|month|year"><xsl:apply-templates/>
</xsl:template>
<xsl:template match="contactpersons"><p> <h3>Contact Persons</h3>
<ul><xsl:apply-templates/></ul>
</p></xsl:template>
<xsl:template match="involvedpersons"><p> <h3>Involved Persons</h3>
Norbert Fuhr
XML (Extensible Markup Language) 58
<ul><xsl:apply-templates/></ul>
</p></xsl:template>
<xsl:template match="sponsoredby"><p> <h3>Sponsored by</h3>
<ul><xsl:apply-templates/>
</ul></p>
</xsl:template>
<xsl:template match="publicationlist"><p> <h3>Publications</h3>
<ul><xsl:apply-templates/>
</ul></p>
</xsl:template>
<xsl:template match="publication"><li><xsl:apply-templates/></li>
</xsl:template>
<xsl:template match="sponsor">
Norbert Fuhr
XML (Extensible Markup Language) 59
<li><xsl:apply-templates/></li></xsl:template>
<xsl:template match="participatinginstitutes"><p> <h3>Participating Institutes</h3>
<ul><xsl:apply-templates/></ul>
</p></xsl:template>
<xsl:template match="institute"><li><xsl:apply-templates/></li>
</xsl:template>
<xsl:template match="description"><h3>Description</h3>
<xsl:apply-templates/></xsl:template>
<xsl:template match="notes"><h3>Notes</h3>
<xsl:apply-templates/></xsl:template>
<xsl:template match="linkdescription"><xsl:apply-templates/>
Norbert Fuhr
XML (Extensible Markup Language) 60
</xsl:template>
<xsl:templatematch="a[@href]|A[@HREF]|a[@name]|A[@NAME]|A[@href]">
<xsl:if test="@href"><a href="{@href}"><xsl:apply-templates/></a>
</xsl:if><xsl:if test="@HREF">
<a href="{@HREF}"><xsl:apply-templates/></a></xsl:if><xsl:if test="@name">
<a name="{@name}"><xsl:apply-templates/></a></xsl:if><xsl:if test="@NAME">
<a name="{@NAME}"><xsl:apply-templates/></a></xsl:if>
</xsl:template>
<xsl:template match="personnel"><li><xsl:apply-templates/></li>
</xsl:template>
</xsl:stylesheet>
Norbert Fuhr
XML (Extensible Markup Language) 61
HTML output
<html xmlns="http://www.w3.org/TR/REC-html40"><head><META http-equiv="Content-Type"content="text/html; charset=iso-8859-1">
<title> MIND </title><meta name="description"content="University of Dortmund,Department of Computer Science (Chair VI): MIND,Resource Selection and Data Fusion for MultimediaInternational Digital Libraries ">
</head><body bgcolor="white"><table width="100%"><tr><td width="10%"></td><td width="80%" align="center">
[<a href="/ir/projects.html.en">IR Projects</a>][<a href="/ir/index.html.en">IR</a>][<a href="/issi/index.html.en">IS and Security</a>]</td><td width="10%" align="right"><a href="index.html.de">(deutsch)</a></td>
</tr></table>
<h1> MIND </h1><hr noshade size="2" width="100%"><em>Resource Selection and Data Fusion for
Norbert Fuhr
XML (Extensible Markup Language) 62
Multimedia International Digital Libraries</em><br><img src="mast2_sm.gif" align="right"><p> <h3>Field of operation</h3>Information Retrieval </p>
<p> <h3>Project Duration</h3>From 01. 02. 2001 until 31. 07. 2003</p>
<p> <h3>Contact Persons</h3><ul> <li><a href="/staff/members/nottelma.html">Dipl.-Inform. Henrik Nottelmann</a> </li></ul> </p>
<p><h3>Sponsored by</h3><ul><li>EU FP5</li></ul></p><p> <h3>Participating Institutes</h3><ul><li><a href="http://www.strath.ac.uk/">University of Strathclyde </a> </li><li> <ahref="http://ls6-www.informatik.uni-dortmund.de">
University of Dortmund </a> </li></ul> </p><h3>Description</h3><p xmlns="">This research addresses problems associated withthe emergence of thousands of heterogeneousmultimedia Digital libraries ... </p><h3>Notes</h3><ul xmlns=""><li>
Norbert Fuhr
XML (Extensible Markup Language) 63
<a href="internal/index.html"xmlns="http://www.w3.org/TR/REC-html40">Internal pages</a></li></ul><p>
<h3>Publications</h3><ul><li><a href="overview/mind-overview.html">MIND Overview slides </a>
</li></ul>
</p><hr noshade size="2" width="100%">
<address><a href="mailto:[email protected]">Henrik Nottelmann</a><[email protected]>,20. March 2001</address>
</body></html>
Norbert Fuhr
XML (Extensible Markup Language) 64
8.7 XLink: XML linking language
linking possible in any XML-DTD→ no special linking elements
linking via special attribute (for arbitrary elements):xml:link
terminology:
resource: adressable service or unit of information thatparticipates in a link
link: explicit relationship between two or more resources
locator: data, provided as part of a link, which identifies aresource(attribute HREF)
inline link: link which serves as one of its own resourcese.g. A in HTML
out-of-line link: link whose content does not serve as one ofthe link’s resources
Norbert Fuhr
XML (Extensible Markup Language) 65
Simple links
• one-directional
• mostly inline
<mylink xml:link="simple" title="Citation"href="http://www.xyz.com/xml/foo.xml"show="new" content-role="Reference">as discussed in Smith(1997)</mylink>
<!ELEMENT mylink (#PCDATA)><!ATTLIST mylink
xml:link CDATA #FIXED "simple"href CDATA #REQUIREDcontent-role CDATA #IMPLIED
>
Norbert Fuhr
XML (Extensible Markup Language) 66
Extended linksusually out-of-line links
capabilities:
• enable outgoing links in read-only documents
• create links to and from resouces in other formats
• applying and filtering sets of relevant links on demand
• enable other advanced hypermedia capabilities(e.g. via attribute ROLE)
example out-of-line extended link:
<commentary xml:link="extended" inline="false"><locator href="smith2.1" role="Essay"/><locator href="jones1.4" role="Rebuttal"/><locator href="robin3.2" role="Comparison"/>
</commentary>
Norbert Fuhr
XML (Extensible Markup Language) 67
definitions:
<!ELEMENT extended ANY><!ATTLIST extended
xml:link CDATA #FIXED "extended"%link-semantics.att;%local-resource-semantics.att;
>
<!ELEMENT locator ANY><!ATTLIST locator
xml:link CDATA #FIXED "locator"%locator.att;%remote-resource-semantics.att;
>
Norbert Fuhr
XML (Extensible Markup Language) 68
<!ENTITY % locator.att"href CDATA #REQUIRED"
>
<!ENTITY % link-semantics.att"inline (true|false) ’true’role CDATA #IMPLIED"
>
<!ENTITY % local-resource-semantics.att"content-role CDATA #IMPLIEDcontent-title CDATA #IMPLIED"
>
<!ENTITY % remote-resource-semantics.att"role CDATA #IMPLIEDtitle CDATA #IMPLIEDshow (embed|replace|new) #IMPLIEDactuate (auto|user) #IMPLIEDbehavior CDATA #IMPLIED"
>
Norbert Fuhr
XML (Extensible Markup Language) 69
Link behaviour
SHOW attribute:describes display behaviour on traversal of link
• embed: designated resource embedded in body ofcurrent resource
• replace: designated resource replaces current resource
• new: designated resource displayed in a new window
ACTUATE attribute:when should traversal of link occur?
• auto: retrieve resource when current resource isencountered
• user: present resource only upon request from user
all combinations of SHOW and ACTUATE values are possible!
Norbert Fuhr
XML (Extensible Markup Language) 70
8.8 XPointer: XML Pointer Language
for locators in XLink
• reference to whole document
• reference to named element in document
• reference to unnamed element in read-only document
locator syntax
Locator ::= URI| Connector ( XPointer | Name)| URI Connector (XPointer | Name)
Connector ::= ’#’ | ’|’URI ::= URIchar*
Norbert Fuhr
XML (Extensible Markup Language) 71
XPointer syntax
• location of individual nodes in element tree
• spanning locations across several elements
• arbitrary set of elements
syntax:
XPointer ::= AbsTerm ’.’ OtherTerms| AbsTerm| OtherTerms
OtherTerms ::= OtherTerm| OtherTerm ’.’ OtherTerm
OtherTerm ::= RelTerm| SpanTerm| AttrTerm| StringTerm
Norbert Fuhr
XML (Extensible Markup Language) 72
Absolute location terms
AbsTerm ::= ’root()’ | ’origin()’ | IdLoc | HTMLAddrIdLoc ::= ’id(’ Name ’)’
HTMLAddr ::= ’html(’ SkipLit ’)’
• root: root element of containing resource
• origin: application-dependent
• id: element with named id value
• html(NAMEVALUE): A element in HTML withNAME=NAMEVALUE
Norbert Fuhr
XML (Extensible Markup Language) 73
Relative location terms
RelTerm ::= Keyword? ArgumentsKeyword ::= ’child’
| ’descendant’| ’ancestor’| ’preceding’| ’following’| ’psibling’| ’fsibling’
example:child(2,section).child(1,subsection)
Norbert Fuhr
XML (Extensible Markup Language) 74
relative location term arguments
• selection by instance number
• selection by node type
• selection by attribute
Norbert Fuhr
XML (Extensible Markup Language) 75
Spanning location termdata between two XPointers:
SpanTerm ::= ’span(’ XPointer ’,’ XPointer ’)’
examples:
id(a23).span(child(1),child(3))
span(id(sec2.1).child(-1,P),id(sec2.2).child(1,P))
Attribute location termreturns value of named attribute
String location termstring match
Norbert Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
76
8.9
XM
Lqu
ery
lang
uage
s
fort
hcom
ing
reco
mm
enda
tion:
XQ
uery
basic
stru
ctur
eof
XQ
uery
expr
ession
s:
FOR
Path
Expr
essi
onWH
ERE
Addi
tion
alSe
lect
ionC
rite
rai
RETU
RNRe
sult
Cons
truc
tion
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
77
8.9.
1Pat
hex
pres
sion
s
Synt
ax
Path
Expr
::=
Rela
tive
Path
Expr
|("/
"Re
lati
vePa
thEx
pr?)
|("/
/"Re
lati
vePa
thEx
pr?)
Rela
tive
Path
Expr
::=
Step
Expr
(("
/"|"
//")
Step
Expr
)*St
epEx
pr::
=Ax
isSt
epEx
pr|
Othe
rSte
pExp
rAx
isSt
epEx
pr::
=Ax
isNo
deTe
stSt
epQu
alif
iers
Othe
rSte
pExp
r::
=Pr
imar
yExp
rSt
epQu
alif
iers
Step
Qual
ifie
rs::
=(
("["
Expr
"]")
|("
=>"
Name
Test
))*
Axis
::=
(NCN
ame
"::"
)|
"@"
Prim
aryE
xpr
::=
"."
|"..
"|N
odeT
est
|Var
iabl
e|L
iter
alN
orbe
rtFu
hr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
78
|Fun
ctio
nCal
l|P
aren
thes
ized
Expr
|Cas
tExp
r|E
leme
ntCo
nstr
ucto
rLi
tera
l::
=Nu
meri
cLit
eral
|St
ring
Lite
ral
Node
Test
::=
Name
Test
|Ki
ndTe
stNa
meTe
st::
=QN
ame
|Wi
ldca
rdKi
ndTe
st::
=PI
Test
|Co
mmen
tTes
t|
Text
Test
|An
yKin
dTes
tPI
Test
::=
"pro
cess
ing-
inst
ruct
ion"
"("
Stri
ngLi
tera
l?")
"Co
mmen
tTes
t::
="c
omme
nt"
"("
")"
Text
Test
::=
"tex
t""(
"")
"An
yKin
dTes
t::
="n
ode"
"("
")"
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
79
Pat
hex
pres
sion
s:Exa
mpl
es
Inth
ese
cond
chap
ter
ofth
edo
cum
ent
nam
ed"z
oo.x
ml"
,fin
dth
efig
ure(
s)w
ithca
ptio
n"T
ree
Frog
s".
docu
ment
("zo
o.xm
l")/
/cha
pter
[2]/
/fig
ure[
capt
ion
="T
ree
Frog
s"]
Find
allt
hefig
ures
inch
apte
rs2
thro
ugh
5of
the
docu
men
tna
med
"zoo
.xm
l."
docu
ment
("zo
o.xm
l")/
/cha
pter
[2TO
5]//
figu
re
Find
capt
ions
offig
ures
that
are
refe
renc
edby
<fig
ref>
elem
ents
inth
ech
apte
rof
"zoo
.xm
l"w
ithtit
le"F
rogs
".
docu
ment
("zo
o.xm
l")/
/cha
pter
[tit
le=
"Fro
gs"]
//fi
gref
/@re
fid=
>fig
/cap
tion
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
80
List
the
nam
esof
the
seco
nd-le
vel
man
ager
sof
all
empl
oyee
sw
hose
ratin
gis
"Poo
r".
//em
p[ra
ting
="P
oor"
]/@m
gr=>
emp/
@mgr
=>em
p/na
me
Find
all
capt
ions
offig
ures
and
tabl
esin
the
chap
ter
of"z
oo.x
ml"
with
title
"Mon
keys
".
docu
ment
("zo
o.xm
l")/
/cha
pter
[tit
le=
"Mon
keys
"]//
(fig
ure
|ta
ble)
/cap
tion
From
ado
cum
ent
that
cont
ains
empl
oyee
san
dth
eir
mon
thly
sala
ries,
extr
act
the
annu
alsa
lary
ofth
eem
ploy
eena
med
"Fre
d".
//em
p[na
me="
Fred
"]/s
alar
y*
12
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
81
8.9.
2Ele
men
tco
nstr
ucto
rs
Synt
ax
Elem
entC
onst
ruct
or::
="<
"Na
meSp
ecAt
trib
uteL
ist
("/>
"|
(">"
Elem
entC
onte
nt*
"</"
(QNa
meS?
)?">
"))
Name
Spec
::=
QNam
e|
("{
"Ex
pr"}
")
Attr
ibut
eLis
t::
=(S
(Nam
eSpe
cS?
"="
S?(A
ttri
bute
Valu
e|
Encl
osed
Expr
)At
trib
uteL
ist)
?)?
Attr
ibut
eVal
ue::
=(
["]
Attr
ibut
eVal
ueCo
nten
t*["
])
|(
[’]
Attr
ibut
eVal
ueCo
nten
t*[’
])
Elem
entC
onte
nt::
=Ch
ar|
Elem
entC
onst
ruct
or|
Encl
osed
Expr
|Cd
ataS
ecti
on|
Char
Ref
|Pr
edef
ined
Enti
tyRe
fAt
trib
uteV
alue
Cont
ent
::=
Char
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
82
|Ch
arRe
f|
Encl
osed
Expr
|Pr
edef
ined
Enti
tyRe
fCd
ataS
ecti
on::
="<
![CD
ATA[
"Ch
ar*
"]]>
"En
clos
edEx
pr::
="{
"Ex
prSe
quen
ce"}
"
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
83
Ele
men
tCon
stru
ctor
s:Exa
mpl
es
Gen
erat
ean
<emp
>el
emen
tth
atha
san
"em
pid"
attr
ibut
ean
dne
sted
<nam
e>an
d<j
ob>
elem
ents
.
<emp
empi
d=
"123
45">
<nam
e>Jo
hnSm
ith<
/nam
e><j
ob>A
nthr
opol
ogis
t</j
ob>
</em
p>
Gen
erat
ean
<emp
>el
emen
tth
atha
san
"em
pid"
attr
ibut
e.T
heva
lue
ofth
eat
trib
ute
and
the
cont
ent
ofth
eel
emen
tar
esp
ecifi
edby
varia
bles
that
are
boun
din
othe
rpa
rts
ofth
equ
ery.
<emp
empi
d=
{$id
}>{$
name
}{$
job}
</em
p>N
orbe
rtFu
hr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
84
Var
iabl
e$e
isbo
und
toso
me
elem
ent
with
num
eric
cont
ent.
Con
stru
cta
new
elem
ent
havi
ngth
esa
me
nam
ean
dat
trib
utes
as$e
,an
dw
ithnu
mer
icco
nten
teq
ualt
otw
ice
the
cont
ent
of$e
.
<{na
me($
e)}>
#re
plic
ates
the
name
of$e
{$e/
@*}
#re
plic
ates
the
attr
ibut
esof
$e{2
*nu
mber
($e)
}#
doub
les
the
cont
ent
of$e
</>
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
85
8.9.
3FL
WR
expr
ession
s
Synt
ax
FLWR
Expr
::=
(For
Clau
se|
LetC
laus
e)+
Wher
eCla
use?
"ret
urn"
Expr
ForC
laus
e::
="f
or"
Vari
able
"in"
Expr
(","
Vari
able
"in"
Expr
)*Le
tCla
use
::=
"let
"Va
riab
le":
="Ex
pr("
,"Va
riab
le":
="Ex
pr)*
Wher
eCla
use
::=
"whe
re"
Expr
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
86
Exp
ress
ion
Synt
ax
Addi
tive
Expr
::=
Expr
("+"
|"-
")Ex
prMu
ltip
lica
tive
Expr
::=
Expr
("*"
|"d
iv"
|"m
od")
Expr
Unar
yExp
r::
=("
-"|
"+")
Expr
Equa
lity
Expr
::=
Expr
("="
|"!
="|
"=="
|"!
==")
Expr
Rela
tion
alEx
pr::
=Ex
pr("
<"|
"<="
|">
"|
">="
)Ex
prOr
Expr
::=
Expr
"or"
Expr
AndE
xpr
::=
Expr
"and
"Ex
prPa
rent
hesi
zedE
xpr
::=
"("
Expr
Sequ
ence
?")
"Ex
prSe
quen
ce::
=Ex
pr("
,"Ex
pr)*
Rang
eExp
r::
=Ex
pr"t
o"Ex
prUn
ionE
xpr
::=
Expr
("un
ion"
|"|
")Ex
prIn
ters
ectE
xcep
tExp
r::
=Ex
pr("
inte
rsec
t"|
"exc
ept"
)Ex
prBe
fore
Afte
rExp
r::
=Ex
pr("
befo
re"
|"a
fter
")Ex
pr
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
87
FLW
R:Exa
mpl
es
<boo
k><t
itle
>XM
L:An
Intr
oduc
tion
</ti
tle>
<aut
hor>
Smit
h</
auth
or>
<aut
hor>
Mill
er</
auth
or>
<pub
lish
er>M
orga
nKa
ufma
nn</
publ
ishe
r><y
ear>
1998
</ye
ar>
<pri
ce>5
0</p
rice
></
book
><b
ook>
<tit
le>X
SLT
Cour
se</
titl
e><a
utho
r>Jo
nes<
/aut
hor>
<pub
lish
er>A
ddis
onWe
sley
</pu
blis
her>
<yea
r>20
00</
year
><p
rice
>40<
/pri
ce>
</bo
ok>
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
88
List
the
title
sof
book
spu
blishe
dby
Mor
gan
Kau
fman
nin
1998
.
FOR
$bIN
docu
ment
("bi
b.xm
l")/
/boo
kWH
ERE
$b/p
ubli
sher
="M
orga
nKa
ufma
nn"
AND
$b/y
ear
="1
998"
RETU
RN$b
/tit
le
List
each
publ
ishe
ran
dth
eav
erag
epr
ice
ofits
book
s.
FOR
$pIN
dist
inct
(doc
umen
t("b
ib.x
ml")
//pu
blis
her)
LET
$a:=
avg(
docu
ment
("bi
b.xm
l")/
/boo
k[pu
blis
her
=$p
]/pr
ice)
RETU
RN <pub
lish
er>
<nam
e>{$
p/te
xt()
}</
name
><a
vgpr
ice>
{$a}
</av
gpri
ce>
</pu
blis
her>
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
89
List
the
publ
ishe
rsw
hoha
vepu
blishe
dm
ore
than
100
book
s.
<big
_pub
lish
ers>
{ FOR
$pIN
dist
inct
(doc
umen
t("b
ib.x
ml")
//pu
blis
her)
LET
$b:=
docu
ment
("bi
b.xm
l")/
/boo
k[pu
blis
her
=$p
]WH
ERE
coun
t($b
)>
100
RETU
RN$p
}</
big_
publ
ishe
rs>
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
90
Inve
rtth
est
ruct
ure
ofth
ein
put
docu
men
tso
that
,in
stea
dof
each
book
elem
ent
cont
aini
nga
sequ
ence
ofau
thor
s,ea
chdi
stin
ctau
thor
elem
entco
ntai
nsa
sequ
ence
ofbo
ok-t
itles
.
<aut
hor_
list
>{ FO
R$a
INdi
stin
ct(d
ocum
ent(
"bib
.xml
")//
auth
or)
RETU
RN<a
utho
r><n
ame>
{$a/
text
()}
</na
me>
{ FOR
$bIN
docu
ment
("bi
b.xm
l")/
/boo
k[au
thor
=$a
]RE
TURN
$b/t
itle
}</
auth
or>
}</
auth
or_l
ist>
Nor
bert
Fuhr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
91
Forea
chbo
okw
hose
pric
eis
grea
terth
anth
eav
erag
epr
ice,
retu
rnth
etit
leof
the
book
and
the
amou
ntby
whi
chth
ebo
ok’s
pric
eex
ceed
sth
eav
erag
epr
ice.
<res
ult>
{ LET
$a:=
avg(
docu
ment
("bi
b.xm
l")/
/boo
k/pr
ice)
FOR
$bIN
docu
ment
("bi
b.xm
l")/
/boo
kWH
ERE
$b/p
rice
>$a
RETU
RN <exp
ensi
ve_b
ook>
{$b/
titl
e}<p
rice
_dif
fere
nce>
{$b/
pric
e-
$a}
</pr
ice_
diff
eren
ce>
</ex
pens
ive_
book
>}
</re
sult
>N
orbe
rtFu
hr
XM
L(E
xten
sibl
eM
arku
pLa
ngua
ge)
92
Con
stru
cta
new
elem
ent
havi
ngth
esa
me
nam
eas
the
elem
ent
boun
dto
$e.
Tran
sfor
mal
lthe
attr
ibut
esof
$ein
tosu
bele
men
ts,an
dal
lthe
sube
lem
ents
of$e
into
attr
ibut
es.
<{na
me($
e)}>
{ FOR
$cIN
$e/*
RETU
RNat
trib
ute(
name
($c)
,st
ring
($c)
)} { FO
R$a
IN$e
/@*
RETU
RN <{na
me($
a)}>
{str
ing(
$a)}
</>
}</
>N
orbe
rtFu
hr