static XmlSchemaElement CreateAsbieSchemaElement(IAsbie asbie, GeneratorContext context, XmlSchema schema)
        {
            XmlSchemaElement refASBIE = new XmlSchemaElement();

            refASBIE.Name            = NDR.GetXsdElementNameFromAsbie(asbie);
            refASBIE.SchemaTypeName  = new XmlQualifiedName(context.NamespacePrefix + ":" + NDR.TrimElementName(asbie.AssociatedAbie.Name));
            refASBIE.MinOccursString = AdjustBound(asbie.LowerBound);
            refASBIE.MaxOccursString = AdjustBound(asbie.UpperBound);
            return(refASBIE);
        }
Exemplo n.º 2
0
        internal static XmlSchemaComplexType GenerateComplexTypeABIE(GeneratorContext context, XmlSchema schema, IAbie abie, string abiePrefix)
        {
            // R A4CE, R AF95: a complex type must be defined for each ABIE
            XmlSchemaComplexType complexTypeBIE = 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'.
            complexTypeBIE.Name = abie.Name + "Type";

            if (context.Annotate)
            {
                complexTypeBIE.Annotation = GetABIEAnnotation(abie);
            }

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

            foreach (IBbie bbie in abie.Bbies)
            {
                // R 89A6: for every BBIE a named element must be locally declared
                XmlSchemaElement elementBBIE = new XmlSchemaElement();

                // R AEFE, R 96D9, R9A40, R A34A are implemented in GetXsdElementNameFromBbie(...)
                elementBBIE.Name = NDR.GetXsdElementNameFromBbie(bbie);

                // 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.
                elementBBIE.SchemaTypeName =
                    new XmlQualifiedName(NSPREFIX_BDT + ":" + NDR.GetXsdTypeNameFromBdt(bbie.Bdt));


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

                if (context.Annotate)
                {
                    elementBBIE.Annotation = GetBBIEAnnotation(bbie);
                }

                // add the element created to the sequence
                sequenceBBIEs.Items.Add(elementBBIE);
            }


            foreach (IAsbie asbie in abie.Asbies.OrderBy(a => a.Name))
            {
                XmlSchemaElement elementASBIE = new XmlSchemaElement();

                // R A08A: name of the ASBIE
                elementASBIE.Name           = NDR.GetXsdElementNameFromAsbie(asbie);
                elementASBIE.SchemaTypeName =
                    new XmlQualifiedName(abiePrefix + ":" + asbie.AssociatedAbie.Name + "Type");

                if (context.Annotate)
                {
                    elementASBIE.Annotation = GetASBIEAnnotiation(asbie);
                }

                if (asbie.AggregationKind == AggregationKind.Shared)
                {
                    XmlSchemaElement refASBIE = new XmlSchemaElement();
                    refASBIE.RefName = new XmlQualifiedName(abiePrefix + ":" + elementASBIE.Name);

                    // every shared ASCC may only appear once in the XSD file
                    if (!globalASBIEs.Contains(elementASBIE.Name))
                    {
                        // R 9241: for ASBIEs with AggregationKind = shared a global element must be declared.
                        schema.Items.Add(elementASBIE);
                        globalASBIEs.Add(elementASBIE.Name);
                    }
                    sequenceBBIEs.Items.Add(refASBIE);
                }
                else
                {
                    //R 9025: ASBIEs with Aggregation Kind = composite a local element for the
                    //        associated ABIE must be declared in the associating ABIE complex type.
                    sequenceBBIEs.Items.Add(elementASBIE);
                }
            }

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