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

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -