Home arrow XML arrow Page 3 - Designing Your own XML Schema: Learn the Essentials
XML

Designing Your own XML Schema: Learn the Essentials


This is the first article in a series which guides you in designing XML Schemas right from the basics without any hurdles.

Author Info:
By: Jagadish Chaterjee
Rating: 4 stars4 stars4 stars4 stars4 stars / 22
March 06, 2006
TABLE OF CONTENTS:
  1. · Designing Your own XML Schema: Learn the Essentials
  2. · XML Schema: beginning with the simplest way
  3. · XML Schema: the complex way
  4. · XML Schema: a simple practical example
  5. · XML Schema: a simple practical example continued
  6. · XML Schema: a more practical example

print this article
SEARCH DEVARTICLES

Designing Your own XML Schema: Learn the Essentials - XML Schema: the complex way
(Page 3 of 6 )

The previous section covered defining the schema in a very simple manner with simple data types.  Now, we need to extend this to “complex” types.

“Simple” types are generally used for defining simple XML structures of some standard data types.  As your schema grows with several other complicated structures (and might even be nested within them), the “simple” types may not be quite enough to handle the entire schema accurately.

Complicated structures generally include nested structures, relations between structures, attributes, links to other structures in external schemas, and so on.  All these complications cannot be handled by “simple” types at all.  This requires the  “complex” type of declarations.

Let us start with a tiny “complex” type XSD declaration:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
      <xs:element name="Employees">
            <xs:annotation>
                  <xs:documentation>Contains All Employee information</xs:documentation>
            </xs:annotation>
            <xs:complexType/>
      </xs:element>
</xs:schema>

The above defines a new root element, “Employees,” as a complex type (but doesn't yet define what type or how complex it is).  The “annotation” is generally used for documenting your definition.  Though it is optional, it is a good practice to maintain “documentation” with every definition.  This would also help other users (or consumers) of several other heterogeneous environments to understand your schema better.

Even though the above schema is not very useful, I just meant it for a simple example.  Let us now look into more practical scenarios.


blog comments powered by Disqus
XML ARTICLES

- Open XML Finally Supported by MS Office
- XML Features Added to Two Systems
- Using Regions with XSL Formatting Objects
- Using XSL Formatting Objects
- More Schematron Features
- Schematron Patterns and Validation
- Using Schematron
- Datatypes and More in RELAX NG
- Providing Options in RELAX NG
- An Introduction to RELAX NG
- Path, Predicates, and XQuery
- Using Predicates with XQuery
- Navigating Input Documents Using Paths
- XML Basics
- Introduction to XPath

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials