Presentation is loading. Please wait.

Presentation is loading. Please wait.

Similar presentations


Presentation on theme: ""— Presentation transcript:

1 http://aigroup.ceid.upatras.gr/index.php/el/krweb

2 Specify: – the structure of instance documents – the datatype of each element/attribute

3 XML File XML Schema

4 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.books.org" xmlns="http://www.books.org" elementFormDefault="qualified"> All XML Schemas have "schema" as the root element.

5 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.books.org" xmlns="http://www.books.org" elementFormDefault="qualified"> The elements and datatypes that are used to construct schemas - schema - element - complexType - sequence - string come from the http://…/XMLSchema namespace

6 Indicates that the elements defined by this schema - BookStore - Book - Title - Author - Date - ISBN - Publisher are to go in the http://www.books.org namespace <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.books.org" xmlns="http://www.books.org" elementFormDefault="qualified">

7 Bookstore is the default <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.books.org" xmlns="http://www.books.org" elementFormDefault="qualified"> This is referencing a Book element declaration. The Book in what namespace? Since there is no namespace qualifier it is referencing the Book element in the default namespace, which is the targetNamespace! Thus, this is a reference to the Book element declaration in this schema.

8 <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.books.org" xmlns:bk="http://www.books.org" elementFormDefault="qualified"> Here, XMLSchema is the Default

9 There are 3 types - Build-in typee.g. integer,string… - simpleTypeextensions of the build-in types e.g. Telephone, Binary -complexTypeelements with child elements or attributes 21

10 There are 3 types - Build-in typee.g. integer,string - simpleTypeextensions of the build-in types e.g. Telephone, Binary -complexTypeelements with child elements or attributes 21

11 There are 3 types - Build-in typee.g. integer,string - simpleTypeextensions of the build-in types e.g. Telephone, Binary -complexTypeelements with child elements or attributes My Life and Times Paul McCartney 1998 94303-12021-43892

12 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.books.org" xmlns="http://www.books.org" elementFormDefault="qualified"> complexType when: -Element has attribute -Element has child elements Inline, without name - cannot be reused

13 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.books.org" xmlns="http://www.books.org" elementFormDefault="qualified"> Global Global with Name - can be reused

14 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.books.org" xmlns="http://www.books.org" elementFormDefault="qualified"> My Life and Times build-in type

15 Primitive Datatypes – string – boolean – decimal – float – double – duration – dateTime – time – date – gYearMonth – gYear – gMonthDay Atomic, built-in – "Hello World" – {true, false, 1, 0} – 7.08 – 12.56E3, 12, 12560, 0, -0, INF, -INF, NAN – P1Y2M3DT10H30M12.3S – format: CCYY-MM-DDThh:mm:ss – format: hh:mm:ss.sss – format: CCYY-MM-DD – format: CCYY-MM – format: CCYY – format: --MM-DD Note: 'T' is the date/time separator INF = infinity NAN = not-a-number

16 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.books.org" xmlns="http://www.books.org" elementFormDefault="qualified"> These elements refer to elements defined globaly in the schema

17 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.books.org" xmlns="http://www.books.org" elementFormDefault="qualified"> minOccurs, maxOccurs - Default=1 Bookstore can now contain a sequence of books

18 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.books.org" xmlns="http://www.books.org" elementFormDefault="qualified"> AND OR AND OR

19 This simpleType uses EarthSurfaceElevation as its base type.

20 Equivalent Inline without name Global with name

21 … 1 2 … 3 Can be: -Build-in type -simpleType already defined -complexType already defined

22 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.books.org" xmlns="http://www.books.org" elementFormDefault="qualified"> BookPublication is a Publication that also contains ISBN and Publisher elements

23 SingleAuthorPublication is a Publication that can contain only one Author Many Authors Only One Author

24

25 Illusions: The Adventures of a Reluctant Messiah Richard Bach 1977 0-440-34319-4 Dell Publishing Co. Natural Health 1999 The First and Last Freedom J. Krishnamurti 1954 0-06-064831-7 Harper & Row Book and Magazine elements can now be used wherever Publication element is used

26 Attributes apply to the element they are nested within My Life and Times Paul McCartney July, 1998 94303-12021-43892 McMillin Publishing Attributes are defined like elements but can only be of build-in type or simpleType (never complexType)

27

28 required optional prohibited The "use" attribute must be optional if you use default or fixed. xsd:string xsd:integer xsd:boolean... … 1 2 Can be: -Build-in type -SimpleType already defined

29 Ομαδοποίηση elements

30 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.travel.org" xmlns="http://www.travel.org" elementFormDefault="qualified"> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.binary.org" xmlns="http://www.binary.org" elementFormDefault="qualified"> Transportation can contain one(and only one) of the train, plane, automobile elements Binary-string can contain a sequence of zero and one elements

31 <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.books.org" xmlns="http://www.books.org" elementFormDefault="qualified"> means that Book must contain all five child elements, but they may occur in any order.

32 Now in the instance XML file we can add after the Publisher element any element of our choice

33 <BookStore xmlns="http://www.BookRetailers.org" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation= "http://www. BookRetailers.org BookSeller.xsd http://www. repository.org SchemaRepository.xsd"> My Life and Times Paul McCartney 1998 94303-12021-43892 McMillin Publishing Roger Costello Illusions: The Adventures of a Reluctant Messiah Richard Bach 1977 0-440-34319-4 Dell Publishing Co.

34 Now in the instance XML file we can add in a Book element any attribute of our choice

35 NotePad++ http://sourceforge.net/projects/notepad- plus/files/notepad%2B%2B%20releases%20binary/npp%205.5.1%20bin/npp.5.5.1.Installer.e xe/download External Libraries (extract in Notepad++ install folder) http://sourceforge.net/projects/npp- plugins/files/XML%20Tools/External%20libs/ext_libs.zip/download XML Tools plugin (extract in Notepad++/plugins folder) http://sourceforge.net/projects/npp- plugins/files/XML%20Tools/Xml%20Tools%202.3.1%20r764%20Unicode%20Beta1/xmltools_ 2.3.1_r764_unicode_beta1.zip/download


Download ppt ""

Similar presentations


Ads by Google