///////////////////////////////////////////////////////////////////////////////////////////////////
        ////////////BUILD FROM V2.1 SCHEMA                 //////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Initializes a new instance of the <see cref="CategorySchemeMapCore"/> class.
        /// </summary>
        /// <param name="catMapType">
        /// The cat map type. 
        /// </param>
        /// <param name="parent">
        /// The parent. 
        /// </param>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.
        /// </exception>
        public CategorySchemeMapCore(CategorySchemeMapType catMapType, IStructureSetObject parent)
            : base(catMapType, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.CategorySchemeMap), parent)
        {
            this.categoryMaps = new List<ICategoryMap>();

            this.SourceRef = RefUtil.CreateReference(this, catMapType.GetTypedSource<CategorySchemeReferenceType>());
            this.TargetRef = RefUtil.CreateReference(this, catMapType.GetTypedTarget<CategorySchemeReferenceType>());

            if (catMapType.ItemAssociation != null)
            {
                foreach (CategoryMap catMap in catMapType.ItemAssociation)
                {
                    ICategoryMap categoryMap = new CategoryMapCore(catMap.Content, this);
                    this.categoryMaps.Add(categoryMap);
                }
            }

            try
            {
                this.Validate();
            }
            catch (SdmxSemmanticException e)
            {
                throw new SdmxSemmanticException(e, ExceptionCode.FailValidation, this);
            }
        }
        /// <summary>
        /// The process category scheme map.
        /// </summary>
        /// <param name="structureSetType">
        /// The structure set type.
        /// </param>
        /// <param name="buildFrom">
        /// The build from.
        /// </param>
        private void ProcessCategorySchemeMap(StructureSetType structureSetType, ICategorySchemeMapObject buildFrom)
        {
            var catSchemeMap = new CategorySchemeMapType();
            structureSetType.CategorySchemeMap = catSchemeMap;

            string value = buildFrom.Id;
            if (!string.IsNullOrWhiteSpace(value))
            {
                catSchemeMap.id = buildFrom.Id;
            }

            IList<ITextTypeWrapper> names = buildFrom.Names;
            if (ObjectUtil.ValidCollection(names))
            {
                catSchemeMap.Name = this.GetTextType(names);
            }

            IList<ITextTypeWrapper> descriptions = buildFrom.Descriptions;
            if (ObjectUtil.ValidCollection(descriptions))
            {
                catSchemeMap.Description = this.GetTextType(descriptions);
            }

            if (buildFrom.SourceRef != null)
            {
                var catRefType = new CategorySchemeRefType();
                catSchemeMap.CategorySchemeRef = catRefType;
                SetCategorySchemeRefAttributes(catRefType, buildFrom.SourceRef);
            }

            if (buildFrom.TargetRef != null)
            {
                var catRefType0 = new CategorySchemeRefType();
                catSchemeMap.TargetCategorySchemeRef = catRefType0;
                SetCategorySchemeRefAttributes(catRefType0, buildFrom.TargetRef);
            }

            IList<ICategoryMap> categoryMapBeans = buildFrom.CategoryMaps;
            if (ObjectUtil.ValidCollection(categoryMapBeans))
            {
                /* foreach */
                foreach (ICategoryMap categoryMapBean in categoryMapBeans)
                {
                    var categoryMapType = new CategoryMapType();
                    catSchemeMap.CategoryMap.Add(categoryMapType);
                    string value1 = categoryMapBean.Alias;
                    if (!string.IsNullOrWhiteSpace(value1))
                    {
                        categoryMapType.categoryAlias = categoryMapBean.Alias;
                    }

                    if (categoryMapBean.SourceId != null)
                    {
                        var categoryIdType = new CategoryIDType();
                        categoryMapType.CategoryID = categoryIdType;
                        SetCategoryIdAttributes(categoryIdType, categoryMapBean.SourceId);
                    }

                    if (categoryMapBean.TargetId != null)
                    {
                        var categoryIdType1 = new CategoryIDType();

                        categoryMapType.TargetCategoryID = categoryIdType1;
                        SetCategoryIdAttributes(categoryIdType1, categoryMapBean.TargetId);
                    }
                }
            }

            if (this.HasAnnotations(buildFrom))
            {
                catSchemeMap.Annotations = this.GetAnnotationsType(buildFrom);
            }
        }