Creating Groups of Elements and Attributes in An XML Schema: Objectives
Creating Groups of Elements and Attributes in An XML Schema: Objectives
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
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
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.
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.
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.
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.