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

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
  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

Designing Your own XML Schema: Learn the Essentials - XML Schema: a simple practical example
(Page 4 of 6 )

Since you understand some basics about XML schema by now, we should extend our discussion to a more practical example.  Let us have a look at the following XML schema now:

<?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:documentation>Contains All Employee information</xs:documentation>
                        <xs:element name="Employee">
                                          <xs:element name="ID" type="xs:string"/>
                                          <xs:element name="Name" type="xs:string"/>
                                          <xs:element name="Age" type="xs:int"/>

Now you can see that I extended my previous example to define the “complextype.”  According to the above example, the document root element would be “Employees.”  The element “Employees” internally contains another element, “Employee.”  And finally, the element “Employee” internally contains three more elements: “ID,” “Name” and “Age.”

You should observe that “ID,” “Name” and “Age” are defined with “simple types” rather than with “complex types.”  The only complex elements are “Employees” and “Employee.”

Now, how would an XML document look when made to conform to the above XML Schema?  The following would be a sample XML document which conforms to the XML Schema above.

<?xml version="1.0" encoding="UTF-8"?>
<Employees xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="C:\Employees.xsd">

blog comments powered by Disqus

- 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 

Developer Shed Affiliates


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