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"?>
<Street>13-2-26, Nallam vari thota, Gunupudi</Street>
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.”