SlideShare ist ein Scribd-Unternehmen logo
1 von 28
Creating Groups of Elements and Attributes in
an XML Schema

Objectives
In this lesson, you will learn to:
 Create groups of elements and attributes in an XML
  schema
 Use the following XSD elements:
     sequence
     group
     choice
     all
     attributeGroup


©NIIT                    eXtensible Markup Language/Lesson 4/Slide 1 of 28
Creating Groups of Elements and Attributes in
  an XML Schema

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.
  ©NIIT                  eXtensible Markup Language/Lesson 4/Slide 2 of 28
Creating Groups of Elements and Attributes in
an XML Schema
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.


©NIIT                  eXtensible Markup Language/Lesson 4/Slide 3 of 28
Creating Groups of Elements and Attributes in
an XML Schema
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:
     CUSTOMERDATA
     CUSTOMER
     FIRSTNAME
     LASTNAME
     CONTACTINFO
     RESIDENCE
     OFFICE

©NIIT                  eXtensible Markup Language/Lesson 4/Slide 4 of 28
Creating Groups of Elements and Attributes in
an XML Schema

Task 1: Identify the …to store data. (Contd.)
    ADDRESS
     PHONE
 The attribute required for storing details about
  customers is:
     CUSTOMERID




©NIIT                 eXtensible Markup Language/Lesson 4/Slide 5 of 28
Creating Groups of Elements and Attributes in
  an XML Schema

Task 1: Identify the … to store data. (Contd.)
              C U S T O M E R D A T A



                       C U S T O M E R



                             F I R S T N A M E


                              L A S T N A M E


                           C O N T A C T I N F O



                                  R E S I D E N C E



                                           A D D R E S S


                                             P H O N E


                                        O F F I C E



                                           A D D R E S S


                                             P H O N E


  ©NIIT                                  eXtensible Markup Language/Lesson 4/Slide 6 of 28
Creating Groups of Elements and Attributes in
an XML Schema

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:
     Create a reusable group of elements and
      attributes:
        ®A reusable group can be used to specify the
         content model for a complex type.
        ® Thiseliminates the task of declaring the
         elements, which have already been
         declared in some other context.

©NIIT                  eXtensible Markup Language/Lesson 4/Slide 7 of 28
Creating Groups of Elements and Attributes in
an XML Schema

Task 2: Identify the …to be grouped. (Contd.)
     Select a single element from a group:
        ® Attimes, 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.




©NIIT                   eXtensible Markup Language/Lesson 4/Slide 8 of 28
Creating Groups of Elements and Attributes in
an XML Schema

Task 2: Identify the …to be grouped. (Contd.)
     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.




©NIIT                  eXtensible Markup Language/Lesson 4/Slide 9 of 28
Creating Groups of Elements and Attributes in
an XML Schema

Task 2: Identify the …to be grouped. (Contd.)
Result
 The various elements required to store customer
  details can be grouped as follows:
     ADDRESS and PHONE:
         ® Sincethese elements are used in RESIDENCE
          as well as OFFICE elements, these elements
          can be grouped together as ADDPHONE.
         ® Thisgroup can then be reused within the
          declaration of the RESIDENCE and OFFICE
          elements.


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




©NIIT                 eXtensible Markup Language/Lesson 4/Slide 11 of 28
Creating Groups of Elements and Attributes in
an XML Schema
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:
     sequence
     group
     choice
     all
     attributeGroup



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




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




©NIIT                 eXtensible Markup Language/Lesson 4/Slide 14 of 28
Creating Groups of Elements and Attributes in
an XML Schema
Task 3: Identify a mechanism … in a schema.
(Contd.)
     The following is the syntax for declaring a group
      element:
    group maxOccurs=nonNegetiveInteger |
      unbounded minOccurs=nonNegetiveInteger
      name=NCName ref=QName /group




©NIIT                  eXtensible Markup Language/Lesson 4/Slide 15 of 28
Creating Groups of Elements and Attributes in
an XML Schema
Task 3: Identify a mechanism … in a schema.
(Contd.)
     The following table describes the attributes of the
      group element:
  Attribute                          Description
maxOccurs      Used 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.
minOccurs      Used 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.

©NIIT                    eXtensible Markup Language/Lesson 4/Slide 16 of 28
Creating Groups of Elements and Attributes in
an XML Schema
Task 3: Identify a mechanism … in a schema.
(Contd.)

      Attribute                        Description
name              Used to assign a name for the group element. The
                  name assigned to the group must not contain any
                  colon.
ref               Used to refer to a group in a complex type element.




©NIIT                     eXtensible Markup Language/Lesson 4/Slide 17 of 28
Creating Groups of Elements and Attributes in
an XML Schema

Task 3: Identify a mechanism … in a schema.
(Contd.)
The choice Element
     XSD enables you to specify alternative options by
      using the choice element.
     The choice element allows only one of the
      elements contained in the group to be present
      within the parent element.




©NIIT                 eXtensible Markup Language/Lesson 4/Slide 18 of 28
Creating Groups of Elements and Attributes in
an XML Schema

Task 3: Identify a mechanism … in a schema.
(Contd.)
     The syntax for declaring a choice element:
        choice id=ID maxOccurs=nonNegativeInteger|
        unbounded minOccurs=nonNegativeInteger  /
        choice
     In the above syntax, id, maxOccurs, and
      minOccurs are the attributes of the choice
      element.
     These attributes are similar to the attributes of the
      group element mentioned earlier.



©NIIT                  eXtensible Markup Language/Lesson 4/Slide 19 of 28
Creating Groups of Elements and Attributes in
an XML Schema
Task 3: Identify a mechanism … in a schema.
(Contd.)
 The all Element
     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.
     The syntax for using the all element:
    all maxOccurs=positiveInteger minOccurs=0|1 /all
     In the above syntax, the maxOccurs and
      minOccurs attributes have the same meaning as
      the maxOccurs and minOccurs elements of the
      group element.

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




©NIIT                 eXtensible Markup Language/Lesson 4/Slide 21 of 28
Creating Groups of Elements and Attributes in
an XML Schema
Task 3: Identify a mechanism … in a schema.
(Contd.)
     The syntax of the attributeGroup element:
        attributeGroup
        attribute1
        attribute2
         :
        /attributeGroup
     In the above syntax, attribute1 and attribute2 are
      the declaration statements of the various attributes
      that are to be grouped using the
      attributeGroup element.
©NIIT                  eXtensible Markup Language/Lesson 4/Slide 22 of 28
Creating Groups of Elements and Attributes in
an XML Schema
Task 3: Identify a mechanism … in a schema.
(Contd.)
Result
 In the given scenario, you need to use the following
  XSD elements:
     To group the ADDRESS and PHONE elements
      under a common name, you need to use the group
      element of XSD.
     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.


©NIIT                 eXtensible Markup Language/Lesson 4/Slide 23 of 28
Creating Groups of Elements and Attributes in
an XML Schema
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.




©NIIT             eXtensible Markup Language/Lesson 4/Slide 24 of 28
Creating Groups of Elements and Attributes in
 an XML Schema

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.




 ©NIIT                 eXtensible Markup Language/Lesson 4/Slide 25 of 28
Creating Groups of Elements and Attributes in
 an XML Schema

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.

 ©NIIT                  eXtensible Markup Language/Lesson 4/Slide 26 of 28
Creating Groups of Elements and Attributes in
 an XML Schema

Summary
In this lesson, you learned that:
 You can group elements and attributes using the
following elements:
     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.
     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.


  ©NIIT                  eXtensible Markup Language/Lesson 4/Slide 27 of 28
Creating Groups of Elements and Attributes in
an XML Schema

