Appendix C   Promotion XML Schema


This appendix provides a sample XML schema (xsd) for a promotion.

<?xml version="1.0"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"xmlns:xs="http://www.w3.org/2001/XMLSchema">

<!-- ********************** -->
<!-- New Simple Types -->
<!-- ********************** -->

<xs:simpleType name="string_Generic">
   <xs:restriction base="xs:string">
    <xs:pattern value="\S.*" />
   </xs:restriction>
  </xs:simpleType>

<xs:simpleType name="enum_QueryOperator">
   <xs:restriction base="xs:string">
    <xs:enumeration value="is" />
    <xs:enumeration value="contains" />
    <xs:enumeration value="starts with" />
    <xs:enumeration value="ends with" />
   </xs:restriction>
  </xs:simpleType>

<xs:simpleType name="enum_BucketSelectionOperator">
   <xs:restriction base="xs:string">
    <xs:enumeration value="is" />
    <xs:enumeration value="is subtree" />
   </xs:restriction>
  </xs:simpleType>

<xs:simpleType name="enum_DateOperator">
   <xs:restriction base="xs:string">
    <xs:enumeration value="is" />
    <xs:enumeration value="is before" />
    <xs:enumeration value="is after" />
    <xs:enumeration value="is between" />
   </xs:restriction>
  </xs:simpleType>

<xs:simpleType name="enum_DayOfWeekOperator">
   <xs:restriction base="xs:string">
    <xs:enumeration value="is one of" />
   </xs:restriction>
  </xs:simpleType>

<xs:simpleType name="enum_RuleType">
   <xs:restriction base="xs:string">
    <xs:enumeration value="all" />
    <xs:enumeration value="any" />
   </xs:restriction>
  </xs:simpleType>

<xs:simpleType name="enum_DayOfWeek">
   <xs:restriction base="xs:string">
    <xs:enumeration value="sun" />
    <xs:enumeration value="mon" />
    <xs:enumeration value="tue" />
    <xs:enumeration value="wed" />
    <xs:enumeration value="thu" />
    <xs:enumeration value="fri" />
    <xs:enumeration value="sat" />
   </xs:restriction>
  </xs:simpleType>

<!-- The Day of week is expected in the server's internationalized language.
       For English you can use the following:
         sun,mon,tue,wed,thu,fri,sat.
       Specify the days you would like and leave out the rest.
       For your language, convert the above options into your language.
  -->
  <xs:simpleType name="enum_DayOfWeekValue">
   <xs:restriction base="string_Generic">
   </xs:restriction>
  </xs:simpleType>

<!-- host attribute is ignored. No Need to specify. -->
  <xs:attributeGroup name="parametricSelectionAttributes">
    <xs:attribute name="parametricIndex" type="string_Generic" use="required" />
    <xs:attribute name="host" type="string_Generic" use="optional" />
    <xs:attribute name="bucketset" type="string_Generic" use="required" />
    <xs:attribute name="bucket" type="string_Generic" use="required" />
  </xs:attributeGroup>

<!-- The date is expected to be in the date format based on the server locale.
       e.g. Mar 31,2005.
       If the operator is "is", use the attribute date
       If the operator is "is before" use the attribute date
       If the operator is "is after" use the attribute date
       If the operator is "is between" use the attribute startDate and endDate
  -->
  <xs:attributeGroup name="dateSelectionAttributes">
   <xs:attribute name="date" type="string_Generic" use="optional"/>
   <xs:attribute name="startDate" type="string_Generic" use="optional" />
   <xs:attribute name="endDate" type="string_Generic" use="optional" />
  </xs:attributeGroup>

<xs:simpleType name="enum_propertyTypes">
   <xs:restriction base="xs:string">
    <xs:enumeration value="string"/>
   </xs:restriction>
  </xs:simpleType>

<!-- ********************** -->
<!-- End New Simple Types -->
<!-- ********************** -->

<!-- *********************** -->
<!-- New Element Types -->
<!-- *********************** -->

<!-- Start Definition of Promotion Template -->
   <xs:complexType name="type_PromotionTemplate">
    <xs:sequence>
     <xs:element minOccurs="0" maxOccurs="unbounded" name="PromotionTemplateProperty" type="type_PromotionTemplateProperty"/>
    </xs:sequence>
   </xs:complexType>
  <!-- End Definition of Promotion Template -->

<!-- Start Definition of Promotion Template Property -->
   <xs:complexType name="type_PromotionTemplateProperty">
    <xs:attribute name="name" type="string_Generic" use="required" />
    <xs:attribute name="type" type="enum_propertyTypes" use="optional" />
   </xs:complexType>
  <!-- End Definition of Promotion Template Property -->

<!-- Start Definition of Promotion Sets -->
   <xs:complexType name="type_PromotionSets">
    <xs:sequence>
     <xs:element maxOccurs="unbounded" name="PromotionSet" type="type_PromotionSet"/>
    </xs:sequence>
   </xs:complexType>
  <!-- End Definition of Promotion Sets -->

