Faculty of Science, Technology and Communication (FSTC) 
Bachelor en informatique (professionnel) 
SSeemmaannttiicc WWeebb...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
Semantic Web Roadmap: 
Controlled growth bottom 
up according to thi...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
3.1. Why iiss HHTTMMLL nnoott SSuuffffiicciieenntt?? 
33..22.. XXMML...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
3.1. Why is HHTTMMLL nnoott SSuuffffiicciieenntt?? 
<h1>Christoph Me...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..22.. XXMMLL -- IInnttrroodduuccttiioonn 
Extensible Markup Langu...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..22.. XXMMLL -- IInnttrroodduuccttiioonn 
Picture created by Hara...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..22.. XXMMLL -- IInnttrroodduuccttiioonn 
Picture created by Hara...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..22.. XXMMLL -- IInnttrroodduuccttiioonn 
Standard Generalized Ma...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..22.. XXMMLL -- IInnttrroodduuccttiioonn 
Welcome to LIASIT 
How ...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..22.. XXMMLL -- IInnttrroodduuccttiioonn 
 
What...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..22.. XXMMLL -- IInnttrroodduuccttiioonn 
<title>...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
How we can help… 
33..22.. XXMMLL -- IInnttrroodduuccttiioonn 
<...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..33.. XXMMLL -- IInnttrroodduuccttiioonn 
<profs> 
<name>Thomas E...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
3.3. XXMMLL –– LLaanngguuaaggee SSppeecciiffiiccaattiioonnss 
<perso...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
3.3. XXMMLL –– LLaanngguuaaggee SSppeecciiffiiccaattiioonnss 
XML st...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
3.3. XXMMLL –– LLaanngguuaaggee SSppeecciiffiiccaattiioonnss 
XML Na...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
3.3. XXMMLL –– LLaanngguuaaggee SSppeecciiffiiccaattiioonnss 
XML de...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
3.4. Document TTyyppee DDeeffiinniittiioonnss ((DDTTDD)) 
<person ty...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
3.4. Document TTyyppee DDeeffiinniittiioonnss ((DDTTDD)) 
<?xml vers...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
3.4. Document TTyyppee DDeeffiinniittiioonnss ((DDTTDD)) 
<?xml vers...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
3.4. Document TTyyppee DDeeffiinniittiioonnss ((DDTTDD)) 
Attribute ...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
3.4. Document TTyyppee DDeeffiinniittiioonnss ((DDTTDD)) 
DTD – ID, ...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
3.4. Document TTyyppee DDeeffiinniittiioonnss ((DDTTDD)) 
Problems a...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..55.. XXMMLL SScchheemmaass 
XML Schema - Overview 
XML Schema is...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..55.. XXMMLL SScchheemmaass 
Atomic types (more than 40!) 
string...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..55.. XXMMLL SScchheemmaass 
More about restrictions 
Restriction...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..55.. XXMMLL SScchheemmaass 
More about restrictions 
Enforcing f...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..55.. XXMMLL SScchheemmaass 
Complex types 
A complex type is an ...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..55.. XXMMLL SScchheemmaass 
Occurrence Constraints 
Set the numb...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..55.. XXMMLL SScchheemmaass 
Derived complex types 
Deriving by e...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..55.. XXMMLL SScchheemmaass 
Attribute declarations 
Attributes c...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..55.. XXMMLL SScchheemmaass 
Conclusion: DTD vs. XML Schemas 
XML...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..66.. NNaammeessppaacceess 
Problem of ambiguous names 
<compactD...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..66.. NNaammeessppaacceess 
Using XML namespaces 
<cd:compactDisk...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..77.. PPrrooggrraammmmiinngg MMooddeellss 
Common XML processing ...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..77.. PPrrooggrraammmmiinngg MMooddeellss 
DOM overview 
The enti...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
DOM tree 
root node 
node 
value node 
continent name 
Asia 
33..77....
API 
Application 
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..77.. PPrrooggrraammmmiinngg MMooddeellss 
DOM ...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..77.. PPrrooggrraammmmiinngg MMooddeellss 
DOM Java API - general...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..77.. PPrrooggrraammmmiinngg MMooddeellss 
DOM Java API – node AP...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..77.. PPrrooggrraammmmiinngg MMooddeellss 
DOM Java API – node AP...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..77.. PPrrooggrraammmmiinngg MMooddeellss 
DOM Java API – node AP...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..77.. PPrrooggrraammmmiinngg MMooddeellss 
DOM Java API – node AP...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
DOM tree 
root node 
node 
value node 
continent name 
Asia 
33..77....
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..77.. PPrrooggrraammmmiinngg MMooddeellss 
Example 
45 
// print ...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..77.. PPrrooggrraammmmiinngg MMooddeellss 
DOM Java API – node AP...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
Picture created by Harald Sack 
Semantic Web ::: Serge Linckels ::: ...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..88.. XXLLiinnkk,, XXPPaatthh aanndd XXPPooiinntteerr 
Overview 
...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..88.. XXLLiinnkk,, XXPPaatthh aanndd XXPPooiinntteerr 
XLink - ge...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..88.. XXLLiinnkk,, XXPPaatthh aanndd XXPPooiinntteerr 
XLink – pa...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..88.. XXLLiinnkk,, XXPPaatthh aanndd XXPPooiinntteerr 
XLink – pa...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..88.. XXLLiinnkk,, XXPPaatthh aanndd XXPPooiinntteerr 
XLink – pa...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..88.. XXLLiinnkk,, XXPPaatthh aanndd XXPPooiinntteerr 
XLink – Ex...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..88.. XXLLiinnkk,, XXPPaatthh aanndd XXPPooiinntteerr 
XPointer a...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..88.. XXLLiinnkk,, XXPPaatthh aanndd XXPPooiinntteerr 
XML Pointe...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..88.. XXLLiinnkk,, XXPPaatthh aanndd XXPPooiinntteerr 
XML Path L...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
Picture created by Harald Sack 
Semantic Web ::: Serge Linckels ::: ...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
3.9. XXSSLL TTrraannssffoorrmmaattiioonnss ((XXSSLLTT)) 
XSLT overvi...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
3.9. XXSSLL TTrraannssffoorrmmaattiioonnss ((XXSSLLTT)) 
XSLT transf...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
3.9. XXSSLL TTrraannssffoorrmmaattiioonnss ((XXSSLLTT)) 
XSLT transf...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
3.9. XXSSLL TTrraannssffoorrmmaattiioonnss ((XXSSLLTT)) 
<data> 
XML...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
3.9. XXSSLL TTrraannssffoorrmmaattiioonnss ((XXSSLLTT)) 
Perform XSL...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
3.9. XXSSLL TTrraannssffoorrmmaattiioonnss ((XXSSLLTT)) 
Perform XSL...
33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 
33..100.. RReeffeerreenncceess 
E-Librarian Service 
User-Friendly S...
Upcoming SlideShare
Loading in …5
×

