Esempio n. 1
0
        /// <summary>
        /// Normalizes the SDMXV20 data structure.
        /// </summary>
        /// <param name="crossDsd">The cross DSD.</param>
        public static void NormalizeSdmxv20DataStructure(this ICrossSectionalDataStructureMutableObject crossDsd)
        {
            crossDsd.ConvertToStub();
            var annotation = CustomAnnotationType.SDMXv20Only.ToAnnotation <AnnotationMutableCore>();

            crossDsd.AddAnnotation(annotation);
        }
Esempio n. 2
0
        /// <summary>
        /// Convert measure representation from SDMX v2.0 to SDMX v2.1 and <see cref="ICrossSectionalDataStructureObject"/>.
        /// </summary>
        /// <param name="crossSectionalDataStructure">
        /// The cross sectional data structure.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="crossSectionalDataStructure"/> is null
        /// </exception>
        /// <remarks>
        /// HACK HORIBLE HACK 
        /// in 2.0 measure dimensions have a codelist based representation. On 2.1 have concept scheme based representation.
        /// </remarks>
        public static void ConvertMeasureRepresentation(ICrossSectionalDataStructureMutableObject crossSectionalDataStructure)
        {
            if (crossSectionalDataStructure == null)
            {
                throw new ArgumentNullException("crossSectionalDataStructure");
            }

            IDimensionMutableObject measureDim = crossSectionalDataStructure.Dimensions.FirstOrDefault(o => o.MeasureDimension);
            if (measureDim != null && crossSectionalDataStructure.CrossSectionalMeasures.Count > 0)
            {
                IStructureReference crossSectionalMeasureConceptRef = crossSectionalDataStructure.CrossSectionalMeasures[0].ConceptRef;
                IDictionary<string, IStructureReference> measureDimensionCodelistMapping = crossSectionalDataStructure.MeasureDimensionCodelistMapping;
                IStructureReference cocneptSchemeRef = new StructureReferenceImpl(
                    crossSectionalMeasureConceptRef.MaintainableReference, SdmxStructureType.GetFromEnum(SdmxStructureEnumType.ConceptScheme));
                measureDimensionCodelistMapping.Add(measureDim.Id ?? measureDim.ConceptRef.ChildReference.Id, measureDim.Representation.Representation);
                measureDim.Representation.Representation = cocneptSchemeRef;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Setup cross sectional DSD.
        /// </summary>
        /// <param name="parent">
        /// The parent.
        /// </param>
        /// <param name="crossDataSet">
        /// The list of components attached to cross-sectional data set.
        /// </param>
        /// <param name="crossGroup">
        /// The list of components attached to cross-sectional group.
        /// </param>
        /// <param name="crossSection">
        /// The list of components attached to cross-sectional section.
        /// </param>
        /// <param name="crossObs">
        /// The list of components attached to cross-sectional observation level
        /// </param>
        /// <param name="crossSectionalMeasures">
        /// The cross sectional measures.
        /// </param>
        /// <param name="measureCodelistRepresentation">
        /// The SDMX v2.0 measure dimension codelist representation; otherwise null
        /// </param>
        /// <returns>
        /// The <see cref="IDataStructureMutableObject"/>.
        /// </returns>
        private static IDataStructureMutableObject SetupCrossSectionalDsd(
            IDataStructureMutableObject parent,
            ICollection <string> crossDataSet,
            ICollection <string> crossGroup,
            ICollection <string> crossSection,
            ICollection <string> crossObs,
            IEnumerable <ICrossSectionalMeasureMutableObject> crossSectionalMeasures,
            IStructureReference measureCodelistRepresentation)
        {
            if (
                parent.Dimensions.All(
                    o =>
                    o.FrequencyDimension || o.TimeDimension || o.MeasureDimension || crossDataSet.Contains(o.Id) || crossGroup.Contains(o.Id) || crossSection.Contains(o.Id) || crossObs.Contains(o.Id)))
            {
                if (parent.AttributeList == null ||
                    parent.AttributeList.Attributes.All(o => crossDataSet.Contains(o.Id) || crossGroup.Contains(o.Id) || crossSection.Contains(o.Id) || crossObs.Contains(o.Id)))
                {
                    ICrossSectionalDataStructureMutableObject crossDsd = _crossDsdBuilder.Build(parent);
                    crossDsd.CrossSectionalAttachDataSet.AddAll(crossDataSet);
                    crossDsd.CrossSectionalAttachSection.AddAll(crossSection);
                    crossDsd.CrossSectionalAttachGroup.AddAll(crossGroup);
                    crossDsd.CrossSectionalAttachObservation.AddAll(crossObs);
                    IDimensionMutableObject measure = crossDsd.Dimensions.FirstOrDefault(o => o.MeasureDimension);
                    if (measure != null)
                    {
                        foreach (ICrossSectionalMeasureMutableObject crossSectionalMeasureMutableObject in crossSectionalMeasures)
                        {
                            crossSectionalMeasureMutableObject.MeasureDimension = measure.Id;
                            crossDsd.CrossSectionalMeasures.Add(crossSectionalMeasureMutableObject);
                        }

                        if (measureCodelistRepresentation == null)
                        {
                            DataStructureUtil.ConvertMeasureRepresentation(crossDsd);
                        }
                    }

                    return(crossDsd);
                }
            }

            return(parent);
        }
Esempio n. 4
0
        /// <summary>
        /// Setups the group attributes.
        /// </summary>
        /// <param name="dataStructure">The data structure.</param>
        /// <param name="dsdId">The DSD identifier.</param>
        private void SetupAttributesAttachmentCrossMeasures(ICrossSectionalDataStructureMutableObject dataStructure, long dsdId)
        {
            if (dataStructure == null || !ObjectUtil.ValidCollection(dataStructure.Attributes) || !ObjectUtil.ValidCollection(dataStructure.CrossSectionalMeasures))
            {
                return;
            }

            var idToAttribureMap = dataStructure.Attributes.Where(o => dataStructure.CrossSectionalAttachObservation.Contains(o.Id)).ToDictionary(o => o.Id, StringComparer.Ordinal);

            if (idToAttribureMap.Count == 0)
            {
                return;
            }

            using (DbCommand command = this._commandBuilder.Build(new ItemSqlQuery(this._attributeMeasureQueryInfo, dsdId)))
            {
                using (IDataReader dataReader = this.MappingStoreDb.ExecuteReader(command))
                {
                    while (dataReader.Read())
                    {
                        var measureId   = DataReaderHelper.GetString(dataReader, "XSM_ID");
                        var attributeId = DataReaderHelper.GetString(dataReader, "ATTR_ID");
                        IAttributeMutableObject attribute;
                        if (idToAttribureMap.TryGetValue(attributeId, out attribute))
                        {
                            Debug.Assert(attribute != null, "BUG. Attribute is null");
                            IList <string> measures;
                            if (!dataStructure.AttributeToMeasureMap.TryGetValue(attributeId, out measures))
                            {
                                measures = new List <string>();
                                dataStructure.AttributeToMeasureMap.Add(attributeId, measures);
                            }

                            measures.Add(measureId);
                        }
                        else
                        {
                            _log.WarnFormat("Attribute with ID {0} of DSD {1} has measure mappings but its attachment level is not observation", attributeId, dataStructure.Id);
                        }
                    }
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Converts the specified <paramref name="crossDsd"/> to stub.
        /// </summary>
        /// <param name="crossDsd">The cross DSD.</param>
        public static void ConvertToStub(this ICrossSectionalDataStructureMutableObject crossDsd)
        {
            crossDsd.Stub = true;
            crossDsd.ExternalReference = TertiaryBool.GetFromEnum(TertiaryBoolEnumType.True);
            crossDsd.StructureURL      = _defaultUri;

            // remove components
            crossDsd.AttributeList = null;
            crossDsd.DimensionList = new DimensionListMutableCore();
            crossDsd.Dimensions.Clear();
            crossDsd.Groups.Clear();
            crossDsd.MeasureList = null;
            crossDsd.CrossSectionalAttachDataSet.Clear();
            crossDsd.CrossSectionalAttachGroup.Clear();
            crossDsd.CrossSectionalAttachSection.Clear();
            crossDsd.CrossSectionalAttachObservation.Clear();
            crossDsd.CrossSectionalMeasures.Clear();
            crossDsd.MeasureDimensionCodelistMapping.Clear();
            crossDsd.AttributeToMeasureMap.Clear();
        }
 /// <summary>
 /// Builds an object of type <see cref="IDataStructureMutableObject"/> from the specified <paramref name="buildFrom"/>
 /// </summary>
 /// <param name="buildFrom">
 /// An <see cref="ICrossSectionalDataStructureMutableObject"/> object to build the output object from
 /// </param>
 /// <returns>
 /// Object of type <see cref="IDataStructureMutableObject"/>
 /// </returns>
 public IDataStructureMutableObject Build(ICrossSectionalDataStructureMutableObject buildFrom)
 {
     var imutableDsd = new DataStructureObjectCore(buildFrom);
     return new DataStructureMutableCore(imutableDsd);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="CrossSectionalDsdHelper"/> class.
 /// </summary>
 /// <param name="dsd">
 /// The DSD.
 /// </param>
 public CrossSectionalDsdHelper(IDataStructureMutableObject dsd)
 {
     this._crossSectional = dsd as ICrossSectionalDataStructureMutableObject;
     if (this._crossSectional != null)
     {
         this._crossDataSet = new HashSet<string>(
             this._crossSectional.CrossSectionalAttachDataSet, StringComparer.Ordinal);
         this._crossGroup = new HashSet<string>(
             this._crossSectional.CrossSectionalAttachGroup, StringComparer.Ordinal);
         this._crossSection = new HashSet<string>(
             this._crossSectional.CrossSectionalAttachSection, StringComparer.Ordinal);
         this._crossObs = new HashSet<string>(
             this._crossSectional.CrossSectionalAttachObservation, StringComparer.Ordinal);
         this._attributeMap = this._crossSectional.AttributeToMeasureMap;
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="CrossSectionalDataStructureObjectCore"/> class.
        /// </summary>
        /// <param name="itemMutableObject">
        /// The itemMutableObject.
        /// </param>
        /// <exception cref="SdmxSemmanticException">
        /// Throws Validate exception.
        /// </exception>
        public CrossSectionalDataStructureObjectCore(ICrossSectionalDataStructureMutableObject itemMutableObject)
            : base(itemMutableObject)
        {
            this._crossSectionalMeasures = new List<ICrossSectionalMeasure>();
            this._crossSectionalAttachDataSet = new List<IComponent>();
            this._crossSectionalAttachGroup = new List<IComponent>();
            this._crossSectionalAttachSection = new List<IComponent>();
            this._crossSectionalAttachObservation = new List<IComponent>();
            this._attributeToMeasuresMap = new Dictionary<string, IList<ICrossSectionalMeasure>>();
            this._measureDimensions = new List<string>();
            this._codelistMap = new Dictionary<string, ICrossReference>();

            if (itemMutableObject.CrossSectionalMeasures != null)
            {
                foreach (ICrossSectionalMeasureMutableObject currentMeasure in itemMutableObject.CrossSectionalMeasures)
                {
                    this._crossSectionalMeasures.Add(new CrossSectionalMeasureCore(currentMeasure, this));
                }
            }

            if (itemMutableObject.MeasureDimensionCodelistMapping != null)
            {
                foreach (KeyValuePair<string, IStructureReference> pair in itemMutableObject.MeasureDimensionCodelistMapping)
                {
                    this._codelistMap.Add(pair.Key, new CrossReferenceImpl(this, pair.Value));
                }
            }

            foreach (IDimensionMutableObject dim in itemMutableObject.Dimensions)
            {
                if (dim.MeasureDimension)
                {
                    this._measureDimensions.Add(dim.ConceptRef.IdentifiableIds[0]);
                }
            }

            if (itemMutableObject.CrossSectionalAttachDataSet != null)
            {
                foreach (string componentId in itemMutableObject.CrossSectionalAttachDataSet)
                {
                    this.AddComponentToList(componentId, this._crossSectionalAttachDataSet);
                }
            }

            if (itemMutableObject.CrossSectionalAttachGroup != null)
            {
                foreach (string componentId0 in itemMutableObject.CrossSectionalAttachGroup)
                {
                    this.AddComponentToList(componentId0, this._crossSectionalAttachGroup);
                }
            }

            if (itemMutableObject.CrossSectionalAttachSection != null)
            {
                foreach (string componentId1 in itemMutableObject.CrossSectionalAttachSection)
                {
                    this.AddComponentToList(componentId1, this._crossSectionalAttachSection);
                }
            }

            if (itemMutableObject.CrossSectionalAttachObservation != null)
            {
                foreach (string componentId2 in itemMutableObject.CrossSectionalAttachObservation)
                {
                    this.AddComponentToList(componentId2, this._crossSectionalAttachObservation);
                }
            }

            if (itemMutableObject.AttributeToMeasureMap != null)
            {
                foreach (KeyValuePair<string, IList<string>> pair in itemMutableObject.AttributeToMeasureMap)
                {
                    this.SetAttributeMeasures(pair.Key, pair.Value);
                }
            }

            try
            {
                this.Validate();
            }
            catch (SdmxSemmanticException ex)
            {
                throw new SdmxSemmanticException(ex, ExceptionCode.ObjectStructureConstructionError, this.Urn);
            }
            catch (Exception th)
            {
                throw new SdmxException(th, ExceptionCode.ObjectStructureConstructionError, this.Urn);
            }
        }
        /// <summary>
        /// Handle end element.
        /// </summary>
        /// <param name="localname">
        /// The element local name.
        /// </param>
        protected override void HandleEndElement(object localname)
        {
            if (NameTableCache.IsElement(localname, ElementNameTable.KeyFamily))
            {
                Debug.Assert(this._currentDsd != null, "_currentDsd is null", "Local name: {0}", localname);
                if (this._currentDsd != null)
                {
                    // do we have components attached to cross sectional levels ?
                    if (IsCrossSectionalDsd(this._currentDsd))
                    {
                        if (this._currentDsd.CrossSectionalMeasures.Count > 0)
                        {
                           DataStructureUtil.ConvertMeasureRepresentation(this._currentDsd);
                        }

                        this.Structure.AddDataStructure(this._currentDsd);
                    }
                    else
                    {
                        this.Structure.AddDataStructure(_builder.Build(this._currentDsd));
                    }

                    this._currentDsd = null;
                }
            }
        }
        /////// <summary>
        ///////     Initialize handlers based on parent type for Elements and element text
        /////// </summary>
        ////private void InitializeTypeSwitch()
        ////{
        ////    // add element text handlers
        ////    this.AddHandleText<IAttributeMutableObject>(this.HandleTextChildElement);
        ////    this.AddHandleText<IGroupMutableObject>(this.HandleTextChildElement);
        ////    this.AddHandleText<IAnnotationMutableObject>(this.HandleTextChildElement);
        ////    this.AddHandleText<INameableMutableObject>(
        ////        (parent, localName) => this.HandleCommonTextChildElement(parent, localName));

        ////    // add element handlers
        ////    this.AddHandleElement<IComponentMutableObject>(this.HandleChildElements);
        ////    this.AddHandleElement<ICrossSectionalDataStructureMutableObject>(this.HandleChildElements);
        ////    this.AddHandleElement<ICollection<IAnnotationMutableObject>>(HandleChildElements);
        ////    this.AddHandleElement<IdentifiableMutableCore>(HandleChildElements); // super type move last
        ////    this.AddHandleElement<IMutableObjects>(this.HandleTopLevel);
        ////}

        /// <summary>
        /// Populates the properties of the given IAttributeMutableObject object from the given xml attributes dictionary
        /// </summary>
        /// <param name="parent">
        /// The parent.
        /// </param>
        /// <param name="component">
        /// The given IAttributeMutableObject object
        /// </param>
        /// <param name="attributes">
        /// The dictionary contains the attributes of the element
        /// </param>
        private void ParseAttributes(ICrossSectionalDataStructureMutableObject parent, IAttributeMutableObject component, IDictionary<string, string> attributes)
        {
            ParseComponentBaseAttributes(parent, component, attributes);
            string attachmentLevel = Helper.TrySetFromAttribute(attributes, AttributeNameTable.attachmentLevel, string.Empty);
            if (attachmentLevel == "Series")
            {
                component.AttachmentLevel = AttributeAttachmentLevel.DimensionGroup;
                foreach (IDimensionMutableObject dimension in this._currentDsd.Dimensions)
                {
                    if (!dimension.TimeDimension)
                    {
                        component.DimensionReferences.Add(dimension.ConceptRef.ChildReference.Id);
                    }
                }
            }
            else
            {
                AttributeAttachmentLevel modelAttachementLevel;

                if (Enum.TryParse(attachmentLevel, out modelAttachementLevel))
                {
                    component.AttachmentLevel = modelAttachementLevel;
                }
            }

            component.AssignmentStatus = Helper.TrySetFromAttribute(attributes, AttributeNameTable.assignmentStatus, component.AssignmentStatus);

            //// TODO JAVA 0.9.9 missing TimeFormat property from IAttributeMutableObject.
            bool timeFormat = Helper.TrySetFromAttribute(attributes, AttributeNameTable.isTimeFormat, false);
            if (timeFormat)
            {
                //// TODO FIXME HACK because of missing TimeFormat property from java 0.9.9
                component.Id = "TIME_FORMAT";
            }

            //// TODO java not supported by the Common API as in Java version 0.9.9
            ////component.IsEntityAttribute = Helper.TrySetFromAttribute(
            ////    attributes, AttributeNameTable.isEntityAttribute, component.IsEntityAttribute);
            ////component.IsNonObservationalTimeAttribute = Helper.TrySetFromAttribute(
            ////    attributes, AttributeNameTable.isNonObservationalTimeAttribute, component.IsNonObservationalTimeAttribute);
            ////component.IsCountAttribute = Helper.TrySetFromAttribute(
            ////    attributes, AttributeNameTable.isCountAttribute, component.IsCountAttribute);
            ////component.IsFrequencyAttribute = Helper.TrySetFromAttribute(
            ////    attributes, AttributeNameTable.isFrequencyAttribute, component.IsFrequencyAttribute);
            ////component.IsIdentityAttribute = Helper.TrySetFromAttribute(
            ////    attributes, AttributeNameTable.isIdentityAttribute, component.IsIdentityAttribute);
        }
        /// <summary>
        /// Handles the KeyFamily element child elements
        /// </summary>
        /// <param name="parent">
        /// The parent IDataStructureMutableObject object
        /// </param>
        /// <param name="localName">
        /// The name of the current xml element
        /// </param>
        /// <returns>
        /// The <see cref="StructureReaderBaseV20.ElementActions"/>.
        /// </returns>
        private ElementActions HandleChildElements(ICrossSectionalDataStructureMutableObject parent, object localName)
        {
            ElementActions actions = null;
            if (NameTableCache.IsElement(localName, ElementNameTable.Dimension))
            {
                var dimension = new DimensionMutableCore();
                ParseAttributes(parent, dimension, this.Attributes);
                parent.AddDimension(dimension);
                actions = this.BuildElementActions(dimension, this.HandleChildElements, DoNothing);
            }
            else if (NameTableCache.IsElement(localName, ElementNameTable.TimeDimension))
            {
                var timeDimension = new DimensionMutableCore { TimeDimension = true, Id = DimensionObject.TimeDimensionFixedId };
                ParseAttributes(parent, timeDimension, this.Attributes);
                parent.AddDimension(timeDimension);
                actions = this.BuildElementActions(timeDimension, this.HandleChildElements, DoNothing);
            }
            else if (NameTableCache.IsElement(localName, ElementNameTable.PrimaryMeasure))
            {
                var measure = new PrimaryMeasureMutableCore();
                ParseComponentBaseAttributes(parent, measure, this.Attributes);
                parent.PrimaryMeasure = measure;
                actions = this.BuildElementActions(measure, this.HandleChildElements, DoNothing);
            }
            else if (NameTableCache.IsElement(localName, ElementNameTable.CrossSectionalMeasure))
            {
                var measure = new CrossSectionalMeasureMutableCore();
                ParseAttributes(parent, measure, this.Attributes);
                parent.AddCrossSectionalMeasures(measure);
                actions = this.BuildElementActions(measure, this.HandleChildElements, DoNothing);
            }
            else if (NameTableCache.IsElement(localName, ElementNameTable.Attribute))
            {
                var attribute = new AttributeMutableCore();
                ParseAttributes(parent, attribute, this.Attributes);
                parent.AddAttribute(attribute);
                actions = this.BuildElementActions(attribute, this.HandleChildElements, this.HandleTextChildElement);
            }
            else if (NameTableCache.IsElement(localName, ElementNameTable.Components))
            {
                //// Component element contains the rest of elements so we use the same action again.
                actions = this.BuildElementActions(parent, this.HandleChildElements, DoNothing);
            }
            else if (NameTableCache.IsElement(localName, ElementNameTable.Group))
            {
                var groupMutableCore = new GroupMutableCore();
                ParseAttributes(groupMutableCore, this.Attributes);
                parent.AddGroup(groupMutableCore);
                actions = this.BuildElementActions(groupMutableCore, this.HandleAnnotableChildElements, this.HandleTextChildElement);
            }

            return actions;
        }
        /// <summary>
        /// Populates the properties of the given IComponentMutableObject object from the given xml attributes dictionary
        /// </summary>
        /// <param name="parent">
        /// The <see cref="ICrossSectionalDataStructureMutableObject"/>
        /// </param>
        /// <param name="component">
        /// The given IComponentMutableObject object
        /// </param>
        /// <param name="attributes">
        /// The dictionary contains the attributes of the element
        /// </param>
        private static void ParseComponentBaseAttributes(ICrossSectionalDataStructureMutableObject parent, IComponentMutableObject component, IDictionary<string, string> attributes)
        {
            var conceptRef = ParseComponentConceptAttributes(component, attributes);

            // code list attributes
            string codelist = Helper.TrySetFromAttribute(attributes, AttributeNameTable.codelist, string.Empty);
            if (!string.IsNullOrEmpty(codelist))
            {
                component.Representation = new RepresentationMutableCore();
                string codelistVersion = Helper.TrySetFromAttribute(attributes, AttributeNameTable.codelistVersion, string.Empty);
                string codelistAgency = Helper.TrySetFromAttribute(attributes, AttributeNameTable.codelistAgency, string.Empty);
                component.Representation.Representation = new StructureReferenceImpl(codelistAgency, codelist, codelistVersion, SdmxStructureEnumType.CodeList);
            }

            // XS
            var id = component.Id ?? conceptRef;
            AddCrossSectionalAttach(id, parent.CrossSectionalAttachDataSet, AttributeNameTable.crossSectionalAttachDataSet, attributes);
            AddCrossSectionalAttach(id, parent.CrossSectionalAttachGroup, AttributeNameTable.crossSectionalAttachGroup, attributes);
            AddCrossSectionalAttach(id, parent.CrossSectionalAttachSection, AttributeNameTable.crossSectionalAttachSection, attributes);
            AddCrossSectionalAttach(id, parent.CrossSectionalAttachObservation, AttributeNameTable.crossSectionalAttachObservation, attributes);
        }
        ///// <summary>
        ///// Populates the proporties of the given IDimensionMutableObject object from the given xml attributes dictionary
        ///// </summary>
        ///// <param name="timeDimension">The given IDimensionMutableObject object</param>
        ///// <param name="attributes">The dictionary contains the attributes of the element</param>
        // private static void ParseAttributes(IDimensionMutableObject timeDimension, IDictionary<string, string> attributes) {
        // ParseAttributes((IComponentMutableObject) timeDimension, attributes);
        // }

        /// <summary>
        /// Populates the properties of the given IDimensionMutableObject object from the given xml attributes dictionary
        /// </summary>
        /// <param name="artefact">
        /// The <see cref="ICrossSectionalDataStructureMutableObject"/>
        /// </param>
        /// <param name="dimension">
        /// The given IDimensionMutableObject object
        /// </param>
        /// <param name="attributes">
        /// The dictionary contains the attributes of the element
        /// </param>
        private static void ParseAttributes(ICrossSectionalDataStructureMutableObject artefact, IDimensionMutableObject dimension, IDictionary<string, string> attributes)
        {
            //// TODO java not supported by the Common API as in Java version 0.9.9
            ////dimension.IsCountDimension = Helper.TrySetFromAttribute(
            ////    attributes, AttributeNameTable.isCountAttribute, dimension.IsCountDimension);
            dimension.MeasureDimension = Helper.TrySetFromAttribute(attributes, AttributeNameTable.isMeasureDimension, dimension.MeasureDimension);
            dimension.FrequencyDimension = Helper.TrySetFromAttribute(attributes, AttributeNameTable.isFrequencyDimension, dimension.FrequencyDimension);

            //// TODO java not supported by the Common API as in Java version 0.9.9
            ////dimension.IsEntityDimension = Helper.TrySetFromAttribute(
            ////    attributes, AttributeNameTable.isEntityDimension, dimension.IsEntityDimension);
            ////dimension.IsNonObservationTimeDimension = Helper.TrySetFromAttribute(
            ////    attributes, AttributeNameTable.isNonObservationTimeDimension, dimension.IsNonObservationTimeDimension);
            ////dimension.IsIdentityDimension = Helper.TrySetFromAttribute(
            ////    attributes, AttributeNameTable.isIdentityAttribute, dimension.IsIdentityDimension);
            ParseComponentBaseAttributes(artefact, dimension, attributes);
        }
        ///// <summary>
        ///// Populates the proporties of the given IPrimaryMeasureMutableObject object from the given xml attributes dictionary
        ///// </summary>
        ///// <param name="measure">The given IPrimaryMeasureMutableObject objectt</param>
        ///// <param name="attributes">The dictionary contains the attributes of the element</param>
        // private static void ParseAttributes(IPrimaryMeasureMutableObject measure, IDictionary<string, string> attributes) {
        // ParseAttributes((IComponentMutableObject) measure, attributes);
        // }

        /// <summary>
        /// Populates the properties of the given ICrossSectionalMeasureMutableObject object from the given xml attributes dictionary
        /// </summary>
        /// <param name="artefact">
        /// The <see cref="ICrossSectionalDataStructureMutableObject"/>
        /// </param>
        /// <param name="measure">
        /// The given ICrossSectionalMeasureMutableObject object
        /// </param>
        /// <param name="attributes">
        /// The dictionary contains the attributes of the element
        /// </param>
        private static void ParseAttributes(ICrossSectionalDataStructureMutableObject artefact, ICrossSectionalMeasureMutableObject measure, IDictionary<string, string> attributes)
        {
            ParseComponentBaseAttributes(artefact, measure, attributes);
            measure.MeasureDimension = Helper.TrySetFromAttribute(attributes, AttributeNameTable.measureDimension, measure.MeasureDimension);
            measure.Code = Helper.TrySetFromAttribute(attributes, AttributeNameTable.code, measure.Code);
        }
        /// <summary>
        /// Checks if the current DSD is a valid SDMX v2.0 Cross Sectional DSD
        /// </summary>
        /// <param name="dsd">
        /// The DSD.
        /// </param>
        /// <returns>
        /// Returns true if it is a valid SDMX v2.0 Cross Sectional DSD; otherwise false
        /// </returns>
        private static bool IsCrossSectionalDsd(ICrossSectionalDataStructureMutableObject dsd)
        {
            ISet<string> crossSectionalAttached = new HashSet<string>(dsd.CrossSectionalAttachDataSet);
            crossSectionalAttached.UnionWith(dsd.CrossSectionalAttachGroup);
            crossSectionalAttached.UnionWith(dsd.CrossSectionalAttachSection);
            crossSectionalAttached.UnionWith(dsd.CrossSectionalAttachObservation);

            IList<IDimensionMutableObject> dimensions = dsd.Dimensions;
            foreach (IDimensionMutableObject dimension in dimensions)
            {
                if (!dimension.FrequencyDimension && !dimension.MeasureDimension && !dimension.TimeDimension && !crossSectionalAttached.Contains(dimension.ConceptRef.ChildReference.Id))
                {
                    return false;
                }
            }

            if (dsd.AttributeList != null)
            {
                IList<IAttributeMutableObject> attributes = dsd.AttributeList.Attributes;
                foreach (IAttributeMutableObject attribute in attributes)
                {
                    if (!crossSectionalAttached.Contains(attribute.ConceptRef.ChildReference.Id))
                    {
                        return false;
                    }
                }
            }

            return true;
        }
        /// <summary>
        /// Handles the Structure top level elements
        ///     This includes Codelist
        /// </summary>
        /// <param name="parent">
        /// The parent <see cref="IMutableObjects"/>
        /// </param>
        /// <param name="localName">
        /// The name of the current xml element
        /// </param>
        /// <returns>
        /// The <see cref="StructureReaderBaseV20.ElementActions"/>.
        /// </returns>
        protected override ElementActions HandleTopLevel(IMutableObjects parent, object localName)
        {
            ElementActions actions = null;
            if (NameTableCache.IsElement(localName, ElementNameTable.KeyFamily))
            {
                var kf = new CrossSectionalDataStructureMutableCore();
                ParseAttributes(kf, this.Attributes);

                //// NOTE this is handled at HandleEndElement because we need to decide if it will remain a XS DSD or should it be converted to a non XS (2.0) one.
                //// parent.AddDataStructure(kf);
                this._currentDsd = kf;
                actions = this.AddNameableAction(kf, this.HandleChildElements);
            }

            return actions;
        }