Friday, July 23, 2010

Posted by SAMAJ SHEKHAR

0

Windows Sidebar Gadget's Manifest's Schema



While developing my app (see previous post) i came across a need to validate my generated xml with a schema. I searched around the internet but couldn’t find any schema for the Windows Sidebar Gadget.xml. Many people were asking for one various forums but they got no reply. I needed it too so i thought why not create one for myself, since i didn't knew much about creating xml schemas so referenced some websites and wrote the following schema in Visual Studio. Using Visual Studio made it all easier for me to write a schema cause it helped me by automatically completing and closing tags and it also suggested various attributes i can set, through its "intellisense".  Visual Studio obviously boosts productivity and makes learning new things easy.
Following is the schema code for the Windows sidebar gadget’s manifest.


<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="SidebarGadget"
              xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="gadget" type="Tgadget"/>
  <xs:complexType name="Tgadget">
    <xs:sequence maxOccurs="1">
      <xs:element name="name" type="xs:string"/>
      <xs:element name="namespace" type="xs:string"/>
      <xs:element name="version" type="xs:string"/>
      <xs:element name="author" type="Tauthor"/>
      <xs:element name="copyright" type="xs:string"/>
      <xs:element name="description" type="xs:string"/>
      <xs:element name="icons" type="Ticons" maxOccurs="unbounded"/>
      <xs:element name="hosts" type="Thosts"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="Tauthor">
    <xs:sequence>
      <xs:element name="info" type="Turl"/>
      <xs:element name="logo" type="Tlogo"/>
    </xs:sequence>
    <xs:attribute name="name" type="xs:string"/>
  </xs:complexType>
  <xs:complexType name="Turl">
    <xs:attribute name="url" type="xs:string"/>
  </xs:complexType>
  <xs:complexType name="Tlogo">
    <xs:attribute name="src" type="xs:string"/>
  </xs:complexType>
  <xs:complexType name="Ticons">
    <xs:sequence>
      <xs:element name="icon" type="Ticon"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="Ticon">
    <xs:attribute name="hight" type="xs:nonNegativeInteger"/>
    <xs:attribute name="width" type="xs:nonNegativeInteger"/>
    <xs:attribute name="src" type="xs:string"/>
  </xs:complexType>
  <xs:complexType name="Thosts">
    <xs:sequence>
      <xs:element name="host" type ="Thost"/>
    </xs:sequence>
  </xs:complexType>
  <xs:complexType name="Thost">
    <xs:sequence>
      <xs:element name="base" type="Tbase"/>
      <xs:element name="permission" type="xs:string"/>
      <xs:element name="platform" type="Tplatform"/>
      <xs:element name="autoscaleDPI" type="xs:boolean" nillable="true"/>
      <xs:element name="defaultImage" type="TdefaultImage"/>
    </xs:sequence>
    <xs:attribute name="name" type="xs:string" default="sidebar"/>
  </xs:complexType>
  <xs:complexType name="Tbase">
    <xs:attribute name="type" type="xs:string"/>
    <xs:attribute name="apiVersion" type="xs:string"/>
    <xs:attribute name="src" type="xs:string"/>
  </xs:complexType>
  <xs:complexType name="Tplatform">
    <xs:attribute name="minPlatformVersion" type="xs:double"/>
  </xs:complexType>
  <xs:complexType name="TdefaultImage">
    <xs:attribute name="src" type="xs:short"/>
  </xs:complexType>
</xs:schema>
 
I hope this could be useful to someone who need it and don't have time to make one.
Comments or suggestion are welcome...



No comments:

Post a Comment