I was trying to create FK and PK in the XML schema, but it is showing an error in the featured code above. Is shows the message: src-resolve: Cannot resolve the name 'PkReportsTo' to a(n) 'identity constraint' component. [XSD]
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://www.ricardoterra.com.br"
elementFormDefault="qualified">
<xs:element name="employees">
<xs:complexType>
<xs:sequence>
<xs:element name="employee" maxOccurs="unbounded">
<xs:complexType>
<xs:all>
<xs:element name="firstName" type="xs:string"></xs:element>
<xs:element name="lastName" type="xs:string"></xs:element>
<xs:element name="extension">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="([x][1-9])\w+"></xs:pattern>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="email">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="([a-z])\w+(@)([a-z])\w+(.[a-z]+)*"></xs:pattern>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="officeCode" type="xs:string"></xs:element>
<xs:element name="jobTitle" type="xs:string"></xs:element>
<xs:element name="reportsTo" type="xs:integer" minOccurs="0">
</xs:element>
</xs:all>
<xs:attribute name="number" type="xs:integer"></xs:attribute>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:unique name="number">
<xs:selector xpath="employee"></xs:selector>
<xs:field xpath="@number"></xs:field>
</xs:unique>
<xs:key name="PkEmploye">
<xs:selector xpath="employee"/>
<xs:field xpath="@number"></xs:field>
</xs:key>
<xs:key name="PkReportsTo">
<xs:selector xpath="employee/reportsTo"></xs:selector>
<xs:field xpath="."></xs:field>
</xs:key>
<xs:keyref name="FKtoReportsToEmployee" refer="PkReportsTo">
<xs:selector xpath="employee"></xs:selector>
<xs:field xpath="@number"></xs:field>
</xs:keyref>
</xs:element>
</xs:schema>
I am with a error at the part of my code:
<xs:keyref name="FKtoReportsToEmployee" refer="PkReportsTo">
<xs:selector xpath="employee"></xs:selector>
<xs:field xpath="@number"></xs:field>
</xs:keyref>
I don't know why.
I think you want the target namespace of the schema to be
http://www.ricardoterra.com.brso useand that error is likely to go away.