API v0.5/XSD

From OpenStreetMap Wiki
Jump to: navigation, search

This is an attempt to create an XSD (XML Schema) defining the format of .osm files and responses from the 'map' call. This may be old and out of date. There are two different XSDs, both created back in 2008 which was while we were running API v0.5. In fact this was created based upon API v0.5/DTD, the equivalent definition in DTD format. For more XSDs and work on create more up-to-date definitions, see XSD

Dspies version

User:Dspies appears to have created this in June 2008. Some more notes on the Talk:API v0.5/XSD page.

 <?xml version="1.0" encoding="utf-8"?>
 <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
   <xs:element name="osm" type="T_osm" />
   <xs:complexType name="T_osm">
     <xs:sequence>
       <xs:element minOccurs="0" maxOccurs="unbounded" name="bound" type="T_bound" />
       <xs:choice minOccurs="0" maxOccurs="unbounded">
         <xs:element name="node" type="T_node" />
         <xs:element name="way" type="T_way" />
         <xs:element name="relation" type="T_relation" />
       </xs:choice>
     </xs:sequence>
     <xs:attribute fixed="0.5" name="version" type="xs:decimal" use="required" />
     <xs:attribute name="generator" type="xs:string" use="required" />
   </xs:complexType>
   <xs:complexType name="T_node">
     <xs:sequence>
       <xs:element minOccurs="0" maxOccurs="unbounded" name="tag" type="T_tag" />
     </xs:sequence>
     <xs:attribute name="id" type="xs:unsignedLong" use="required" />
     <xs:attribute name="timestamp" type="xs:dateTime" use="optional" />
     <xs:attribute name="visible" type="xs:boolean" use="optional" />
     <xs:attribute name="user" type="xs:string" use="optional" />
     <xs:attribute name="lat" type="xs:float" use="required" />
     <xs:attribute name="lon" type="xs:float" use="required" />
   </xs:complexType>
   <xs:complexType name="T_way">
     <xs:sequence>
       <xs:element minOccurs="0" maxOccurs="unbounded" name="tag" type="T_tag" />
       <xs:element name="nd" type="T_nd" />
       <xs:element minOccurs="0" maxOccurs="unbounded" name="tag" type="T_tag" />
       <xs:element name="nd" type="T_nd" />
       <xs:choice minOccurs="0" maxOccurs="unbounded">
         <xs:element name="nd" type="T_nd" />
         <xs:element name="tag" type="T_tag" />
       </xs:choice>
     </xs:sequence>
     <xs:attribute name="id" type="xs:unsignedLong" use="required" />
     <xs:attribute name="user" type="xs:string" use="optional" />
     <xs:attribute name="timestamp" type="xs:dateTime" use="optional" />
     <xs:attribute name="visible" type="xs:boolean" use="optional" />
   </xs:complexType>
   <xs:complexType name="T_relation">
     <xs:choice minOccurs="1" maxOccurs="unbounded">
       <xs:element name="member" type="T_member" />
       <xs:element name="tag" type="T_tag" />
     </xs:choice>
     <xs:attribute name="user" type="xs:string" use="optional" />
     <xs:attribute name="timestamp" type="xs:dateTime" use="optional" />
     <xs:attribute name="visible" type="xs:boolean" use="optional" />
     <xs:attribute name="id" type="xs:unsignedLong" use="required" />
   </xs:complexType>
   <xs:complexType name="T_bound">
     <xs:attribute name="origin" type="xs:string" use="required" />
     <xs:attribute name="box" type="xs:string" use="required" />
   </xs:complexType>
   <xs:complexType name="T_nd">
     <xs:attribute name="ref" type="xs:unsignedLong" use="required" />
   </xs:complexType>
   <xs:complexType name="T_tag">
     <xs:attribute name="k" type="xs:string" use="required" />
     <xs:attribute name="v" type="xs:string" use="required" />
   </xs:complexType>
   <xs:complexType name="T_member">
     <xs:attribute name="role" type="xs:string" use="optional" />
     <xs:attribute name="ref" type="xs:unsignedLong" use="required" />
     <xs:attribute name="type" type="T_type" use="required" />
   </xs:complexType>
   <xs:simpleType name="T_type">
     <xs:restriction base="xs:string">
       <xs:enumeration value="node" />
       <xs:enumeration value="way" />
       <xs:enumeration value="relation" />
     </xs:restriction>
   </xs:simpleType>
 </xs:schema>


