XML
  Home arrow XML arrow Page 7 - Designing Your own XML Schema: Restriction...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
XML

Designing Your own XML Schema: Restrictions and User Defined Types
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 5
    2006-03-20

    Table of Contents:
  • Designing Your own XML Schema: Restrictions and User Defined Types
  • Restrictions based on patterns in XML Schema
  • How to define your own simple type (user-defined data type) in XML Schema
  • Understanding the user-defined simple type in XML Schema
  • User-defined Simple Type with enumeration in XML Schema
  • Understanding the simple type with enumeration in XML Schema
  • User-defined Complex Type in XML Schema

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Designing Your own XML Schema: Restrictions and User Defined Types - User-defined Complex Type in XML Schema


    (Page 7 of 7 )

    In the previous sections, we dealt only with simple user-defined types.  Now, we shall deal with the user-defined complex type.

    Let us consider that I would like to define my own data type called “AddressType,” which holds Street, City and Zip elements.  After defining “AddressType,” I would like to use it with two elements, “ResAddress” (residential address) and “OffAddress” (Office Address) as part of the “Employee” definition.  The following listing of a complete XML Schema does the same:

    <?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" maxOccurs="unbounded">
              <xs:complexType>
                <xs:sequence>
                  <xs:element name="ID" type="xs:string">
                  </xs:element>
                  <xs:element name="Name" type="xs:string" />
                  <xs:element name="ResAddress" type="AddressType" />
                  <xs:element name="OffAddress" type="AddressType" />
                </xs:sequence>
              </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:complexType name="AddressType">
        <xs:sequence>
          <xs:element name="Street" type="xs:string" />
          <xs:element name="City" type="xs:string" />
          <xs:element name="zip" type="xs:string" />
        </xs:sequence>
      </xs:complexType>
    </xs:schema>

    Any comments, suggestions, feedback, bugs, errors are highly appreciated at jag_chat@yahoo.com


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · Hello, I extended the XML-Schema series. enjoy and don't hesitate to post, if you...
     

    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







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek