XML schema part1 EN

Information about XML schema part1 EN

Published on December 5, 2007

Author: Gavril

Source: authorstream.com

Content

MULTIMEDIA DOCUMENTS XML Schema (Part 1):  MULTIMEDIA DOCUMENTS XML Schema (Part 1) Christine Vanoirbeek EPFL – IC – CGC Bâtiment BC (Station 14) 1015 LAUSANNE [email protected] About DTDs:  About DTDs DTDs aim at defining document classes; they specify The type of authorized elements in a document instance, as well as potential attributes associated to those elements The organization rules of elements 2 constructors (sequence and choice) 3 occurrence indicators (optional element, optional element potentially repeated, mandatory element potentially repeated) DTDs:  DTDs An example <?xml version="1.0" encoding="UTF-8"?> <!ELEMENT recipe (title, comment*, item+, picture?)> <!ATTLIST recipe nbPers CDATA #REQUIRED difficulty (easy | medium | difficult) #IMPLIED > <!ELEMENT item (header?, ((ingredient+, step+) | (ingredient+, step)+))> <!ATTLIST item name ID #IMPLIED > <!ELEMENT ingredient (#PCDATA)> <!ATTLIST ingredient quant CDATA #REQUIRED unit CDATA #IMPLIED name CDATA #IMPLIED > <!ELEMENT step (#PCDATA | link)*> <!ATTLIST step duration CDATA #IMPLIED> <!ELEMENT title (#PCDATA)> <!ELEMENT header (#PCDATA)> <!ELEMENT comment (#PCDATA)> <!ELEMENT picture EMPTY> <!ATTLIST picture source CDATA #REQUIRED format (jpeg | png) #IMPLIED > <!ELEMENT link (#PCDATA)> <!ATTLIST link ref IDREF #IMPLIED> DTDs:  DTDs Some comments Global structure of the recipe 2 structures are proposed for « item »; they take into consideration 2 frequent types of recipes [1] [2] Attributes (role, type, optional or mandatory, assignment of the value) Empty elements Links Why XML schema?:  Why XML schema? From publishing to document processing! Typed elements and attributes number date boolean … Hierarchy of types (similarly to programming languages) Why XML schema?:  Why XML schema? The DTDs only offer very basic possibilities for reusing definition of elements Such as,by example: address, references, etc. An object oriented approach supporting the specialization and extension of elements definition <!ENTITY % base "(deepDish | thinCrust | stuffed)" > <!ENTITY % topping "(sausage | mushroom | pepper | ...)"> <!ELEMENT pizza - - (%base, cheese & tomato, (%topping;)* )> Why XML schema?:  Why XML schema? Using DTDs, 3 occurrence indicators are available ? * + Using XML schema, it is possible to mention explicitely the minimum and maximum number of occurrences Example: specification of a limited number of keywords in a paper Why XML schema?:  Why XML schema? DTDs make use of a specific syntax, it implies two major drawbacks Existing XML-based tools (validation, transformation, etc.) may not be used Namespaces are not supported The XML schema language is based on the XML syntax Objective: to propose a unified paradigm Namespaces:  Namespaces A simple XML schema <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="recipe"> <xs:complexType> <xs:sequence> <xs:element name="title" type="xs:string"/> <xs:element name="comment" type="xs:string" minOccurs="0" maxOccurs="unbounded"/> <xs:element name="item" type="xs:string" maxOccurs="unbounded"/> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> Namespaces:  Namespaces How to deal with several languages inside an XML document? element complexType schema sequence http://www.w3.org/2001/XMLSchema string integer boolean Recipe Title Comment http://www.recipes.org The XML schema vocabulary allows a document class designer to specify its own vocabulary Item Main components of an XML Schema:  Main components of an XML Schema Prologue <?xml version="1.0" encoding="UTF-8"?> Schema root <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> Definition of elements Complex elements (subdivided into sub-elements) Simple elements (potentially typed) Mixed elements (text + tagged elements) Empty elements Element of « any » type Definition of structured elements:  Definition of structured elements The name of an element is specified via the “name” attribute associated to the XML schema “element” The composition rule is specified via the child element “complexType”; it may include 3 constructors sequence choice all The number of occurrences are specified by the attributes “minOccurs” et “maxOccurs” Sequence:  Sequence <xs:element name="recipe"> <xs:complexType> <xs:sequence> <xs:element name="title" type="xs:string"/> <xs:element name="comment" type="xs:string" minOccurs="0" maxOccurs="unbounded"/> <xs:element name="item" maxOccurs="unbounded"/> <xs:element name="picture" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> Choice:  Choice <xs:element name="item" maxOccurs="unbounded"> <xs:complexType> <xs:sequence> <xs:element name="header" type="xs:string" minOccurs="0"/> <xs:choice> <xs:sequence> <xs:element name="ingredient" type="xs:string“ maxOccurs="unbounded"/> <xs:element name="step" type="xs:string" maxOccurs="unbounded"/> </xs:sequence> <xs:choice maxOccurs="unbounded"> <xs:element name="ingredient" type="xs:string"/> <xs:element name="step" type="xs:string"/> </xs:choice> </xs:choice> </xs:sequence> </xs:complexType> </xs:element> All:  All <xs:element name="Description"> <xs:complexType> <xs:all> <xs:element name="country" type="xs:string"/> <xs:element name="originalTitle" type="xs:string"/> <xs:element name="author" type="xs:string"/> </xs:all> </xs:complexType> </xs:element> Definition of the content models:  Definition of the content models Local definition <xs:element name="Description"> <xs:complexType> <xs:all> <xs:element name="country" type="xs:string"/> <xs:element name="originalTitle" type="xs:string"/> <xs:element name="author" type="xs:string"/> </xs:all> </xs:complexType> </xs:element> Definition of the content models:  Definition of the content models Global definition <xs:element name="recipe"> <xs:complexType> <xs:sequence> <xs:element name="title" type="xs:string"/> <xs:element name="comment" type="xs:string" minOccurs="0" maxOccurs="unbounded"/> <xs:element ref="item" maxOccurs="unbounded"/> <xs:element name="picture" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> <xs:element name="item"> <xs:complexType> … </xs:complexType> </xs:element> Definition of the content models:  Definition of the content models Use of an explicit type declaration <xs:complexType name="itemType"> … </xs:complexType> <xs:element name="recipe"> <xs:complexType> <xs:sequence> <xs:element name="title" type="xs:string"/> <xs:element name="comment" type="xs:string" minOccurs="0" maxOccurs="unbounded"/> <xs:element name="item" type="itemType"/> <xs:element name="picture" minOccurs="0"/> </xs:sequence> </xs:complexType> </xs:element> Definition of the content models (summary):  Definition of the content models (summary) Local definitions Global definitions Benefit: definitions are factorized Use of an explicit type declaration Object-oriented mechanisms may be used Important remark: the use of one or another way to define the elements is not reflected in the document instance. Definition of simple types:  Definition of simple types Preliminary remark Lexical space Exemple: float (2.57 , +2.57 , .257E1) Value space Hierarchy of predefined types:  Hierarchy of predefined types Text Numbers Time related types Type derivation:  Type derivation Restriction Limits the value range of the base type; the semantic is not affected List Specify the content type of a simple element as a list of values of one type Union The value may be specified using alternate type candidates Restriction:  Restriction Use of facets <xs:simpleType name =”myInteger”> <xs:restriction base="xs:integer"> <xs:minInclusive value="-2"/> <xs:maxExclusive value="5"/> </xs:restriction> </xs:simpleType> List:  List <xs:simpleType name=”integerListType”> <xs:list itemType=”xs:integer”> </xs:list> </xs:simpleType> <integerList>1 -25000 1000</integerList> Union:  Union <xs:simpleType name=”integerOrDate”> <xs:union memberTypes=”xs:integer xs:date”/> </xs:simpleType> Definition of attributes:  Definition of attributes Example 1 <xs:element name="picture" minOccurs="0"> <xs:complexType> <xs:attribute name="source" type="xs:anyURI"/> </xs:complexType> </xs:element> Definition of attributes:  Definition of attributes Example 2 <xs:element name="recipe"> <xs:complexType> ... <xs:attribute name="difficulty"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="easy"/> <xs:enumeration value="medium"/> <xs:enumeration value="difficult"/> </xs:restriction> </xs:simpleType> </xs:attribute> </xs:complexType> </xs:element> Definition of attributes:  Definition of attributes Occurrences and default value <xs:element name="recipe"> <xs:complexType> ... <xs:attribute name="difficulty“ use =“optional” > <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="easy"/> <xs:enumeration value="medium"/> <xs:enumeration value="difficult"/> </xs:restriction> </xs:simpleType> </xs:attribute> </xs:complexType> </xs:element> Group of attributes:  Group of attributes xs:attributeGroup name="pictureFeatures"> <xs:attribute name="source" type="xs:anyURI" use="required"/> <xs:attribute name="format" use="required"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="jpeg"/> <xs:enumeration value="png"/> <xs:enumeration value="gif"/> </xs:restriction> </xs:simpleType> </xs:attribute> </xs:attributeGroup> <xs:element name="picture" minOccurs="0"> <xs:complexType> <xs:attributeGroup ref="pictureFeatures"/> </xs:complexType> </xs:element> Example of recipe (1):  Example of recipe (1) Example of recipe (2):  Example of recipe (2)

