<?xml version="1.0" encoding="utf-8" ?> 
<xsd:schema elementFormDefault="qualified"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema">

  <xsd:simpleType name="Alignment">
    <xsd:annotation>
      <xsd:documentation>
        Specifies the horizontal alignment of the contained text or image on the page, although devices need not conform to the setting of this property. If not specified, the default is "l" for left alignment. Other options are "r" and "c" for right and center respectivelly.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:restriction base="xsd:string">
      <xsd:pattern value="l|r|c" />
    </xsd:restriction>
  </xsd:simpleType>	

  <xsd:simpleType name="ButtonKey">
    <xsd:annotation>
      <xsd:documentation>
        The key to map to this dialog button. "enter", "back", "left" or "right".
      </xsd:documentation>
    </xsd:annotation>
    <xsd:restriction base="xsd:string">
      <xsd:pattern value="enter|back|left|right" />
    </xsd:restriction>
  </xsd:simpleType>	
	
  <xsd:simpleType name="ColorRGB">
    <xsd:annotation>
      <xsd:documentation>
        Specifies the RGB value of the color to use for the contained text. Devices need not conform to the setting of this attribute. Hexadecimal numbers containing from one through six digits, inclusive.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:restriction base="xsd:hexBinary">
      <xsd:minLength value="1" />
      <xsd:maxLength value="6" />
    </xsd:restriction>
  </xsd:simpleType>	
	
	<xsd:simpleType name="ContentBackgroundFitMode">
    <xsd:annotation>
      <xsd:documentation>
        Determines how the background image is laid out on the page. "s" (scale), "t" (tile) or "c" (center).
        If not specified, the default behavior is to scale the image.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:restriction base="xsd:string">
      <xsd:pattern value="s|t|c" />
     </xsd:restriction>
   </xsd:simpleType>

  <xsd:simpleType name="ImageFit">
    <xsd:annotation>
      <xsd:documentation>
        Specifies how the image is rendered relative to the screen on the device ("native", "width", "screen" or "auto").
      </xsd:documentation>
    </xsd:annotation>    
    <xsd:restriction base="xsd:string">
      <xsd:pattern value="native|width|screen|auto" />
    </xsd:restriction>
  </xsd:simpleType>	
	
  <xsd:simpleType name="MenuItemDefault">
    <xsd:annotation>
      <xsd:documentation>
        Used to specify whether this menu item is the default menu item ("1") or not ("0").
        If multiple menu items are set as the default, the first such menu item is treated as the default.
        If no menu items are set as the default, the first enabled menu item is treated as the default.
      </xsd:documentation>
    </xsd:annotation>    <xsd:restriction base="xsd:nonNegativeInteger">
      <xsd:minInclusive value="0" />
      <xsd:maxInclusive value="1" />
    </xsd:restriction>
  </xsd:simpleType>	
	
  <xsd:simpleType name="MenuItemEnabled">
    <xsd:annotation>
      <xsd:documentation>
        Used to specify whether ("1") or not ("0") this menu item is enabled.
        Devices should render menu items that are not enabled as dimmed and non-interactive, or they should not be rendered at all.
      </xsd:documentation>
    </xsd:annotation>    <xsd:restriction base="xsd:nonNegativeInteger">
      <xsd:minInclusive value="0" />
      <xsd:maxInclusive value="1" />
    </xsd:restriction>
  </xsd:simpleType>	
	
	<xsd:simpleType name="SelectAction">
    <xsd:annotation>
      <xsd:documentation>
        Defines whether selection of an item in the menu navigates to the item's specified target page ("target"), or whether it invokes the item's specified context menu. If "menuid" is specified and the item has no menuid attribute, the device will navigate to the item's specified target instead. 
      </xsd:documentation>
    </xsd:annotation>
    <xsd:restriction base="xsd:string">
      <xsd:pattern value="target|menuid" />
    </xsd:restriction>
  </xsd:simpleType>

  <xsd:simpleType name="TextWrap">
    <xsd:annotation>
      <xsd:documentation>
        Specifies whether the contained text must fit on a single line, truncated if necessary (enter "0"), or whether the contained text is allowed to wrap onto multiple lines. If not specified, the default is "1" for text wrapping.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:restriction base="xsd:nonNegativeInteger">
      <xsd:minInclusive value="0" />
      <xsd:maxInclusive value="1" />
    </xsd:restriction>
  </xsd:simpleType>	

	<xsd:complexType name="BodyType">
    <xsd:annotation>
      <xsd:documentation>
        Specifies the beginning and end of the document.
      </xsd:documentation>
    </xsd:annotation>
		<xsd:choice>
			<xsd:element name="content" type="ContentType">
        <xsd:unique name="UniqueButtonKeyContent">
					<xsd:selector xpath="./btn" />
					<xsd:field xpath="@key" />
				</xsd:unique>
			</xsd:element>
			<xsd:element name="menu" type="MenuType">
        <xsd:unique name="UniqueId">
					<xsd:selector xpath="./item" />
					<xsd:field xpath="@id" />
				</xsd:unique>
			</xsd:element>					
			<xsd:element name="dialog" type="DialogType">
        <xsd:unique name="UniqueButtonKeyDialog">
					<xsd:selector xpath="./btn" />
					<xsd:field xpath="@key" />
				</xsd:unique>
			</xsd:element>
    </xsd:choice>			
	</xsd:complexType>

  <xsd:complexType name="BrType">
    <xsd:annotation>
      <xsd:documentation>
        Specifies that a line break should occur at the specified location in the rendered content.
      </xsd:documentation>
    </xsd:annotation>
  </xsd:complexType>  
	
	<xsd:complexType name="ButtonType">
    <xsd:annotation>
      <xsd:documentation>
        Specifies a mapping for a button on a content, dialog or menu page.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:simpleContent>
      <xsd:extension base="xsd:string">
        <xsd:attribute name="key" type="ButtonKey" use="required" />
        <xsd:attribute name="target" type="xsd:positiveInteger" use="required">
          <xsd:annotation>
            <xsd:documentation>
              The content identifier of the page to navigate to when the button associated with this element is selected. Any positive integer that corresponds to the content identifier of a page.
            </xsd:documentation>
          </xsd:annotation>
        </xsd:attribute>
      </xsd:extension>
    </xsd:simpleContent>
  </xsd:complexType>

  <xsd:complexType name="ColorType" mixed="true">
    <xsd:annotation>
      <xsd:documentation>
        Specifies an alternate value for the color of the text that is contained within this element.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:sequence minOccurs="0" maxOccurs="unbounded">
      <xsd:element name="em" type="EmphasisType"/>
    </xsd:sequence>
    <xsd:attribute name="rgb" type="ColorRGB" use="required" />
  </xsd:complexType>	

	<xsd:complexType name="ContentType">
    <xsd:annotation>
      <xsd:documentation>
        Specifies a collection of static text and images, laid out in a flow manner.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:group ref="ContentChild" maxOccurs="unbounded" />
    <xsd:attribute name="id" type="xsd:positiveInteger" use="required">
      <xsd:annotation>
        <xsd:documentation>
          The actual content identifier of the current page (positive integer).
        </xsd:documentation>
      </xsd:annotation>    
    </xsd:attribute>
    <xsd:attribute name="title" type="xsd:string" use="optional">
      <xsd:annotation>
        <xsd:documentation>
          The title to be displayed in the title bar or at the top of the page. If not specified, the gadget name will be used.
        </xsd:documentation>
      </xsd:annotation>
    </xsd:attribute>
    <xsd:attribute name="bg" type="xsd:positiveInteger" use="optional">
      <xsd:annotation>
        <xsd:documentation>
          The content identifier of the image to be used as the background for this page. Some Windows SideShow-compatible devices may not support background images and therefore ignore this attribute (positive integer).
        </xsd:documentation>
      </xsd:annotation>
    </xsd:attribute>
    <xsd:attribute name="bgfit" type="ContentBackgroundFitMode" use="optional" />
    <xsd:attribute name="menuid" type="xsd:positiveInteger" use="optional">
      <xsd:annotation>
        <xsd:documentation>
          The content identifier of a menu page that serves as the context menu for this page (positive integer).
        </xsd:documentation>
      </xsd:annotation>
    </xsd:attribute>
	</xsd:complexType>	

	<xsd:complexType name="DialogType">
    <xsd:annotation>
      <xsd:documentation>
        Specifies text, buttons, and possibly a single image to be displayed on a page that requires a response from the user.
      </xsd:documentation>
    </xsd:annotation>
		<xsd:group ref="DialogChild" maxOccurs="unbounded" />
		<xsd:attribute name="id" type="xsd:positiveInteger" use="required">
      <xsd:annotation>
        <xsd:documentation>
          The actual content identifier of the current page (positive integer).
        </xsd:documentation>
      </xsd:annotation>
    </xsd:attribute>
		<xsd:attribute name="title" type="xsd:string" use="optional">
      <xsd:annotation>
        <xsd:documentation>
          The title to be displayed in the title bar or at the top of the page. If not specified, the gadget name will be used.
        </xsd:documentation>
      </xsd:annotation>
    </xsd:attribute>
    <xsd:attribute name="imgid" type="xsd:positiveInteger" use="optional">
      <xsd:annotation>
        <xsd:documentation>
          The content identifier of binary image data to be displayed as part of the dialog page (positive integer).
          Devices may ignore the setting of this property.
        </xsd:documentation>
      </xsd:annotation>
    </xsd:attribute>
	</xsd:complexType>

  <xsd:complexType name="DivType">
    <xsd:annotation>
      <xsd:documentation>
        Specifies that a dividing line should occur at the specified point in a sequence of rendered menu items.
      </xsd:documentation>
    </xsd:annotation>
  </xsd:complexType>

  <xsd:complexType name="EmphasisType" mixed="true">
    <xsd:annotation>
      <xsd:documentation>
        Specifies that the text contained within this element should be emphasized.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:sequence minOccurs="0" maxOccurs="unbounded">
      <xsd:element name="clr" type="ColorType" />
    </xsd:sequence>
  </xsd:complexType>	
	
	<xsd:complexType name="ImageType">
    <xsd:annotation>
      <xsd:documentation>
        Specifies information about an image included within a content page, including its content identifier, rendering preferences, and an alternative string that describes the image.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:attribute name="id" type="xsd:positiveInteger" use="required">
      <xsd:annotation>
        <xsd:documentation>
          The content identifier of the associated binary image data (positive integer).
        </xsd:documentation>
      </xsd:annotation>
    </xsd:attribute>
		<xsd:attribute name="align" type="Alignment" use="optional" />
		<xsd:attribute name="fit" type="ImageFit" use="optional" />
    <xsd:attribute name="alt" type="xsd:string" use="optional">
      <xsd:annotation>
        <xsd:documentation>
          Specifies alternative text to be displayed in place of the image, when necessary.
        </xsd:documentation>
      </xsd:annotation>
    </xsd:attribute>
	</xsd:complexType>
	
  <xsd:complexType name="ItemType" mixed="true">
    <xsd:annotation>
      <xsd:documentation>
        Describes a single item in the containing menu, as specified by a menu element.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:sequence minOccurs="0" maxOccurs="1">
      <xsd:element name="br" type="BrType" />
    </xsd:sequence>
    <xsd:attribute name="id" type="xsd:positiveInteger" use="optional" />
    <xsd:attribute name="target" type="xsd:positiveInteger" use="required" />
    <xsd:attribute name="imgid" type="xsd:positiveInteger" use="optional" />
    <xsd:attribute name="def" type="MenuItemDefault" use="optional" />
    <xsd:attribute name="enable" type="MenuItemEnabled" use="optional" />
    <xsd:attribute name="menuid" type="xsd:positiveInteger" use="optional" />
  </xsd:complexType>	

	<xsd:complexType name="MenuType">
    <xsd:annotation>
      <xsd:documentation>
        Specifies the list of menu items that constitutes a menu page.
      </xsd:documentation>
    </xsd:annotation>
		<xsd:group ref="MenuChild" maxOccurs="unbounded" />
		<xsd:attribute name="id" type="xsd:positiveInteger" use="required">
      <xsd:annotation>
        <xsd:documentation>
          The actual content identifier of the current page (positive integer).
        </xsd:documentation>
      </xsd:annotation>
    </xsd:attribute>
		<xsd:attribute name="title" type="xsd:string" use="optional">
      <xsd:annotation>
        <xsd:documentation>
          The title to be displayed in the title bar or at the top of the page. If not specified, the gadget name will be used.
        </xsd:documentation>
      </xsd:annotation>
    </xsd:attribute>
		<xsd:attribute name="selectaction" type="SelectAction" use="optional" />
	</xsd:complexType>	

  <xsd:complexType name="TextType" mixed="true">
    <xsd:annotation>
      <xsd:documentation>
        Specifies that the text contained within this element should be rendered on the associated device according to the alignment, wrap, and color characteristics provided by the corresponding attributes.
      </xsd:documentation>
    </xsd:annotation>
    <xsd:group ref="Text" minOccurs="0" maxOccurs="unbounded" />
    <xsd:attribute name="align" type="Alignment" use="optional" />
    <xsd:attribute name="wrap" type="TextWrap" use="optional" />
    <xsd:attribute name="rgb" type="ColorRGB" use="optional" />
  </xsd:complexType>	

  <xsd:group name="Text">
    <xsd:choice>
      <xsd:element name="em" type="EmphasisType" />
      <xsd:element name="clr" type="ColorType" />
      <xsd:element name="br" type="BrType" />
    </xsd:choice>
  </xsd:group>	
	
  <xsd:group name="ContentChild">
    <xsd:choice>
      <xsd:element name="txt" type="TextType"/>
      <xsd:element name="br" type="BrType" />
      <xsd:element name="img" type="ImageType" />
      <xsd:element name="btn" type="ButtonType" />
    </xsd:choice>
  </xsd:group>

  <xsd:group name="MenuChild">
    <xsd:choice>
      <xsd:element name="item" type="ItemType" minOccurs="1" />
      <xsd:element name="div" type="DivType" />
      <xsd:element name="btn" type="ButtonType" />
    </xsd:choice>
  </xsd:group>

  <xsd:group name="DialogChild">
    <xsd:choice>
			<xsd:element name="txt" type="TextType" minOccurs="1" />
			<xsd:element name="btn" type="ButtonType"  minOccurs="1" />
    </xsd:choice>
  </xsd:group>	
	
	<xsd:element name="body" type="BodyType" />	
</xsd:schema>
