XSD: XML Schema Language Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.

Slides:



Advertisements
Similar presentations
XML Schema Heewon Lee. Contents 1. Introduction 2. Concepts 3. Example 4. Conclusion.
Advertisements

1 Web Data Management XML Schema. 2 In this lecture XML Schemas Elements v. Types Regular expressions Expressive power Resources W3C Draft:
XML 6.5 XML Schema (XSD) 6. What is XML Schema? The origin of schema  XML Schema documents are used to define and validate the content and structure.
1 XML DTD & XML Schema Monica Farrow G30
XML Schemas Microsoft XML Schemas W3C XML Schemas.
A Simple Schema Design. First Schema Design Being a Dog Is a Full-Time Job Charles M. Schulz Snoopy Peppermint Patty extroverted beagle Peppermint.
XML Schema Definition Language
2/9/00 EECS 684: Current Topics in Databases1 ( W3C Working Draft 17 December 1999 )
1 Week5 – Schema Why Schema? Schemas vs. DTDs Introduction – W3C vs. Microsoft XDR Schema, How To? Element Types – Simple vs. Complex Attributes Restrictions/Facets.
XML Schemas. “Schemas” is a general term--DTDs are a form of XML schemas –According to the dictionary, a schema is “a structured framework or plan” When.
Sunday, June 28, 2015 Abdelali ZAHI : FALL 2003 : XML Schemas XML Schemas Presented By : Abdelali ZAHI Instructor : Dr H.Haddouti.
XML Schema Describing the structure of XML documents. A very brief introduction 1XML Schema.
Unit 4 – XML Schema XML - Level I Basic.
Introduction to XML This material is based heavily on the tutorial by the same name at
Manohar – Why XML is Required Problem: We want to save the data and retrieve it further or to transfer over the network. This.
Processing of structured documents Spring 2003, Part 3 Helena Ahonen-Myka.
17 Apr 2002 XML Schema Andy Clark. What is it? A grammar definition language – Like DTDs but better Uses XML syntax – Defined by W3C Primary features.
XP New Perspectives on XML Tutorial 4 1 XML Schema Tutorial – Carey ISBN Working with Namespaces and Schemas.
Why XML ? Problems with HTML HTML design - HTML is intended for presentation of information as Web pages. - HTML contains a fixed set of markup tags. This.
XML Schema Vinod Kumar Kayartaya. What is XML Schema?  XML Schema is an XML based alternative to DTD  An XML schema describes the structure of an XML.
1 XML Schemas. 2 Useful Links Schema tutorial links:
Dr. Azeddine Chikh IS446: Internet Software Development.
CSE4500 Information Retrieval Systems XML Schema – Part 1.
XML and friends Part 2 - XML Schema ELAG 2001 workshop 8 Jan Erik Kofoed © BIBSYS Library Automation.
XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.
Li Tak Sing COMPS311F. XML Schemas XML Schema is a more powerful alternative to DTD to describe XML document structures. The XML Schema language is also.
Document Type Definitions Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
Underlying Technologies XML Is the Glue Program the Web XML Browse the Web HTML T C P/IP Connect the Web Technology Innovation ConnectivityPresentation.
XP 1 DECLARING A DTD A DTD can be used to: –Ensure all required elements are present in the document –Prevent undefined elements from being used –Enforce.
What is XML?  XML stands for EXtensible Markup Language  XML is a markup language much like HTML  XML was designed to carry data, not to display data.
1 Dr Alexiei Dingli XML Technologies X-Schema. 2 XML-based alternative to DTD Describes the structure of an XML document Also referred to as XML Schema.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation XML Schema 2 Lecturer.
Processing of structured documents Spring 2002, Part 2 Helena Ahonen-Myka.
Of 33 lecture 3: xml and xml schema. of 33 XML, RDF, RDF Schema overview XML – simple introduction and XML Schema RDF – basics, language RDF Schema –
New Perspectives on XML, 2nd Edition
Waqas Anwar Next SlidePrevious Slide. Waqas Anwar Next SlidePrevious Slide XML XML stands for EXtensible Markup Language.
XML Schema. Why Schema? To define a class of XML documents Serve same purpose as DTD “Instance document" used for XML document conforming to schema.
Schemas 1www.tech.findforinfo.com. What is a Schema a schematic or preliminary plan Description of a structure, details... 2www.tech.findforinfo.com.
Lecture 16 Introduction to XML Boriana Koleva Room: C54
XML – Part III. The Element … This type of element either has the element content or the mixed content (child element and data) The attributes of the.
An Introduction to XML Sandeep Bhattaram
Sheet 1XML Technology in E-Commerce 2001Lecture 2 XML Technology in E-Commerce Lecture 2 Logical and Physical Structure, Validity, DTD, XML Schema.
XSD Presented by Kushan Athukorala. 2 Agenda XML Namespaces XML Schema XSD Indicators XSD Data Types XSD Schema References.
XML 2nd EDITION Tutorial 4 Working With Schemas. XP Schemas A schema is an XML document that defines the content and structure of one or more XML documents.
1 Tutorial 14 Validating Documents with Schemas Exploring the XML Schema Vocabulary.
Tutorial 13 Validating Documents with Schemas
EGEE is a project funded by the European Union under contract IST XML Schema 3 – 4 June
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2.
CS 157B: Database Management Systems II February 18 Class Meeting Department of Computer Science San Jose State University Spring 2013 Instructor: Ron.
QUALITY CONTROL WITH SCHEMAS CSC1310 Fall BASIS CONCEPTS SchemaSchema is a pass-or-fail test for document Schema is a minimum set of requirements.
Introduction to XML Schema John Arnett, MSc Standards Modeller Information and Statistics Division NHSScotland Tel: (x2073)
CSE 6331 © Leonidas Fegaras XML Schema 1 XML Schema Leonidas Fegaras.
XML Schema Definition (XSD). Definition of a Schema It is a model for describing the structure and content of data The XML Schema was developed as a content.
Deriving Complex Types In XML Schema By: Roy Navon.
XML Schema Lecture 3. Indicators There are seven indicators: Order indicators: All Choice Sequence Occurrence indicators: maxOccurs minOccurs Group indicators:
Lecture 0 W3C XML Schema. Topics Status Motivation Simple type vs. complex type.
XML Schema – Simple Type Web site:
XSD 2015, Fall Pusan National University HyungGyu Ryoo 1.
CITA 330 Section 4 XML Schema. XML Schema (XSD) An alternative industry standard for defining XML dialects More expressive than DTD Using XML syntax Promoting.
XML SCHEMA 1 CH 20. Objective 2 What’s wrong with DTDs? What is a schema? The W3C XML Schema Language Hello schemas Complex types Simple types Deriving.
XML Schemas Dr. Awad Khalil Computer Science Department AUC.
Session III Chapter 10 – Defining Simple Types
CMP 051 XML Introduction Session IV
Well-formed and Valid XML Documents
Data Modeling II XML Schema & JAXB Marc Dumontier May 4, 2004
Design and Implementation of Software for the Web
XML Technologies X-Schema.
Quiz Points 2 Rules Raise your hand if you know the question
XML Schema Diyar A. Abdulqder
New Perspectives on XML
Presentation transcript:

