示例#1
0
        /// <summary>
        /// Return a <see cref="ICategorisationObject"/>  with the specified <paramref name="categoryReference"/> and <paramref name="structureReference"/>
        /// </summary>
        /// <param name="categoryReference">
        /// The category reference.
        /// </param>
        /// <param name="structureReference">
        /// The structure reference.
        /// </param>
        /// <returns>
        /// The <see cref="ICategorisationObject"/>.
        /// </returns>
        public ICategorisationObject Build(IStructureReference categoryReference, IStructureReference structureReference)
        {
            ICategorisationMutableObject mutable = new CategorisationMutableCore();

            mutable.CategoryReference  = categoryReference;
            mutable.StructureReference = structureReference;

            var    structureRef      = structureReference.MaintainableReference;
            var    categorySchemeRef = categoryReference.MaintainableReference;
            string name =
                string.Format(
                    CultureInfo.InvariantCulture,
                    "{0}@{1}@{2}@{3}@{4}@{5}",
                    structureRef.MaintainableId,
                    structureRef.AgencyId,
                    structureRef.Version,
                    categorySchemeRef.MaintainableId,
                    categorySchemeRef.Version,
                    categoryReference.ChildReference.Id).Replace(".", string.Empty);

            mutable.Id = name.Length > 50 ? BuildHash(name) : name;

            mutable.Version  = "1.0";
            mutable.AgencyId = categorySchemeRef.AgencyId;
            mutable.AddName("en", name);
            return(mutable.ImmutableInstance);
        }
        /// <summary>
        /// Return a <see cref="ICategorisationObject"/>  with the specified <paramref name="categoryReference"/> and <paramref name="structureReference"/>
        /// </summary>
        /// <param name="categoryReference">
        /// The category reference.
        /// </param>
        /// <param name="structureReference">
        /// The structure reference.
        /// </param>
        /// <returns>
        /// The <see cref="ICategorisationObject"/>.
        /// </returns>
        public ICategorisationObject Build(IStructureReference categoryReference, IStructureReference structureReference)
        {
            ICategorisationMutableObject mutable = new CategorisationMutableCore();
            mutable.CategoryReference = categoryReference;
            mutable.StructureReference = structureReference;

            var structureRef = structureReference.MaintainableReference;
            var categorySchemeRef = categoryReference.MaintainableReference;
            string name =
                string.Format(
                    CultureInfo.InvariantCulture,
                    "{0}@{1}@{2}@{3}@{4}@{5}",
                    structureRef.MaintainableId,
                    structureRef.AgencyId,
                    structureRef.Version,
                    categorySchemeRef.MaintainableId,
                    categorySchemeRef.Version,
                    categoryReference.ChildReference.Id).Replace(".", string.Empty);
            mutable.Id = name.Length > 50 ? BuildHash(name) : name;

            mutable.Version = "1.0";
            mutable.AgencyId = categorySchemeRef.AgencyId;
            mutable.AddName("en", name);
            return mutable.ImmutableInstance;
        }
        /// <summary>
        /// Handle end element.
        /// </summary>
        /// <param name="localname">
        /// The element local name.
        /// </param>
        protected override void HandleEndElement(object localname)
        {
            if (NameTableCache.IsElement(localname, ElementNameTable.DataflowRef))
            {
                if (this._currentDataflowReference != null)
                {
                    IStructureReference categoryReference = CreateReference(this._currentCategoryScheme, SdmxStructureEnumType.Category, this._currentDataflowReference.ReferenceFrom.Id);
                    IStructureReference dataflowReference = this._currentDataflowReference.CreateReference();
                    var categorisation = new CategorisationMutableCore
                                             {
                                                 CategoryReference = categoryReference, 
                                                 StructureReference = dataflowReference, 
                                                 AgencyId = this._currentCategoryScheme.AgencyId
                                             };
                    categorisation.Id = string.Format(CultureInfo.InvariantCulture, "{0}_{1}", categorisation.CategoryReference.GetHashCode(), categorisation.StructureReference.GetHashCode());

                    if (this._currentDataflowReference.ReferenceFrom.Names.Count > 0)
                    {
                        categorisation.Names.AddAll(this._currentDataflowReference.ReferenceFrom.Names);
                    }
                    else
                    {
                        string name = string.Format(
                            CultureInfo.InvariantCulture, 
                            "Categorisation between Category {0} and Dataflow {1}", 
                            categorisation.CategoryReference, 
                            categorisation.StructureReference.MaintainableReference);
                        categorisation.AddName("en", name);
                    }

                    this.Structure.AddCategorisation(categorisation);
                    this._currentDataflowReference = null;
                }
            }
        }