Summary (Contd.)
     choice: Allows you to specify that only one of the
      specified set of elements can be used at a time.
     all: Allows you to create a group of elements that
      can be used in any sequence within the parent
      element.
     attributeGroup: Allows you to create a group of
      attributes that can be reused in different elements.




 ©NIIT                 eXtensible Markup Language/Lesson 4/Slide 28 of 28

Weitere ähnliche Inhalte

Was ist angesagt?

Object oriented database model
Object oriented database modelObject oriented database model
Object oriented database modelPAQUIAAIZEL
 
Islamic University Previous Year Question Solution 2018 (ADBMS)
Islamic University Previous Year Question Solution 2018 (ADBMS)Islamic University Previous Year Question Solution 2018 (ADBMS)
Islamic University Previous Year Question Solution 2018 (ADBMS)Rakibul Hasan Pranto
 
Object Oriented Dbms
Object Oriented DbmsObject Oriented Dbms
Object Oriented Dbmsmaryeem
 
9. Object Relational Databases in DBMS
9. Object Relational Databases in DBMS9. Object Relational Databases in DBMS
9. Object Relational Databases in DBMSkoolkampus
 
Module 5 oodb systems semantic db systems
Module 5 oodb systems  semantic db systemsModule 5 oodb systems  semantic db systems
Module 5 oodb systems semantic db systemsTaher Barodawala
 
Database Design and Normalization Techniques
Database Design and Normalization TechniquesDatabase Design and Normalization Techniques
Database Design and Normalization TechniquesNishant Munjal
 
08. Object Oriented Database in DBMS
08. Object Oriented Database in DBMS08. Object Oriented Database in DBMS
08. Object Oriented Database in DBMSkoolkampus
 
Overview of Object-Oriented Concepts Characteristics by vikas jagtap
Overview of Object-Oriented Concepts Characteristics by vikas jagtapOverview of Object-Oriented Concepts Characteristics by vikas jagtap
Overview of Object-Oriented Concepts Characteristics by vikas jagtapVikas Jagtap
 
Oracle soa xml faq
Oracle soa xml faqOracle soa xml faq
Oracle soa xml faqxavier john
 
Xml viva questions
Xml viva questionsXml viva questions
Xml viva questionsVipul Naik
 
Building XML Based Applications
Building XML Based ApplicationsBuilding XML Based Applications
Building XML Based ApplicationsPrabu U
 
SQL Queries Information
SQL Queries InformationSQL Queries Information
SQL Queries InformationNishant Munjal
 

Was ist angesagt? (20)

Object oriented database model
Object oriented database modelObject oriented database model
Object oriented database model
 
Object oriented database
Object oriented databaseObject oriented database
Object oriented database
 
Object oriented data model
Object oriented data modelObject oriented data model
Object oriented data model
 
Chapt 1 odbms
Chapt 1 odbmsChapt 1 odbms
Chapt 1 odbms
 
Islamic University Previous Year Question Solution 2018 (ADBMS)
Islamic University Previous Year Question Solution 2018 (ADBMS)Islamic University Previous Year Question Solution 2018 (ADBMS)
Islamic University Previous Year Question Solution 2018 (ADBMS)
 
03 x files
03 x files03 x files
03 x files
 
Object Oriented Dbms
Object Oriented DbmsObject Oriented Dbms
Object Oriented Dbms
 
9. Object Relational Databases in DBMS
9. Object Relational Databases in DBMS9. Object Relational Databases in DBMS
9. Object Relational Databases in DBMS
 
Module 5 oodb systems semantic db systems
Module 5 oodb systems  semantic db systemsModule 5 oodb systems  semantic db systems
Module 5 oodb systems semantic db systems
 
Database Design and Normalization Techniques
Database Design and Normalization TechniquesDatabase Design and Normalization Techniques
Database Design and Normalization Techniques
 
12 SQL
12 SQL12 SQL
12 SQL
 
08. Object Oriented Database in DBMS
08. Object Oriented Database in DBMS08. Object Oriented Database in DBMS
08. Object Oriented Database in DBMS
 
