
Enable IntelliSense for HTML and XML Documents #32
Chapter 4, Customizing Visual Studio
|
125
HACK
<xsd:complexType name="AlphaControlDef">
<xsd:attribute name="Alpha" type="xsd:boolean" />
<xsd:attribute name="Delta" type="xsd:double" />
<xsd:attribute name="Gamma">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:enumeration value="ValueOne" />
<xsd:enumeration value="ValueTwo" />
<xsd:enumeration value="ValueThree" />
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
<xsd:attributeGroup ref="BaseClassAttributes" />
</xsd:complexType>
This type represents a few simple attributes that demonstrate much of the
flexibility of the schema. Our element contains three attributes and also a
group of attributes defined elsewhere. Both Alpha and Delta have simple
xsd
types set, and Visual Studio will simply prompt you to enter a value of the
appropriate type, providing a list of choices where applicable (such as True/
False with Boolean attributes).
The attribute definition for Gamma defines a custom
simpleType, which
allows us to enhance the built-in
xsd types. We start with a string, but we
add a restriction to it. When we edit this type in Visual Studio, this restric-
tion tells Visual Studio that the value for Gamma can only be one of the
options listed in the enumeration, so it will prompt the developer to pick
one of them, as shown in Figure 4-22.
XML schemas provide a great many options ...