Extending TourML

Charles Moad edited this page Sep 14, 2012 · 4 revisions

As an alternative to application profiles, you might want to formally extend the TourML specification in order to be able to include other XML Schemas. This is best demonstrated by example.

Note: You can see these complete examples at SampleTourMLExtension.xsd and SampleTourMLExtensionInstance.xml. For more information on extending XML Schemas refer to the w3schools reference.

Here is the TourML v1.0.0 specification for the StopType:

<xsd:complexType name="StopType">
  <xsd:sequence>
    <xsd:element name="Title" type="tourml:TitleType" minOccurs="0" maxOccurs="unbounded" />
    <xsd:element name="Description" type="tourml:DescriptionType" minOccurs="0" maxOccurs="unbounded" />
    <xsd:element name="AssetRef" type="tourml:AssetRefType" minOccurs="0" maxOccurs="unbounded" />
    <xsd:element name="PropertySet" type="tourml:PropertySetType" minOccurs="0" maxOccurs="1" />
  </xsd:sequence>
  <xsd:attribute ref="tourml:id" use="required" />
  <xsd:attribute ref="tourml:view" use="required" />
</xsd:complexType>

Let's say for a particular application we would like to add an optional GML:Point so we can specify a geographic location in which a Stop should be displayed on a map. We would need to create a new XML Schema which extends the existing StopType.

<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema targetNamespace="http://example.com/SampleTourMLExtension"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:tourml="http://tapintomuseums.org/TourML"
  xmlns:gml="http://www.opengis.net/gml"
  attributeFormDefault="qualified"
  elementFormDefault="qualified">

  <xsd:import namespace="http://tapintomuseums.org/TourML" schemaLocation="TourML.xsd" />
  <xsd:import namespace="http://www.opengis.net/gml" schemaLocation="http://schemas.opengis.net/gml/3.1.1/base/feature.xsd" />

  <xsd:complexType name="CustomStopType">
    <xsd:complexContent>
      <xsd:extension base="tourml:StopType">
        <xsd:sequence>
          <xsd:element ref="gml:Point" minOccurs="0" maxOccurs="1" />
        </xsd:sequence>
      </xsd:extension>
    </xsd:complexContent>
  </xsd:complexType>

</xsd:schema>

You can now create a new XML Schema instance using your extended TourML schema:

<?xml version="1.0" encoding="UTF-8"?>
<tourml:Tour xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:tourml="http://tapintomuseums.org/TourML"
  xmlns:sample="http://example.com/SampleTourMLExtension"
  xmlns:gml="http://www.opengis.net/gml"
  xsi:schemaLocation="http://tapintomuseums.org/TourML TourML.xsd
    http://example.com/SampleTourMLExtension SampleTourMLExtension.xsd"
  tourml:id="com.example.SampleTourMLExtension">

  <tourml:Stop xsi:type="sample:CustomStopType" tourml:view="geo-stop" tourml:id="geo-stop-1">
    <tourml:Title>Sample Geo Stop</tourml:Title>
    <gml:Point srsDimension="2" srsName="http://www.opengis.net/def/crs/EPSG/0/4326">
      <gml:pos>49.40 -123.26</gml:pos>
    </gml:Point>
  </tourml:Stop>

</tourml:Tour>
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.