Overview of Object-Oriented Concepts Characteristics by vikas jagtap
Overview of Object-Oriented Concepts Characteristics by vikas jagtapOverview of Object-Oriented Concepts Characteristics by vikas jagtap
Overview of Object-Oriented Concepts Characteristics by vikas jagtap
 
Oracle soa xml faq
Oracle soa xml faqOracle soa xml faq
Oracle soa xml faq
 
Xml viva questions
Xml viva questionsXml viva questions
Xml viva questions
 
Object & classes
Object & classes Object & classes
Object & classes
 
Building XML Based Applications
Building XML Based ApplicationsBuilding XML Based Applications
Building XML Based Applications
 
SQL Queries Information
SQL Queries InformationSQL Queries Information
SQL Queries Information
 
Unit 5 xml (1)
Unit 5   xml (1)Unit 5   xml (1)
Unit 5 xml (1)
 
02 xml schema
02 xml schema02 xml schema
02 xml schema
 

Ähnlich wie 02 sm3 xml_xp_04

01 sm3 xml_xp_02
01 sm3 xml_xp_0201 sm3 xml_xp_02
01 sm3 xml_xp_02Niit Care
 
Class diagram java
Class diagram javaClass diagram java
Class diagram javaravinlaheri2
 
04 sm3 xml_xp_08
04 sm3 xml_xp_0804 sm3 xml_xp_08
04 sm3 xml_xp_08Niit Care
 
C programming session 09
C programming session 09C programming session 09
C programming session 09Dushmanta Nath
 
Data structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pdData structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pdNimmi Weeraddana
 
C++ beginner's guide ch08
C++ beginner's guide ch08C++ beginner's guide ch08
C++ beginner's guide ch08Jotham Gadot
 
Abap object-oriented-programming-tutorials
Abap object-oriented-programming-tutorialsAbap object-oriented-programming-tutorials
Abap object-oriented-programming-tutorialscesarmendez78
 
Object Oriented Programming with C#
Object Oriented Programming with C#Object Oriented Programming with C#
Object Oriented Programming with C#SyedUmairAli9
 
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .NetGreg Sohl
 
Ch.03 - Class Diagram_1 OBJECT ORIENTED ANALYSIS AND DESIGN [O] .pptx
Ch.03 - Class Diagram_1 OBJECT ORIENTED ANALYSIS AND DESIGN [O] .pptxCh.03 - Class Diagram_1 OBJECT ORIENTED ANALYSIS AND DESIGN [O] .pptx
Ch.03 - Class Diagram_1 OBJECT ORIENTED ANALYSIS AND DESIGN [O] .pptxSohagSrz
 

Ähnlich wie 02 sm3 xml_xp_04 (20)

01 sm3 xml_xp_02
01 sm3 xml_xp_0201 sm3 xml_xp_02
01 sm3 xml_xp_02
 
Tp2
Tp2Tp2
Tp2
 
Class diagram java
Class diagram javaClass diagram java
Class diagram java
 
class diagram
class diagramclass diagram
class diagram
 
M1803058993
M1803058993M1803058993
M1803058993
 
Jazz
JazzJazz
Jazz
 
04 sm3 xml_xp_08
04 sm3 xml_xp_0804 sm3 xml_xp_08
04 sm3 xml_xp_08
 
uml.pptx
uml.pptxuml.pptx
uml.pptx
 
UNIONS.pptx
UNIONS.pptxUNIONS.pptx
UNIONS.pptx
 
C programming session 09
C programming session 09C programming session 09
C programming session 09
 
Data structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pdData structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pd
 
C++ beginner's guide ch08
C++ beginner's guide ch08C++ beginner's guide ch08
C++ beginner's guide ch08
 
Lecture 9
Lecture 9Lecture 9
Lecture 9
 
Abap object-oriented-programming-tutorials
Abap object-oriented-programming-tutorialsAbap object-oriented-programming-tutorials
Abap object-oriented-programming-tutorials
 
Unit 4 qba
Unit 4 qbaUnit 4 qba
Unit 4 qba
 
Object Oriented Programming with C#
Object Oriented Programming with C#Object Oriented Programming with C#
Object Oriented Programming with C#
 
Hibernate II
Hibernate IIHibernate II
Hibernate II
 
Object Oriented Programming In .Net
Object Oriented Programming In .NetObject Oriented Programming In .Net
Object Oriented Programming In .Net
 
ITU - MDD - XText
ITU - MDD - XTextITU - MDD - XText
ITU - MDD - XText
 
Ch.03 - Class Diagram_1 OBJECT ORIENTED ANALYSIS AND DESIGN [O] .pptx
Ch.03 - Class Diagram_1 OBJECT ORIENTED ANALYSIS AND DESIGN [O] .pptxCh.03 - Class Diagram_1 OBJECT ORIENTED ANALYSIS AND DESIGN [O] .pptx
Ch.03 - Class Diagram_1 OBJECT ORIENTED ANALYSIS AND DESIGN [O] .pptx
 

Mehr von Niit Care (20)

Ajs 1 b
Ajs 1 bAjs 1 b
Ajs 1 b
 
Ajs 4 b
Ajs 4 bAjs 4 b
Ajs 4 b
 
Ajs 4 a
Ajs 4 aAjs 4 a
Ajs 4 a
 
Ajs 4 c
Ajs 4 cAjs 4 c
Ajs 4 c
 
Ajs 3 b
Ajs 3 bAjs 3 b
Ajs 3 b
 
Ajs 3 a
Ajs 3 aAjs 3 a
Ajs 3 a
 
Ajs 3 c
Ajs 3 cAjs 3 c
Ajs 3 c
 
Ajs 2 b
Ajs 2 bAjs 2 b
Ajs 2 b
 
Ajs 2 a
Ajs 2 aAjs 2 a
Ajs 2 a
 
Ajs 2 c
Ajs 2 cAjs 2 c
Ajs 2 c
 
Ajs 1 a
Ajs 1 aAjs 1 a
Ajs 1 a
 
Ajs 1 c
Ajs 1 cAjs 1 c
Ajs 1 c
 
Dacj 4 2-c
Dacj 4 2-cDacj 4 2-c
Dacj 4 2-c
 
Dacj 4 2-b
Dacj 4 2-bDacj 4 2-b
Dacj 4 2-b
 
Dacj 4 2-a
Dacj 4 2-aDacj 4 2-a
Dacj 4 2-a
 
Dacj 4 1-c
Dacj 4 1-cDacj 4 1-c
Dacj 4 1-c
 
Dacj 4 1-b
Dacj 4 1-bDacj 4 1-b
Dacj 4 1-b
 
Dacj 4 1-a
Dacj 4 1-aDacj 4 1-a
Dacj 4 1-a
 
Dacj 1-2 b
Dacj 1-2 bDacj 1-2 b
Dacj 1-2 b
 
Dacj 1-3 c
Dacj 1-3 cDacj 1-3 c
Dacj 1-3 c
 

Kürzlich hochgeladen

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 

