xsd - specifying XML schema for a XML document for a particular string -
i had xsd follows
<xs:schema attributeformdefault="unqualified" elementformdefault="qualified" xmlns:xs="http://www.w3.org/2001/xmlschema"> <xs:element name="college"> <xs:complextype> <xs:sequence> <xs:element type="xs:string" name="name" maxoccurs="unbounded" minoccurs="1"/> </xs:sequence> </xs:complextype> </xs:element> </xs:schema> it must allow 2 values example abc , cbs allowed
<college> <name>abc</name> <name>abc</name> <name>cbs</name> </college> which should not allowed
<college> <name>abc</name> <name>abc</name> <name>cbs</name> <name>xyz</name> </college>
since have countable number of options can use enumeration restrict them. replace xs:element declaration this:
<xs:element name="name" maxoccurs="unbounded" minoccurs="1"> <xs:simpletype> <xs:restriction base="xs:string"> <xs:enumeration value="abc"/> <xs:enumeration value="cbs"/> </xs:restriction> </xs:simpletype> </xs:element>
Comments
Post a Comment