Semantic Web - XML

938 views

Published on

Published in: Technology, Education
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
938
On SlideShare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
0
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Semantic Web - XML

  1. 1. Faculty of Science, Technology and Communication (FSTC) Bachelor en informatique (professionnel) SSeemmaannttiicc WWeebb Unit 3: XML and its Sub-Languages Trust Proof Rules Logic Data Ontology vocabulary RDF + RDF Schema Data XML + Namespaces + XML Schema •URI •Unicode Digital Signature Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 1
  2. 2. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess Semantic Web Roadmap: Controlled growth bottom up according to this architecture. Architecture was (slightly) modified in the last years. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 2
  3. 3. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 3.1. Why iiss HHTTMMLL nnoott SSuuffffiicciieenntt?? 33..22.. XXMMLL -- IInnttrroodduuccttiioonn 33..33.. XXMMLL –– LLaanngguuaaggee SSppeecciiffiiccaattiioonnss 33..44.. DDooccuummeenntt TTyyppee DDeeffiinniittiioonnss ((DDTTDD)) 33..55.. XXMMLL SScchheemmaass 33..66.. NNaammeessppaacceess 33..77.. PPrrooggrraammmmiinngg MMooddeellss 33..88.. XXLLiinnkk,, XXPPaatthh aanndd XXPPooiinntteerr 33..99.. XXSSLL TTrraannssffoorrmmaattiioonnss ((XXSSLLTT)) 33..1100.. RReeffeerreenncceess Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 3
  4. 4. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 3.1. Why is HHTTMMLL nnoott SSuuffffiicciieenntt?? <h1>Christoph Meinel</h1> <h2>Viola Brehmer</h2> <ul> <li>Long Wang</li> <li>Feng Cheng</li> <li>Dirk Cordel</li> <li>Serge Linckels</li> </ul> Harald Sack Limitations of HTML HTML was initiated to give a structure to a document and to modify its layout; NOT to describe semantics What is this Web page about? What position has "Viola Brehmer"? … Meta-Tags <meta name="description" content="Homepage of Serge Linckels"> <meta name="keywords" content="teacher, athlete"> <meta name="Author" content="The Master of the Universe"> <meta name="xyz" content="nothing special"> Do you believe in Meta-Tags? HTML metadata are created by the author of the Web page. Their syntax and semantics are individual. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 4
  5. 5. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..22.. XXMMLL -- IInnttrroodduuccttiioonn Extensible Markup Language (XML) Markup Language: allows to give a structure to text documents by using tags Meta Language: XML does not have a fixed set of tags (new tags can be created) Extensible: XML can be adapted (extended) to meet many different domains, e.g., • Mathematical Markup Language (MathML) • Chemical Markup Language (CML) • Synchronized Multimedia Integration Language (SMIL) • WAP Markup Language (WML) Creator Jon Bosak, 1996 XML is not… a programming language a network transport protocol a database XML is… a simple data format platform independent does not require special applications Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 5
  6. 6. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..22.. XXMMLL -- IInnttrroodduuccttiioonn Picture created by Harald Sack Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 6
  7. 7. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..22.. XXMMLL -- IInnttrroodduuccttiioonn Picture created by Harald Sack Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 7
  8. 8. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..22.. XXMMLL -- IInnttrroodduuccttiioonn Standard Generalized Markup Language (SGML) The Standard Generalized Markup Language (SGML) is a metalanguage in which one can define markup languages for documents Î Ì HTML XML Î XHTML • Instance of SGML • Layout of data • Layout and data are mixed-up • Subset of SGML • Structure of data • Layout and data are separated Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 8
  9. 9. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..22.. XXMMLL -- IInnttrroodduuccttiioonn Welcome to LIASIT How we can see this… LIASIT stands for Luxembourg Advanced Studies in Information Technology and since August 01, 2006 is a Doctoral School in the Faculty of Science, Technology and Communication. The faculty is composed of the following professors: David BASIN, Pascal BOUVRY, Eric DUBOIS, Thomas ENGEL, Franck LEPREVOST, Christoph MEINEL, Nicolas GUELFI, and Björn OTTERSTEN. The PhD Students are: Christoph BRANDT, Pandu DEVARAKOTA, Daniel FISCHER, Benjamin GATEAU, Markus GROSS, Joel GROTZ, Annie GUERRIERO, Serge LINCKELS, Nicolas MAYER, Michael NOLL, Benoît RIES, Michael STIEGHAHN. Magali MARTIN is the secretary of LIASIT... and also a nice entertainer. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 9
  10. 10. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..22.. XXMMLL -- IInnttrroodduuccttiioonn  What a computer sees…                 Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 10
  11. 11. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..22.. XXMMLL -- IInnttrroodduuccttiioonn <title></title> How we can help… <description>   </description> <profs> <name></name> <name></name> <name></name> </profs> <students> <name></name> <name></name> <name></name> <name></name> </students> <administration> <name> <name> </administration> Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 11
  12. 12. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess How we can help… 33..22.. XXMMLL -- IInnttrroodduuccttiioonn <></> <>   </> <> <></> <></> <></> </> <> <></> <></> <></> <></> </> <> <> </> </> Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 12
  13. 13. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..33.. XXMMLL -- IInnttrroodduuccttiioonn <profs> <name>Thomas Engel</name> <name>Christoph Meinel</name> <name>David Basin</name> <name> Björn Ottersten</name> </profs> <students> <name>Benoît Ries</name> <name>Daniel Fischer</name> <name>Christoph Brandt,</name> <name>Pandu Devarakota</name> <name>Serge Linckels</name> </students> XML file Benefits of XML Document is well-structured Applications can process the file Thomas Engel Christoph Meinel David Basin Björn Ottersten Benoît Ries Daniel Fischer Christoph Brandt Pandu Devarakota Serge Linckels pure text file Problems with text file No structure Difficult to process Attention: although XML adds a certain amount of semantics to the document, there are sill information that are missing, e.g., what is the relation between "profs" and "students"? Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 13
  14. 14. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 3.3. XXMMLL –– LLaanngguuaaggee SSppeecciiffiiccaattiioonnss <person type="Teacher"> attribute <name>Serge Linckels</name> <hp>http://www.linckels.lu</hp> <size>173</size> <phone>691-111111</phone> </person> Terminology element child-element value Tree representation person name hp size phone Serge Linckels http://www.linckels.lu 173 691-111111 General XML is composed of text and tags Tags come in pairs, e.g., <hp></hp> Tags are case sensitive: <hp> ≠ <HP> Tags must be properly nested, e.g., <person><hp></person></hp> <person><hp></hp></person> Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 14
  15. 15. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 3.3. XXMMLL –– LLaanngguuaaggee SSppeecciiffiiccaattiioonnss XML structure <staff> <person type="Teacher"> <name>Serge Linckels</name> <hp>http://www.linckels.lu</hp> <size>173</size> <phone>26 00 11 22</phone> <phone>691-111111</phone> </person> <person type="Teacher"> <name>Denis Zampunieris</name> <phone>4666445290</phone> </person> </staff> Nested tags can be part of a list too. Order is not significant. same element can be used repeatedly Element or attribute? <name> <first>Serge</first> <last>Linckels</last> </name> <name first="Serge" last="Linckels”></name> Both variants are semantically identical or Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 15
  16. 16. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 3.3. XXMMLL –– LLaanngguuaaggee SSppeecciiffiiccaattiioonnss XML Names Can include: - letters (a..z, A..Z) - digits (0..9) - these punctuation chars: - underscore (_) - hyphen (-) - period (.) - special chars like ö, ç, Ω Examples for valid XML Names: <drivers_licence> <_oki-doki> <téléphone> <this.works> CDATA Sections Everything between <![CDATA[ and ]]> is treated as raw character data. <person type="Teacher"> <name>Serge Linckels</name> <![CDATA[This is just some code that is ignored, 10 print "Hello world" 20 goto 10 ]]> <phone>26 00 11 22</phone> </person> Comments Comments are between <!-- and --> like in HTML Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 16
  17. 17. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 3.3. XXMMLL –– LLaanngguuaaggee SSppeecciiffiiccaattiioonnss XML declaration <?xml version="1.0" encoding="ASCII" standalone="yes"?> <person type="Teacher"> <name>Serge Linckels</name> <hp>http://www.linckels.lu</hp> <size>173</size> <phone>691-111111</phone> </person> encoding: XML is pure text, but can use different encoding, e.g., ASCII, Latin-1, Unicode, ISO-8859-1. When omitted then Unicode is default. standalone: - "yes", no external DTD/Schema is given - "no", external DTD/Schema is specified XML-defined character sets Unicode: 95156 characters from most of Earths living languages (variants: UCS-2, UCS-4, UTF-8, UTF-16) ISO character sets: e.g., ISO-8859-15 (Latin 9) is ASCII + accented letters + € Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 17
  18. 18. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 3.4. Document TTyyppee DDeeffiinniittiioonnss ((DDTTDD)) <person type="Teacher"> <name> <first>Serge</first> <last>Linckels</last> </name> <phone>691-111111</phone> </person> <Personne> <Type>Teacher</Type> <Nom>Serge Linckels</Nom> <HP>http://www.linckels.lu</HP> <Sexe>M</Sexe> </Personne> ? Formal syntax is required DTD – Document Type Definitions Syntax of XML document is described Validating parser checks syntax: XML document with DTD syntax A XML document is valid if it respects the syntax defined in its DTD A person-element can contain 1 name sub-element and 0..* phone sub-elements <!ELEMENT person (name, phone*)> <!ELEMENT name (first, last)> <!ELEMENT first (#PCDATA)> <!ELEMENT last (#PCDATA)> <!ELEMENT phone (#PCDATA)> Attention: a document can be well-formed but not valid! Web browser only checks if well-formed. #PCDATA: value of type string Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 18
  19. 19. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 3.4. Document TTyyppee DDeeffiinniittiioonnss ((DDTTDD)) <?xml version="1.0" standalone="no"?> <!DOCTYPE person SYSTEM "http://www.linckels.lu/person.dtd"> <person type="Teacher"> <name> <first>Serge</first> <last>Linckels</last> </name> <phone>691-111111</phone> </person> URI of the DTD-file person.xml <!ELEMENT person (name, phone*)> <!ELEMENT name (first, last)> <!ELEMENT first (#PCDATA)> <!ELEMENT last (#PCDATA)> <!ELEMENT phone (#PCDATA)> person.dtd e.g., "/mydisk/person.dtd" Validating a document A Web browser does not validate documents but only checks it for well-formedness XML validators APIs are available in Java Online validators, e.g., http://www.stg.brown.edu/service/xmlvalid/ http://www.w3.org/2001/03/webdata/xsv Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 19
  20. 20. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 3.4. Document TTyyppee DDeeffiinniittiioonnss ((DDTTDD)) <?xml version="1.0"?> <!DOCTYPE person [ <!ELEMENT person (name, phone*)> <!ELEMENT name (first, last)> <!ELEMENT first (#PCDATA)> <!ELEMENT last (#PCDATA)> <!ELEMENT phone (#PCDATA)> ]> <person type="Teacher"> <name> <first>Serge</first> <last>Linckels</last> </name> <phone>691-111111</phone> </person> Valid XML document with internal DTD Sequences * Zero or more of the element is allowed ? Zero or one of the element is allowed + One or more of the element is required Elements must appear in the specified order Choices <!ELEMENT color (red | green) Here, the element color can have a child-element red or green, not both at a time. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 20
  21. 21. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 3.4. Document TTyyppee DDeeffiinniittiioonnss ((DDTTDD)) Attribute declarations <?xml version="1.0"?> <!DOCTYPE person [ <!ELEMENT person (name, phone*)> <!ATTLIST name first CDATA #IMPLIED last CDATA #REQUIRED > <!ELEMENT phone (#PCDATA)> ]> <person type="Teacher"> <name first="Serge" last="Linckels" /> <phone>691-111111</phone> </person> Attribute defaults: #IMPLIED: value is optional #REQUIRED: value is required #FIXED: value is constant Literal: value is given as quoted string Attribute types: CDATA: any string of text Enumeration: list of values ID: unique XML name IDREF: unique identification of some element in the document Valid XML document with internal DTD IDREFS: set of IDREFs Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 21
  22. 22. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 3.4. Document TTyyppee DDeeffiinniittiioonnss ((DDTTDD)) DTD – ID, IDREF and IDREFS <family> <person id="jane" mother="mary" father="john"> <name>Jane Doe</name> </person> <person id="john" children="jane jack"> <name>John Doe</name> </person> <person id="mary" children="jane jack"> <name>Mary Smith</name> </person> <person id="jack" mother="mary" father="john"> <name>Jack Smith</name> </person> </family> <!DOCTYPE family [ <!ELEMENT family (person*)> <!ELEMENT person (name)> <!ELEMENT name (#PCDATA)> <!ATTLIST person id ID #REQUIRED mother IDREF #IMPLIED father IDREF #IMPLIED children IDREFS #IMPLIED> ]> XML document DTD Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 22
  23. 23. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 3.4. Document TTyyppee DDeeffiinniittiioonnss ((DDTTDD)) Problems and limitations DTD are context-free grammars; recursive definitions are possible Order matters, e.g., <!ELEMENT person (last, first)> Workaround: <!ELEMENT person ((last, first) | (first, last))> Can become unclear: <!ELEMENT person ((name | phone | e-mail)*)> Lacks of expressiveness, e.g., restriction over references are not possible All elements are global in one namespace No support for newer features of XML DTD are expressed in a non-XML syntax XML Schema, more powerful than DTD and W3C recommendation …but there are numerous other XML schema languages, e.g., RELAX NG, ISO DSDL, Schematron… Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 23
  24. 24. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..55.. XXMMLL SScchheemmaass XML Schema - Overview XML Schema is an XML document containing a formal description of what comprises a valid XML document An XML document described by a schema is called an instance document More explicit restrictions on the number and sequence of child elements are possible Example <?xml version="1.0"?> <fullName>Serge Linckels</fullname> XML document <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="fullName" type="xs:string" /> </xs:schema> XML Schema xs: is standard prefix for XML Schema namespace Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 24
  25. 25. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..55.. XXMMLL SScchheemmaass Atomic types (more than 40!) string: Unicode string integer: positive or negative number boolean: true/false or 0/1 ID, IDREF, IDREFS: cf. DTD <xs:element name="first" type="xs:string" /> <xs:element name="age" type="xs:integer" /> <xs:element name="link" type="xs:anyURI" /> <xs:element name="year" type="xs:year" /> Simple types New simple types can be created by using atomic types <xs:simpleType name="aName" base="xs:string" /> Restrictions can be defined <xs:simpleType name="aName"> <xs:resriction base="xs:string> <xs:maxLength value="50" /> </xs:restriction> </xs:simpleType> Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 25
  26. 26. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..55.. XXMMLL SScchheemmaass More about restrictions Restrictions (facets) can be defined over simple types using xs:restriction Enumerations: <xs:simpleType name="location"> <xs:resriction base="xs:string> <xs:enumeration value="work" /> <xs:enumeration value="school" /> <xs:enumeration value="mobile" /> </xs:restriction> </xs:simpleType> Numeric facets: <xs:simpleType name="age"> <xs:resriction base="xs:unsignedShort> <xs:minExclusive value="0" /> <xs:maxInclusive value="120" /> </xs:restriction> </xs:simpleType> possible values: • minInclusive • maxInclusive • minExclusive • maxExclusive Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 26
  27. 27. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..55.. XXMMLL SScchheemmaass More about restrictions Enforcing format: <xs:simpleType name="mobile-phone"> <xs:resriction base="xs:string> <xs:pattern value="ddd-dd dd dd" /> </xs:restriction> </xs:simpleType> Enforces the rule that a mobile phone-number consists of 3 digits, a dash, 2 digits, a space, 2 digits, another space and finally 2 digits. Lists: <xs:simpleType name="TypeAuthor"> <xs:list itemType="xs:string /> </xs:simpleType> XML Schema – simple type definition <xs:element name="author" type="TypeAuthor" /> XML Schema – element definition The author element of an instance document can contain an unlimited list of strings, each separated by a whitespace Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 27
  28. 28. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..55.. XXMMLL SScchheemmaass Complex types A complex type is an element that contains child-elements <?xml version="1.0"?> <person> <first>Serge</first> <last>Linckels</last> </person> XML document Only elements can have complex types, attributes always have simple types <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="person"> <xs:complexType> <xs:sequence> <xs:element name="first" type="xs:string" /> <xs:element name="last" type="xs:string" /> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> XML Schema sequence: order of elements matters (a,b) all: order of elements does not matter (a,b or b,a) choice: one or the other element (a xor b) Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 28
  29. 29. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..55.. XXMMLL SScchheemmaass Occurrence Constraints Set the number of times an element may occur: minOccurs: minimum occurrences maxOccurs: maximum occurrences The default value for minOccurs and maxOccurs is 1 The value unbounded indicates that the element may appear an unlimited number of times. <xs:element name="middle" type="xs:string" minOccurs="0" maxOccurs="unbounded“ /> In this example, maxOccurs is not set, but has a default value of 1. Therefore, the middle element may appear 0 or 1 times. Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 29
  30. 30. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..55.. XXMMLL SScchheemmaass Derived complex types Deriving by extension: add new definitions to existing complex type. E.g., add the phone element to the existing person type. <xs:complexType name="PersonWithPhone"> <xs:extension base="person"> <xs:sequence> <xs:element name="phone" type="xs:string" /> </xs:sequence> </xs:extension> </xs:complexType> Deriving by restriction: by omitting parts of the parent definition, the restriction element create a new, constrained type. <xs:complexType name="PersonWithMoreNames"> <xs:restriction base="person"> <xs:sequence> Only available for complex types <xs:element name="first" type="xs:string" minOccurs="2" /> <xs:element name="last" type="xs:string" /> </xs:sequence> </xs:restriction> </xs:complexType> Structure cannot be changed! Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 30
  31. 31. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..55.. XXMMLL SScchheemmaass Attribute declarations Attributes can be declared globally by top-level xs:attribute <xs:attribute name="job" type="xs:string" use="optional" /> Attributes can be declared locally as part of a complex type definition <xs:element name="person"> <xs:complexType> <xs:sequence> <xs:element name="first" type="xs:string" /> <xs:element name="last" type="xs:string" /> </xs:sequence> <xs:attribute name="job" type="xs:string" /> </xs:complexType> </xs:element> <?xml version="1.0"?> <person job="Teacher"> <first>Serge</first> <last>Linckels</last> </person> possible values: optional or required XML document Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 31
  32. 32. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..55.. XXMMLL SScchheemmaass Conclusion: DTD vs. XML Schemas XML Schemas is a more powerful language than DTD to specify the syntax of XML documents; therefore, it is more expressive in terms of semantics XML Schemas is a W3C recommendation and widely used. As DTD are simpler to use, they are still used today Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 32
  33. 33. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..66.. NNaammeessppaacceess Problem of ambiguous names <compactDisk author="HS"> <titel>Remixes</titel> <track number="1"> <titel>Night over Manaus</titel> <author>Boozoo Bajou</author> </track> </compactDisk> XML names can be used for different elements. But this creates ambiguities. XML namespaces disambiguate elements with the same name from each other by assigning elements and attributes to URIs. Qualified names, prefixes and local parts Elements are identified by qualified names: cd:titel prefix local name qualified name Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 33
  34. 34. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..66.. NNaammeessppaacceess Using XML namespaces <cd:compactDisk xmlns:cd = "http://www.linckels.lu/cd" xmlns:tr = "http://www.xyz.com/tracks" author="HS"> <cd:titel>Remixes</cd:titel> <tr:track number="1"> <tr:titel>Night over Manaus</tr:titel> <tr:author>Boozoo Bajou</tr:author> </tr:track> </cd:compactDisk> Each element exists in a unique namespace Namespace URIs are purely formal identifiers; they are not the addresses of a page, and they are not meant to be followed as links Namespaces only apply to elements, not to attributes Namespace binding: each prefix in a qualified name must be associated with a URI Instead of using a prefix, the complete URI can be indicated, e.g., <tr:title>Remixes</tr:title> <http://www.xyz.com/tracks#title> Remixes </http://www.xyz.com/tracks#title> Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 34
  35. 35. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..77.. PPrrooggrraammmmiinngg MMooddeellss Common XML processing models Treating XML as text Treating XML as events; the document is read as it happens (e.g., an "event" can be the start of an element, the content of an element, and the end of an element) Treating XML as tree models XML transformations Abstracting XML always; do not consider the XML elements Most commonly used Document Object Model (DOM) Simple API for XML (SAX) Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 35
  36. 36. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..77.. PPrrooggrraammmmiinngg MMooddeellss DOM overview The entire document must be read and parsed before it is available as DOM; unsuitable for very large documents User accesses data by traversing the tree (tree and its traversal conform to a W3C standard) The API allows for constructing, accessing and manipulating the structure and content of XML documents Example: <countries> <country continent="Asia"> <name>Israel</name> <population year="2001">6199008</population> <city capital="yes"><name>Jerusalem</name></city> <city><name>Ashdod</name></city> </country> <country continent="Europe"> <name>France</name> <population year="2004">60424213</population> </country> </countries> Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 36
  37. 37. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess DOM tree root node node value node continent name Asia 33..77.. PPrrooggrraammmmiinngg MMooddeellss population year 2001 population 60424213 document countries country Israel capital 6199008 city name yes Jerusalem city capital country name name no Ashod continent year Europe France 2004 Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 37
  38. 38. API Application 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..77.. PPrrooggrraammmmiinngg MMooddeellss DOM Java API - general XML document DOM parser DOM tree (in memory) DOM tree is generated by a DocumentBuilder The builder is generated by a Factory to be implementation independent. The factory is chosen according the system configuration DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document myXMLdoc = builder.parse("world.xml"); Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 38
  39. 39. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..77.. PPrrooggrraammmmiinngg MMooddeellss DOM Java API - general import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; import org.w3c.dom.Element; Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 39
  40. 40. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..77.. PPrrooggrraammmmiinngg MMooddeellss DOM Java API – node API The nodes of the DOM tree include - a special root (denoted document) - element nodes - text nodes and CDATA sections - attributes - comments - and more ... Examples: //create the root element Element root = myXMLdoc.createElement("root"); //add it to the xml tree myXMLdoc.appendChild(root); myXMLdoc root The value of Attribute 1 Child //create child element Element childElement = myXMLdoc.createElement("Child"); //add the attribute to the child childElement.setAttribute("attribute1","The value of Attribute 1"); //add child element to the root element root.appendChild(childElement); attribute1 Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 40
  41. 41. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..77.. PPrrooggrraammmmiinngg MMooddeellss DOM Java API – node API Every node in the DOM tree implements the Node interface DocumentFragment Document Element Attribute CDATA DocumentType Notation Entity EntityReference ProcessInstruction Node Text Comment CDATA Section Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 41
  42. 42. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..77.. PPrrooggrraammmmiinngg MMooddeellss DOM Java API – node API Every node has a specific location in tree Node interface specifies methods for tree navigation • Node getFirstChild(); • Node getLastChild(); • Node getNextSibling(); • Node getPreviousSibling(); • Node getParentNode(); • NodeList getChildNodes(); • NamedNodeMap getAttributes(); getParentNode() getPreviousSibling() getNextSibling() getFirstChild() getChildNodes() getLastChild() Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 42
  43. 43. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..77.. PPrrooggrraammmmiinngg MMooddeellss DOM Java API – node API Every node has : • a type • a name • a value • attributes The roles of these properties differ according to the node types Node-types: ELEMENT_NODE = 1 ATTRIBUTE_NODE = 2 TEXT_NODE = 3 CDATA_SECTION_NODE = 4 ENTITY_REFERENCE_NODE = 5 ENTITY_NODE = 6 PROCESSING_INSTRUCTION_NODE = 7 COMMENT_NODE = 8 DOCUMENT_NODE = 9 DOCUMENT_TYPE_NODE = 10 DOCUMENT_FRAGMENT_NODE = 11 NOTATION_NODE = 12 if (myNode.getNodeType() == Node.ELEMENT_NODE) { //process node … } Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 43
  44. 44. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess DOM tree root node node value node continent name Asia 33..77.. PPrrooggrraammmmiinngg MMooddeellss population year 2001 population 60424213 document countries country Israel capital 6199008 city name yes Jerusalem city capital country name name no Ashod continent year Europe France 2004 Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 44
  45. 45. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..77.. PPrrooggrraammmmiinngg MMooddeellss Example 45 // print one given city (city is given as element) public static void printCity(Element city) { Node nameNode = city.getElementsByTagName("name").item(0); String cName = nameNode.getFirstChild().getNodeValue(); System.out.println("Found City: " + cName); } // prints all cities found in the DOM tree public static void printCities(Document myXMLdoc) { NodeList cities = myXMLdoc.getElementsByTagName("city"); for(int i = 0; i < cities.getLength(); ++i) { printCity((Element)cities.item(i)); } } Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 45
  46. 46. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..77.. PPrrooggrraammmmiinngg MMooddeellss DOM Java API – node API Children of a node in a DOM tree can be manipulated; added, edited, deleted, copied etc. To construct new nodes, use the methods of Document: createElement, createAttribute, createTextNode, createCDATASection etc. To manipulate a node, use the methods of Node: appendChild, insertBefore, removeChild, replaceChild, setNodeValue, cloneNode(boolean deep) etc. insertBefore() new replaceChild() new cloneNode(false) new cloneNode(true) new Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 46
  47. 47. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess Picture created by Harald Sack Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 47
  48. 48. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..88.. XXLLiinnkk,, XXPPaatthh aanndd XXPPooiinntteerr Overview XML Linking Language (XLink) is a XML markup language used for creating hyperlinks in XML documents, e.g., HTML <a>-tag XPointer is a system for addressing components of XML based internet media XML Path Language (XPath) is a language for selecting nodes from an XML document <a href="…"> <a name="…"> Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 48
  49. 49. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..88.. XXLLiinnkk,, XXPPaatthh aanndd XXPPooiinntteerr XLink - general Allows to create unidirectional links between exactly 2 resources Origin of the link is always the starting document (where the link is nested) Browsers are free to interpret this link as they like (depends on used CSS) Example as an implementation as HTML hyperlink, but can be more… <a href="…"> Starting document Destination document Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 49
  50. 50. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..88.. XXLLiinnkk,, XXPPaatthh aanndd XXPPooiinntteerr XLink – parameters 1/3 xlink: specifies that this is an XLink definition title: (optional) textual information about the link (display in a browser as hint) href: URI of linked destination resource (must not necessarily be a URL) role: (optional) points to a resource that specifies the meaning of the connection between the resources, e.g., a Web page that gives further information <publications xmlns:xlink="http//www.w3.org/1999/xlink" xlink:title="My publications" xlink:href="http://www.linckels.lu/publications.txt" xlink:role="http://www.dblp.de" xlink:show="new" xlink:actuate="onRequest" xlink:type="simple" /> Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 50
  51. 51. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..88.. XXLLiinnkk,, XXPPaatthh aanndd XXPPooiinntteerr XLink – parameters 2/3 show: (optional) context in which the linked resource is to display - new: new window - replace: current window - embed: embed in current document - other: customized - none: no behavior actuate: (optional) specifies when an application that encounters an XLink should follow it - onLoad: as soon as the application sees it - onRequest: when the user asks to follow it - other: customized - none: no behavior (e.g., if the link is an ISBN number of a "physical book") <publications xmlns:xlink="http//www.w3.org/1999/xlink" xlink:title="My publications" xlink:href="http://www.linckels.lu/publications.txt" xlink:role="http://www.dblp.de/" xlink:show="new" xlink:actuate="onRequest" xlink:type="simple" /> Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 51
  52. 52. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..88.. XXLLiinnkk,, XXPPaatthh aanndd XXPPooiinntteerr XLink – parameters 3/3 type: specifies the type of the link - simple: one standard link between two resources (i.e., HTML hyperlinks) - extended: more links between a collection of resources (≈ directed graph) 1..n relation E.g., a book is published in three particular editions sequences E.g., a book has two preceding versions Link basis n..m relation Starting documents Destination documents E.g., pizza is composed of different ingredients and can result in different compositions Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 52
  53. 53. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..88.. XXLLiinnkk,, XXPPaatthh aanndd XXPPooiinntteerr XLink – Extended type example <xlink:extended xmlns:xlink="http//www.w3.org/1999/xlink/" link:role="http://www.pizza.de/pizzaworld" xlink:title="Pizza Tonno"> <xlink:locator href="Pizzaboden.xml" role="http://www.pizza.de/base" title="Pizzaboden"/> <xlink:locator href="Basilikum.xml" role="http://www.pizza.de/base" title="Basilikum"/> <xlink:arc from="http://www.pizza.de/base" to="http://www.pizza.de/special" show="new" actuate="onRequest"/> </xlink:extended> Specifies the resources involved Pizzaboden Basilikum Pizza Tonno base special Specifies how the resources relate to each other Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 53
  54. 54. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..88.. XXLLiinnkk,, XXPPaatthh aanndd XXPPooiinntteerr XPointer and XPath - general Fix an anchor inside a document, e.g., HTML: <a name="…"> Problems with HTML-anchors: • not possible inside remote documents (no permission to modify the source code) • the complete destination document must be transmitted, even if only one sub-part of the document is addressed Principle solution: • represent documents as trees • address sub-tree only (navigation through tree) Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 54
  55. 55. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..88.. XXLLiinnkk,, XXPPaatthh aanndd XXPPooiinntteerr XML Pointer Language (XPointer) General definition of an XML Pointer: URI#xpointer(anchor description) Example : <gedicht> <strophe ID="strophe1"> <zeile ID="zeile1">Dreifach ist des Raumes Maß:</zeile> <zeile ID="zeile2">Rastlos fort ohne Unterlaß</zeile> <zeile ID="zeile3">Strebt die Länge fort ins Weite,</zeile> <zeile ID="zeile4">Endlos gießet sich die Breite,</zeile> <zeile ID="zeile5">Grundlos senkt die Tiefe sich</zeile> </strophe> </gedicht> XML document http://www.bsp.de/gedicht.xml#xpointer(ID('zeile2')) http://www.bsp.de/gedicht.xml#xpointer(//zeile[@ID="zeile2"]) http://www.bsp.de/gedicht.xml#element(/1/1/2) XPointers Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 55
  56. 56. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..88.. XXLLiinnkk,, XXPPaatthh aanndd XXPPooiinntteerr XML Path Language (XPath) XPath is a non-XML language for identifying particular parts of XML documents, i.e., for picking out nodes an sets of nodes out of a tree Example : Addressed-node Context-node child descendant following following sibling parent ancestor preceding preceding sibling gedicht.xml#xpointer(/child::gedicht[position()=3]) axis context-node predicate Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 56
  57. 57. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess Picture created by Harald Sack Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 57
  58. 58. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 3.9. XXSSLL TTrraannssffoorrmmaattiioonnss ((XXSSLLTT)) XSLT overview Extensible Stylesheet Language Transformations (XSLT) is an XML-based language used to specify rules by which one XML document is transformed into another (XML) document The resulting document may be XML syntax or another format, such as HTML or plain text Examples of applications of XSLT: - convert data between different XML schemas - convert XML data into HTML or XHTML documents for web pages (e.g., with CSS) - creating a dynamic web page - convert into an intermediate XML format that can be converted to PDF documents Such a transformation is based on the following languages: - XSLT: specifies the transformation rules - XSL-FO: describes how to transform layout - XPath: access to specific parts of an XML document Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 58
  59. 59. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 3.9. XXSSLL TTrraannssffoorrmmaattiioonnss ((XXSSLLTT)) XSLT transformation principle (example) XML documents DTD/XML-S XSL document 1 XSL document 2 PDF document HTML WML XSLT processor Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 59
  60. 60. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 3.9. XXSSLL TTrraannssffoorrmmaattiioonnss ((XXSSLLTT)) XSLT transformation principle (example) XSL works on the abstract tree representation of the XML document A set of transformation rules are required in form a an XSLT document, e.g., template (XSL stylesheet) The structure tree is browsed and for each node the appropriate template from the XSL stylesheet is applied XSL stylesheet tree representation of XML document output document + Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 60
  61. 61. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 3.9. XXSSLL TTrraannssffoorrmmaattiioonnss ((XXSSLLTT)) <data> XML document <row num="1">toto 1</row> <row num="2">toto 2</row> <row num="3">toto 3</row> </data> <?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/ Transform"> <xsl:template match="/data"> <html><body> <h1>Demo</h1> <xsl:for-each select="row"> <br/>Row: <xsl:value-of select="@num"/> - Data: <xsl:value-of select="."/> </xsl:for-each> </body></html> </xsl:template> </xsl:stylesheet> XSL stylesheet XSLT processor <html><body> <h1>Demo</h1> <br/>Row: 1 - Data: toto 1 <br/>Row: 2 - Data: toto 2 <br/>Row: 3 - Data: toto 3 </body></html> HTML document Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 61
  62. 62. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 3.9. XXSSLL TTrraannssffoorrmmaattiioonnss ((XXSSLLTT)) Perform XSL transformation using a Java programme import java.io.FileReader; import javax.xml.transform.Result; import javax.xml.transform.Source; import javax.xml.transform.Transformer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; public class TestTransformation { public static void main(String[] args) throws Exception { Source sourceXSL = new StreamSource(new FileReader("stylesheet.xsl")); Source sourceXML = new StreamSource(new FileReader("data.xml")); TransformerFactory trFac = TransformerFactory.newInstance(); Transformer tf; Result resultOnScreen = new StreamResult(System.out); tf = trFac.newTransformer(sourceXSL); tf.transform(sourceXML, resultOnScreen); } } Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 62
  63. 63. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 3.9. XXSSLL TTrraannssffoorrmmaattiioonnss ((XXSSLLTT)) Perform XSL transformation using a stylesheet <?xml version="1.0" encoding="ISO-8859-1"?> <?xml-stylesheet type="text/xsl" href="stylesheet.xsl" ?> <person type="Teacher"> <name>Serge Linckels</name> <hp>http://www.linckels.lu</hp> <size>173</size> <phone>691-111111</phone> </person> Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 63
  64. 64. 33.. XXMMLL aanndd iittss SSuubb--LLaanngguuaaggeess 33..100.. RReeffeerreenncceess E-Librarian Service User-Friendly Semantic Search in Digital Libraries Serge Linckels, Christoph Meinel XML in a Nutshell Elliotte R. Harold, W. Scott Means, W. Scott Means Semantic Web ::: Serge Linckels ::: www.linckels.lu ::: serge@linckels.lu ::: 64

×