Presentation is loading. Please wait.

Presentation is loading. Please wait.

XML and friends Part 2 - XML Schema ELAG 2001 workshop 8 Jan Erik Kofoed © BIBSYS Library Automation.

Similar presentations


Presentation on theme: "XML and friends Part 2 - XML Schema ELAG 2001 workshop 8 Jan Erik Kofoed © BIBSYS Library Automation."— Presentation transcript:

1 XML and friends Part 2 - XML Schema ELAG 2001 workshop 8 Jan Erik Kofoed © BIBSYS Library Automation

2 2 Schema XML Schema W3C Recommendation 2 May 2001 Will replace DTD Comprehensive system divided into: –Structures –Data types Three parts: –Primer http://www.w3c.org/TR/xmlschema-0/http://www.w3c.org/TR/xmlschema-0/ –Structures http://www.w3c.org/TR/xmlschema-1/http://www.w3c.org/TR/xmlschema-1/ –Datatypes http://www.w3c.org/TR/xmlschema-2/http://www.w3c.org/TR/xmlschema-2/

3 3 Purchase order example PO (1) Alice Smith 123 Maple Street Mill Valley CA 90952 Robert Smith 8 Oak Avenue Old Town PA 95819 Hurry, my lawn is going wild! Lawnmower 1 148.95 Confirm this is electric Baby Monitor 1 39.98 1999-05-21

4 4 PO (2) – XML-file, part 1 Alice Smith 123 Maple Street Mill Valley CA 90952 Robert Smith 8 Oak Avenue Old Town PA 95819

5 5 PO (3) XML-file, part 2 Hurry, my lawn is going wild! Lawnmower 1 148.95 Confirm this is electric Baby Monitor 1 39.98 1999-05-21

6 6 PO (4) DTD

7 7 Schema structure Schema can be divided into: –Prologue –Element declarations –Type declarations Complex Type) Simple Type) Those may be nested in different manners!

8 8 PO (5) schema, overview...............

9 9 PO (6) schema, part 1 Purchase order schema for Example.com. Copyright 2000 Example.com. All rights reserved.

10 10 PO (7) schema, part 2

11 11 PO (8) schema, part 3

12 12 PO (9) schema, part 4

13 13 PO (10) schema, part 5

14 14 Components of a schema element – declaration of elements attribute – declaration of attributes, must be declared after the elements complexType – allows a content of elements and attributes simpleType – does not allow a content of elements and attributes elements may refer to globally declared elements elements may assign a certain type

15 15 Occurrence of elements and attributes Element –minOccurs –maxOccurs –fixed –default Attribute –use (optional | prohibited | required | default | fixed) –value See, Primer table 1table 1

16 16 Simple Types (1) 45 predefined typespredefined types New types are made as extensions of those Restrictions define the base type ”Facet” used to define constraintsFacet –length, minLength, maxLength –pattern (regular expression)regular expression –enumeration (list of values) –whiteSpace (preserve | replace | collapse) –maxInclusive, maxExclusive, minInclusive, minExclusive –precision, scale –duration, period

17 17 Simple types (2) list –defines a new type as a list of another union –defines a new type as a union of other types

18 18 Documentation in schema annotation, may include –documentation (free text) –appinfo (information to processes)

19 19 Content models (1) Extension of simple types: – Mixed content: – Empty content –Drop declaration of elements in

20 20 Content models (2) Sequence – Choice – All once in arbitrary order – Groups –

21 21 Keys Unique value – Keys –

22 22 Reference to keys Declares that one value shall be equal to another declared as key.: –

23 23 Include other schemas Read another schema: – Read another schema and allow alterations: –... all corrections must come here...

24 24 Namespace Example: <xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema" xmlns="http://example.org/ns/books/" targetNamespace="http://example.org/ns/books/" elementFormDefault="qualified" attributeFormDefault="unqualified”

25 25 Unknown content Unknown content may be declared using any and anyAttribute: http://www.w3.org/1999/xhtml

26 26 Using a Schema in XML Use one of two types of XMLSchema-Instance:


Download ppt "XML and friends Part 2 - XML Schema ELAG 2001 workshop 8 Jan Erik Kofoed © BIBSYS Library Automation."

Similar presentations


Ads by Google