Home arrow XML arrow Designing Your Own XML Schema: Indicators
XML

Designing Your Own XML Schema: Indicators


This is the fourth (and last) in this series of articles, which guides you in designing XML Schemas right from the basics without any hurdles. This part explains what indicators are and how to use them.

Author Info:
By: Jagadish Chaterjee
Rating: 5 stars5 stars5 stars5 stars5 stars / 9
March 27, 2006
TABLE OF CONTENTS:
  1. · Designing Your Own XML Schema: Indicators
  2. · The Choice indicator in XML Schema
  3. · The Sequence indicator in XML Schema
  4. · The maxOccurs and minOccurs indicators in XML Schema
  5. · Groups in XML Schema
  6. · Attribute Groups in XML Schema

print this article
SEARCH DEVARTICLES

Designing Your Own XML Schema: Indicators
(Page 1 of 6 )

If you are new to XML Schema, I strongly suggest you to go through my first article in the same series, which you can find right here

The All indicator in XML Schema

Indicators? What are they?

Indicators are specially used to control the occurrences of elements in different orders.  Sometimes, we may want certain elements to occur only once, or certain elements may not be in a particular order, or certain elements may not be necessary at all (optional) and so on.  We can handle these kinds of issues by using indicators.

One of them is the “All” indicator.  It is specially used to inform that the child elements of a parent element (of the complex type) can occur in any order and only once.  Let us consider the following schema:

<?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:sequence>
                  <xs:element name="Employee" >
                        <xs:complexType>
                              <xs:all>
                                    <xs:element name="ID"
 type="xs:string" />
                                    <xs:element name="Name"
 type="xs:string" />
                              </xs:all>
                        </xs:complexType>
                  </xs:element>
            </xs:sequence>
      </xs:complexType>
      <xs:key name="PK_Employee_ID">
            <xs:selector xpath=".//Employee" />
            <xs:field xpath="ID" />
      </xs:key>
  </xs:element>
</xs:schema>



The most important fragment to concentrate on is the following:

 

<xs:element name="Employee" >
        <xs:complexType>
              <xs:all>
                    <xs:element name="ID" type="xs:string" />
                    <xs:element name="Name" type="xs:string" />
              </xs:all>
        </xs:complexType>
  </xs:element>

The above specifies that the “Employee” element mainly contain “ID” and “Name” elements, which can occur in any order and must exist.


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