<!-- Start Definition of Promotion Set -->
   <xs:complexType name="type_PromotionSet">
    <xs:sequence>
     <xs:element maxOccurs="1" name="PromotionRule" type="type_PromotionRule"/>
     <xs:element maxOccurs="1" name="Promotions" type="type_Promotions"/>
     <xs:element minOccurs="0" maxOccurs="1" name="Description" type="string_Generic" />
     <xs:element minOccurs="0" maxOccurs="1" name="EditorNotes" type="string_Generic" />
     <xs:element minOccurs="0" maxOccurs="unbounded" name="UserDefinedProperty" type="type_UserDefinedProperty"/>
    </xs:sequence>
    <xs:attribute name="name" type="string_Generic" use="required" />
   </xs:complexType>
  <!-- End Definition of Promotion Set -->

<!-- Start Definition of Promotions -->
   <xs:complexType name="type_Promotions">
    <xs:sequence>
     <xs:element minOccurs="0" maxOccurs="unbounded" name="Promotion" type="type_Promotion"/>
    </xs:sequence>
   </xs:complexType>
  <!-- End Definition of Promotions -->

<!-- Start Definition of Promotion -->
   <xs:complexType name="type_Promotion">
    <xs:sequence>
     <xs:element maxOccurs="unbounded" name="PromotionProperty" type="type_PromotionProperty"/>
    </xs:sequence>
   </xs:complexType>
  <!-- End Definition of Promotion -->

<!-- Start Definition of Promotion Property -->
   <xs:complexType name="type_PromotionProperty">
    <xs:simpleContent>
     <xs:extension base="string_Generic">
      <xs:attribute name="name" type="string_Generic" use="required" />
     </xs:extension>
    </xs:simpleContent>
   </xs:complexType>
  <!-- End Definition of Promotion Property -->

<!-- Start Definition of Promotion Rule -->
   <xs:complexType name="type_PromotionRule">
    <xs:choice maxOccurs="unbounded">
     <xs:element minOccurs="0" name="DayOfWeek" type="type_RuleDayOfWeek"/>
     <xs:element minOccurs="0" name="Date" type="type_RuleDate"/>
     <xs:element minOccurs="0" name="BucketSelection" type="type_RuleBucketSelection"/>
     <xs:element minOccurs="0" name="Query" type="type_RuleQuery"/>
    </xs:choice>
<xs:attribute name="type" type="enum_RuleType" use="optional" />
</xs:complexType>
  <!-- End Definition of PromotionRule -->

<!-- Start Definition of Day Of Week -->
   <xs:complexType name="type_RuleDayOfWeek">
    <xs:attribute name="operator" type="enum_DayOfWeekOperator" use="required" />
    <xs:attribute name="days" type="enum_DayOfWeekValue" use="required" />
   </xs:complexType>
  <!-- End Definition of Day Of Week -->

<!-- Start Definition of Date -->
   <xs:complexType name="type_RuleDate">
    <xs:attribute name="operator" type="enum_DateOperator" use="required" />
    <xs:attributeGroup ref="dateSelectionAttributes"/>
   </xs:complexType>
  <!-- End Definition of Date -->

<!-- Start Definition of BucketSelection -->
   <xs:complexType name="type_RuleBucketSelection">
    <xs:attribute name="operator" type="enum_BucketSelectionOperator" use="required" />
    <xs:attributeGroup ref="parametricSelectionAttributes"/>
   </xs:complexType>
  <!-- End Definition of BucketSelection -->

  <!-- Start Definition of Query -->
   <xs:complexType name="type_RuleQuery">
    <xs:attribute name="operator" type="enum_QueryOperator" use="required" />
    <xs:attribute name="value" type="string_Generic" use="required" />
   </xs:complexType>
  <!-- End Definition of Query -->

<!-- Start Definition of User Defined Property -->
   <xs:complexType name="type_UserDefinedProperty">
    <xs:attribute name="name" type="string_Generic" use="required" />
    <xs:attribute name="value" type="string_Generic" use="required" />
   </xs:complexType>
  <!-- End Definition of User Defined Property -->

<!-- *********************** -->
<!--  End New Element Types  -->
<!-- *********************** -->

<!-- Start Definition of Promotion Group -->
  <xs:element name="PromotionGroup">
   <xs:complexType>
    <xs:sequence>
     <xs:element minOccurs="1" maxOccurs="1" name="PromotionTemplate" type="type_PromotionTemplate"/>
     <xs:element minOccurs="1" maxOccurs="1" name="PromotionSets" type="type_PromotionSets"/>
    </xs:sequence>
   </xs:complexType>

<!-- The name attribute of all Promotion Set must be unique -->
   <xs:key name="PromotionSetName">
    <xs:selector xpath="./PromotionSets/PromotionSet"/>
    <xs:field xpath="@name"/>
   </xs:key>
   <!-- End unique value defintion -->

<!-- The name attribute of all properties in this template must be unique -->
   <xs:key name="PromotionTemplatePropertyName">  
    <xs:selector xpath="./PromotionTemplate/PromotionTemplateProperty"/>
    <xs:field xpath="@name"/>
   </xs:key>
   <!-- End unique value definition -->

<!-- The name of the properties defined in this promotion must
        be defined as a property in Promotion Template -->
   <xs:keyref name="propertyName" refer="PromotionTemplatePropertyName">
    <xs:selector xpath="./PromotionSets/PromotionSet/Promotions/Promotion/ PromotionProperty"/>
    <xs:field xpath="@name"/>
   </xs:keyref>
   <!-- End property name relation definition -->

</xs:element>
  <!-- End Definition of Promotion Group -->

</xs:schema>