Mega Code Archive

 
Categories / XML / XML Schema
 

String value based on pattern

File: Data.xml <?xml version="1.0"?> <target id="uuid:093a2da1-q345-739r"         xmlns="http://www.rntsoft.com"         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"         xsi:schemaLocation=                           "http://www.rntsoft.com                            Schema.xsd">          <location>                 <latitude>32.904237</latitude>                 <longitude>73.620290</longitude>                 <uncertainty units="meters">2</uncertainty>         </location> </target> File: Schema.xsd <?xml version="1.0" encoding="UTF-8"?> <schema xmlns="http://www.w3.org/2001/XMLSchema"             targetNamespace="http://www.rntsoft.com"             xmlns:mti="http://www.rntsoft.com"             elementFormDefault="qualified">     <element name="target">         <complexType>             <sequence>                 <element name="location" maxOccurs="unbounded">                     <complexType>                         <sequence>                             <element name="latitude" type="mti:latType"/>                             <element name="longitude" type="mti:lonType"/>                             <element name="uncertainty" type="mti:uncertaintyType"/>                         </sequence>                     </complexType>                 </element>             </sequence>             <attribute name="id" type="string" use="required"/>         </complexType>     </element>     <simpleType name="latType">         <restriction base="string">             <pattern value="[0-9]\.[0-9]{6}|[1-8][0-9]\.[0-9]{6}|90\.[0-9]{6}|-[0-9]\.[0-9]{6}|-[1-8][0-9]\.[0-9]{6}|-90\.[0-9]{6}"/>         </restriction>     </simpleType>     <simpleType name="lonType">         <restriction base="string">             <pattern value="[0-9]\.[0-9]{6}|[1-9][0-9]\.[0-9]{6}|1[0-7][0-9]\.[0-9]{6}|180\.[0-9]{6}|-[0-9]\.[0-9]{6}|-[1-9][0-9]\.[0-9]{6}|-1[0-7][0-9]\.[0-9]{6}|-180\.[0-9]{6}"/>         </restriction>     </simpleType>     <complexType name="uncertaintyType">         <simpleContent>             <extension base="nonNegativeInteger">                 <attribute name="units" use="required">                     <simpleType>                         <restriction base="string">                             <enumeration value="meters"/>                             <enumeration value="feet"/>                         </restriction>                     </simpleType>                 </attribute>             </extension>         </simpleContent>     </complexType> </schema>