private IBcc GetBcc(IAcc acc, string name)
        {
            List <IBcc> bccsForAcc;

            if (!bccsByAccId.TryGetValue(acc.Id, out bccsForAcc))
            {
                bccsForAcc          = new List <IBcc>(acc.Bccs);
                bccsByAccId[acc.Id] = bccsForAcc;
            }
            foreach (IBcc bcc in bccsForAcc)
            {
                if (name == NDR.GenerateBCCName(bcc))
                {
                    return(bcc);
                }
            }
            return(null);
        }
        internal static XmlSchemaComplexType GenerateComplexTypeACC(GeneratorContext context, XmlSchema schema, IAcc acc, string accPrefix)
        {
            // R A4CE, R AF95: a complex type must be defined for each ABIE
            XmlSchemaComplexType complexTypeACC = new XmlSchemaComplexType();

            // R 9D83: the name of the ABIE must be the DictionaryEntryName with all whitespace and separators
            //         removed. The 'Details' suffix is replaced with 'Type'.
            complexTypeACC.Name = acc.Name + "Type";

            if (context.Annotate)
            {
                complexTypeACC.Annotation = GetACCAnnotation(acc);
            }

            // create the sequence for the BBIEs within the ABIE
            XmlSchemaSequence sequenceBCCs = new XmlSchemaSequence();

            foreach (IBcc bcc in acc.Bccs.OrderBy(a => a.Name))
            {
                // R 89A6: for every BBIE a named element must be locally declared
                XmlSchemaElement elementBCC = new XmlSchemaElement();

                // R AEFE, R 96D9, R9A40, R A34A are implemented in GetXsdElementNameFromBbie(...)
                elementBCC.Name = NDR.GenerateBCCName(bcc);

                // R 8B85: every BBIE type must be named the property term and qualifiers and the
                //         representation term of the basic business information entity (BBIE) it represents
                //         with the word 'Type' appended.
                elementBCC.SchemaTypeName =
                    new XmlQualifiedName(NSPREFIX_CDT + ":" + bcc.Cdt.Name + bcc.Cdt.Con.BasicType.Name + "Type");


                // R 90F9: cardinality of elements within the ABIE
                elementBCC.MinOccursString = AdjustLowerBound(bcc.LowerBound);
                elementBCC.MaxOccursString = AdjustUpperBound(bcc.UpperBound);

                if (context.Annotate)
                {
                    elementBCC.Annotation = GetBCCAnnotation(bcc);
                }

                // add the element created to the sequence
                sequenceBCCs.Items.Add(elementBCC);
            }


            foreach (IAscc ascc in acc.Asccs.OrderBy(a => a.Name))
            {
                XmlSchemaElement elementASCC = new XmlSchemaElement();

                // R A08A: name of the ASBIE
                elementASCC.Name           = NDR.GenerateASCCName(ascc);
                elementASCC.SchemaTypeName =
                    new XmlQualifiedName(accPrefix + ":" + ascc.AssociatedAcc.Name + "Type");

                if (context.Annotate)
                {
                    elementASCC.Annotation = GetASCCAnnotiation(ascc);
                }

                // R 9241: for ASBIEs with AggregationKind = shared a global element must be declared.
                // ASCCs are always shared (as defined in UPCC)
                XmlSchemaElement refASCC = new XmlSchemaElement();
                refASCC.RefName = new XmlQualifiedName(accPrefix + ":" + elementASCC.Name);

                // every shared ASCC may only appear once in the XSD file
                if (!globalASCCs.Contains(elementASCC.Name))
                {
                    schema.Items.Add(elementASCC);
                    globalASCCs.Add(elementASCC.Name);
                }
                sequenceBCCs.Items.Add(refASCC);
            }

            // add the sequence created to the complex type
            complexTypeACC.Particle = sequenceBCCs;
            return(complexTypeACC);
        }