I have an xml file that will contain a number of articles details.
So far I've created the XML and XSD - here's the XSD:
<xs:simpleType name="ArticleKey">
<xs:restriction base="xs:string">
<xs:enumeration value="Key1" />
<xs:enumeration value="Key2" />
</xs:restriction>
</xs:simpleType>
<xs:element name="Articles">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="Article">
<xs:complexType>
<xs:sequence>
<xs:element name="Key" type="ArticleKey" />
<xs:element name="Title" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
I've also manually created the class object:
public class Article
{
public ArticleKey Key { get; set; }
public string Title { get; set; }
}
In order to do this I've also had to create the enum 'ArticleKey' separately like this:
public enum ArticleKey
{
Key1,
Key2
}
However, this obviously leads to the maintenance of duplicate enum values in the XSD and as a standalone enum.
Is there a way to link the two and avoid the maintenance issue or is this as easy as it gets?