XML Schema Diyar A. Abdulqder

Slides:



Advertisements
Similar presentations
1 Web Data Management XML Schema. 2 In this lecture XML Schemas Elements v. Types Regular expressions Expressive power Resources W3C Draft:
Advertisements

1 XML DTD & XML Schema Monica Farrow G30
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
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.
Enabling Grids for E-sciencE ISSGC’05 XML Schemas (XSD) Richard Hopkins, National e-Science Centre, Edinburgh June 2005.
Sunday, June 28, 2015 Abdelali ZAHI : FALL 2003 : XML Schemas XML Schemas Presented By : Abdelali ZAHI Instructor : Dr H.Haddouti.
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.
VICTORIA UNIVERSITY OF WELLINGTON Te Whare Wananga o te Upoko o te Ika a Maui SWEN 432 Advanced Database Design and Implementation XML Schema 1 Lecturer.
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:
CSE4500 Information Retrieval Systems XML Schema – Part 1.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Schemas Ellen Pearlman Eileen Mullin Programming the Web Using XML.
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.
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.
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.
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 –
Beginning XML 4th Edition. Chapter 5: XML Schemas.
New Perspectives on XML, 2nd Edition
 XML DTD and XML Schema Discussion Sessions 1A and 1B Session 2.
Web 310 XML Schema : What You Need to Know and Why Yasser Shohoud Program Manager XML Messaging Microsoft Corporation.
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.
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
XML Schema. Why Validate XML? XML documents can generally have any structure XML grammars define specific document structures Validation is the act of.
EGEE is a project funded by the European Union under contract IST XML Schema 3 – 4 June
XML Schema (W3C) Thanks to Jussi Pohjolainen TAMK University of Applied Sciences.
XSD: XML Schema Language Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
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:
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.
4 Copyright © 2004, Oracle. All rights reserved. Validating XML by Using XML Schema.
Creating Groups of Elements and Attributes in an XML Schema ©NIITeXtensible Markup Language/Lesson 4/Slide 1 of 28 Objectives In this lesson, you will.
XML Schemas Dr. Awad Khalil Computer Science Department AUC.
XML Schema.
ACG 4401 XML Schemas XML Namespaces XLink.
XML.
ACG 4401 XML Schemas XML Namespaces XLink.
CMP 051 XML Introduction Session IV
Unit 3: The Client Tier (10 Hrs.)
XML Schema Languages Dongwon Lee, Ph.D.
Database Systems Week 12 by Zohaib Jan.
Data Modeling II XML Schema & JAXB Marc Dumontier May 4, 2004
Discussion on XSD open issues
XML Validation III Schemas
{ XML Technologies } BY: DR. M’HAMED MATAOUI Chapter III: XML Grammars
ISSGC’05 XML Schemas (XSD)
دانشكده مهندسي كامپيوتر
Design and Implementation of Software for the Web
Introduction to XML Extensible Markup Language
DTD and XML Schema.
ece 720 intelligent web: ontology and beyond
CMP 051 XML Introduction Session III
XML Technologies X-Schema.
Working with Namespaces and Schemas
Optimising XML Schema for IODEF Data model
XML Schema In this first lesson, XML Schema, you will learn to:
CH 20 XML Schema.
New Perspectives on XML
Presentation transcript:

XML Schema Diyar A. Abdulqder Computer science & Information technology department University of salahaddin - Hawler Third stage XML Technologies XML Schema Diyar A. Abdulqder E-Mail: diyar.abdlqadr@su.edu.krd Lecture: 8

XSD Complex Elements A complex element contains other elements and/or attributes. There are four kinds of complex elements: Empty elements Example: <product pid="1345"/> Elements that contain only other elements Example: Elements that contain only text Example: <food type="dessert">Ice cream</food> Elements that contain both other elements and text Example: Note: Each of these elements may contain attributes as well! <employee>   <firstname>John</firstname>   <lastname>Smith</lastname> </employee> <description> It happened on <date lang="norwegian">03.03.99</date> .... </description>

How to Define a Complex Element (1) We can create a complex element in two ways: Define a complex type directly by naming <xs:element name="employee">   <xs:complexType>     <xs:sequence>       <xs:element name="name" type="xs:string"/>       <xs:element name="lastname" type="xs:string"/>     </xs:sequence>   </xs:complexType> </xs:element> <employee>   <firstname>John</firstname>   <lastname>Smith</lastname> </employee>

How to Define a Complex Element (2) Define a complex type and then create an element using the type attribute If you use the method described above, several elements can refer to the same complex type <xs:element name="student" type="personinfo"/> <xs:element name="member" type="personinfo"/> You can also base a complex element on an existing complex element and add some elements <xs:element name="employee" type="personinfo"/> <xs:complexType name="personinfo">   <xs:sequence>     <xs:element name="firstname" type="xs:string"/>     <xs:element name="lastname" type="xs:string"/>   </xs:sequence> </xs:complexType>

Complex Empty Element (1) An empty XML element: <product prodid="1345" /> We can declare Complex Empty elements using the following methods: Use type attribute <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:complexType name = "productType"> <xs:attribute name = 'prodid' type = 'xs:positiveInteger'/> </xs:complexType> <xs:element name = 'product' type = 'productType' /> </xs:schema> <product xsi:noNamespaceSchemaLocation="correct.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" prodid="1345"/>

