Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Schema Simple Type Union 1

Status
Not open for further replies.

Frink

Programmer
Mar 16, 2001
798
GB
Hallo,

I want to specify a Latitude as a simple type, which I do as follows:
Code:
  <xs:simpleType name="csecLatitude">
    <xs:union memberTypes="csecLatitude00To89 csecLatitude90"/>
  </xs:simpleType>
  <xs:simpleType name="csecLatitude00To89">
    <xs:restriction base="xs:string">
      <xs:pattern value="[0-8][0-9] [0-5][0-9].[0-5][0-9] [NS]"/>
    </xs:restriction>
  </xs:simpleType>
  <xs:simpleType name="csecLatitude90">
    <xs:restriction base="xs:string">
      <xs:pattern value="90 00.00 [NS]"/>
    </xs:restriction>
  </xs:simpleType>

It's not quite as simple as a single pattern as '90 59.59' is not allowed, so I've used a union to allow the North and South Poles.
Is there any way of containing csecLatitude00To89 and csecLatitude90 within csecLatitude, as they don't make sense on their own, so would be best to hide them.

- Frink
 
Use or operator? Like this.
[tt]
<xs:simpleType name="csecLatitude">
<xs:restriction base="xs:string">
<xs:pattern value="(90 00.00|[0-8][0-9] [0-5][0-9].[0-5][0-9]) [NS]"/>
</xs:restriction>
</xs:simpleType>
[/tt]
 
Amendment

Upon re-reading, I think you, and my above posting as well, have to further escape the "dot" separator to be 100% numeric latitude (otherwise 90 00x00 would validate as well which may not be discovered at the first instance with incomplete test set).
[tt]
<xs:simpleType name="csecLatitude">
<xs:restriction base="xs:string">
<xs:pattern value="(90 00[red]\[/red].00|[0-8][0-9] [0-5][0-9][red]\[/red].[0-5][0-9]) [NS]"/>
</xs:restriction>
</xs:simpleType>
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top