示例#4
0
        /// <summary>
        ///  Create a ImmutableInstance of Categorisation
        /// </summary>
        /// <param name="DataflowCode">Dataflow Code</param>
        /// <param name="DataflowAgency">Dataflow Agency Id</param>
        /// <param name="DataflowVersion">Dataflow Version</param>
        /// <param name="CategoryParent">list of category parent, from hightLevel parent to low level child category</param>
        /// <returns>ICategorisationObject</returns>
        public ICategorisationObject BuildCategorisation(string DataflowCode, string DataflowAgency, string DataflowVersion, List <string> CategoryParent)
        {
            try
            {
                ICategorisationMutableObject ca = new CategorisationMutableCore();
                ca.AgencyId = this.CategorySchemeAgencyId;
                ca.Version  = this.CategorySchemeVersion;
                string IDName = string.Format("{0}@{1}@{2}@{3}@{4}@{5}",
                                              DataflowCode, DataflowAgency, DataflowVersion.Replace(".", ""),
                                              this.Code, this.CategorySchemeVersion.Replace(".", ""), CategoryParent[CategoryParent.Count - 1]);
                ca.Id = IDName;
                ca.AddName("en", IDName);

                //IAnnotationMutableObject ann = new AnnotationMutableCore();
                //ann.Type="CategoryScheme_node_order";
                //ann.Text.Add(new TextTypeWrapperMutableCore("en", (CategoryParent.Count).ToString()));
                //ca.AddAnnotation(ann);

                //ca.Id = string.Format(FlyConfiguration.CategorisationFormat, DataflowCode);
                //foreach (SdmxObjectNameDescription item in this.Names)
                //    ca.AddName(item.Lingua, item.Name);

                if (!this.ParsingObject.ReturnStub)
                {
                    if (this.VersionTypeResp == SdmxSchemaEnumType.VersionTwo)
                    {
                        ca.CategoryReference = ReferenceBuilder.CreateCategoryReference(this.Code, this.CategorySchemeAgencyId, this.CategorySchemeVersion, CategoryParent.ToArray());
                    }
                    else
                    {
                        ca.CategoryReference = ReferenceBuilder.CreateCategoryReference(this.Code, this.CategorySchemeAgencyId, this.CategorySchemeVersion, CategoryParent != null && CategoryParent.Count > 0 ? new string[1] {
                            CategoryParent[CategoryParent.Count - 1]
                        } : CategoryParent.ToArray());
                    }

                    ca.StructureReference = ReferenceBuilder.CreateDataflowReference(DataflowCode, DataflowAgency, DataflowVersion);
                }

                ca.FinalStructure = TertiaryBool.ParseBoolean(true);

                //if (this.ParsingObject.isReferenceOf || this.ParsingObject.ReturnStub)
                //{
                //    ca.ExternalReference = TertiaryBool.ParseBoolean(true);
                //    ca.StructureURL = RetreivalStructureUrl.Get(this, ca.Id, ca.AgencyId, ca.Version);
                //}

                return(ca.ImmutableInstance);
            }
            catch (SdmxException) { throw; }
            catch (Exception ex)
            {
                throw new SdmxException(this, FlyExceptionObject.FlyExceptionTypeEnum.CreateImmutable, ex);
            }
        }
