Hi,

I am currently developing xsd in Visual Studio .net but I think the question may possibly be relevant still.

If I create a complex type (say myType1) with a key field. Then create subtypes (myType11, myType12 for example) which inherit myType1 using the extension semantic. Next I instantiate these types in my schema. Finally I want to reference the key of say myInstance11:myType11 from another part of the schema which I do with the keyref keyword.

In the schema view there is no complete link from the keyref element to the key element. This leads me to a couple of questions:
1. have I misunderstood the inheritance of xsd?
2. is there a promlem with the Visual Studio schema view tool
3. Am I misunderstanding the use of keys and keyrefs?

below is an example of what I am talking about:

<?xml version="1.0" encoding="utf-8" ?>
<xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/XMLSchema.xsd" xmlns:mns="http://tempuri.org/XMLSchema.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="root">
<xs:complexType>
<xs:sequence>
<xs:element name="element1" type="complexType11"></xs:element>
<xs:element name="element2">
<xs:complexType>
<xs:sequence />
<xs:attribute name="name" type="xs:string" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:key name="element1Key">
<xs:selector xpath=".//mns:element1" />
<xs:field xpath="@name" />
</xs:key>
<xs:keyref name="element1element2" refer="element1Key">
<xs:selector xpath=".//mns:element2" />
<xs:field xpath="@name" />
</xs:keyref>
</xs:element>
<xs:complexType name="complexType1">
<xs:sequence />
<xs:attribute name="name" type="xs:string" />
<xs:attribute name="value" type="xs:string" />
</xs:complexType>
<xs:complexType name="complexType11">
<xs:complexContent>
<xs:extension base="complexType1">
<xs:sequence></xs:sequence>
<xs:attribute name="value2" type="xs:string" />
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>

Many thanks in advance
Ian