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.

Slides:



Advertisements
Similar presentations
XML-XSL Introduction SHIJU RAJAN SHIJU RAJAN Outline Brief Overview Brief Overview What is XML? What is XML? Well Formed XML Well Formed XML Tag Name.
Advertisements

XML Language Family Detailed Examples Most information contained in these slide comes from: These slides are intended.
1 DTD (Document Type Definition) Imposing Structure on XML Documents (W3Schools on DTDs)W3Schools on DTDs.
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.
Sunday, June 28, 2015 Abdelali ZAHI : FALL 2003 : XML Schemas XML Schemas Presented By : Abdelali ZAHI Instructor : Dr H.Haddouti.
5-1 Facilitating Business over the Internet: The XML language CR (2004) Prentice Hall, Inc. The xml goals The main objects of xml: Diagrams: Blocks and.
1 Print your own copy If you bring it along, hand in with your exam script Do not write anything extra or you will be penalized Student Name: Student Number:
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.
Chapter 12 Creating and Using XML Documents HTML5 AND CSS Seventh Edition.
XP New Perspectives on XML Tutorial 3 1 DTD Tutorial – Carey ISBN
Integrating XML with Microsoft SQL Server ©NIITeXtensible Markup Language/Lesson 9/Slide 1 of 31 Objectives In this lesson, you will learn to: * Generate.
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:
Neminath Simmachandran
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Schemas Ellen Pearlman Eileen Mullin Programming the Web Using XML.
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.
XML A Single Entity. xml a single entity Objectives Objectives :  understand the data model  describe the XML Document  describe the XML Schema  describe.
Using JavaBeans and Custom Tags in JSP Lesson 3B / Slide 1 of 37 J2EE Web Components Pre-assessment Questions 1.The _____________ attribute of a JSP page.
1 © Netskills Quality Internet Training, University of Newcastle Introducing XML © Netskills, Quality Internet Training University.
August Chapter 2 - Markup and Core Concepts Learning XML by Erik T. Ray Slides were developed by Jack Davis College of Information Science and Technology.
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 Tutorial 13 Validating Documents with DTDs Working with Document Type Definitions.
Avoid using attributes? Some of the problems using attributes: Attributes cannot contain multiple values (child elements can) Attributes are not easily.
XML A web enabled data description language 4/22/2001 By Mark Lawson & Edward Ryan L’Herault.
JSTL, XML and XSLT An introduction to JSP Standard Tag Library and XML/XSLT transformation for Web layout.
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.
Copyrighted material John Tullis 10/17/2015 page 1 04/15/00 XML Part 3 John Tullis DePaul Instructor
Entity-Relationship (ER) Modelling ER modelling - Identify entities - Identify relationships - Construct ER diagram - Collect attributes for entities &
Microsoft ® Office Excel 2003 Training Using XML in Excel SynAppSys Educational Services presents:
An Introduction to XML Sandeep Bhattaram
XML Introduction. What is XML? XML stands for eXtensible Markup Language XML stands for eXtensible Markup Language XML is a markup language much like.
The eXtensible Markup Language (XML). Presentation Outline Part 1: The basics of creating an XML document Part 2: Developing constraints for a well formed.
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
Internet & World Wide Web How to Program, 5/e. © by Pearson Education, Inc. All Rights Reserved.2.
Working with XML Schemas ©NIITeXtensible Markup Language/Lesson 3/Slide 1 of 36 Objectives In this lesson, you will learn to: * Declare attributes in an.
Representing data with XML SE-2030 Dr. Mark L. Hornick 1.
XSD: XML Schema Language Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
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.
Accessing XML Documents Using DOM ©NIITeXtensible Markup Language/Lesson 8/Slide 1 of 23 Objectives In this lesson, you will learn to: * Use XML DOM objects.
XML Schema Lecture 3. Indicators There are seven indicators: Order indicators: All Choice Sequence Occurrence indicators: maxOccurs minOccurs Group indicators:
XML blocks XML STRUCTURE The most basic building blocks of an XML file are elements, attributes and comments. Compiled based on Tutorial PhUSE 2008 XML.
XML Extensible Markup Language
Displaying Data with XSLT ©NIITeXtensible Markup Language/Lesson 6/Slide 1 of 45 Objectives In this lesson, you will learn to: * Perform conditional formatting.
Learning XML Basics ©NIITeXtensible Markup Language/Lesson 1/Slide 1 of 40 Objectives In this session, you will learn to: * Identify the limitations of.
Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 1 of 46 Objectives In this session, you will learn to: * Define rendering * Identify.
XML Namespaces In this first lesson XML Namespaces, you will learn to:
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.
Web Services: Principles & Technology Slide 3.1 Chapter 3 Brief Overview of XML COMP 4302/6302.
4 Copyright © 2004, Oracle. All rights reserved. Validating XML by Using XML Schema.
CITA 330 Section 2 DTD. Defining XML Dialects “Well-formedness” is the minimal requirement for an XML document; all XML parsers can check it Any useful.
XML Schemas Dr. Awad Khalil Computer Science Department AUC.
In this session, you will learn to:
XML: Extensible Markup Language
In this session, you will learn to:
Overview of MDM Site Hub
In this session, you will learn to:
ece 720 intelligent web: ontology and beyond
New Perspectives on XML
New Perspectives on XML
Presentation transcript:

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 learn to: *Create groups of elements and attributes in an XML schema * Use the following XSD elements: 3sequence 3group 3choice 3all 3attributeGroup

Creating Groups of Elements and Attributes in an XML Schema ©NIITeXtensible Markup Language/Lesson 4/Slide 2 of 28 Problem Statement 4.D.1 CyberShoppe requires a centralized repository of data about its customers. For this purpose, the data needs to be collated from the branch offices that maintain data on their computerized systems. The data needs to be maintained at a centralized location so that it is available to various sections including the Accounts and the Sales sections of various branches, regardless of the hardware and software platforms being used at the branches. After collating the data about customers from various branches, the head office needs to verify that all the required information is supplied by the branch offices. It also needs to verify that the data is stored in a consistent format. The data to be stored includes customer ID, first name, last name, and contact information, such as address and phone number. A customer may specify residential or official contact information.

Creating Groups of Elements and Attributes in an XML Schema ©NIITeXtensible Markup Language/Lesson 4/Slide 3 of 28 Task List *Identify the elements and attributes required to store data. *Identify the elements and attributes that need to be grouped. *Identify a mechanism for grouping elements and attributes in a schema. *Declare a group of elements and attributes in a schema. *Create an XML document to store data. *Validate the XML document against the schema.

Creating Groups of Elements and Attributes in an XML Schema ©NIITeXtensible Markup Language/Lesson 4/Slide 4 of 28 Task 1: Identify the elements and attributes required to store data. Result *The elements required for storing details about customers in an XML document are: 3CUSTOMERDATA 3CUSTOMER 3FIRSTNAME 3LASTNAME 3CONTACTINFO 3RESIDENCE 3OFFICE

Creating Groups of Elements and Attributes in an XML Schema ©NIITeXtensible Markup Language/Lesson 4/Slide 5 of 28 Task 1: Identify the …to store data. (Contd.) 3ADDRESS 3PHONE *The attribute required for storing details about customers is: 3 CUSTOMERID

Creating Groups of Elements and Attributes in an XML Schema ©NIITeXtensible Markup Language/Lesson 4/Slide 6 of 28 Task 1: Identify the … to store data. (Contd.)

Creating Groups of Elements and Attributes in an XML Schema ©NIITeXtensible Markup Language/Lesson 4/Slide 7 of 28 Task 2: Identify the elements and attributes that need to be grouped. * XSD enables you to combine related elements and attributes into groups. This feature of creating grouped elements and attributes enables you to perform the following tasks: 3 Create a reusable group of elements and attributes: ä A reusable group can be used to specify the content model for a complex type. ä This eliminates the task of declaring the elements, which have already been declared in some other context.

Creating Groups of Elements and Attributes in an XML Schema ©NIITeXtensible Markup Language/Lesson 4/Slide 8 of 28 Task 2: Identify the …to be grouped. (Contd.) 3 Select a single element from a group: ä At times, you may want to use just one element or attribute from a group. For example, you may want to specify either the residence or the office phone number of an employee. ä You can create a group of such elements and allow one of them to be used in the XML document.

