我有一个xsd文件,如下所示: xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"xs:element name="Configurations"xs:complexTypexs:sequencexs:element maxOccurs="unbo
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="Configurations"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" name="Schema"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" name="Table"> <xs:complexType> <xs:sequence> <xs:element maxOccurs="unbounded" name="Key"> <xs:complexType> <xs:sequence> <xs:element name="Column" maxOccurs="unbounded"> <xs:complexType> <xs:attribute name="Name" type="xs:string" use="required" /> <xs:attribute name="Value" type="xs:string" use="required" /> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute name="Name" type="xs:string" use="required" /> <xs:attribute name="Value" type="xs:string" use="required" /> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute name="Name" type="xs:string" use="required" /> </xs:complexType> </xs:element> </xs:sequence> <xs:attribute name="Name" type="xs:string" use="required" /> <xs:attribute name="ConnectionString" type="xs:string" use="required" /> </xs:complexType> </xs:element> </xs:sequence>
我只是无法弄清楚如何为Schema元素的Name属性创建一个xs:enumeration,这样只需要为该属性使用几个指定的值.我对xsd不擅长,有点帮助会很感激:)
如果要为所有Name属性重用受限类型,请在根级别添加simpleType:<xs:simpleType name="Name_type"> <xs:restriction base="xs:string"> <xs:enumeration value="Foo" /> <xs:enumeration value="Bar" /> <xs:enumeration value="Baz" /> </xs:restriction> </xs:simpleType>
然后将其作为Name属性的类型引用:
<xs:attribute name="Name" type="Name_type" use="required" />