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

TOOLS YOU CAN USE

advertisement
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

- 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
- Simple Web Syndication with RSS 2.0
- Java UI Design with an IDE

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



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