示例#5
0
        private void GetCategorisationDataflow()
        {
            _dtCategorisationDataflow = DbAccess.ExecutetoTable(DBOperationEnum.GetCategorisationDataflow, null);

            if (_dtCategorisationDataflow.Rows.Count <= 0)
            {
                return;
            }

            ReferencesObject.Categorisation = new List <ICategorisationObject>();

            string DFID, DFAgency, DFVersion, CSID, CSAgency, CSVersion, CatCode, IDCAT, IDDataFlow;

            DataView  viewCSDF = new DataView(_dtCategorisationDataflow);
            DataTable dtCSDF   = viewCSDF.ToTable(true, "IDDataFlow", "DFID", "DFAgency", "DFVersion", "CSID",
                                                  "CSAgency", "CSVersion", "CatCode", "IDCAT");
            DataTable dtCatNames = viewCSDF.ToTable(true, "IDCAT", "CubeLang", "CubeName", "IDDataFlow");

            ICategorisationMutableObject categorisation;

            foreach (DataRow row in dtCSDF.Rows)
            {
                IDDataFlow = row["IDDataFlow"].ToString();
                DFID       = row["DFID"].ToString();
                DFAgency   = row["DFAgency"].ToString();
                DFVersion  = row["DFVersion"].ToString();
                CSID       = row["CSID"].ToString();
                CSAgency   = row["CSAgency"].ToString();
                CSVersion  = row["CSVersion"].ToString();
                CatCode    = row["CatCode"].ToString();
                IDCAT      = row["IDCAT"].ToString();

                categorisation = new CategorisationMutableCore()
                {
                    Id             = DFID,
                    AgencyId       = DFAgency,
                    Version        = DFVersion,
                    FinalStructure = TertiaryBool.ParseBoolean(true),
                };

                IStructureReference structureRef = new StructureReferenceImpl(DFAgency, DFID, DFVersion,
                                                                              SdmxStructureEnumType.Dataflow);
                IStructureReference categoryRef = new StructureReferenceImpl(CSAgency, CSID, CSVersion,
                                                                             SdmxStructureEnumType.Category, CatCode);

                categorisation.StructureReference = structureRef;
                categorisation.CategoryReference  = categoryRef;

                SetNames(dtCatNames.Select("IDCat = " + IDCAT + " AND IDDataFlow = " + IDDataFlow), categorisation);

                ReferencesObject.Categorisation.Add(categorisation.ImmutableInstance);
            }
        }
        protected void btnSaveCategorisation_Click(object sender, EventArgs e)
        {
            // Controllo su selezione categoria
            if (String.IsNullOrEmpty(tvCategory.SelectedValue))
                return;

            // Creo la Categorisation e la salvo

            // Creazione delle info di base della categorisation
            // Recupero della category selezionata

            string catsID = cmbCategorySchemes.SelectedValue.Replace(',', '_').Replace(".", "") + "_" +
                                        tvCategory.SelectedValue + "-" +
                                        ucArtIdentity.ID + "_" +
                                        ucArtIdentity.Agency + "_" +
                                        ucArtIdentity.Version.Replace(".", "");

            ICategorisationMutableObject categorisation = new CategorisationMutableCore();
            categorisation.Id = catsID;
            categorisation.AgencyId = ucArtIdentity.Agency;
            categorisation.Version = ucArtIdentity.Version;
            categorisation.AddName("en", "Categorisation " + ucArtIdentity.ToString());

            IStructureReference structureRef = new StructureReferenceImpl(ucArtIdentity.Agency,
                                                                            ucArtIdentity.ID,
                                                                            ucArtIdentity.Version,
                                                                            GetStructureType());
            categorisation.StructureReference = structureRef;

            ArtefactIdentity artIDCS = Utils.GetArtefactIdentityFromString(cmbCategorySchemes.SelectedValue);

            IStructureReference categoryRef = new StructureReferenceImpl(artIDCS.Agency,
                                                                        artIDCS.ID,
                                                                        artIDCS.Version,
                                                                        SdmxStructureEnumType.Category,
                                                                        tvCategory.SelectedValue);
            categorisation.CategoryReference = categoryRef;

            ISdmxObjects sdmxCategorisationInsert = new SdmxObjectsImpl();

            sdmxCategorisationInsert.AddCategorisation(categorisation.ImmutableInstance);

            _wsModel.SubmitStructure(sdmxCategorisationInsert);

            // Controllo su errore

            // Messaggio di inserimento avvenuto con successo

            // Refresh della Gridview
            PopolateGVCategorisations();
            ResetCatPanel();
        }
        /// <summary>
        /// Creates dataflow and categorisations based on the input dataflow
        /// </summary>
        /// <param name="dataflowsType">
        /// - if null will not add anything to the sdmxObjects container
        /// </param>
        /// <param name="beans">
        /// - to add dataflow and categorisations to
        /// </param>
        protected internal void ProcessDataflows(DataflowsType dataflowsType, ISdmxObjects beans)
        {
            var urns = new HashSet<Uri>();
            if (dataflowsType != null && ObjectUtil.ValidCollection(dataflowsType.Dataflow))
            {
                /* foreach */
                foreach (DataflowType currentType in dataflowsType.Dataflow)
                {
                    try
                    {
                        IDataflowObject currentDataflow = new DataflowObjectCore(currentType);
                        this.AddIfNotDuplicateURN(beans, urns, currentDataflow);

                        // CATEGORISATIONS FROM DATAFLOWS
                        if (currentType.CategoryRef != null)
                        {
                            /* foreach */
                            foreach (CategoryRefType cateogryRefType in currentType.CategoryRef)
                            {
                                // use mutable for now until the following issue is fixed. 
                                // http://www.metadatatechnology.com/mantis/view.php?id=1341
                                ICategorisationMutableObject mutable = new CategorisationMutableCore();
                                mutable.AgencyId = currentDataflow.AgencyId;
                                mutable.CategoryReference = RefUtil.CreateCategoryRef(cateogryRefType);

                                // TODO create specialized collections for TextTypeWrapperMutable and TextTypeWrapper 
                                foreach (ITextTypeWrapper name in currentDataflow.Names)
                                {
                                    mutable.Names.Add(new TextTypeWrapperMutableCore(name));
                                }

                                mutable.StructureReference = currentDataflow.AsReference;
                                mutable.Id = string.Format(
                                    CultureInfo.InvariantCulture,
                                    "{0}_{1}",
                                    mutable.CategoryReference.GetHashCode(),
                                    mutable.StructureReference.GetHashCode());

                                // TODO use MT fix in java when is done. Mantis ticket:
                                // http://www.metadatatechnology.com/mantis/view.php?id=1341
                                beans.AddCategorisation(new CategorisationObjectCore(mutable));

                                ////sdmxObjects.AddCategorisation(new CategorisationObjectCore(currentDataflow, cateogryRefType));
                            }
                        }
                    }
                    catch (Exception th)
                    {
                        throw new MaintainableObjectException(
                            th,
                            SdmxStructureType.GetFromEnum(SdmxStructureEnumType.Dataflow),
                            currentType.agencyID,
                            currentType.id,
                            currentType.version);
                    }
                }
            }
        }
        /// <summary>
        /// Create Categorisations from Version 2.0 category, adds the categorisation to the sdmxObjects container
        /// </summary>
        /// <param name="beans">
        /// container to add to
        /// </param>
        /// <param name="categoryType">
        /// The category Type.
        /// </param>
        /// <param name="categoryBean">
        /// The category Bean.
        /// </param>
        protected internal void ProcessCategory(
            ISdmxObjects beans, CategoryType categoryType, ICategoryObject categoryBean)
        {
            if (categoryType.DataflowRef != null)
            {
                foreach (DataflowRefType dataflowRefType in categoryType.DataflowRef)
                {
                    // use mutable for now until the following issue is fixed. 
                    // http://www.metadatatechnology.com/mantis/view.php?id=1341
                    ICategorisationMutableObject mutable = new CategorisationMutableCore();
                    mutable.AgencyId = categoryBean.MaintainableParent.AgencyId;

                    mutable.CategoryReference = categoryBean.AsReference;

                    // TODO create specialized collections for TextTypeWrapperMutable and TextTypeWrapper 
                    foreach (ITextTypeWrapper name in categoryBean.Names)
                    {
                        mutable.Names.Add(new TextTypeWrapperMutableCore(name));
                    }

                    mutable.StructureReference = dataflowRefType.URN != null
                                                     ? new StructureReferenceImpl(dataflowRefType.URN)
                                                     : new StructureReferenceImpl(
                                                           dataflowRefType.AgencyID,
                                                           dataflowRefType.DataflowID,
                                                           dataflowRefType.Version,
                                                           SdmxStructureEnumType.Dataflow);
                    mutable.Id = string.Format(
                        CultureInfo.InvariantCulture,
                        "{0}_{1}",
                        mutable.CategoryReference.GetHashCode(),
                        mutable.StructureReference.GetHashCode());

                    // TODO use MT fix in java when is done. Mantis ticket:
                    // http://www.metadatatechnology.com/mantis/view.php?id=1341
                    // sdmxObjects.AddCategorisation(new CategorisationObjectCore(categoryBean, dataflowRefType));
                    beans.AddCategorisation(new CategorisationObjectCore(mutable));
                }
            }

            if (categoryType.MetadataflowRef != null)
            {
                foreach (var mdfRef in categoryType.MetadataflowRef)
                {
                    beans.AddCategorisation(new CategorisationObjectCore(categoryBean, mdfRef));
                }
            }
        }
        private ICategorisationMutableObject GetCategorizationForm()
        {
            bool isInError = false;                 // Indicatore di errore
            string messagesGroup = string.Empty;    // Stringa di raggruppamento errori
            int errorCounter = 1;                   // Contatore errori

            #region CATEGORIZATION ID
            if (!ValidationUtils.CheckIdFormat(txt_id.Text.Trim()))
            {
                messagesGroup += Convert.ToString(errorCounter) + ") " + Resources.Messages.err_id_format + "<br /><br />";
                errorCounter++;
                isInError = true;
            }
            #endregion

            #region CATEGORIZATION AGENCY
            if (cmb_agencies.Text.Trim().Equals(string.Empty))
            {
                messagesGroup += Convert.ToString(errorCounter) + ") " + Resources.Messages.err_agency_missing + "<br /><br />";
                errorCounter++;
                isInError = true;
            }
            #endregion

            #region CATEGORIZATION VERSION
            if (!ValidationUtils.CheckVersionFormat(txt_version.Text.Trim()))
            {
                messagesGroup += Convert.ToString(errorCounter) + ") " + Resources.Messages.err_version_format + "<br /><br />";
                errorCounter++;
                isInError = true;
            }
            #endregion

            /* URI NOT REQUIRED */
            #region CATEGORIZATION URI
            if ((txt_uri.Text != string.Empty) && !ValidationUtils.CheckUriFormat(txt_uri.Text))
            {
                messagesGroup += Convert.ToString(errorCounter) + ") " + Resources.Messages.err_uri_format + "<br /><br />";
                errorCounter++;
                isInError = true;
            }
            #endregion

            #region CATEGORIZATION NAMES
            if (AddTextName.TextObjectList == null || AddTextName.TextObjectList.Count == 0)
            {
                messagesGroup += Convert.ToString(errorCounter) + ") " + Resources.Messages.err_list_name_format + "<br /><br />";
                errorCounter++;
                isInError = true;
            }
            #endregion

            #region CATEGORIZATION START END DATE
            bool checkForDatesCombination = true;

            if (!txt_valid_from.Text.Trim().Equals(string.Empty) && !ValidationUtils.CheckDateFormat(txt_valid_from.Text))
            {
                messagesGroup += Convert.ToString(errorCounter) + ") " + Resources.Messages.err_date_from_format + "<br /><br />";
                errorCounter++;
                checkForDatesCombination = false;
                isInError = true;
            }

            if (!txt_valid_to.Text.Trim().Equals(string.Empty) && !ValidationUtils.CheckDateFormat(txt_valid_to.Text))
            {
                messagesGroup += Convert.ToString(errorCounter) + ") " + Resources.Messages.err_date_to_format + "<br /><br />";
                errorCounter++;
                checkForDatesCombination = false;
                isInError = true;
            }

            if (!txt_valid_from.Text.Trim().Equals(string.Empty) && !txt_valid_to.Text.Trim().Equals(string.Empty))
            {
                // Controllo congruenza date
                if (checkForDatesCombination)
                {
                    if (!ValidationUtils.CheckDates(txt_valid_from.Text, txt_valid_to.Text))
                    {
                        messagesGroup += Convert.ToString(errorCounter) + ") " + Resources.Messages.err_date_diff + "<br /><br />";
                        errorCounter++;
                        isInError = true;
                    }
                }
            }
            #endregion

            if (isInError)
            {
                Utils.ShowDialog(messagesGroup, 300);
                return null;
            }

            ICategorisationMutableObject tmpCategorization = new CategorisationMutableCore();
            #region CREATE CATEGORIZATION FROM FORM

            tmpCategorization.AgencyId = GetAgencyValue();
            tmpCategorization.Id = txt_id.Text;
            tmpCategorization.Version = txt_version.Text;
            tmpCategorization.FinalStructure = TertiaryBool.ParseBoolean(chk_isFinal.Checked);
            tmpCategorization.Uri = (!txt_uri.Text.Trim().Equals(string.Empty) && ValidationUtils.CheckUriFormat(txt_uri.Text)) ? new Uri(txt_uri.Text) : null;
            if (!txt_valid_from.Text.Trim().Equals(string.Empty))
            {
                tmpCategorization.StartDate = DateTime.ParseExact(txt_valid_from.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            }
            if (!txt_valid_to.Text.Trim().Equals(string.Empty))
            {
                tmpCategorization.EndDate = DateTime.ParseExact(txt_valid_to.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            }
            foreach (var tmpName in AddTextName.TextObjectList)
            {
                tmpCategorization.AddName(tmpName.Locale, tmpName.Value);
            }
            if (AddTextDescription.TextObjectList != null)
                foreach (var tmpDescription in AddTextDescription.TextObjectList)
                {
                    tmpCategorization.AddDescription(tmpDescription.Locale, tmpDescription.Value);
                }
            if (AnnotationGeneralControl.AnnotationObjectList != null)
                foreach (var annotation in AnnotationGeneralControl.AnnotationObjectList)
                {
                    tmpCategorization.AddAnnotation(annotation);
                }
            #endregion

            string kindOfStructure = Session["tmpKindOfStructure"].ToString();
            SdmxStructureEnumType typeOfTheStructure = 0;

            switch (kindOfStructure)
            {
                case "CODELIST":
                    typeOfTheStructure = SdmxStructureEnumType.CodeList;
                    break;
                case "CONCEPT_SCHEME":
                    typeOfTheStructure = SdmxStructureEnumType.ConceptScheme;
                    break;
                case "CATEGORY_SCHEME":
                    typeOfTheStructure = SdmxStructureEnumType.CategoryScheme;
                    break;
                case "DATAFLOW":
                    typeOfTheStructure = SdmxStructureEnumType.Dataflow;
                    break;
                case "AGENCY_SCHEME":
                    typeOfTheStructure = SdmxStructureEnumType.AgencyScheme;
                    break;
                case "DATA_PROVIDER_SCHEME":
                    typeOfTheStructure = SdmxStructureEnumType.DataProviderScheme;
                    break;
                case "DATA_CONSUMER_SCHEME":
                    typeOfTheStructure = SdmxStructureEnumType.DataConsumerScheme;
                    break;
                case "ORGANIZATION_UNIT_SCHEME":
                    typeOfTheStructure = SdmxStructureEnumType.OrganisationUnitScheme;
                    break;
                case "STRUCTURE_SET":
                    typeOfTheStructure = SdmxStructureEnumType.StructureSet;
                    break;
                case "CONTENT_CONSTRAINT":
                    typeOfTheStructure = SdmxStructureEnumType.ContentConstraint;
                    break;
                case "KEY_FAMILY":
                    typeOfTheStructure = SdmxStructureEnumType.Dsd;
                    break;
            }

            string referenceOfTheObject = Session["tmpReferenceOfTheObject"].ToString();
            string[] elementsOfTheReference = referenceOfTheObject.Split('-');

            IStructureReference structureRef = new StructureReferenceImpl(elementsOfTheReference[1], elementsOfTheReference[0], elementsOfTheReference[2], typeOfTheStructure);
            tmpCategorization.StructureReference = structureRef;

            string[] referenceOfTheCategory = { Session["tmpCategoryReference"].ToString() };
            string referenceOfTheCategoryScheme = Session["tmpCategorySchemeReference"].ToString();
            string[] elementsOfTheCategoryScheme = referenceOfTheCategoryScheme.Split('-');
            IStructureReference categoryRef = new StructureReferenceImpl(elementsOfTheCategoryScheme[1], elementsOfTheCategoryScheme[0], elementsOfTheCategoryScheme[2], SdmxStructureEnumType.Category, referenceOfTheCategory);
            tmpCategorization.CategoryReference = categoryRef;

            return tmpCategorization;
        }
        /// <summary>
        /// Handle end element.
        /// </summary>
        /// <param name="localname">
        /// The element local name.
        /// </param>
        protected override void HandleEndElement(object localname)
        {
            if (NameTableCache.IsElement(localname, ElementNameTable.KeyFamilyRef))
            {
                Debug.Assert(this._currentReferenceInfo != null, "_currentReferenceInfo is null.", "local name: {0}", localname);
                Debug.Assert(this._currentDataflow != null, "_currentDataflow is null.", "local name: {0}", localname);
                if (this._currentReferenceInfo != null && this._currentDataflow != null)
                {
                    this._currentDataflow.DataStructureRef = this._currentReferenceInfo.CreateReference(new string[] { });
                }

                this._currentReferenceInfo = null;
            }
            else if (NameTableCache.IsElement(localname, ElementNameTable.CategoryRef))
            {
                Debug.Assert(this._currentReferenceInfo != null, "_currentReferenceInfo is null.", "local name: {0}", localname);
                Debug.Assert(this._currentDataflow != null, "_currentDataflow is null.", "local name: {0}", localname);
                if (this._currentReferenceInfo != null && this._currentDataflow != null)
                {
                    ICategorisationMutableObject categorisation = new CategorisationMutableCore();
                    categorisation.StructureReference = CreateReference(this._currentDataflow);
                    categorisation.CategoryReference = this._currentReferenceInfo.CreateReference(this._currentCategoryIds.ToArray());

                    categorisation.AgencyId = this._currentDataflow.AgencyId;
                    categorisation.Id = string.Format(CultureInfo.InvariantCulture, "{0}_{1}", categorisation.CategoryReference.GetHashCode(), categorisation.StructureReference.GetHashCode());

                    categorisation.Names.AddAll(this._currentDataflow.Names);

                    this.Structure.AddCategorisation(categorisation);

                    this._currentCategoryIds.Clear();
                }

                this._currentReferenceInfo = null;
            }
        }