Creating Groups of Elements and Attributes in an XML Schema ©NIITeXtensible Markup Language/Lesson 4/Slide 9 of 28 Task 2: Identify the …to be grouped. (Contd.) 3 Specify the sequence of elements: ä You can create a group of elements and specify the sequence in which each element in the group should appear in the XML document.

Creating Groups of Elements and Attributes in an XML Schema ©NIITeXtensible Markup Language/Lesson 4/Slide 10 of 28 Task 2: Identify the …to be grouped. (Contd.) Result * The various elements required to store customer details can be grouped as follows: 3 ADDRESS and PHONE: ä Since these elements are used in RESIDENCE as well as OFFICE elements, these elements can be grouped together as ADDPHONE. ä This group can then be reused within the declaration of the RESIDENCE and OFFICE elements.

Creating Groups of Elements and Attributes in an XML Schema ©NIITeXtensible Markup Language/Lesson 4/Slide 11 of 28 Task 2: Identify the … to be grouped. (Contd.) 3 OFFICE and RESIDENCE: ä These elements can be grouped together to ensure that only one of them is used for each occurrence of the CUSTOMER element.

Creating Groups of Elements and Attributes in an XML Schema ©NIITeXtensible Markup Language/Lesson 4/Slide 12 of 28 Task 3: Identify a mechanism for grouping elements and attributes in a schema. * XSD provides a number of elements that can be used to group user-defined elements and attributes. These are: 3 sequence 3 group 3 choice 3 all 3 attributeGroup

Creating Groups of Elements and Attributes in an XML Schema ©NIITeXtensible Markup Language/Lesson 4/Slide 13 of 28 Task 3: Identify a mechanism …in a schema. (Contd.)  The sequence Element 3 The sequence element helps you ensure that elements declared within the opening and closing tags of this element appear in a specific order.

Creating Groups of Elements and Attributes in an XML Schema ©NIITeXtensible Markup Language/Lesson 4/Slide 14 of 28 Task 3: Identify a mechanism …in a schema. (Contd.)  The group Element 3 In XSD, a set of elements can be grouped together by a common name and incorporated into a complex data type. 3 Grouping of elements is beneficial when you want a set of related elements to be referred by a common name.

Creating Groups of Elements and Attributes in an XML Schema ©NIITeXtensible Markup Language/Lesson 4/Slide 15 of 28 Task 3: Identify a mechanism … in a schema. (Contd.) 3 The following is the syntax for declaring a group element:

Creating Groups of Elements and Attributes in an XML Schema ©NIITeXtensible Markup Language/Lesson 4/Slide 16 of 28 Task 3: Identify a mechanism … in a schema. (Contd.) 3 The following table describes the attributes of the group element: AttributeDescription maxOccursUsed to specify the maximum number of times a group can occur in the XML document. The value of the maxOccurs attribute must be an integer greater than or equal to zero. If you do not want to set a limit on the maximum number, you can specify "unbounded" as the value to this attribute. minOccursUsed to specify the minimum number of times a group can occur in the XML document. The value of the minOccurs attribute must be an integer greater than or equal to zero. To specify that the group is optional, set the value of this attribute to zero.

Creating Groups of Elements and Attributes in an XML Schema ©NIITeXtensible Markup Language/Lesson 4/Slide 17 of 28 Task 3: Identify a mechanism … in a schema. (Contd.) AttributeDescription nameUsed to assign a name for the group element. The name assigned to the group must not contain any colon. refUsed to refer to a group in a complex type element.

Creating Groups of Elements and Attributes in an XML Schema ©NIITeXtensible Markup Language/Lesson 4/Slide 18 of 28 Task 3: Identify a mechanism … in a schema. (Contd.) The choice Element 3 XSD enables you to specify alternative options by using the choice element. 3 The choice element allows only one of the elements contained in the group to be present within the parent element.

Creating Groups of Elements and Attributes in an XML Schema ©NIITeXtensible Markup Language/Lesson 4/Slide 19 of 28 Task 3: Identify a mechanism … in a schema. (Contd.) 3 The syntax for declaring a choice element: 3 In the above syntax, id, maxOccurs, and minOccurs are the attributes of the choice element. 3 These attributes are similar to the attributes of the group element mentioned earlier.

