XML
  Home arrow XML arrow Page 3 - One-One, One-Many and Many-Many Relations ...
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

One-One, One-Many and Many-Many Relations in XML Schema
By: Jagadish Chaterjee
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 9
    2006-04-24

    Table of Contents:
  • One-One, One-Many and Many-Many Relations in XML Schema
  • Implementing a “One to One” relation in XML Schema: schema explained
  • Implementing a “One to One” relation in XML Schema: a sample XML document
  • Implementing a “One to Many” relation in XML Schema: the schema
  • Implementing a “One-Many” relation in XML Schema: a sample XML document
  • Implementing a Many to Many relation in XML Schema: the 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


    One-One, One-Many and Many-Many Relations in XML Schema - Implementing a “One to One” relation in XML Schema: a sample XML document


    (Page 3 of 6 )

    In the previous section, I defined an XML Schema to enforce a one to one relation in between two element hierarchies.  The following would be an XML document sample for the previously defined XML Schema.

    <?xml version="1.0" encoding="utf-8"?>
    <Organization>
          <Employee>
                <PersonalDetails>
                      <Empno>1001</Empno>
                      <FirstName>Jagadish</FirstName>
                      <LastName>Chatarji</LastName>
                      <DOB>1978-06-25</DOB>
                </PersonalDetails>
                <AddressDetails>
                      <Empno>1001</Empno>
                      <Street>13-2-26, Nallam vari thota,
    Gunupudi</Street>
                      <City>Bhimavaram</City>
                      <ZIP>534201</ZIP>
                </AddressDetails>
          </Employee>
          <Employee>
                <PersonalDetails>
                      <Empno>1002</Empno>
                      <FirstName>Winner</FirstName>
                      <LastName></LastName>
                      <DOB>1985-09-08</DOB>
                </PersonalDetails>
                <AddressDetails>
                      <Empno>1002</Empno>
                      <Street>some address</Street>
                      <City>some city</City>
                      <ZIP>some zip</ZIP>
                </AddressDetails>
          </Employee>
    </Organization>

    The above XML document is error free, as the values in the “Empno” element of “AddressDetails” exist in the “Empno” element of “PersonalDetails.”  Try to change “1002” (in “AddressDetails”) to “1003” (which does not exist in “PersonalDetails”).  The XML document becomes invalid during parsing!

    There is another issue to remember about the “Employee” element.  I just meant it to separate the employee details only for the sake of explanation.  It would be more practical if we remove “Employee” and directly have “PersonalDetails” and “AddressDetails” under the root element “Organization.”

    More XML Articles
    More By Jagadish Chaterjee


       · Hello guys, this is another extension to the XML Schema series. Enjoy it.
     

    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 3 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek