private void CompileXsdTypesFromBdt(IBdt bdt)
        {
            if (!alreadyCompiledTypes.Contains(bdt.Id))
            {
                alreadyCompiledTypes.Add(bdt.Id);

                XsdType xsdType = AddXsdType(bdt.Name);

                foreach (IBdtSup sup in bdt.Sups)
                {
                    xsdType.AddChild(sup.Name);
                }
            }
        }
        private XsdType AddXsdType(string upccName)
        {
            string xsdName = XsdType.ExtractXsdName(upccName);

            XsdType xsdType;

            if (!(xsdTypes.TryGetValue(xsdName, out xsdType)))
            {
                xsdType = new XsdType(upccName);
                xsdTypes.Add(xsdType.XsdName, xsdType);
            }

            return(xsdType);
        }
        private void CompileXsdTypesFromMa(IMa ma)
        {
            if (!alreadyCompiledTypes.Contains(ma.Id))
            {
                alreadyCompiledTypes.Add(ma.Id);

                XsdType xsdType = AddXsdType(ma.Name);

                foreach (IAsma asma in ma.Asmas)
                {
                    BieAggregator bieAggregator = asma.AssociatedBieAggregator;

                    if (bieAggregator.IsMa)
                    {
                        xsdType.AddChild(asma.Name);

                        CompileXsdTypesFromMa(bieAggregator.Ma);
                    }
                    else if (bieAggregator.IsAbie)
                    {
                        //if (bieAggregator.Name == "PaymentConditionsType_PaymentTerms")
                        //{
                        //    int y = 1;
                        //}

                        // BUG FIX:
                        xsdType.AddChild(asma.Name);

                        // In case that trough the ASMA aggregated element is an ABIE,
                        // then the ASMA is not an actual complex element of the MA's
                        // complex type.
                        CompileXsdTypesFromAbie(bieAggregator.Abie);
                    }
                    else
                    {
                        throw new Exception("The ASMA " + asma.Name + " of the MA " + ma.Name +
                                            " neither aggregates a MA nor an ABIE.");
                    }
                }
            }
        }
        private void CompileXsdTypesFromAbie(IAbie abie)
        {
            if (!alreadyCompiledTypes.Contains(abie.Id))
            {
                alreadyCompiledTypes.Add(abie.Id);

                XsdType xsdType = AddXsdType(abie.Name);

                foreach (IBbie bbie in abie.Bbies)
                {
                    xsdType.AddChild(bbie.Name);

                    CompileXsdTypesFromBdt(bbie.Bdt);
                }

                foreach (IAsbie asbie in abie.Asbies)
                {
                    xsdType.AddChild(asbie.Name);

                    CompileXsdTypesFromAbie(asbie.AssociatedAbie);
                }
            }
        }