[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xml-dev
Subject:    [xml-dev] Creating a XML Schema from an existing Database - Part 2
From:       "Marco Mastrocinque" <mmfive () netspace ! net ! au>
Date:       2005-03-26 8:47:34
Message-ID: 20050326084737.7857710BCDA () mail ! netspace ! net ! au
[Download RAW message or body]

Hi All,
      Thanks for your previous comments; I'm still having implementation
issues with my XML Schema. I have attached the files to this email. I have a
number of questions:

1) In the Divisions subgroup each Division has unique identifying attribute
'DID', which has been declared to be unique. In the Employees subgroup each
employee belongs to a unique division, which done by the 'refDID.' This
should reference the DID attribute as being in a corresponding Division. It
does not seem to work, any suggestions?

 
2) Can the key & keyref system used to ensure uniqueness, when two parts to
be unique? Please see my files. An example with two attributes would be
nice. For example, from my files:

<Project PID="M34" refDID="Mar">
References the PID (declared to be unique); refDID references DID from the
Division attribute. 

<Assign refEID="Mar" refDID="M34">
References the refEID from the EID from the Employee attribute; refPID
references from the DID from the Division attribute. 


I'm using Apache Xerces to validate it. If I can't this part licked, I've
got it working. I been at it for a day, and made no headway. Any suggestions
most appreciated.

Thanks Marco Mastrocinque       
          

["company.xml" (text/xml)]

<?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>
	</Divisions>
	<Employess>
		<Employee EID="S12345" refDID="Mar">
			<ENAME>Marco Mastrocinque</ENAME>
			<OFFICE>1204</OFFICE>
			<BIRTHDATE>07061970</BIRTHDATE>
			<SALARY>650000</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>


["company.xsd" (text/xml)]

<?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>
					<!--Decalre DID as unique -->
					<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>
					<!--This is where you reference the DID attribute (Primary Key) in the Division \
subgroup  -->  <xs:keyref name="RefEmployeeToDivision" refer="KeyEmployeeByID">
						<xs:selector xpath="c:Divisions/c:Division"/>
						<xs:field xpath="c:Employee/@refDID"/>
					</xs:keyref>
					<xs:key name="KeyEmployeeByID">
						<xs:selector xpath="c:Employees/c:Employee"/>
						<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"/>
		</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"/>
			<xs:attribute name="refDID" type="xs:string"/>
		</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"/>
			<xs:attribute name="refDID" type="xs:string"/>
		</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"/>
			<xs:attribute name="refEID" type="xs:string"/>
		</xs:complexType>
	</xs:element>
</xs:schema>



-----------------------------------------------------------------
The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
initiative of OASIS <http://www.oasis-open.org>

The list archives are at http://lists.xml.org/archives/xml-dev/

To subscribe or unsubscribe from this list use the subscription
manager: <http://www.oasis-open.org/mlmanage/index.php>

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic