OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Key and Keyref not working properly

[ Lists Home | Date Index | Thread Index ]

Hi All,
       I'm using key and keyref system to implement Primary and Foreign Key
relationships. I have tried everything; I'm using Apache Xerecs to validate
it. If I can implement the 'refDID' attribute in Employee to reference the
'DID' attribute in Division, I can do the rest myself. Any suggestions most
appreciated. Please have a look at the files inserted with my email. It will
not catch the deliberate errors I have introduced.  

Thanks Marco Mastrocinque
   
    
<?xml version="1.0" encoding="UTF-8"?>
<companyInformationSystem xmlns="http://www.myexample/companyInformationSystem"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; xsi:schemaLocation="http://www.myexample/companyInformationSystem
company.xsd">
	<Divisions>
		<Division DID="Mar">
			<DName>Marketing</DName>
			<Location>10th Floor - D Block</Location>
		</Division>
		<Division DID="Wmd">
			<DName>Research and Development</DName>
			<Location>12th Floor - A Block</Location>
		</Division>
	</Divisions>
	<Employess>
		<Employee EID="S12345" refDID="Marr">
			<ENAME>Marco Mastrocinque</ENAME>
			<OFFICE>1204</OFFICE>
			<BIRTHDATE>07061970</BIRTHDATE>
			<SALARY>650000</SALARY>
		</Employee>
		<Employee EID="XXXXXX" refDID="xxx">
			<ENAME>John Smith</ENAME>
			<OFFICE>12th Floor - A Block</OFFICE>
			<BIRTHDATE>07011969</BIRTHDATE>
			<SALARY>50000</SALARY>
		</Employee>
	</Employess>
	<Projects>
		<Project PID="M34" refDID="Mar">
			<PNAME>Just Jeans commercial</PNAME>
			<BUDGET>650000</BUDGET>
		</Project>
	</Projects>
	<Assigns>
		<Assign refDID="Mar" refEID="S12345">
			<HOURS>0012</HOURS>
		</Assign>
	</Assigns>
</companyInformationSystem>
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"; xmlns="http://www.myexample/companyInformationSystem"; xmlns:c="http://www.myexample/companyInformationSystem"; targetNamespace="http://www.myexample/companyInformationSystem"; elementFormDefault="qualified">
	<!--The root element companyIformationSystem -->
	<xs:element name="companyInformationSystem">
		<xs:annotation>
			<xs:documentation>This is the root element of the XML file. Assignment done by Marco Mastrocinque (s8812209), Bill Kascamanidis (s5391490) and Alex Filip (s4035542).</xs:documentation>
		</xs:annotation>
		<xs:complexType>
			<xs:sequence>
				<!--The first major subgroup Divisions -->
				<xs:element name="Divisions">
					<xs:complexType>
						<xs:sequence>
							<!--The subgroup Division -->
							<xs:element ref="Division" maxOccurs="unbounded"/>
						</xs:sequence>
					</xs:complexType>
					<!--Declare DID as unique -->
					<!--This part part works -->
					<xs:unique name="divisionIDNumber">
						<xs:selector xpath="c:Division"/>
						<xs:field xpath="@DID"/>
					</xs:unique>
				</xs:element>
				<!--The second major subgroup Employess-->
				<xs:element name="Employess">
					<xs:complexType>
						<xs:sequence>
							<!--The subgroup Employee-->
							<xs:element ref="Employee" maxOccurs="unbounded"/>
						</xs:sequence>
					</xs:complexType>
					<!--Declare the combination of EID and refDID is unique -->
					<!--This part works -->
					<xs:unique name="employeeEIDandrefDID">
						<xs:selector xpath="c:Employee"/>
						<xs:field xpath="@EID"/>
					</xs:unique>
					<!--This is where you reference the DID attribute (Foreign  Key) in the Division subgroup  -->
					<xs:keyref name="RefEmployeeToDivision" refer="KeyEmployeeByDivisionID">
						<xs:selector xpath="c:Employees/c:Employee"/>
						<xs:field xpath="@refDID"/>
					</xs:keyref>
					<!-- The Primary Key the DID attribute in the Employee subgroup -->
					<xs:key name="KeyEmployeeByDivisionID">
						<xs:selector xpath="c:Divisions/c:Division"/>
						<xs:field xpath="@DID"/>
					</xs:key>
				</xs:element>
				<!--The third major subgroup Projects -->
				<xs:element name="Projects">
					<xs:complexType>
						<xs:sequence>
							<!--The subgroup Project -->
							<xs:element ref="Project" maxOccurs="unbounded"/>
						</xs:sequence>
					</xs:complexType>
				</xs:element>
				<!--This is the fouth and major subgroup Assigns -->
				<xs:element name="Assigns">
					<xs:complexType>
						<xs:sequence>
							<xs:element ref="Assign" maxOccurs="unbounded"/>
						</xs:sequence>
					</xs:complexType>
				</xs:element>
			</xs:sequence>
		</xs:complexType>
	</xs:element>
	<!--This is the Division subgroup -->
	<xs:element name="Division">
		<xs:complexType>
			<xs:sequence>
				<xs:element name="DName" type="xs:string"/>
				<xs:element name="Location" type="xs:string"/>
			</xs:sequence>
			<xs:attribute name="DID" type="xs:string" use="required"/>
		</xs:complexType>
	</xs:element>
	<!--This is the Employee subgroup -->
	<xs:element name="Employee">
		<xs:complexType>
			<xs:sequence>
				<xs:element name="ENAME" type="xs:string"/>
				<xs:element name="OFFICE" type="xs:string"/>
				<xs:element name="BIRTHDATE" type="xs:string"/>
				<xs:element name="SALARY" type="xs:integer"/>
			</xs:sequence>
			<xs:attribute name="EID" type="xs:string" use="required"/>
			<xs:attribute name="refDID" type="xs:string" use="required"/>
		</xs:complexType>
	</xs:element>
	<!--This is the Project subgroup -->
	<xs:element name="Project">
		<xs:complexType>
			<xs:sequence>
				<xs:element name="PNAME" type="xs:string"/>
				<xs:element name="BUDGET" type="xs:integer"/>
			</xs:sequence>
			<xs:attribute name="PID" type="xs:string" use="required"/>
			<xs:attribute name="refDID" type="xs:string" use="required"/>
		</xs:complexType>
	</xs:element>
	<!--This is the Assign subgroup -->
	<xs:element name="Assign">
		<xs:complexType>
			<xs:sequence>
				<xs:element name="HOURS" type="xs:integer"/>
			</xs:sequence>
			<xs:attribute name="refDID" type="xs:string" use="required"/>
			<xs:attribute name="refEID" type="xs:string" use="required"/>
		</xs:complexType>
	</xs:element>
</xs:schema>




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS