Presentation is loading. Please wait.

Presentation is loading. Please wait.

ΑΝΑΠΑΡΑΣΤΑΣΗ ΓΝΩΣΗΣ ΣΤΟΝ ΠΑΓΚΟΣΜΙΟ ΙΣΤΟ XML Schema

Similar presentations


Presentation on theme: "ΑΝΑΠΑΡΑΣΤΑΣΗ ΓΝΩΣΗΣ ΣΤΟΝ ΠΑΓΚΟΣΜΙΟ ΙΣΤΟ XML Schema"— Presentation transcript:

1 ΑΝΑΠΑΡΑΣΤΑΣΗ ΓΝΩΣΗΣ ΣΤΟΝ ΠΑΓΚΟΣΜΙΟ ΙΣΤΟ XML Schema 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"> My Life and Times build-in type

13 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

14 <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

15 This simpleType uses EarthSurfaceElevation as its base type.

16 Equivalent Inline without name Global with name

17 <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

18 <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

19 <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

20 <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

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 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

28 <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

29 <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.

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

31 <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.

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

33 ExpressionDescription nodenameSelects all nodes with the name "nodename" /Selects from the root node //Selects nodes in the document from the current node that match the selection no matter where they are.Selects the current node..Selects the parent of the current node @Selects attributes

34 XML file in editor XML file in Browser

35 XSL file Xpath

36 XML file XML file in browser

37 ...some output if the expression is true... http://www.w3schools.com/xsl/

38 NotePad++ http://notepad-plus-plus.org/ Plugins-> Plugin Manager -> Show Plugin Manager Update Plugin Manager if update available Find, select and install XML Tools Plugin Plugins - >XML Tools -> Validate Now Plugins - >XML Tools -> Evaluate Xpath Expression


Download ppt "ΑΝΑΠΑΡΑΣΤΑΣΗ ΓΝΩΣΗΣ ΣΤΟΝ ΠΑΓΚΟΣΜΙΟ ΙΣΤΟ XML Schema"

Similar presentations


Ads by Google