Complex Element vs. Simple Element

This section describes what is a complex element and how to declare different types of complex elements.

What is a simple element? A simple element is an XML element that does not have any attributes or any sub (child) elements. A simple element can be declared with a simple datatype.

What is a complex element? A complex element is an XML element that have at least one attribute, or at least one sub (child) element. A simple element can be declared with a complex datatype.

Rule 1. A complex element must be declared by an Element Declaration Component with a complex datatype.

Rule 2. A complex datatype must be defined by a Complex Type Definition Component.

Rule 3. The XML representation of a Complex Type Definition Component is a "complexType" element.

Rule 4. A "complexType" element must have "name" attribute, if it is used to define a named datatype.

Rule 5. A "complexType" element may have the following possible sub elements:

Combine with what learn from other chapters in this book, now we know that there are 7 different types of elements with different ways to declare them:

Tutorial examples will be provided on how to declare element for each of the 7 types listed above in other sections in this chapter.

Table of Contents

 About This Book

 Introduction to XML Schema

 XML Editor and Schema Processor - XMLPad

 Java API for XML Processing - JAXP

 JAXP - XML Schema (XSD) Validation

 Xerces2 Java Parser - Java API of XML Parsers

 Using Xerces2 Java APIs

 XML Schema Language - Basics

 Introduction of XSD Built-in Datatypes

 "string" and Its Derived Datatypes

 "decimal" and Its Derived Datatypes

 "dateTime" and Its Related Datatypes

 Miscellaneous Built-in Datatypes

 Facets, Constraining Facets and Restriction Datatypes

 "simpleType" - Defining Your Own Simple Datatypes

Complex Element Declaration

Complex Element vs. Simple Element

 Declaring Empty Elements

 Declaring Simple Elements

 Declaring Complex Elements with Simple Content

 Declaring Complex Elements with Attributes Only

 Declaring Complex Elements with Sub Elements Only

 Declaring Complex Elements with Attributes and Sub Elements

 Declaring Complex Elements with Attributes, Sub Elements & Text Content

 Using Shorthand for "complexContent" with "restriction"

 Identity-Constraints: unique, key and keyref

 Assertion as Custom Validation Rules

 XML Schema Location and Namespace in XML Documents

 Overriding Element Types in XML Documents

 Linking Multiple Schema Documents Together

 Glossary

 Archived Tutorials

 References

 Full Version in PDF/EPUB