XSD: XML Schema Language Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University

168493: XML and Web Services (II/2546) 2 XML Schema & DTD Like a DTD, its purpose is to define the legal building blocks of an XML document defines elements that can appear in a document defines attributes that can appear in a document defines which elements are child elements

168493: XML and Web Services (II/2546) 3 XML Schema & DTD (Cont.) defines the order of child elements defines the number of child elements defines whether an element is empty or can include text defines data types for elements and attributes defines default and fixed values for elements and attributes

168493: XML and Web Services (II/2546) 4 Advantages of XSD over DTD XML Schemas use XML syntax Do not need to learn a new syntax Use any XML parser to parse XML schemas XML Schemas support many data types and allow you to create new data types No ‘Integer’ or ‘Double’ types in DTD

168493: XML and Web Services (II/2546) 5 Adv. of XSD over DTD (Cont.) XML Schemas allow you to group elements to control the recurrence of elements and attributes In DTD, we cannot specify that the number of occurrences of elements must be at least 2 and at most 5 XML Schemas support namespaces

168493: XML and Web Services (II/2546) 6 The Element The element is the root element of every XML Schema:...

168493: XML and Web Services (II/2546) 7 The Element (Cont.)...

168493: XML and Web Services (II/2546) 8 Attributes of xmlns:xs=“ 01/XMLSchema” Indicates that the elements and data types used in the schema (schema, element,…) come from the namespace These elements and data types should be prefixed with xs:

168493: XML and Web Services (II/2546) 9 Attributes of (Cont.) targetNamespace=“ Indicates that the elements defined by this schema (Note, To, From,..) is in the " namespace

168493: XML and Web Services (II/2546) 10 Attributes of (Cont.) xmlns=“ Indicates that the default namespace is elementFormDefault="qualified“ indicates that any elements used by the XML instance document which were declared in this schema must be namespace qualified.

168493: XML and Web Services (II/2546) 11 XSD Simple Elements A simple element Can contain only text Cannot contain any other elements Cannot contain any attributes Can text be any other types besides string? It can be date, etc., or even a custom type that you can define yourself

168493: XML and Web Services (II/2546) 12 Defining a Simple Element The syntax for defining a simple element is: where xxx is the name of the element and yyy is the data type of the element.

168493: XML and Web Services (II/2546) 13 Simple Elements: Example Some XML elements Wasee 34 Corresponding element definitions

168493: XML and Web Services (II/2546) 14 Built-in Data Types xs:string xs:decimal xs:integer xs:boolean xs:date xs:time

168493: XML and Web Services (II/2546) 15 Simple Elements: Default Values Simple elements can have a default value A default value is automatically assigned to the element when no value is specified

168493: XML and Web Services (II/2546) 16 Simple Elements: Fixed Values A fixed value is automatically assigned to elements We cannot specify another value

168493: XML and Web Services (II/2546) 17 XSD Attributes All attributes are declared as simple types Only complex elements can have attributes An element with attributes always has a complex type definition

168493: XML and Web Services (II/2546) 18 Defining an Attribute Syntax: Where xxx is the name of the attribute and yyy is the data type of the attribute Examples: XML: Dee XSD:

168493: XML and Web Services (II/2546) 19 Default & Fixed Values for Attributes Attributes can have a default value or a fixed value specified Examples:

168493: XML and Web Services (II/2546) 20 Optional & Required Attributes All attributes are optional by default To explicitly specify that the attribute is optional or required, use the “use” attribute Examples:

168493: XML and Web Services (II/2546) 21 Restrictions on Content When an XML element or attribute has a type defined, it puts a restriction for the element’s or attribute’s content We can also add our own restrictions to our XML elements and attributes These restrictions are called facets

168493: XML and Web Services (II/2546) 22 XSD Restrictions/Facets Restrictions are used to control acceptable values for XML elements or attributes Many kinds of restrictions/facets Restrictions on values Restrictions on white spaces Restrictions on length

168493: XML and Web Services (II/2546) 23 Restrictions on Values This example defines an element called “age” with a restriction. … What range the value of age is in? Cannot be lower than 0 or greater than 60

168493: XML and Web Services (II/2546) 24 Restriction on a Set of Values To limit the content of an XML element to a set of acceptable values, we would use the enumeration constraint …

168493: XML and Web Services (II/2546) 25 Restrictions on a Series of Values To limit the content to a series of numbers or letters, use the pattern constraint … What are the acceptable values of the “letter” element?

168493: XML and Web Services (II/2546) 26 Restrictions on a Series of Values … What are the acceptable values of the “letter” element?

168493: XML and Web Services (II/2546) 27 Restrictions on a Series of Values … What are the acceptable values of the “password” element?

168493: XML and Web Services (II/2546) 28 Restrictions on White Space Characters To specify how white space characters should be handled, use the whiteSpace constraint … </xs:element The XML processor will not remove any white space characters

168493: XML and Web Services (II/2546) 29 Restrictions on White Space Characters Three values of whiteSpace preserve: the XML processor will not remove any white space characters replace: the XML processor will replace all white space characters with spaces collapse: the XML processor will remove all white space characters (leading and trailing spaces are removed)

168493: XML and Web Services (II/2546) 30 Restrictions on Length … Can we specify the minimum and maximum length of the value? Yes, use “minLength” and “maxLength”

168493: XML and Web Services (II/2546) 31 What is a Complex Element? A complex element is an XML element that contains other elements and/or attributes Four kinds of complex elements Empty elements Elements that contain only other elements Elements that contain only text Elements that contain both other elements and text

168493: XML and Web Services (II/2546) 32 Complex Elements Ex1: Ex2: 1 2 Ex3: Ice cream Ex4: Today is

168493: XML and Web Services (II/2546) 33 Defining a Complex Element …

168493: XML and Web Services (II/2546) 34 Sharing the Element Type <xs:element name=“firstname” …

168493: XML and Web Services (II/2546) 35 Defining Based on Other Types … …

168493: XML and Web Services (II/2546) 36 Types for Empty Elements XML: XSD:

168493: XML and Web Services (II/2546) 37 Elements w/ Only Sub-Elements XML: A B XSD:

168493: XML and Web Services (II/2546) 38 Elements w/ Only Text XML: 8 XSD: …

168493: XML and Web Services (II/2546) 39 Types w/ Mixed Content XML: Today is XSD: …

168493: XML and Web Services (II/2546) 40 Indicators Order indicators: All, choice, sequence Occurrence indicators: maxOccurs, minOccurs Group indicators: Group name attributeGroup name

168493: XML and Web Services (II/2546) 41 All Indicator Specify by default that the child elements can appear in any order and each child element must occur once and only once <xs:element name=“fname” type=“xs:string”/> …

168493: XML and Web Services (II/2546) 42 Choice Indicator Specify that either one child element or another can occur...

168493: XML and Web Services (II/2546) 43 Sequence Indicator Specify that the child elements must appear in a specific order …

168493: XML and Web Services (II/2546) 44 Occurrence Indicator Define how often an element can occur maxOccurs Indicator: maximum number of times an element can occur …

168493: XML and Web Services (II/2546) 45 Occurrence Indicator (Cont.) minOccurs Indicator: minimum number of times an element can occur …

168493: XML and Web Services (II/2546) 46 Group Indicators Define related sets of elements Element Groups are defined with the group declaration, like this: … After defining a group, we can reference it in another complex type definition

168493: XML and Web Services (II/2546) 47 Element Groups … …

168493: XML and Web Services (II/2546) 48 Attribute Groups … …