#required presentations

Related presentations


Other presentations created by Gavril

Chapter6
01. 01. 2008
0 views

Chapter6

CVPR2007 tutorial bag of words
22. 11. 2007
0 views

CVPR2007 tutorial bag of words

satcommsspring2005
28. 11. 2007
0 views

satcommsspring2005

25 5
26. 10. 2007
0 views

25 5

ROME PRESENTATION
29. 10. 2007
0 views

ROME PRESENTATION

ISPS Presentation
05. 11. 2007
0 views

ISPS Presentation

Positioning
20. 11. 2007
0 views

Positioning

Presentacion1 rebecca final
23. 11. 2007
0 views

Presentacion1 rebecca final

Meditation
17. 12. 2007
0 views

Meditation

ShipFF Satterfield
07. 11. 2007
0 views

ShipFF Satterfield

hipaa 101 revised ver3 20070627
25. 12. 2007
0 views

hipaa 101 revised ver3 20070627

NLTS2 briefing 06 14
27. 12. 2007
0 views

NLTS2 briefing 06 14

ABC4All JG
29. 12. 2007
0 views

ABC4All JG

WebCT 3 8CE Gradebook v1 0
13. 12. 2007
0 views

WebCT 3 8CE Gradebook v1 0

Parshall ppt
03. 12. 2007
0 views

