Mega Code Archive

 
Categories / XML Tutorial / XML Schema
 

Restrict the data type by restricting its attributes

<?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"   targetNamespace="http://www.rntsoft.com" xmlns="http://www.rntsoft.com"   elementFormDefault="qualified">   <xs:complexType name="tokenWithLangAndNote">     <xs:simpleContent>       <xs:extension base="xs:token">         <xs:attribute name="lang" type="xs:language" />         <xs:attribute name="note" type="xs:token" />       </xs:extension>     </xs:simpleContent>   </xs:complexType>   <xs:element name="title">     <xs:complexType>       <xs:simpleContent>         <xs:restriction base="tokenWithLangAndNote">           <xs:maxLength value="255" />           <xs:attribute name="lang">             <xs:simpleType>               <xs:restriction base="xs:language">                 <xs:enumeration value="en" />                 <xs:enumeration value="es" />               </xs:restriction>             </xs:simpleType>           </xs:attribute>         </xs:restriction>       </xs:simpleContent>     </xs:complexType>   </xs:element> </xs:schema>