SQL Server Developer Center > SQL Server Forums > Database Design > How to override a Xml Schema element?

Unanswered How to override a Xml Schema element?

  • Wednesday, June 23, 2010 12:01 PM
     
     

    In the following sample:

    • A employeeID always is a personID, but not every personID is a employeeeID.
    • employeeID is a restriction of personID.
    • A Empolyee always is a Person, but not every Person is a Employee.
    • Employee is a extension from Person.
    • A employeeID must be validated as "employeeID", but also, must be acessible as a "personID".

    The following code generates the following validation error in the ID declaration of the Employee type: "Elements with the same name and in the same scope must have the same type."

    Help!

     

     

    	<xs:simpleType name="PersonID">
    		<xs:restriction base="xs:token"></xs:restriction>
    	</xs:simpleType>
    
    	<xs:simpleType name="EmployeeID">
    			<xs:restriction base="PersonID"></xs:restriction>
    	</xs:simpleType>
    
    	<xs:complexType name="Person">
    		<xs:sequence>
    			<xs:element name="ID"
    						type ="PersonID"></xs:element>
    		</xs:sequence>
    	</xs:complexType>
    
    	<xs:complexType name="Employee">
    		<xs:complexContent>
    			<xs:extension base="Person">
    				<xs:sequence>
    					<xs:element name="ID"
    								type="EmployeeID"
    								></xs:element>
    				</xs:sequence>
    			</xs:extension>
    		</xs:complexContent>
    	</xs:complexType>