Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to XML Schema John Arnett, MSc Standards Modeller Information and Statistics Division NHSScotland Tel: 0131 551 8073 (x2073)

Similar presentations


Presentation on theme: "Introduction to XML Schema John Arnett, MSc Standards Modeller Information and Statistics Division NHSScotland Tel: 0131 551 8073 (x2073)"— Presentation transcript:

1 Introduction to XML Schema John Arnett, MSc Standards Modeller Information and Statistics Division NHSScotland Tel: 0131 551 8073 (x2073) mailto:John.Arnett@isd.csa.scot.nhs.uk http://isdscotland.org/xml

2 Contents Introduction Document Type Definitions - reminder W3C Schema –Schema Structures –Built-In Types Summary Find Out More

3 Introduction Schema –a diagram, plan or framework –XML – a document that describes an XML document.

4 Introduction Purpose –Data validation –Contract –System documentation –Processing information

5 Introduction Schema Data Validation –Element and attribute structure –Element ordering –Value constraints Built-in data types Size and pattern constraints Enumerations –Uniqueness constraints

6 Introduction Schema Languages –Document Type Definitions (DTD’s) –W3C XML Schema –OASIS RELAX NG –Schematron

7 Document Type Definitions DTD Benefits –Easy to understand and implement –Lightweight alternative to schemas

8 Document Type Definitions DTD Limitations –Use non-XML syntax –Only limited support for data typing and namespaces –Difficult to extend

9 W3C Schema W3C Recommendation –XML Schema Part 0: Primer Introduction (guidance) –XML Schema Part I: Structures defines schema components –XML Schema Part 2: Datatypes defines built-in datatypes and their restrictions

10 W3C Schema Structures Most commonly used structures: –element s and attribute s –simpleType s –complexType s –model group s –minOccurs and maxOccurs –annotation and documentation –schema and namespaces

11 W3C Schema Structures element and attribute –Basic building blocks of documents

12 W3C Schema Structures element and attribute –valid instances of Record element Arnett John M 1963-06-01 Smith FEMALE 1971-04-11

13 W3C Schema Structures element and attribute –invalid Record element instance Mr Arnett John M 06-Jan-63

14 W3C Schema Structures simpletype Definitions –Define element content –Character data only - no nested (child) elements permitted –No attribute s permitted –Always derived from a built-in types (using restriction)

15 W3C Schema Structures simpletype definition examples

16 W3C Schema Structures complexType Definitions –Define element content –Child elements and character data permitted –attribute s permitted

17 W3C Schema Structures complexType definition examples

18 W3C Schema Structures –sequence elements must occur in the order specified –choice one of several child elements must be selected –all 0 or 1 occurences in any order Model group s

19 W3C Schema Structures Model group examples

20 W3C Schema Structures Model group s –Valid instances of Record element Arnett John M 1963-06-01 Smith Jane F 28

21 W3C Schema Structures minOccurs and maxOccurs –control the occurence of element instances minOccurs=“0” –occurrence is optional maxOccurs=“unbounded” –multiple occurences allowed –may be applied to any child element, sequence or choice

22 W3C Schema Structures minOccurs and maxOccurs examples

23 W3C Schema Structures minOccurs and maxOccurs –Valid instances of Record element Arnett John Gordon M 1963-06-01 Smith Jane 28

24 W3C Schema Structures Namespaces –W3C namespace http//www.w3.org/2001/XMLSchema element, complexType, sequence, etc –targetNamespace Optional User defined One per schema document

25 W3C Schema Structures schema with namespaces.........

26 W3C Schema Structures annotation and documentation The sex of an individual for administrative purposes.

27 W3C Schema Structures annotation and documentation This is used when the sex cannot be determined for physical reasons, e.g. a new born baby

28 Built-in Simple Types 44 built-in simple types - most are atomic Used directly in schemas or used to create user-defined simple types

29 Built-in Simple Types String-based types –string –normalizedString –token

30 Built-in Simple Types Numeric Types –float and double –decimal –integer

31 Built-in Simple Types Date and Time Types –date –time –dateTime –gYear, gMonth, gDay –duration

32 Built-in Simple Types Others –boolean –base64Binary and hexBinary –anyURI

33 Built-in Simple Types Facets –length –minLength –maxLength –minExclusive –minInclusive –maxExclusive –minExclusive –totalDigits –fractionDigits –whiteSpace –pattern –enumeration

34 Built-in Simple Types Length facets This is a valid value This is an invalid value because it contains more than 35 characters

35 Built-in Simple Types enumeration facet NK Male

36 Built-in Simple Types pattern facet

37 Advanced Features Multi-document schemas Complex type derivation Reusable groups Element substitution Schema redefinition Identity constraints Schema design

38 Summary Used to validate structure and values XML instance documents Uses XML syntax W3C Recommendation specifies data structures and built-in types Supports namespaces Has many advanced features, incl. several extensibilty mechanisms

39 Find Out More XML Schema Part 0: Primer –www.w3.org/TR/xmlschema-0/ XML Schema Part 0: Structures –www.w3.org/TR/xmlschema-1/ XML Schema Part 0: Datatypes –www.w3.org/TR/xmlschema-2/


Download ppt "Introduction to XML Schema John Arnett, MSc Standards Modeller Information and Statistics Division NHSScotland Tel: 0131 551 8073 (x2073)"

Similar presentations


Ads by Google