Christoph.Beckmann version

User:Christoph.Beckmann appears to have created this in October 2008. It's not clear what the difference is with the above

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
	version="0.5" targetNamespace="http://openstreetmap.org/osm" xmlns:osm="http://openstreetmap.org/osm">
	<xs:element name="osm" type="osm:osm"></xs:element>
	<xs:complexType name="bound">
		<xs:attribute name="origin" type="xs:string" use="required" />
		<xs:attribute name="box" type="xs:string" use="required" />
	</xs:complexType>
	<xs:complexType name="tag">
		<xs:attribute name="k" type="xs:string" use="required" />
		<xs:attribute name="v" type="xs:string" use="required" />
	</xs:complexType>
	<xs:complexType name="node">
		<xs:sequence>
			<xs:choice maxOccurs="unbounded" minOccurs="0">
				<xs:element type="osm:tag" name="tag"/>
			</xs:choice>
		</xs:sequence>
		<xs:attribute name="id" type="xs:string" use="required" />
		<xs:attribute name="lat" type="xs:string" use="required" />
		<xs:attribute name="lon" type="xs:string" use="required" />
		<xs:attribute name="visible" type="xs:string" />
		<xs:attribute name="user" type="xs:string" />
		<xs:attribute name="timestamp" type="xs:string" />
	</xs:complexType>
	<xs:complexType name="nd">
		<xs:attribute name="ref" type="xs:string" use="required" />
	</xs:complexType>
	<xs:complexType name="way">
		<xs:sequence>
			<xs:choice maxOccurs="unbounded" minOccurs="0">
				<xs:element type="osm:tag" name="tag" />
				<xs:element type="osm:nd" name="nd" />
			</xs:choice>
		</xs:sequence>
		<xs:attribute name="id" type="xs:string" use="required" />
		<xs:attribute name="visible" type="xs:string" />
		<xs:attribute name="user" type="xs:string" />
		<xs:attribute name="timestamp" type="xs:string" />
	</xs:complexType>
	<xs:complexType name="member">
		<xs:attribute name="type" use="required">
			<xs:simpleType>
				<xs:restriction base="xs:string">
					<xs:enumeration value="way" />
					<xs:enumeration value="node" />
					<xs:enumeration value="relation" />
				</xs:restriction>
			</xs:simpleType>
		</xs:attribute>
		<xs:attribute name="ref" type="xs:string" use="required" />
		<xs:attribute name="role" type="xs:string" />
	</xs:complexType>
	<xs:complexType name="relation">
		<xs:choice maxOccurs="unbounded">
			<xs:element type="osm:tag" name="tag" />
			<xs:element type="osm:member" name="member" />
		</xs:choice>
		<xs:attribute name="id" type="xs:string" use="required" />
		<xs:attribute name="visible" type="xs:string" />
		<xs:attribute name="user" type="xs:string" />
		<xs:attribute name="timestamp" type="xs:string" />
	</xs:complexType>
	<xs:complexType name="osm">
		<xs:sequence>
			<xs:element minOccurs="0" ref="bound" />
			<xs:choice maxOccurs="unbounded" minOccurs="0">
				<xs:element type="osm:node" name="node" />
				<xs:element type="osm:relation" name="relation" />
				<xs:element type="osm:way" name="way" />
			</xs:choice>
		</xs:sequence>
		<xs:attribute name="version" use="required">
			<xs:simpleType>
				<xs:restriction base="xs:string">
					<xs:enumeration value="0.5" />
				</xs:restriction>
			</xs:simpleType>
		</xs:attribute>
		<xs:attribute name="generator" type="xs:string" use="required" />
	</xs:complexType>
</xs:schema>