Complex Empty Element (2) Use ComplexType alone <xs:element name="product"> <xs:complexType> <xs:attribute name="prodid" type="xs:positiveInteger"/> </xs:complexType> </xs:element>

XSD Elements Only An "elements-only" complex type contains an element that contains only other elements. <xs:element name="person">   <xs:complexType>     <xs:sequence>       <xs:element name="firstname" type="xs:string"/>       <xs:element name="lastname" type="xs:string"/>     </xs:sequence>   </xs:complexType> </xs:element> <person>   <firstname>John</firstname>   <lastname>Smith</lastname> </person>

XSD Text-Only Elements This type contains only simple content (text and attributes), therefore we add a simpleContent element around the content. When using simple content, you must define an extension OR a restriction within the simpleContent element Tip: Use the extension/restriction element to expand or to limit the base simple type for the element. <xs:element name="shoesize">   <xs:complexType>     <xs:simpleContent>       <xs:extension base="xs:integer">         <xs:attribute name="country" type="xs:string" />       </xs:extension>     </xs:simpleContent>   </xs:complexType> </xs:element> <shoesize country="france">35</shoesize>

XSD Mixed Content A mixed complex type element can contain attributes, elements, and text. <xs:element name="letter">   <xs:complexType mixed="true">     <xs:sequence>       <xs:element name="name" type="xs:string"/>       <xs:element name="orderid" type="xs:positiveInteger"/>       <xs:element name="shipdate" type="xs:date"/>     </xs:sequence>   </xs:complexType> </xs:element> <letter>   Dear Mr. <name>John Smith</name>.   Your order <orderid>1032</orderid>   will be shipped on <shipdate>2001-07-13</shipdate>. </letter> Note: To enable character data to appear between the child-elements of "letter", the mixed attribute must be set to "true". The <xs:sequence> tag means that the elements defined (name, orderid and shipdate) must appear in that order inside a "letter" element.

XSD Indicators We can control HOW elements are to be used in documents with indicators. There are seven indicators: Order indicators: All Choice Sequenc Occurrence indicators: maxOccurs minOccurs Group indicators: Group name attributeGroup name

All Indicator The <all> indicator specifies that the child elements can appear in any order, and that each child element must occur only once: Note: When using the <all> indicator you can set the <minOccurs> indicator to 0 or 1 and the <maxOccurs> indicator can only be set to 1 (the <minOccurs> and <maxOccurs> are described later). <xs:element name="person">   <xs:complexType>     <xs:all>       <xs:element name="firstname" type="xs:string"/>       <xs:element name="lastname" type="xs:string"/>     </xs:all>   </xs:complexType> </xs:element>

Choice Indicator The <choice> indicator specifies that either one child element or another can occur: <xs:element name="person">   <xs:complexType>     <xs:choice>       <xs:element name="employee" type="employee"/>       <xs:element name="member" type="member"/>     </xs:choice>   </xs:complexType> </xs:element>

Sequence Indicator The <sequence> indicator specifies that the child elements must appear in a specific order: <xs:element name="person">    <xs:complexType>     <xs:sequence>       <xs:element name="firstname" type="xs:string"/>       <xs:element name="lastname" type="xs:string"/>     </xs:sequence>   </xs:complexType> </xs:element>

maxOccurs Indicator The <maxOccurs> indicator specifies the maximum number of times an element can occur: Note: For all "Order" and "Group" indicators (any, all, choice, sequence, group name, and group reference) the default value for maxOccurs and minOccurs is 1. <xs:element name="person">   <xs:complexType>     <xs:sequence>       <xs:element name="full_name" type="xs:string"/>       <xs:element name="child_name" type="xs:string" maxOccurs="10"/>     </xs:sequence>   </xs:complexType> </xs:element> The example above indicates that the "child_name" element can occur a minimum of one time (the default value for minOccurs is 1) and a maximum of ten times in the "person" element.

minOccurs Indicator The <minOccurs> indicator specifies the minimum number of times an element can occur: <xs:element name="person">   <xs:complexType>     <xs:sequence>       <xs:element name="full_name" type="xs:string"/>       <xs:element name="child_name" type="xs:string"       maxOccurs="10" minOccurs="0"/>     </xs:sequence>   </xs:complexType> </xs:element> Tip: To allow an element to appear an unlimited number of times, use the maxOccurs="unbounded" statement:

Group Indicators Group indicators are used to define related sets of elements. Element groups are defined with the group declaration. You must define an all, choice, or sequence element inside the group declaration. After you have defined a group, you can reference it in another definition <xs:group name="groupname"> ... </xs:group>

Example <xs:group name="persongroup">   <xs:sequence>     <xs:element name="firstname" type="xs:string"/>     <xs:element name="lastname" type="xs:string"/>     <xs:element name="birthday" type="xs:date"/>   </xs:sequence> </xs:group> <xs:element name="person" type="personinfo"/> <xs:complexType name="personinfo">   <xs:sequence>     <xs:group ref="persongroup"/>     <xs:element name="country" type="xs:string"/>   </xs:sequence> </xs:complexType>

Attribute Groups Attribute groups are defined with the attributeGroup declaration <xs:attributeGroup name="personattrgroup">   <xs:attribute name="firstname" type="xs:string"/>   <xs:attribute name="lastname" type="xs:string"/>   <xs:attribute name="birthday" type="xs:date"/> </xs:attributeGroup> <xs:element name="person">   <xs:complexType>     <xs:attributeGroup ref="personattrgroup"/>   </xs:complexType> </xs:element>