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!