Home arrow XML arrow Page 5 - One-One, One-Many and Many-Many Relations in XML Schema

TOOLS YOU CAN USE

advertisement
One-One, One-Many and Many-Many Relations in XML Schema - Implementing a “One-Many” relation in XML Schema: a sample XML document
(Page 5 of 6 )

In the previous section, I defined an XML Schema to enforce a simple 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 xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance
" xsi:noNamespaceSchemaLocation="C:\Documents and
Settings\Administrator\Desktop\Employees.xsd
">
      <dept>
            <Deptno>10</Deptno>
            <Dname>Accounting</Dname>
            <Loc>Dallas</Loc>
      </dept>
      <dept>
            <Deptno>20</Deptno>
            <Dname>Production</Dname>
            <Loc>New York</Loc>
      </dept>
      <Employee>
            <Empno>1001</Empno>
            <Ename>Jag</Ename>
            <Sal>2500</Sal>
            <Deptno>10</Deptno>
      </Employee>
      <Employee>
            <Empno>1002</Empno>
            <Ename>Win</Ename>
            <Sal>2600</Sal>
            <Deptno>20</Deptno>
      </Employee>
</Organization>

The above XML document is error free, as the values in the “deptno” element of “Employee” exist in the “deptno” element of “dept.”  Try changing “20” (in “Employee”) to “30” (which does not exist in “dept”).  The XML document becomes invalid during parsing!


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 11 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials