<?xml version="1.0" encoding="UTF-8"?>
<!-- 
  Config file schema 1.0
  
  Yahoo! Blueprint
  Copyright 2007-2008 Yahoo! Inc. All rights reserved.
  
  This file contains the schema for the config.xml file that must be packaged
  with a mobile widget. It contains various metadata and establishes requirements
  for running in a particular environment.
  
  Changes:

  04-Jan-2008 - edv - Removed base, type. Added choice between widget, snippet. Each choice
                      has its own way of expressing the URL (base or href). Finalized namespace.
  08-Feb-2008 - edv - Added icon element. Starting adding some documentation.
  04-Mar-2008 - edv - Enforce at least one shortcut item must be present.
  07-Mar-2008 - edv - Added new required attribute for email.
  14-Mar-2008 - edv - Added way to reference localized labels for shortcut items.
  31-Mar-2008 - edv - Added secure-port
  04-Apr-2008 - edv - Make sure author is required.
  09-May-2008 - edv - Added security section. Moved requirements out to root for readability.
  27-May-2008 - edv - Revised snippet element to allow for settings.
  27-May-2008 - edv - Added VersionNumberType and made widget version and engine-version use it.
  06-Oct-2008 - ts  - Removed dot from valid ID characters ad corrected a documentation typo (hypen -> hyphen)
  07-Oct-2008 - ts  - Removed all snippet occurrences
-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
  targetNamespace="http://mobile.yahoo.com/widgets/schema/1.0/config/"
  xmlns="http://mobile.yahoo.com/widgets/schema/1.0/config/">

  <xs:element name="config">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="1" maxOccurs="1" name="title" type="xs:string">
          <xs:annotation>
            <xs:documentation> The title of the widget. This is displayed in the Widget
              Gallery as well as in the title bars of Widgets. Required. </xs:documentation>
          </xs:annotation>
        </xs:element>

        <xs:element minOccurs="1" maxOccurs="1" name="version" type="VersionNumberType">
          <xs:annotation>
            <xs:documentation> Required version of your widget. It should be in the form 1[.x[.x]],
              e.g 1.0, 1.0.1, 2.1.3. </xs:documentation>
          </xs:annotation>
        </xs:element>

        <xs:element minOccurs="1" maxOccurs="1" name="identifier" type="WidgetIDType">
          <xs:annotation>
            <xs:documentation> The widget identifier can be from 4 to 20 characters in length. It is
              comprised of alphanumeric characters or a hyphen(-). It must start with an
              alphanumeric character.</xs:documentation>
          </xs:annotation>
        </xs:element>

        <xs:element minOccurs="0" name="description" type="xs:string">
          <xs:annotation>
            <xs:documentation> This is used as a short description for your Widget. It is optional.
              It is not the same description as that in the gallery.xml file, which is used as your
              verbose description of your widget. </xs:documentation>
          </xs:annotation>
        </xs:element>

        <xs:element name="icon" type="xs:string">
          <xs:annotation>
            <xs:documentation> This should contain the name of the image you wish to use for your
              icon. You do not need to put the suffix or extension. For example, "homer" is
              sufficient. Your images folder will look for an appropriate image file to use based on
              rules documented in the Blueprint Developer's Guide. </xs:documentation>
          </xs:annotation>
        </xs:element>

        <xs:element name="author">
          <xs:complexType mixed="true">
            <xs:attribute name="href" type="xs:anyURI"/>
            <xs:attribute name="organization"/>
            <xs:attribute name="email" type="email" use="required"/>
          </xs:complexType>
        </xs:element>

        <xs:element minOccurs="0" name="license">
          <xs:complexType mixed="true">
            <xs:attribute name="href" type="xs:anyURI"/>
          </xs:complexType>
        </xs:element>

        <xs:element ref="requirements" minOccurs="0"/>
        <xs:element ref="security" minOccurs="0"/>

        <xs:element ref="widget"/>

      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="requirements">
    <xs:complexType>
      <xs:sequence>
        <xs:element minOccurs="0" maxOccurs="1" name="engine-version" type="VersionNumberType"/>
        <xs:element minOccurs="0" maxOccurs="unbounded" name="device" type="xs:NMTOKEN"/>
        <xs:element minOccurs="0" maxOccurs="unbounded" name="platform">
          <xs:simpleType>
            <xs:restriction base="xs:NMTOKEN">
              <xs:enumeration value="go_client"/>
              <xs:enumeration value="go_html"/>
              <xs:enumeration value="xhtml"/>
            </xs:restriction>
          </xs:simpleType>
        </xs:element>

        <xs:element minOccurs="0" maxOccurs="unbounded" name="feature">
          <xs:simpleType>
            <xs:restriction base="xs:NMTOKEN">
              <xs:enumeration value="gps"/>
              <xs:enumeration value="camera"/>
              <xs:enumeration value="video"/>
              <xs:enumeration value="filesystem"/>
              <xs:enumeration value="3g"/>
            </xs:restriction>
          </xs:simpleType>
        </xs:element>

        <xs:element minOccurs="0" maxOccurs="1" name="minScreen">
          <xs:simpleType>
            <xs:restriction base="xs:NMTOKEN">
              <xs:enumeration value="s1"/>
              <xs:enumeration value="s2"/>
              <xs:enumeration value="s3"/>
              <xs:enumeration value="s4"/>
              <xs:enumeration value="s5"/>
            </xs:restriction>
          </xs:simpleType>
        </xs:element>

      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="security">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="allow-location" minOccurs="0">
          <xs:annotation>
            <xs:documentation> The allow-location element is required if your widget intends to use
              the location-chooser element in Blueprint. In 1.0, this also enforces that the user
              must be 18 years or older to use this feature. If not, your Widget will not be made
              available to them. If your widget does not announce you allow location, and your
              widget uses the location-chooser, your widget will NOT load or function. This security
              measure was implemented to address privacy concerns. In future releases, the
              location-chooser will instead just not allow fine granularity of location instead of
              blocking the widget page from loading. </xs:documentation>
          </xs:annotation>
          <xs:complexType/>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>

  <xs:element name="widget">
    <xs:complexType>
      <xs:sequence>
        <xs:element name="preview">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="icon" type="xs:anyURI"/>
              <xs:element ref="label"/>
            </xs:sequence>
          </xs:complexType>
        </xs:element>

        <xs:element name="shortcuts">
          <xs:complexType>
            <xs:sequence minOccurs="1" maxOccurs="unbounded">
              <xs:element name="item">
                <xs:complexType>
                  <xs:sequence>
                    <xs:element ref="label"/>
                    <xs:element name="href" type="xs:anyURI"/>
                  </xs:sequence>
                  <xs:attribute name="default" type="xs:boolean"/>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
      <xs:attribute name="base" type="xs:anyURI"/>
      <xs:attribute name="secure-port" type="xs:positiveInteger" use="optional"/>
    </xs:complexType>
  </xs:element>

  <xs:simpleType name="email">
    <!-- taken from XForms -->
    <xs:restriction base="xs:string">
      <xs:pattern
        value="([A-Za-z0-9!#-'\*\+\-/=\?\^_`\{-~]+(\.[A-Za-z0-9!#-'\*\+\-/=\?\^_`\{-~]+)*@[A-Za-z0-9!#-'\*\+\-/=\?\^_`\{-~]+(\.[A-Za-z0-9!#-'\*\+\-/=\?\^_`\{-~]+)*)?"
      />
    </xs:restriction>
  </xs:simpleType>

  <xs:element name="label">
    <xs:complexType mixed="true">
      <xs:attribute name="loc-string" type="xs:NMTOKEN"/>
    </xs:complexType>
  </xs:element>

  <xs:simpleType name="WidgetIDType">
    <xs:restriction base="xs:string">
      <xs:pattern value="[a-z,A-Z,0-9][a-z,A-Z,0-9,-]{3,19}"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="VersionNumberType">
    <!-- taken from XForms -->
    <xs:restriction base="xs:string">
      <xs:pattern
        value="[0-9]\.[0-9](\.[0-9])?"
      />
    </xs:restriction>
  </xs:simpleType>
  
  
</xs:schema>
