<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2008 DDI Alliance, DDI 3.0, 2008-04-28

This file is part of DDI 3.0 XML Schema.

DDI 3.0 XML Schema is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.

DDI 3.0 XML Schema is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License along
with DDI 3.0 XML Schema. If not, see <http://www.gnu.org/licenses/>.

-->

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="ddi:comparative:3_0" xmlns:d="ddi:datacollection:3_0" xmlns:r="ddi:reusable:3_0" targetNamespace="ddi:comparative:3_0" elementFormDefault="qualified" attributeFormDefault="unqualified">
   <xs:import namespace="ddi:datacollection:3_0" schemaLocation="datacollection.xsd"/>
   <xs:import namespace="ddi:reusable:3_0" schemaLocation="reusable.xsd"/>
   <xs:element name="Comparison" type="ComparisonType">
      <xs:annotation>
         <xs:documentation>Structures information that is necessary to compare members of a group. This module contains the mapping(s) that inform comparisons and facilitate automation. Note that all maps are pairwise, identifying two schemes and the correlation between two items in those schemes. By using a set of pairwise comparisons, it is possible to describe more complex correspondences - pairwise comparisons are easier to process.</xs:documentation>
      </xs:annotation>
   </xs:element>
   <xs:complexType name="ComparisonType">
      <xs:annotation>
         <xs:documentation>Structures information that is necessary to compare members of a group. Contains the mapping(s) That inform comparisons and facilitate automation. Note that all maps are pairwise, identifying two schemes and the correlation between two items in those schemes. By using a set of pairwise comparisons, it is possible to describe more complex correspondences - pairwise comparisons are easier to process.</xs:documentation>
      </xs:annotation>
      <xs:complexContent>
         <xs:extension base="r:MaintainableType">
            <xs:sequence>
               <xs:element ref="ComparisonDescription" minOccurs="0" maxOccurs="unbounded">
                  <xs:annotation>
                     <xs:documentation>Description of the comparison, intended to be human-readable.</xs:documentation>
                  </xs:annotation>
               </xs:element>
               <xs:element ref="ConceptMap" minOccurs="0" maxOccurs="unbounded">
                  <xs:annotation>
                     <xs:documentation>Maps comparable concepts from two different concept schemes.</xs:documentation>
                  </xs:annotation>
               </xs:element>
               <xs:element ref="VariableMap" minOccurs="0" maxOccurs="unbounded">
                  <xs:annotation>
                     <xs:documentation>Maps comparable variables from two different variable schemes.</xs:documentation>
                  </xs:annotation>
               </xs:element>
               <xs:element ref="QuestionMap" minOccurs="0" maxOccurs="unbounded">
                  <xs:annotation>
                     <xs:documentation>Maps comparable questions from two different question schemes.</xs:documentation>
                  </xs:annotation>
               </xs:element>
               <xs:element ref="CategoryMap" minOccurs="0" maxOccurs="unbounded">
                  <xs:annotation>
                     <xs:documentation>Maps comparable categories from two different category schemes.</xs:documentation>
                  </xs:annotation>
               </xs:element>
               <xs:element ref="CodeMap" minOccurs="0" maxOccurs="unbounded">
                  <xs:annotation>
                     <xs:documentation>Maps comparable codes from two different code schemes.</xs:documentation>
                  </xs:annotation>
               </xs:element>
               <xs:element ref="UniverseMap" minOccurs="0" maxOccurs="unbounded">
                  <xs:annotation>
                     <xs:documentation>Maps comparable universes from two different universe schemes.</xs:documentation>
                  </xs:annotation>
               </xs:element>
               <xs:element ref="r:Note" minOccurs="0" maxOccurs="unbounded">
                  <xs:annotation>
                     <xs:documentation>Notes regarding any information in the module.</xs:documentation>
                  </xs:annotation>
               </xs:element>
            </xs:sequence>
         </xs:extension>
      </xs:complexContent>
   </xs:complexType>
   <xs:complexType name="GenericMapType">
      <xs:annotation>
         <xs:documentation>Maps comparable items from two different schemes.</xs:documentation>
      </xs:annotation>
      <xs:complexContent>
         <xs:extension base="r:VersionableType">
            <xs:sequence>
               <xs:element ref="SourceSchemeReference">
                  <xs:annotation>
                     <xs:documentation>References the scheme that is the source for the mapping.</xs:documentation>
                  </xs:annotation>
               </xs:element>
               <xs:element ref="TargetSchemeReference">
                  <xs:annotation>
                     <xs:documentation>References the scheme that is the target for the mapping.</xs:documentation>
                  </xs:annotation>
               </xs:element>
               <xs:element ref="Correspondence">
                  <xs:annotation>
                     <xs:documentation>Describes the correspondence between the target and source schemes.</xs:documentation>
                  </xs:annotation>
               </xs:element>
               <xs:element ref="ItemMap" minOccurs="0" maxOccurs="unbounded">
                  <xs:annotation>
                     <xs:documentation>Maps an individual item in the source scheme to an item in the target scheme. </xs:documentation>
                  </xs:annotation>
               </xs:element>
            </xs:sequence>
         </xs:extension>
      </xs:complexContent>
   </xs:complexType>
  <xs:complexType name="CorrespondenceType">
      <xs:annotation>
         <xs:documentation>Describes the correspondence between source and target schemes/items.</xs:documentation>
      </xs:annotation>
      <xs:sequence>
         <xs:element ref="Commonality" maxOccurs="unbounded">
            <xs:annotation>
               <xs:documentation>Textual description of the common aspects of the two schemes/items.</xs:documentation>
            </xs:annotation>
         </xs:element>
         <xs:element ref="Difference" maxOccurs="unbounded">
            <xs:annotation>
               <xs:documentation>Textual description of the differing aspects of the two schemes/items.</xs:documentation>
            </xs:annotation>
         </xs:element>
         <xs:element ref="CommonalityTypeCoded" minOccurs="0">
            <xs:annotation>
               <xs:documentation>Provides a type code for commonality of the two schemes/items. Suggested values are "Identical", "High", "Medium", "Low", "None".</xs:documentation>
            </xs:annotation>
         </xs:element>
         <xs:element name="CommonalityWeight" type="CommonalityWeightType" minOccurs="0">
            <xs:annotation>
               <xs:documentation>A value between 0 and 1 expressing the degree of commonality (0 indicates none, 1 indicates that they are identical).</xs:documentation>
            </xs:annotation>
         </xs:element>
         <xs:element ref="UserDefinedCorrespondenceProperty" minOccurs="0" maxOccurs="unbounded">
            <xs:annotation>
               <xs:documentation>A user-defined property defining the corrrespondence.</xs:documentation>
            </xs:annotation>
         </xs:element>
      </xs:sequence>
   </xs:complexType>
   <xs:simpleType name="CommonalityWeightType">
    <xs:restriction base="xs:float">
        <xs:minInclusive value="0"/>
        <xs:maxInclusive value="1"/>
    </xs:restriction>
   </xs:simpleType>
   <xs:complexType name="UserDefinedCorrespondencePropertyType">
            <xs:annotation>
               <xs:documentation>User-defined correspondence of two schemes or items, consisting of a name and a value.</xs:documentation>
            </xs:annotation>
            <xs:sequence>
                <xs:element name="Name" type="xs:string">
                   <xs:annotation>
                      <xs:documentation>Name for the correspondence of two schemes or items</xs:documentation>
                   </xs:annotation>
                </xs:element>
                <xs:element name="Value" type="xs:string">
                   <xs:annotation>
                      <xs:documentation>Value for the correspondence of two schemes or items</xs:documentation>
                   </xs:annotation>
                </xs:element>
            </xs:sequence>
   </xs:complexType>
   <xs:complexType name="CodeMapType">
      <xs:annotation>
         <xs:documentation>Maps comparable codes from two different code schemes.</xs:documentation>
      </xs:annotation>
      <xs:complexContent>
         <xs:extension base="r:VersionableType">
            <xs:sequence>
               <xs:element ref="SourceSchemeReference">
                  <xs:annotation>
                     <xs:documentation>References the code scheme that is the source for the mapping.</xs:documentation>
                  </xs:annotation>
               </xs:element>
               <xs:element ref="TargetSchemeReference">
                  <xs:annotation>
                     <xs:documentation>References the coce scheme that is the target for the mapping.</xs:documentation>
                  </xs:annotation>
               </xs:element>
         <xs:element ref="Correspondence">
            <xs:annotation>
               <xs:documentation>Describes the difference between source and target schemes.</xs:documentation>
            </xs:annotation>
         </xs:element>
               <xs:element ref="d:GenerationInstruction" minOccurs="0" maxOccurs="unbounded">
                  <xs:annotation>
                     <xs:documentation>Allows for use of programmatic logic to construct a detailed comparison map between individual codes in the source and target schemes.</xs:documentation>
                  </xs:annotation>
               </xs:element>
            </xs:sequence>
         </xs:extension>
      </xs:complexContent>
   </xs:complexType>
   <xs:complexType name="ItemMapType">
      <xs:annotation>
         <xs:documentation>Maps two items (codes, concepts, categories, questions, variables, etc.) from different schemes.</xs:documentation>
      </xs:annotation>
      <xs:sequence>
         <xs:element name="SourceItem" type="xs:NCName">
            <xs:annotation>
               <xs:documentation>References an item in the source scheme.</xs:documentation>
            </xs:annotation>
         </xs:element>
         <xs:element name="TargetItem" type="xs:NCName">
            <xs:annotation>
               <xs:documentation>References a comparable item in the target scheme.</xs:documentation>
            </xs:annotation>
         </xs:element>
         <xs:element ref="Correspondence">
            <xs:annotation>
               <xs:documentation>Describes the correspondence between source and target items</xs:documentation>
            </xs:annotation>
         </xs:element>
      </xs:sequence>
      <xs:attribute name="alias" type="xs:NCName" use="optional">
         <xs:annotation>
            <xs:documentation>Allows for an alias to be assigned to the correspondence between two items, so that it can be referred to with a single name, that would include both related items.</xs:documentation>
         </xs:annotation>
      </xs:attribute>
   </xs:complexType>
   <xs:element name="ComparisonDescription" type="r:StructuredStringType">
      <xs:annotation>
         <xs:documentation>Description of the comparison, intended to be human-readable.</xs:documentation>
      </xs:annotation>
   </xs:element>
   <xs:element name="ConceptMap" type="GenericMapType">
      <xs:annotation>
         <xs:documentation>Maps comparable concepts from two different concept schemes.</xs:documentation>
      </xs:annotation>
   </xs:element>
   <xs:element name="VariableMap" type="GenericMapType">
      <xs:annotation>
         <xs:documentation>Maps comparable variables from two different variable schemes.</xs:documentation>
      </xs:annotation>
   </xs:element>
   <xs:element name="QuestionMap" type="GenericMapType">
      <xs:annotation>
         <xs:documentation>Maps comparable questions from two different question schemes.</xs:documentation>
      </xs:annotation>
   </xs:element>
   <xs:element name="CategoryMap" type="GenericMapType">
      <xs:annotation>
         <xs:documentation>Maps comparable categories from two different category schemes.</xs:documentation>
      </xs:annotation>
   </xs:element>
   <xs:element name="CodeMap" type="CodeMapType">
      <xs:annotation>
         <xs:documentation>Maps comparable codes from two different code schemes.</xs:documentation>
      </xs:annotation>
   </xs:element>
   <xs:element name="UniverseMap" type="GenericMapType">
      <xs:annotation>
         <xs:documentation>Maps comparable universes from two different universe schemes.</xs:documentation>
      </xs:annotation>
   </xs:element>
   <xs:element name="SourceSchemeReference" type="r:ReferenceType">
      <xs:annotation>
         <xs:documentation>References the scheme that is the source for the mapping.</xs:documentation>
      </xs:annotation>
   </xs:element>
   <xs:element name="TargetSchemeReference" type="r:ReferenceType">
      <xs:annotation>
         <xs:documentation>References the scheme that is the target for the mapping.</xs:documentation>
      </xs:annotation>
   </xs:element>
   <xs:element name="Correspondence" type="CorrespondenceType">
      <xs:annotation>
         <xs:documentation>Describes the correspondence between the target and source schemes.</xs:documentation>
      </xs:annotation>
    </xs:element>
   <xs:element name="ItemMap" type="ItemMapType">
      <xs:annotation>
         <xs:documentation>Maps an individual item in the source scheme to an item in the target scheme. </xs:documentation>
      </xs:annotation>
   </xs:element>
   <xs:element name="Commonality" type="r:StructuredStringType">
      <xs:annotation>
         <xs:documentation>Describes the commonality between source and target schemes/items. </xs:documentation>
      </xs:annotation>
   </xs:element>
   <xs:element name="Difference" type="r:StructuredStringType">
      <xs:annotation>
         <xs:documentation>Describes the differences between source and target schemes/items. </xs:documentation>
      </xs:annotation>
   </xs:element>
   <xs:element name="CommonalityTypeCoded" type="r:CodeValueType">
      <xs:annotation>
         <xs:documentation>Provides a type code defining the commonality between source and target schemes/items.</xs:documentation>
      </xs:annotation>
   </xs:element>
   <xs:element name="UserDefinedCorrespondenceProperty" type="UserDefinedCorrespondencePropertyType">
      <xs:annotation>
         <xs:documentation>Provides a user-defined name-value pair describing the correspondence between source and target schemes/items. </xs:documentation>
      </xs:annotation>
   </xs:element>
</xs:schema>