Kürzlich hochgeladen (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

02 sm3 xml_xp_04

  • 1. Creating Groups of Elements and Attributes in an XML Schema Objectives In this lesson, you will learn to: Create groups of elements and attributes in an XML schema Use the following XSD elements: sequence group choice all attributeGroup ©NIIT eXtensible Markup Language/Lesson 4/Slide 1 of 28
  • 2. Creating Groups of Elements and Attributes in an XML Schema 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. ©NIIT eXtensible Markup Language/Lesson 4/Slide 2 of 28
  • 3. Creating Groups of Elements and Attributes in an XML Schema 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. ©NIIT eXtensible Markup Language/Lesson 4/Slide 3 of 28
  • 4. Creating Groups of Elements and Attributes in an XML Schema 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: CUSTOMERDATA CUSTOMER FIRSTNAME LASTNAME CONTACTINFO RESIDENCE OFFICE ©NIIT eXtensible Markup Language/Lesson 4/Slide 4 of 28
  • 5. Creating Groups of Elements and Attributes in an XML Schema Task 1: Identify the …to store data. (Contd.) ADDRESS PHONE The attribute required for storing details about customers is: CUSTOMERID ©NIIT eXtensible Markup Language/Lesson 4/Slide 5 of 28
  • 6. Creating Groups of Elements and Attributes in an XML Schema Task 1: Identify the … to store data. (Contd.) C U S T O M E R D A T A C U S T O M E R F I R S T N A M E L A S T N A M E C O N T A C T I N F O R E S I D E N C E A D D R E S S P H O N E O F F I C E A D D R E S S P H O N E ©NIIT eXtensible Markup Language/Lesson 4/Slide 6 of 28
  • 7. Creating Groups of Elements and Attributes in an XML Schema 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: Create a reusable group of elements and attributes: ®A reusable group can be used to specify the content model for a complex type. ® Thiseliminates the task of declaring the elements, which have already been declared in some other context. ©NIIT eXtensible Markup Language/Lesson 4/Slide 7 of 28
  • 8. Creating Groups of Elements and Attributes in an XML Schema Task 2: Identify the …to be grouped. (Contd.) Select a single element from a group: ® Attimes, 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. ©NIIT eXtensible Markup Language/Lesson 4/Slide 8 of 28
  • 9. Creating Groups of Elements and Attributes in an XML Schema Task 2: Identify the …to be grouped. (Contd.) 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. ©NIIT eXtensible Markup Language/Lesson 4/Slide 9 of 28
  • 10. Creating Groups of Elements and Attributes in an XML Schema Task 2: Identify the …to be grouped. (Contd.) Result The various elements required to store customer details can be grouped as follows: ADDRESS and PHONE: ® Sincethese elements are used in RESIDENCE as well as OFFICE elements, these elements can be grouped together as ADDPHONE. ® Thisgroup can then be reused within the declaration of the RESIDENCE and OFFICE elements. ©NIIT eXtensible Markup Language/Lesson 4/Slide 10 of 28
  • 11. Creating Groups of Elements and Attributes in an XML Schema Task 2: Identify the … to be grouped. (Contd.) OFFICE and RESIDENCE: ® Theseelements can be grouped together to ensure that only one of them is used for each occurrence of the CUSTOMER element. ©NIIT eXtensible Markup Language/Lesson 4/Slide 11 of 28
  • 12. Creating Groups of Elements and Attributes in an XML Schema 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: sequence group choice all attributeGroup ©NIIT eXtensible Markup Language/Lesson 4/Slide 12 of 28
  • 13. Creating Groups of Elements and Attributes in an XML Schema Task 3: Identify a mechanism …in a schema. (Contd.) The sequence Element The sequence element helps you ensure that elements declared within the opening and closing tags of this element appear in a specific order. ©NIIT eXtensible Markup Language/Lesson 4/Slide 13 of 28
  • 14. Creating Groups of Elements and Attributes in an XML Schema Task 3: Identify a mechanism …in a schema. (Contd.) The group Element In XSD, a set of elements can be grouped together by a common name and incorporated into a complex data type. Grouping of elements is beneficial when you want a set of related elements to be referred by a common name. ©NIIT eXtensible Markup Language/Lesson 4/Slide 14 of 28
  • 15. Creating Groups of Elements and Attributes in an XML Schema Task 3: Identify a mechanism … in a schema. (Contd.) The following is the syntax for declaring a group element: group maxOccurs=nonNegetiveInteger | unbounded minOccurs=nonNegetiveInteger name=NCName ref=QName /group ©NIIT eXtensible Markup Language/Lesson 4/Slide 15 of 28
  • 16. Creating Groups of Elements and Attributes in an XML Schema Task 3: Identify a mechanism … in a schema. (Contd.) The following table describes the attributes of the group element: Attribute Description maxOccurs Used 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. minOccurs Used 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. ©NIIT eXtensible Markup Language/Lesson 4/Slide 16 of 28
  • 17. Creating Groups of Elements and Attributes in an XML Schema Task 3: Identify a mechanism … in a schema. (Contd.) Attribute Description name Used to assign a name for the group element. The name assigned to the group must not contain any colon. ref Used to refer to a group in a complex type element. ©NIIT eXtensible Markup Language/Lesson 4/Slide 17 of 28
  • 18. Creating Groups of Elements and Attributes in an XML Schema Task 3: Identify a mechanism … in a schema. (Contd.) The choice Element XSD enables you to specify alternative options by using the choice element. The choice element allows only one of the elements contained in the group to be present within the parent element. ©NIIT eXtensible Markup Language/Lesson 4/Slide 18 of 28
  • 19. Creating Groups of Elements and Attributes in an XML Schema Task 3: Identify a mechanism … in a schema. (Contd.) The syntax for declaring a choice element: choice id=ID maxOccurs=nonNegativeInteger| unbounded minOccurs=nonNegativeInteger / choice In the above syntax, id, maxOccurs, and minOccurs are the attributes of the choice element. These attributes are similar to the attributes of the group element mentioned earlier. ©NIIT eXtensible Markup Language/Lesson 4/Slide 19 of 28
  • 20. Creating Groups of Elements and Attributes in an XML Schema Task 3: Identify a mechanism … in a schema. (Contd.) The all Element 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. The syntax for using the all element: all maxOccurs=positiveInteger minOccurs=0|1 /all In the above syntax, the maxOccurs and minOccurs attributes have the same meaning as the maxOccurs and minOccurs elements of the group element. ©NIIT eXtensible Markup Language/Lesson 4/Slide 20 of 28
  • 21. Creating Groups of Elements and Attributes in an XML Schema Task 3: Identify a mechanism … in a schema. (Contd.) The attributeGroup Element XSD also enables you to group attributes that can be reused with different elements. You can group attributes by using the attributeGroup element. ©NIIT eXtensible Markup Language/Lesson 4/Slide 21 of 28
  • 22. Creating Groups of Elements and Attributes in an XML Schema Task 3: Identify a mechanism … in a schema. (Contd.) The syntax of the attributeGroup element: attributeGroup attribute1 attribute2 : /attributeGroup In the above syntax, attribute1 and attribute2 are the declaration statements of the various attributes that are to be grouped using the attributeGroup element. ©NIIT eXtensible Markup Language/Lesson 4/Slide 22 of 28
  • 23. Creating Groups of Elements and Attributes in an XML Schema Task 3: Identify a mechanism … in a schema. (Contd.) Result In the given scenario, you need to use the following XSD elements: To group the ADDRESS and PHONE elements under a common name, you need to use the group element of XSD. 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. ©NIIT eXtensible Markup Language/Lesson 4/Slide 23 of 28
  • 24. Creating Groups of Elements and Attributes in an XML Schema 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. ©NIIT eXtensible Markup Language/Lesson 4/Slide 24 of 28
  • 25. Creating Groups of Elements and Attributes in an XML Schema 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. ©NIIT eXtensible Markup Language/Lesson 4/Slide 25 of 28
  • 26. Creating Groups of Elements and Attributes in an XML Schema 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. ©NIIT eXtensible Markup Language/Lesson 4/Slide 26 of 28
  • 27. Creating Groups of Elements and Attributes in an XML Schema Summary In this lesson, you learned that: You can group elements and attributes using the following elements: 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. 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. ©NIIT eXtensible Markup Language/Lesson 4/Slide 27 of 28
  • 28. Creating Groups of Elements and Attributes in an XML Schema Summary (Contd.) choice: Allows you to specify that only one of the specified set of elements can be used at a time. all: Allows you to create a group of elements that can be used in any sequence within the parent element. attributeGroup: Allows you to create a group of attributes that can be reused in different elements. ©NIIT eXtensible Markup Language/Lesson 4/Slide 28 of 28