Mega Code Archive

 
Categories / XML Tutorial / XML Schema
 

You dont have to name every custom type

If you're just going to use a type once, you can omit the cross reference between the element and the type. The only difference between an anonymous type and a named type is that a named type can be used more than once.  whereas the anonymous type can only be used for the element in which it is contained. <?xml version="1.0"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"   targetNamespace="http://www.rntsoft.com" xmlns="http://www.rntsoft.com"   elementFormDefault="qualified">   <xsd:element name="zipcode">     <xsd:simpleType>       <xsd:restriction base="xsd:string">         <xsd:pattern value="\d{5}(-\d{4})?" />       </xsd:restriction>     </xsd:simpleType>   </xsd:element> </xsd:schema>