Creating Groups of Elements and Attributes in an XML Schema ©NIITeXtensible Markup Language/Lesson 4/Slide 20 of 28 Task 3: Identify a mechanism … in a schema. (Contd.)  The all Element 3 The all element enables you to use the child elements in any order as against the sequence element, which specifies the order in which the child elements must appear. 3 The syntax for using the all element: 3 In the above syntax, the maxOccurs and minOccurs attributes have the same meaning as the maxOccurs and minOccurs elements of the group element.

Creating Groups of Elements and Attributes in an XML Schema ©NIITeXtensible Markup Language/Lesson 4/Slide 21 of 28 Task 3: Identify a mechanism … in a schema. (Contd.)  The attributeGroup Element 3 XSD also enables you to group attributes that can be reused with different elements. 3 You can group attributes by using the attributeGroup element.

Creating Groups of Elements and Attributes in an XML Schema ©NIITeXtensible Markup Language/Lesson 4/Slide 22 of 28 Task 3: Identify a mechanism … in a schema. (Contd.) 3 The syntax of the attributeGroup element: attribute1 attribute2 : 3 In the above syntax, attribute1 and attribute2 are the declaration statements of the various attributes that are to be grouped using the attributeGroup element.

Creating Groups of Elements and Attributes in an XML Schema ©NIITeXtensible Markup Language/Lesson 4/Slide 23 of 28 Task 3: Identify a mechanism … in a schema. (Contd.) Result * In the given scenario, you need to use the following XSD elements: 3 To group the ADDRESS and PHONE elements under a common name, you need to use the group element of XSD. 3 To group the RESIDENCE and OFFICE elements and to ensure that only one of them can be used for each occurrence of the CUSTOMER element, you need to use the choice element of XSD.

Creating Groups of Elements and Attributes in an XML Schema ©NIITeXtensible Markup Language/Lesson 4/Slide 24 of 28 Task 4: Declare a group of elements and attributes in a schema. Task 5: Create an XML document to store data. Task 6: Validate the XML document against the schema.

Creating Groups of Elements and Attributes in an XML Schema ©NIITeXtensible Markup Language/Lesson 4/Slide 25 of 28 Just a Minute… CyberShoppe sells books to its customers. The book details consist of the name of the book, the name of the author of the book, and the price of the book. The name of the authors of the book can be entered either by using the NAME element or by using the FIRSTNAME and LASTNAME elements.

Creating Groups of Elements and Attributes in an XML Schema ©NIITeXtensible Markup Language/Lesson 4/Slide 26 of 28 Problem Statement 4.P.1 CyberShoppe needs to store the details about its suppliers at a centralized location. Supplier details include the supplier ID, first name, last name, supplier type, address, and phone number. The supplier ID must begin with the character S followed by three digits. This ID must be capable of being reused across documents. The supplier type can be either INDIVIDUAL or COMPANY. The XML document can contain either a combination of the FIRSTNAME and LASTNAME elements for storing the supplier name or it can contain just the NAME element. It must be ensured that either the combination or the single element must be used to store the supplier name. The supplier data must be validated to ensure that it conform to the rules specified above in order to maintain data integrity.

Creating Groups of Elements and Attributes in an XML Schema ©NIITeXtensible Markup Language/Lesson 4/Slide 27 of 28 Summary In this lesson, you learned that: * You can group elements and attributes using the following elements: 3 sequence: Allows you to create a group of elements and specify that all the elements within the group should appear in the same sequence in which they are declared. 3 group : Allows you to group a set of elements and use a common name to refer to these elements. This group can be incorporated into a complex data type.

Creating Groups of Elements and Attributes in an XML Schema ©NIITeXtensible Markup Language/Lesson 4/Slide 28 of 28 Summary (Contd.) 3 choice : Allows you to specify that only one of the specified set of elements can be used at a time. 3 all : Allows you to create a group of elements that can be used in any sequence within the parent element. 3 attributeGroup : Allows you to create a group of attributes that can be reused in different elements.