public static XmlSchema GenerateXSD(GeneratorContext context) { string targetNameSpace = NDR.getTargetNameSpace(context, false); IMa documentRoot = context.DocLibrary.DocumentRoot; var schema = new XmlSchema { TargetNamespace = targetNameSpace }; //namespaces schema.Namespaces.Add("xsd", "http://www.w3.org/2001/XMLSchema"); schema.Namespaces.Add(context.NamespacePrefix, targetNameSpace); //qualifiedSetting schema.ElementFormDefault = XmlSchemaForm.Qualified; schema.AttributeFormDefault = XmlSchemaForm.Unqualified; //version schema.Version = context.DocLibrary.VersionIdentifier.DefaultTo("1"); string schemaFileName = getSchemaFileName(context, false); AddRootElementDeclaration(schema, documentRoot, context); GenerateComplexTypeForMa(context, schema, documentRoot); //non root elements, not used IEnumerable <IMa> nonRootDocLibraryElements = context.DocLibrary.NonRootMas; AddGlobalTypeDefinitions(schema, nonRootDocLibraryElements, context); AddGlobalElementDeclarations(schema, nonRootDocLibraryElements, context); context.AddSchema(schema, schemaFileName, UpccSchematype.ROOT); return(schema); }
private static XmlSchemaAnnotation GetAttributeAnnotation(ICdtSup sup) { var xml = new XmlDocument(); // Deviation from rule [R 9C95]: Generating only a subset of the defined annotations and added some additional annotations. var annNodes = new List <XmlNode>(); AddAnnotation(xml, annNodes, "PropertyTermName", sup.Name); AddAnnotation(xml, annNodes, "RepresentationTermName", NDR.GetBasicTypeName(sup as UpccAttribute)); AddAnnotation(xml, annNodes, "PrimitiveTypeName", NDR.GetBasicTypeName(sup as UpccAttribute)); AddAnnotation(xml, annNodes, "DataTypeName", sup.Cdt.Name); AddAnnotation(xml, annNodes, "UniqueID", sup.UniqueIdentifier); AddAnnotation(xml, annNodes, "VersionID", sup.VersionIdentifier); AddAnnotation(xml, annNodes, "DictionaryEntryName", sup.DictionaryEntryName); AddAnnotation(xml, annNodes, "Definition", sup.Definition); AddAnnotations(xml, annNodes, "BusinessTermName", sup.BusinessTerms); AddAnnotation(xml, annNodes, "ModificationAllowedIndicator", sup.ModificationAllowedIndicator.ToString().ToLower()); AddAnnotation(xml, annNodes, "LanguageCode", sup.LanguageCode); AddAnnotation(xml, annNodes, "AcronymCode", "SUP"); var ann = new XmlSchemaAnnotation(); ann.Items.Add(new XmlSchemaDocumentation { Language = "en", Markup = annNodes.ToArray() }); return(ann); }
internal static XmlSchemaComplexType GenerateComplexTypeABIE(GeneratorContext context, XmlSchema schema, IAbie abie) { // 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 = NDR.TrimElementName(abie.Name); var processedProperties = new List <ICctsProperty>(); // create the sequence for the BBIEs within the ABIE XmlSchemaSequence sequenceBBIEs = new XmlSchemaSequence(); //attributes and associations are mixed in a user defined order foreach (var property in abie.Properties) { if (!processedProperties.Contains(property)) { AddProperty(property, sequenceBBIEs, context, schema, processedProperties); } } // add the sequence created to the complex type complexTypeBIE.Particle = sequenceBBIEs; return(complexTypeBIE); }
private static void GenerateComplexTypeForMa(GeneratorContext context, XmlSchema schema, IMa ma) { var maType = new XmlSchemaComplexType(); maType.Name = ma.Name + "Type"; var sequence = new XmlSchemaSequence(); foreach (IAsma asma in ma.Asmas) { var rasmaElement = new XmlSchemaElement(); rasmaElement.Name = NDR.GetXsdElementNameFromAsma(asma); rasmaElement.SchemaTypeName = new XmlQualifiedName(context.NamespacePrefix + ":" + NDR.TrimElementName(asma.AssociatedBieAggregator.Name)); // R 90F9: cardinality of elements within the ABIE rasmaElement.MinOccursString = AdjustBound(asma.LowerBound); rasmaElement.MaxOccursString = AdjustBound(asma.UpperBound); //add to the sequence sequence.Items.Add(rasmaElement); } //set the sequence as particle of the ma complex type maType.Particle = sequence; //add the maType to the schema schema.Items.Add(maType); }
protected override BdtConSpec SpecifyCON() { return(new BdtConSpec { Name = "Content", BasicType = new BasicType(FindPRIM(NDR.ConvertXsdTypeNameToBasicTypeName(ContentComponentXsdTypeName))) }); }
public bool AddNdr(NdrDTO ndrDTO) { NDR ndr = _mapper.Map <NDR>(ndrDTO); _uow.NdrRepository.AddNdr(ndr); return(_uow.SaveChanges() >= 0); }
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); }
public MailResult(NDRType messageType, string messageTypeString, string bouncedEmailAddress, string helpMessage, NDR ndrMessage, bool willDelete, int newStatus) { MessageType = messageType; MessageTypeString = messageTypeString; BouncedEmailAddress = bouncedEmailAddress; HelpMessage = helpMessage; NdrMessage = ndrMessage; WillDelete = willDelete; NewStatus = newStatus; }
///<summary> ///</summary> ///<param name="abieComplexType"> ///</param> ///<param name="allElementDefinitions"> ///</param> ///<returns> ///</returns> public static IList <AsbieSpec> CumulateAbiesSpecsFromComplexType(ComplexType abieComplexType, IDictionary <string, string> allElementDefinitions) { IList <AsbieSpec> newAsbieSpecs = new List <AsbieSpec>(); string abieName = abieComplexType.Name.Substring(0, abieComplexType.Name.Length - 4); foreach (Element element in abieComplexType.Items) { if (!(element.Ref.Name.Equals(""))) { string associatedABIEName = allElementDefinitions[element.Ref.Name]; associatedABIEName = associatedABIEName.Substring(0, associatedABIEName.Length - 4); IAbie associatedAbie = BieLibrary.GetAbieByName(associatedABIEName); string asbieName = NDR.GetAsbieNameFromXsdElement(element, associatedABIEName); AsbieSpec asbieSpec = MatchAsbieToAscc(FindBaseACCForABIE(abieName), asbieName, associatedAbie); if (asbieSpec == null) { asbieSpec = CumulateAsbieSpec(element, asbieName, associatedAbie, AggregationKind.Shared); } newAsbieSpecs.Add(asbieSpec); } else { if (element.Type.Prefix.Equals("tns")) { string associatedAbieName = element.Type.Name; associatedAbieName = associatedAbieName.Substring(0, associatedAbieName.Length - 4); IAbie associatedAbie = BieLibrary.GetAbieByName(associatedAbieName); string asbieName = element.Name.Substring(0, element.Name.Length - associatedAbieName.Length); AsbieSpec asbieSpec = MatchAsbieToAscc(FindBaseACCForABIE(abieName), asbieName, associatedAbie); if (asbieSpec == null) { asbieSpec = CumulateAsbieSpec(element, asbieName, associatedAbie, AggregationKind.Composite); } newAsbieSpecs.Add(asbieSpec); } } } return(newAsbieSpecs); }
private static IAscc GetAscc(IAcc acc, string name) { foreach (IAscc ascc in acc.Asccs) { if (name == NDR.GenerateASCCName(ascc)) { return(ascc); } } return(null); }
private static ICdtSup GetSup(ICdt cdt, string name) { foreach (ICdtSup sup in cdt.Sups) { if (name == NDR.GetXsdAttributeNameFromSup(sup)) { return(sup); } } return(null); }
protected IEnumerable <BdtSupSpec> SpecifySUPs(XmlSchemaObjectCollection xsdAttributes) { foreach (XmlSchemaAttribute attribute in xsdAttributes) { string basicTypeName = NDR.ConvertXsdTypeNameToBasicTypeName(attribute.SchemaTypeName.Name); yield return(new BdtSupSpec { Name = attribute.Name.Minus(basicTypeName), BasicType = new BasicType(FindPRIM(basicTypeName)), }); } }
private static void AddSimpleTypeDefinition(XmlSchema schema, GeneratorContext context, TempEnum tempEnum) { var restrictedtype = new XmlSchemaSimpleType(); restrictedtype.Name = NDR.GetBasicTypeName(tempEnum.sourceEnum); // enumeration with actual values addEnumRestriction(restrictedtype, tempEnum); //add the restrictedType to the schema schema.Items.Add(restrictedtype); }
protected override IEnumerable <BdtSupSpec> SpecifySUPs() { var extension = (XmlSchemaSimpleContentExtension)ComplexType.ContentModel.Content; foreach (XmlSchemaAttribute attribute in extension.Attributes) { string basicTypeName = NDR.ConvertXsdTypeNameToBasicTypeName(attribute.SchemaTypeName.Name); yield return(new BdtSupSpec { Name = attribute.Name.Minus(basicTypeName), BasicType = new BasicType(FindPRIM(basicTypeName)), }); } }
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); }
protected override BdtConSpec SpecifyCON() { BdtConSpec conSpec; BDTXsdType parent = Parent; if (parent != null) { conSpec = BdtConSpec.CloneBdtCon(parent.BDT.Con); } else { conSpec = new BdtConSpec { Name = "Content", BasicType = new BasicType(FindPRIM(NDR.ConvertXsdTypeNameToBasicTypeName(ContentComponentXsdTypeName))) }; } return(ApplyCONRestrictions(conSpec)); }
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); }
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); }
private static XmlSchemaComplexType GenerateComplexTypeForMa(GeneratorContext context, XmlSchema schema, IMa ma, string abiePrefix) { var maType = new XmlSchemaComplexType(); maType.Name = ma.Name + "Type"; var sequence = new XmlSchemaSequence(); foreach (IAsma asma in ma.Asmas.OrderBy(a => a.Name)) { XmlSchemaElement elementAsma = null; // Take care of ASMAS aggregating ABIEs if (asma.AssociatedBieAggregator.IsAbie) { elementAsma = new XmlSchemaElement { Name = NDR.GetXsdElementNameFromAsma(asma), SchemaTypeName = new XmlQualifiedName(NSPREFIX_BIE + ":" + asma.AssociatedBieAggregator.Name + "Type") }; } else if (asma.AssociatedBieAggregator.IsMa) { elementAsma = new XmlSchemaElement { Name = NDR.GetXsdElementNameFromAsma(asma), SchemaTypeName = new XmlQualifiedName(context.NamespacePrefix + ":" + asma.AssociatedBieAggregator.Name + "Type") }; } var refAsma = new XmlSchemaElement { RefName = new XmlQualifiedName(context.NamespacePrefix + ":" + NDR.GetXsdElementNameFromAsma(asma)) }; // every shared ASCC may only appear once in the XSD file if (!globalAsmas.Contains(elementAsma.Name)) { // R 9241: for ASBIEs with AggregationKind = shared a global element must be declared. schema.Items.Add(elementAsma); globalAsmas.Add(elementAsma.Name); } sequence.Items.Add(refAsma); } maType.Particle = sequence; if (context.Annotate) { maType.Annotation = GetMaAnnotation(ma); } return(maType); }
public static void GenerateXSD(GeneratorContext context, XmlSchema schema) { var enums = new List <IEnum>(); var generatedBDTs = new List <string>(); //loop the bdt's foreach (IBdt bdt in context.Elements .OfType <IBdt>().Where(x => !x.isDirectXSDType)) { var xsdBdtName = NDR.GetXsdTypeNameFromBdt(bdt); //get the enum from the CON attribute and add it to the enums list. var enumToAdd = bdt.Con?.BasicType?.Enum; if (enumToAdd != null && !enums.Any(x => x.Name == enumToAdd.Name)) { enums.Add(enumToAdd); } //make sure we don't generate two BDT's witht he same xsdBdtName if (!generatedBDTs.Contains(xsdBdtName)) { //add the xsdBdtName to the list generatedBDTs.Add(xsdBdtName); var sups = new List <IBdtSup>(bdt.Sups); if (!sups.Any()) { var simpleType = new XmlSchemaSimpleType { Name = xsdBdtName }; var simpleTypeRestriction = new XmlSchemaSimpleTypeRestriction(); simpleTypeRestriction.BaseTypeName = GetXmlQualifiedName(NDR.getConBasicTypeName(bdt), context, bdt.Con?.BasicType); simpleType.Content = simpleTypeRestriction; if (bdt.Con != null && bdt.Con.BasicType != null && bdt.Con.BasicType.Prim != null) { var XSDtype = bdt.Con.BasicType.Prim.xsdType; if (!string.IsNullOrEmpty(XSDtype)) { simpleTypeRestriction.BaseTypeName = new XmlQualifiedName(NSPREFIX_XSD + ":" + XSDtype); } } if (context.Annotate) { simpleType.Annotation = GetTypeAnnotation(bdt); } schema.Items.Add(simpleType); } else { //create the complex type var complexType = new XmlSchemaComplexType(); complexType.Name = xsdBdtName; //add the simple content extension var simpleContent = new XmlSchemaSimpleContent(); var simpleContentExtension = new XmlSchemaSimpleContentExtension(); //get the xsd type if the con is a primitive if (bdt.Con.BasicType != null && bdt.Con.BasicType.Prim != null) { simpleContentExtension.BaseTypeName = GetXmlQualifiedName(bdt.Con.BasicType.Prim.xsdType, context, bdt.Con.BasicType); } else { var basicEnum = bdt.Con?.BasicType?.Enum; if (basicEnum != null) { //enum was already added tot he list above simpleContentExtension.BaseTypeName = new XmlQualifiedName(context.NamespacePrefix + ":" + NDR.GetBasicTypeName(basicEnum)); } else { simpleContentExtension.BaseTypeName = GetXmlQualifiedName(NDR.getConBasicTypeName(bdt), context, bdt.Con.BasicType); } } foreach (IBdtSup sup in sups) { var attribute = new XmlSchemaAttribute(); // Deviation from rule [R ABC1]: Using only attribute name and type as xml attribute name (instead of complete DEN), following the examples given in the specification. attribute.Name = sup.Name; //set optional or required attribute.Use = sup.IsOptional() ? XmlSchemaUse.Optional : XmlSchemaUse.Required; //set the type of the attribute if (sup.BasicType != null && sup.BasicType.IsEnum) { //figure out if the set of values is restricted var basicEnum = sup.BasicType.Enum as UpccEnum; //add the enum to the list if (!enums.Any(x => x.Name == basicEnum.Name)) { enums.Add(basicEnum); } if (basicEnum.CodelistEntries.Any()) { //add the restrictions var restrictedtype = new XmlSchemaSimpleType(); var restriction = new XmlSchemaSimpleTypeRestriction(); restriction.BaseTypeName = new XmlQualifiedName(context.NamespacePrefix + ":" + NDR.GetBasicTypeName(basicEnum)); addEnumerationValues(restriction, basicEnum); //add the restriction to the simple type restrictedtype.Content = restriction; //set the type of the attribute attribute.SchemaType = restrictedtype; } else { attribute.SchemaTypeName = new XmlQualifiedName(context.NamespacePrefix + ":" + NDR.GetBasicTypeName(basicEnum)); } } //set regular type name if not restricted if (attribute.SchemaTypeName.IsEmpty && attribute.SchemaType == null) { attribute.SchemaTypeName = GetXmlQualifiedName(NDR.GetBasicTypeName(sup as UpccAttribute), context, sup.BasicType); } //annotate if needed if (context.Annotate) { attribute.Annotation = GetAttributeAnnotation(sup); } //add the attribute simpleContentExtension.Attributes.Add(attribute); } simpleContent.Content = simpleContentExtension; complexType.ContentModel = simpleContent; if (context.Annotate) { complexType.Annotation = GetTypeAnnotation(bdt); } schema.Items.Add(complexType); } } } context.AddElements(enums); }
private static string GetAttributeName(ICdtSup sup) { string name = sup.Name + NDR.GetBasicTypeName(sup as UpccAttribute); return(name.Replace(".", "")); }
private static string GetTypeName(ICdt cdt) { return(cdt.Name + NDR.getConBasicTypeName(cdt) + "Type"); }
///<summary> ///</summary> ///<param name="context"></param> ///<param name="cdts"></param> public static void GenerateXSD(GeneratorContext context, IEnumerable <ICdt> cdts) { var schema = new XmlSchema { TargetNamespace = context.TargetNamespace }; schema.Namespaces.Add(context.NamespacePrefix, context.TargetNamespace); schema.Namespaces.Add("xsd", "http://www.w3.org/2001/XMLSchema"); schema.Namespaces.Add("ccts", "urn:un:unece:uncefact:documentation:standard:XMLNDRDocumentation:3"); schema.Version = context.DocLibrary.VersionIdentifier.DefaultTo("1"); foreach (ICdt cdt in cdts) { var sups = new List <ICdtSup>(cdt.Sups); if (sups.Count == 0) { var simpleType = new XmlSchemaSimpleType { Name = GetTypeName(cdt) }; var simpleTypeRestriction = new XmlSchemaSimpleTypeRestriction { BaseTypeName = GetXmlQualifiedName(NDR.getConBasicTypeName(cdt)) }; simpleType.Content = simpleTypeRestriction; if (context.Annotate) { simpleType.Annotation = GetTypeAnnotation(cdt); } schema.Items.Add(simpleType); } else { var complexType = new XmlSchemaComplexType { // Deviation from rule [R 90FB]: Using simpler and shorter names for CDT complex types. Name = GetTypeName(cdt) }; var simpleContent = new XmlSchemaSimpleContent(); var simpleContentExtension = new XmlSchemaSimpleContentExtension { BaseTypeName = GetXmlQualifiedName(NDR.getConBasicTypeName(cdt)) }; foreach (ICdtSup sup in sups) { var attribute = new XmlSchemaAttribute { // Deviation from rule [R ABC1]: Using only attribute name and type as xml attribute name (instead of complete DEN), following the examples given in the specification. Name = GetAttributeName(sup), SchemaTypeName = new XmlQualifiedName(GetXSDType(NDR.GetBasicTypeName(sup as UpccAttribute)), "http://www.w3.org/2001/XMLSchema"), }; if (context.Annotate) { attribute.Annotation = GetAttributeAnnotation(sup); } simpleContentExtension.Attributes.Add(attribute); } simpleContent.Content = simpleContentExtension; complexType.ContentModel = simpleContent; if (context.Annotate) { complexType.Annotation = GetTypeAnnotation(cdt); } schema.Items.Add(complexType); } } context.AddSchema(schema, "CoreDataType_" + schema.Version + ".xsd", UpccSchematype.CDT); }
static XmlSchemaElement CreateBbieSchemaElement(IBbie bbie, GeneratorContext context) { // 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. if (bbie.Bdt != null && bbie.Bdt.Con != null) { if (bbie.Bdt.Con.BasicType != null && bbie.Bdt.Con.BasicType.IsEnum) { //figure out if the set of values is restricted var basicEnum = bbie.Bdt.Con.BasicType.Enum as UpccEnum; //use this method only if there are values specified in the basic enum. If not then we simply use the type if (basicEnum != null && basicEnum.CodelistEntries.Any()) { var sourceEnum = basicEnum.SourceElement as UpccEnum; if (sourceEnum != null) { var restrictedtype = new XmlSchemaComplexType(); var sympleContent = new XmlSchemaSimpleContent(); var restriction = new XmlSchemaSimpleContentRestriction(); restriction.BaseTypeName = new XmlQualifiedName(context.NamespacePrefix + ":" + NDR.GetXsdTypeNameFromBdt(bbie.Bdt)); addEnumerationValues(restriction, basicEnum); //add restriction to simplecontent sympleContent.Content = restriction; //add the restriction to the simple type restrictedtype.ContentModel = sympleContent; //set the type of the BBIE elementBBIE.SchemaType = restrictedtype; } } } if (bbie.Bdt.isDirectXSDType) { var XSDtype = bbie.Bdt.xsdType; if (!string.IsNullOrEmpty(XSDtype)) { if (bbie.Bdt.Con.AllFacets.Any()) { //add facets var restrictedtype = new XmlSchemaSimpleType(); var restriction = new XmlSchemaSimpleTypeRestriction(); restriction.BaseTypeName = new XmlQualifiedName(NSPREFIX_XSD + ":" + XSDtype); NDR.addFacets(restriction, bbie.Bdt.Con.AllFacets); //add the restriction to the simple type restrictedtype.Content = restriction; //set the type of the BBIE elementBBIE.SchemaType = restrictedtype; } else { elementBBIE.SchemaTypeName = new XmlQualifiedName(NSPREFIX_XSD + ":" + XSDtype); } } } if (bbie.Facets.Any()) { //add facets if (bbie.Bdt.Sups.Any()) { //create a complex type var complexType = new XmlSchemaComplexType(); //add the simple content extension var simpleContent = new XmlSchemaSimpleContent(); var restriction = new XmlSchemaSimpleContentRestriction(); restriction.BaseTypeName = new XmlQualifiedName(context.NamespacePrefix + ":" + NDR.GetXsdTypeNameFromBdt(bbie.Bdt)); //add the facets NDR.addFacets(restriction, bbie.Facets); //add the simple content to the complex object simpleContent.Content = restriction; complexType.ContentModel = simpleContent; //add the complex type to the element elementBBIE.SchemaType = complexType; } else { //create a simple type var restrictedtype = new XmlSchemaSimpleType(); var restriction = new XmlSchemaSimpleTypeRestriction(); restriction.BaseTypeName = new XmlQualifiedName(context.NamespacePrefix + ":" + NDR.GetXsdTypeNameFromBdt(bbie.Bdt)); NDR.addFacets(restriction, bbie.Facets); //add the restriction to the simple type restrictedtype.Content = restriction; //set the type of the BBIE elementBBIE.SchemaType = restrictedtype; } } if (elementBBIE.SchemaType == null && elementBBIE.SchemaTypeName.IsEmpty) { //use type without facets elementBBIE.SchemaTypeName = new XmlQualifiedName(context.NamespacePrefix + ":" + NDR.GetXsdTypeNameFromBdt(bbie.Bdt)); } } // R 90F9: cardinality of elements within the ABIE elementBBIE.MinOccursString = AdjustLowerBound(bbie.LowerBound); elementBBIE.MaxOccursString = AdjustUpperBound(bbie.UpperBound); return(elementBBIE); }