$$$ Namespace Comment: XSD for CS (CDM <-> Storage) space mapping.

# Mapping
Comment: Root Level element for CS mapping
Must Be: TMapping
Should be empty class.

# TMapping
Comment: Type of root level mapping elements
Element Comment: Top level mapping element can have Alias elements followed by one EntityContainerMapping element
Element: Alias, 0-Unlimited, Type: TAlias
Element: EntityContainerMapping, Required, TEntityContainerMapping
Element Comment: Space represents the space that the mapping occurs. For CS mapping it always has to be "C-S"
Element: Space, Required, Type: TSpace, Fixed Value: C-S

# TAlias
Element: Key, Required, Type: TSimpleIdentifier
Element: Value, Required, Type: string


# TEntityContainerMapping
Comment: Type for EntityContainerMapping element
Element: EntitySetMapping, 0-Unlimited, Type: TEntitySetMapping
Element: AssociationSetMapping, 0-Unlimited, Type: TAssociationSetMapping
Element: FunctionImportMapping, 0-Unlimited, Type: TFunctionImportMapping
Element: CdmEntityContainer, Required, Type: TSimpleIdentifier
Element: StorageEntityContainer, Required, Type: string
Element: GenerateUpdateViews, Optional, Type: boolean

# TFunctionImportMapping
Comment: Type for FunctionImportMapping element
Element: ResultMapping, 0-Unlimited, Type:TFunctionImportMappingResultMapping
Element: FunctionName, Required, Type: string
Element: FunctionImportName, Required, Type:TSimpleIdentifier

# TFunctionImportMappingResultMapping
Comment: Type for FunctionImportMapping/ResultMapping element
Element: EntityTypeMapping, 1-Unlimited, Type: TFunctionImportEntityTypeMapping
Element: ComplexTypeMapping, Required, Type: TFunctionImportComplexTypeMapping
Condition: Only EntityTypeMapping || ComplexTypeMapping may have a value at any given time.

# TFunctionImportEntityTypeMapping
Comment: Type for (FunctionMapping|FunctionImportMapping)/EntityTypeMapping element
Element: ScalarProperty, Optional, Type: TScalarProperty
Element: Condition, Optional, Type: TFunctionImportCondition
Element: TypeName, Required, Type:string

# TFunctionImportCondition
Comment: Type for FunctionImportMapping/Condition element
Element: Value, Optional, Type:String
Element: ColumnName, Required, Type:string
Element: IsNull, Optional, Type: boolean

# TFunctionImportComplexTypeMapping
Comment: Type for FunctionImportMapping/ComplexTypeMapping element
Element: ScalarProperty, 0-Unlimited, Type:TScalarProperty
Element: TypeName, Required, Type: string

#TEntitySetMapping
Comment: Type for EntitySet mapping element
Element: QueryView, 0-Unlimited, Type: TQueryView
Element: EntityTypeMapping, 0-Unlimited, Type: TEntityTypeMapping
Element: MappingFragment, 0-Unlimited, Type: TMappingFragment
Element: Name, Required, Type: TSimpleIdentifier
Element: TypeName, Optional, Type: string
Element: StoreEntitySet, Optional, Type: string
Element: MakeColumnsDistinct, Optional, Type: boolean
Uses Group: TPropertyGroup
Conditions: (QueryView && EntityTypeMapping Must have Value) ||  MappingFragment Must Have Value || A Single Element from TPropertyGroup Must have valuee
Condition Note: the or nots are exclusive, if MappingFragment has a value, no elements in TPropertyGroup can have a value, nor can QueryView, or EntityTypeMapping

#TAssociationSetMapping
Comment: Type for AssociationSetMapping element
Element: QueryView, Optional, Type: string
Element: EndProperty, 0-2, Type: TEndProperty
Element: Condition, 0-Unlimited, Type: TCondition
Element: ModificationFunctionMapping, Optional, Type: TAssociationSetModificationFunctionMapping
Element: Name, Required, Type: TSimpleIdentifier
Element: TypeName, Optional, Type: TQualifiedName
Element: StoreEntitySet, Optional, Type: string

# TQueryView
Comment: Type for QueryView element
Element: TypeName, Optional, Type: string

# TEntityTypeMapping
Comment: Type for EntityTypeMapping element
Element: MappingFragment, 0-Unlimited, Type: TMappingFragment
Element: ModificationFunctionMapping, Optional, Type: TEntityTypeModificationFunctionMapping
Element: TypeName, Required, type: string

#TMappingFragment
Comment: Type for MappingFragment element
Uses Group: TPropertyGroup
Element: StoreEntitySet, Required, Type: string
Element: MakeColumnsDistinct, Optional, Type:Boolean
Condition: Only one element from TPropertyGroup can have a value, and one element in TPropertyGroup Must have a value.

# TEntityTypeModificationFunctionMapping
Comment: Type for EntityTypeMapping/ModificationFunctionMapping element
Element: DeleteFunction, Optional, Type: TEntityTypeModificationFunction
Element: InsertFunction, Optional, Type: TEntityTypeModificationFunctionWithResult
Element: UpdateFunction, Optional, Type: TEntityTypeModificationFunctionWithResult

# TAssociationSetModificationFunctionMapping
Comment: Type for AssociationSetMapping/ModificationFunctionMapping element
Element: DeleteFunction, Optional, Type: TAssociationSetModificationFunction
Element: InsertFunction, Optional, Type: TAssociationSetModificationFunction

# TEntityTypeModificationFunction
Comment: Type for entity type DeleteFunction
Uses Group: TEntityTypeModificationFunctionMappingPropertyGroup
Element: FunctionName, Required, Type: string
Element: RowsAffectedParameter, Optional, Type: string
Condition: at least one property of TEntityTypeModificationFunctionMappingPropertyGroup must have a value

# TEntityTypeModificationFunctionWithResult
Comment:  Extensions to modification function for entity type InsertFunction and UpdateFunction
Extends: TEntityTypeModificationFunction
Uses Group: TResultBindingGroup

# TAssociationSetModificationFunction
Comment: TAssociationSetModificationFunction
Uses Group: TAssociationSetModificationFunctionMappingPropertyGroup
Element: FunctionName, Required, Type: string
Element: RowsAffectedParameter, Optional, Type string
Condition: TAssociationSetModificationFunctionMappingPropertyGroup->EndProperty Must contain at least 1 value.

# TModificationFunctionMappingEndProperty
Comment: Type for function mapping end property
Uses Group: TModificationFunctionMappingAssociationEndPropertyGroup
Element: Name, Required, Type: TSimpleIdentifier

# TModificationFunctionMappingScalarProperty
Comment:  Type for function mapping scalar property
Element:ParameterName, Required, Type: string
Element:Name, Required, Type: TSimpleIdentifier
Element:Version, Optional, Type: TVersion

# TResultBinding
Comment: Type for function mapping result binding
Element: ColumnName, Required, Type: string
Element: Name, Required, Type: TSimpleIdentifier

# TModificationFunctionMappingAssociationEnd
Comment: Type for function mapping association end
Uses Group: TModificationFunctionMappingAssociationEndPropertyGroup
Element: AssociationSet, Required, Type: TSimpleIdentifier
Element: From, Required, Type: TSimpleIdentifier
Element: To, Required, Type: TSimpleIdentifier

# TModificationFunctionMappingComplexProperty
Comment: Type for function mapping complex property
Uses Group: TModificationFunctionMappingComplexPropertyPropertyGroup
Element: Name, Required, Type: TSimpleIdentifier
Element: TypeName, Required, Type: string

# TCondition
Comment: Type for Condition Element
Element: Value, Optional, Type: string
Element: Name, Optional, Type: TSimpleIdentifier
Element: ColumnName, Optional, Type: string
Element: IsNull, Optional, Type: boolean

#TEndProperty
Comment: Type for End Property Elements in Association Maps
Element: ScalarProperty, 1-Unlimited, Type: TScalarProperty
Element: Name, Required, Type: TSimpleIdentifier

# TComplexProperty
Comment: Type for Complex Property Map elements
Element: ScalarProperty, Optional, Type: TScalarProperty
Element: ComplexProperty,Optional, Type: TComplexProperty
Element: ComplexTypeMapping, Optional, Type: TComplexTypeMapping
Element: Condition, Optional, Type: TCondition
Element: Name, Required, Type: TSimpleIdentifier
Element: TypeName, Optional, Type: string
Element: IsPartial, Optional, Type: boolean
Condition: ScalarProperty, ComplexProperty, ComplexTypeMapping, and Condition Must have at least 1 none null entery between them

# TComplexTypeMapping
Comment: Type for Complex Type mapping element
Element: ScalarProperty, Optional, Type: TScalarProperty
Element: ComplexProperty,Optional, Type: TComplexProperty
Element: Condition, Optional, Type: TCondition
Element: TypeName, Optional, Type: string
Element: IsPartial, Optional, Type: boolean
Condition: ScalarProperty, ComplexProperty, and Condition Must have at least 1 none null entery between them

# TScalarProperty
Comment: Type for ScalarProperty Element
Element: Name, Required, Type: TSimpleIdentifier
Element: ColumnName, Required, Type: string