Parshall ppt

AAIWeb Pred2
07. 01. 2008
0 views

AAIWeb Pred2

nyciboga forum
07. 01. 2008
0 views

nyciboga forum

egee den haag nov04
01. 11. 2007
0 views

egee den haag nov04

Part2am 2 BobTetrault
23. 11. 2007
0 views

Part2am 2 BobTetrault

MeierJet
01. 12. 2007
0 views

MeierJet

450 12 13
21. 11. 2007
0 views

450 12 13

voting2
29. 10. 2007
0 views

voting2

measuring mkt share
20. 02. 2008
0 views

measuring mkt share

18816487826712463302 80601076398
24. 02. 2008
0 views

18816487826712463302 80601076398

Calle Capstone Copyright
27. 02. 2008
0 views

Calle Capstone Copyright

PL Tay
04. 01. 2008
0 views

PL Tay

NCLBREAP 000
28. 11. 2007
0 views

NCLBREAP 000

Lyon Diet Heart Study
05. 03. 2008
0 views

Lyon Diet Heart Study

TourismMar607
14. 03. 2008
0 views

TourismMar607

2004 Media Trek Presentation
28. 09. 2007
0 views

2004 Media Trek Presentation

elettivo2007
04. 12. 2007
0 views

elettivo2007

05Carr
27. 03. 2008
0 views

05Carr

cdc tb intervention rev11 07
30. 03. 2008
0 views

cdc tb intervention rev11 07

Tikoo AntarcticIceSheet
03. 10. 2007
0 views

Tikoo AntarcticIceSheet

EYF
13. 04. 2008
0 views

EYF

noh
26. 11. 2007
0 views

noh

14 Feb 06 Byzantine
31. 10. 2007
0 views

14 Feb 06 Byzantine

dogscancer
16. 11. 2007
0 views

dogscancer

IDSS250805PP
24. 12. 2007
0 views

IDSS250805PP

IBCAST Present
07. 11. 2007
0 views

IBCAST Present

Amy Steph Andrea Juan
14. 12. 2007
0 views

Amy Steph Andrea Juan

Magistarski rad Knezevic
05. 01. 2008
0 views

Magistarski rad Knezevic

dallatorre Workshop RICH2004
14. 11. 2007
0 views

dallatorre Workshop RICH2004

mgct2 boylan
29. 11. 2007
0 views

mgct2 boylan

flare0049
06. 11. 2007
0 views

flare0049

CalDay2
28. 11. 2007
0 views

CalDay2

IV 4 1 Fujimoto Security
05. 11. 2007
0 views

IV 4 1 Fujimoto Security

021705astmtgpres
08. 11. 2007
0 views

021705astmtgpres

Great Lakes
28. 12. 2007
0 views

Great Lakes

BreierGrantwriting Mar2001
18. 12. 2007
0 views

BreierGrantwriting Mar2001

Briet
26. 10. 2007
0 views

Briet

FoodPsychology
11. 12. 2007
0 views

FoodPsychology