import NIEMpsm2xsd; import NIEMplatformBinding; modeltype UML uses 'http://www.omg.org/spec/UML/20131001'; modeltype XSD uses 'http://www.eclipse.org/xsd/2002/XSD'; modeltype PROXY uses 'http://release.niem.gov/niem/proxy/xsd/3.0/'; modeltype CAT uses 'http://reference.niem.gov/niem/resource/mpd/catalog/3.0/'; modeltype OASIS uses 'urn:oasis:names:tc:entity:xmlns:xml:catalog'; modeltype CHANGELOG uses 'http://reference.niem.gov/niem/resource/mpd/changelog/1.1/'; modeltype WANTLIST uses 'http://niem.gov/niem/wantlist/2.2';// EXTRA modeltype NC uses 'http://release.niem.gov/niem/niem-core/3.0/'; transformation NIEMmpdmodel2artifact(in uml:UML, in schemaForProxy:XSD,in schemaForStructures:XSD,in schemaForAppinfo:XSD, in schemaForConformanceTargets:XSD,in schemaForLocalTerminology:XSD, out xsd:XSD, out cat:CAT ,out oasis:OASIS ,out wantlist:WANTLIST ) extends transformation NIEMpsm2xsd(uml:UML,schemaForProxy:XSD,schemaForStructures:XSD,schemaForAppinfo:XSD, schemaForConformanceTargets:XSD,schemaForLocalTerminology:XSD, xsd:XSD ); main() { mpdmodel2artifactMain(); return; } helper mpdmodel2artifactMain(){ NIEMpsm2mpdMain(); /////////////////////////EXTRA var wantlistDocument:WANTLIST::DocumentRoot=new WANTLIST::DocumentRoot@wantlist();// EXTRA wantlistPrefixes(wantlistDocument); var topWantList:WANTLIST::WantListType=new WANTLIST::WantListType@wantlist();// EXTRA wantlistDocument.wantList+=topWantList; topWantList.release:='2.1';// EXTRA topWantList.product:='NIEM';// EXTRA // wantlist gather schemas var schemas:Set(XSD::XSDSchema)=xsd.rootObjects() ->select(x|x.oclIsKindOf(XSD::XSDSchema)).oclAsType(XSD::XSDSchema)->asSet(); // wantlist attribute schemas.wantlistAttribute(topWantList); // wantlist element schemas.wantlistElement(topWantList); // wantlist type schemas.wantlistType(topWantList); // wantlist complete ///////////////////////////////sort contents of schemas schemas->forEach(schema){ schema.contents:=schema.contents->sortedBy(content|content.schemaContentOrder()); }; return; } query XSD::XSDSchemaContent::schemaContentOrder():String{ // sort by annotation, import, other, attribute,element,type if(self.oclIsKindOf(XSD::XSDAnnotation))then {return 'a'+self.repr();}endif; if(self.oclIsKindOf(XSD::XSDImport))then {return 'b'+self.oclAsType(XSD::XSDImport).namespace;}endif; if(self.oclIsKindOf(XSD::XSDAttributeDeclaration))then {return 'e'+self.oclAsType(XSD::XSDNamedComponent).name;}endif; if(self.oclIsKindOf(XSD::XSDElementDeclaration))then {return 'f'+self.oclAsType(XSD::XSDNamedComponent).name;}endif; if(self.oclIsKindOf(XSD::XSDTypeDefinition))then {return 'g'+self.oclAsType(XSD::XSDNamedComponent).name;}endif; if(self.oclIsKindOf(XSD::XSDNamedComponent))then {return 'c'+self.oclAsType(XSD::XSDNamedComponent).name;}endif; return 'd'+self.repr(); } helper catalog(){ var documentRoot:CAT::DocumentRoot:=new CAT::DocumentRoot@cat(); documentRoot.catalog+=mpdComponent.map ModelPackageDescription(); // OASIS catalog, do one for base-xsd, optionally constraint-xsd var rootPackage:UML::Package=mpdComponent.getNearestPackage().getNearesProfileApplication(niemXsdProfile); var basePackage:UML::Package=rootPackage.nestedPackage->select(p|p.name='base-xsd')->asSequence()->first(); if(not(basePackage.oclIsUndefined()))then{ var oasisDocumentRoot:OASIS::DocumentRoot:=new OASIS::DocumentRoot@oasis(); oasisDocumentRoot.catalog+=mpdComponent.map OasisCatalog(basePackage); }endif; return; } //////////////////////OASIS mapping UML::InstanceSpecification ::OasisCatalog(basePackage:UML::Package):OASIS::Catalog@oasis { var pimmpd:UML::InstanceSpecification=self; pimmpd.getMpdFileUsages() ->union(pimmpd.getInstanceValues('IEPConformanceTarget').getInstanceValues('ValidityConstraintWithContext').getMpdFileUsages()) .map Uri(basePackage,result); } mapping UML::Usage::Uri(basePackage:UML::Package,inout catalog:OASIS::Catalog):OASIS::Uri@oasis when{self.supplier->select(s|s.oclIsKindOf(UML::Package) and s.oclAsType(UML::Package).isNIEMNamespace())->notEmpty()} { catalog.uri+=result; var schemaPackage:UML::Package=self.supplier ->select(s|s.oclIsKindOf(UML::Package) and s.oclAsType(UML::Package).isNIEMNamespace()).oclAsType(UML::Package) ->asSequence()->first(); uri:=schemaPackage.toRelativePathName(basePackage,result); if(result.uri.oclIsUndefined())then{ uri:='../'+schemaPackage.toRelativePathName(basePackage.nestingPackage,result); }endif; var pimmpd:Stdlib::Element=self.getStereotypeApplication(NIEMFileType).oclAsType(Stdlib::Element); var explicitRelativePathName:String =pimmpd.getFileTypeRelativePathName(); if(not(explicitRelativePathName.oclIsUndefined()) and (explicitRelativePathName<>''))then{ uri:=explicitRelativePathName; }endif; name:=schemaPackage.getTargetNamespace(); } /////////////////////////// mapping String::TextType(context:UML::NamedElement):NC::TextType { value:=self; } mapping String::PersonNameType(context:UML::NamedElement):NC::PersonNameType { personFullName+=self.map PersonNameTextType(context); } mapping String::ProperNameTextType(context:UML::NamedElement):NC::ProperNameTextType inherits String::TextType { } mapping String::PersonNameTextType(context:UML::NamedElement):NC::PersonNameTextType inherits String::ProperNameTextType { } mapping UML::InstanceSpecification ::ModelPackageDescription():CAT::CatalogType@cat { mpdComponent:=self; self.getTopNiemFolders().nestedPackage.mapAbstractPackage(); log('processCatalog start '); mPD:=self.map MPDType(); var pimmpd:UML::InstanceSpecification=self; pimmpd.getMpdFileUsages().map AbstractModelPackageDescriptionFile(result.mPD); log('processCatalog complete '); } mapping UML::InstanceSpecification ::MPDType():CAT::MPDType@cat { // mpd var pimmpd:UML::InstanceSpecification=self; pimmpd.getMpdFileSets().map SchemaDocumentSetType(result); descriptionText:=pimmpd.getDescriptionText().map TextType(self); // IEPConformanceTarget pimmpd.getIEPConformanceTargets().map IEPConformanceTarget(result); // ArtifactOrArtifactSet pimmpd.getArtifactOrArtifactSetInstances().ArtifactOrArtifactSet(result); mPDInformation:=self.map MPDInformationType(); mpdURI:=pimmpd.getMpdBaseURI(); mpdName:=result.mpdURI.getLastSegment(); mpdVersionID:=pimmpd.getMpdVersionID(); result.oclAsType(Stdlib::Element).addListValue('mpdClassURIList','http://reference.niem.gov/niem/specification/model-package-description/3.0/#MPD'); var mpdClassCode:String=pimmpd.getMpdClassCode(); switch{ case(false){} else{ result.oclAsType(Stdlib::Element).addListValue('mpdClassURIList','http://reference.niem.gov/niem/specification/model-package-description/3.0/#IEPD'); }; }; /* var as:CAT::AuthoritativeSourceType=new CAT::AuthoritativeSourceType(); md.authoritativeSource:=as; */ pimmpd.map EntityType(mPDInformation,self); self.clientDependency.map ModelPackageDescriptionRelationship(result.mPDInformation); } mapping UML::InstanceSpecification ::IEPConformanceTarget(inout mpdType:CAT::MPDType):CAT::IEPConformanceTargetType@cat { mpdType.iEPConformanceTarget+=result; self.getValidityConstraintWithContext().ValidityConstraintWithContext(result); descriptionText:=self.getDescriptionText().map TextType(self); // ArtifactOrArtifactSet self.getArtifactOrArtifactSetInstances().ArtifactOrArtifactSet(result); self.getMpdFileUsages().map AbstractModelPackageDescriptionFile(result); } mapping UML::Usage::FileSetFile(inout fileSet:CAT::FileSetType):CAT::FileType@cat{ fileSet.addFileSetFile(result); var schemaPackage:UML::NamedElement=self.supplier->asSequence()->first(); pathURI:=schemaPackage.toRelativePathName(schemaPackage.getNearestPackage().getNearesProfileApplication(niemXsdProfile),result); var pimmpd:Stdlib::Element=self.getStereotypeApplication(NIEMFileType); var explicitRelativePathName:String =pimmpd.getFileTypeRelativePathName(); if(not(explicitRelativePathName.oclIsUndefined()) and (explicitRelativePathName<>''))then{ pathURI:=explicitRelativePathName; }endif; descriptionText:=pimmpd.getDescriptionText().map TextType(self); id:=self.getFileId(); externalURI:=pimmpd.getExternalURI(); } mapping UML::Usage::SubsetSchemaDocument(inout fileSet:CAT::SchemaDocumentSetType):CAT::FileType@cat inherits UML::Usage::FileSetFile { fileSet.oclAsType(Stdlib::Element).add('artifactOrArtifactSetGroup','subsetSchemaDocument',result.oclAsType(Stdlib::Element)); } helper UML::InstanceSpecification ::ValidityConstraintWithContext(inout iepConformanceTargetType:CAT::IEPConformanceTargetType) { // // // // // // // // // // // var names:Sequence(String)=self.classifier.name; switch{ case(names->includes('ValidityContextType')) iepConformanceTargetType.oclAsType(Stdlib::Element).add('validityConstraintWithContextGroup','validityContext',self.map ValidityContextType().oclAsType(Stdlib::Element)); case(names->includes('QualifiedNamesType')) iepConformanceTargetType.oclAsType(Stdlib::Element).add('validityConstraintWithContextGroup','hasDocumentElement',self.map QualifiedNamesType().oclAsType(Stdlib::Element)); case(names->includes('XPathType')) iepConformanceTargetType.oclAsType(Stdlib::Element).add('validityConstraintWithContextGroup','validToXPath',self.map XPathType().oclAsType(Stdlib::Element)); case(names->includes('XMLSchemaType')) iepConformanceTargetType.oclAsType(Stdlib::Element).add('validityConstraintWithContextGroup','xMLSchemaValid',self.map XMLSchemaType().oclAsType(Stdlib::Element)); case(names->includes('SchematronValidationType')) iepConformanceTargetType.oclAsType(Stdlib::Element).add('validityConstraintWithContextGroup','schematronValid',self.map SchematronValidationType().oclAsType(Stdlib::Element)); case(names->includes('RelaxNGValidationType')) iepConformanceTargetType.oclAsType(Stdlib::Element).add('validityConstraintWithContextGroup','relaxNGValid',self.map RelaxNGValidationType().oclAsType(Stdlib::Element)); case(names->includes('ConformanceTargetType')) iepConformanceTargetType.oclAsType(Stdlib::Element).add('validityConstraintWithContextGroup','conformsToConformanceTarget',self.map ConformanceTargetType().oclAsType(Stdlib::Element)); case(names->includes('TextRuleType')) iepConformanceTargetType.oclAsType(Stdlib::Element).add('validityConstraintWithContextGroup','conformsToRule',self.map TextRuleType().oclAsType(Stdlib::Element)); else{ log('ValidityConstraintWithContext not recognized: '+self.repr()); } }; } mapping UML::InstanceSpecification::ValidityContextType():CAT::ValidityContextType{ // // // // descriptionText:=self.getDescriptionText().map TextType(self); xPathText:=self.getXPathText(); self.getValidityConstraintWithContext()->forEach(validityConstraint){ var names:Sequence(String)=validityConstraint.classifier.name; switch{ case(names->includes('XPathType')) result.oclAsType(Stdlib::Element).add('ValidityConstraintGroup','ValidToXPath',self.map XPathType().oclAsType(Stdlib::Element)); case(names->includes('XMLSchemaType')) result.oclAsType(Stdlib::Element).add('ValidityConstraintGroup','XMLSchemaValid',self.map XMLSchemaType().oclAsType(Stdlib::Element)); case(names->includes('SchematronValidationType')) result.oclAsType(Stdlib::Element).add('ValidityConstraintGroup','SchematronValid',self.map SchematronValidationType().oclAsType(Stdlib::Element)); case(names->includes('RelaxNGValidationType')) result.oclAsType(Stdlib::Element).add('ValidityConstraintGroup','RelaxNGValid',self.map RelaxNGValidationType().oclAsType(Stdlib::Element)); case(names->includes('ConformanceTargetType')) result.oclAsType(Stdlib::Element).add('ValidityConstraintGroup','ConformsToConformanceTarget',self.map ConformanceTargetType().oclAsType(Stdlib::Element)); case(names->includes('TextRuleType')) result.oclAsType(Stdlib::Element).add('ValidityConstraintGroup','ConformsToRule',self.map TextRuleType().oclAsType(Stdlib::Element)); else{ log('ValidityContextType not recognized: '+validityConstraint.repr()); } }; }; } mapping UML::InstanceSpecification::QualifiedNamesType():CAT::QualifiedNamesType{ // // // // // // descriptionText:=self.getDescriptionText().map TextType(self); } mapping UML::InstanceSpecification::XPathType():CAT::XPathType{ // // descriptionText:=self.getDescriptionText().map TextType(self); xPathText:=self.getXPathText(); } mapping UML::InstanceSpecification::XMLSchemaType():CAT::XMLSchemaType{ // // // descriptionText:=self.getDescriptionText().map TextType(self); self.getMpdFileUsages().map AbstractXMLSchemaDocument(result); } mapping UML::InstanceSpecification::SchematronValidationType():CAT::SchematronValidationType{ // // descriptionText:=self.getDescriptionText().map TextType(self); } mapping UML::InstanceSpecification::RelaxNGValidationType():CAT::RelaxNGValidationType{ // // descriptionText:=self.getDescriptionText().map TextType(self); } mapping UML::InstanceSpecification::ConformanceTargetType():CAT::ConformanceTargetType{ // // descriptionText:=self.getDescriptionText().map TextType(self); conformanceTargetURI:=self.getConformanceTargetURI(); } mapping UML::InstanceSpecification::TextRuleType():CAT::TextRuleType{ // // descriptionText:=self.getDescriptionText().map TextType(self); ruleText:=self.getRuleText().map TextType(self); } helper UML::InstanceSpecification ::ArtifactOrArtifactSet(owner:OclAny) { } mapping UML::InstanceSpecification ::MPDInformationType():CAT::MPDInformationType@cat { // mpd var pimmpd:UML::InstanceSpecification=self; creationDate:=self.getAnyValue('CreationDate').oclAsType(String) .map ProxyDate(pimmpd,'creationDate')->asSequence()->first(); lastRevisionDate:=self.getAnyValue('LastRevisionDate').oclAsType(String) .map ProxyDate(pimmpd,'lastRevisionDate')->asSequence()->first(); statusText:=pimmpd.getMpdStatusText().map ProxyString(pimmpd,'statusText'); keywordText+=pimmpd.getMpdKeywordText().map ProxyString(pimmpd,'keywordText'); domainText+=pimmpd.getMpdDomainText().map ProxyString(pimmpd,'domainText'); purposeText+=pimmpd.getMpdPurposeText().map ProxyString(pimmpd,'purposeText'); exchangePatternText+=pimmpd.getMpdExchangePatternText().map ProxyString(pimmpd,'exchangePatternText'); exchangePartnerName+=pimmpd.getMpdExchangePartnerName().map ProxyString(pimmpd,'exchangePartnerName'); } mapping UML::InstanceSpecification::EntityType(inout mpdInformationType:CAT::MPDInformationType,context:UML::NamedElement):NC::EntityType{ mpdInformationType.authoritativeSource:=result; var entityRepresentations:Sequence(InstanceSpecification)= self.getAuthoritativeSourceList().value->select(v|v.oclIsKindOf(InstanceValue)).oclAsType(InstanceValue).instance; entityRepresentations->forEach(entityRepresentation){ var isOrganization:Boolean=entityRepresentation.classifier.name->includes('OrganizationType'); if(isOrganization)then{ entityRepresentation.map OrganizationType(result,context); }else{ result.addEntityPerson(entityRepresentation.map PersonType(context)); }endif; }; } mapping UML::InstanceSpecification::PersonType(context:UML::NamedElement):NC::PersonType{ personName+=self.getNames().map PersonNameType(context); } mapping UML::InstanceSpecification::OrganizationType(inout entityType:NC::EntityType,context:UML::NamedElement):NC::OrganizationType{ entityType.addEntityOrganization(result); organizationName+=self.getNames().map TextType(context); self.getOrganizationPrimaryContactInformation()->forEach(poc){ poc.map ContactInformationType(result,context); }; } mapping UML::InstanceSpecification::ContactInformationType(inout organizationType:NC::OrganizationType,context:UML::NamedElement):NC::ContactInformationType{ organizationType.organizationPrimaryContactInformation+=result; // find max length of sequences, add as many ContactMeans to include all var contactEmailID:Sequence(String):=self.contactEmailID(); var contactMailingAddress:Sequence(String):=self.contactMailingAddress(); var contactTelephoneNumber:Sequence(String):=self.contactTelephoneNumber(); var contactWebsiteURI:Sequence(String):=self.contactWebsiteURI(); contactEmailID.map ProxyString(self,'contactEmailID').addContactEmailID(result); contactMailingAddress.map TextType(self).map AddressType(self).addContactMailingAddress(result); contactTelephoneNumber.map ProxyString(self,'contactTelephoneNumber').map TelephoneNumberType().addContactTelephoneNumber(result); contactWebsiteURI.map ProxyAnyURI(self,'contactWebsiteURI').addContactWebsiteURI(result); contactEntity+=self.getContactEntity().map ContactEntity(result,context); contactResponder+=self.getContactResponder().map PersonType(context); } mapping UML::InstanceSpecification::ContactEntity(inout contactInformationType:NC::ContactInformationType,context:UML::NamedElement):NC::EntityType{ contactInformationType.contactEntity+=result; var isOrganization:Boolean=self.classifier.name->includes('OrganizationType'); log('ContactEntity '+isOrganization.repr()+', '+self.repr()); if(isOrganization)then{ log('ContactEntity organization '+result.repr()+', '+context.repr()); self.map OrganizationType(result,context); }else{ result.addEntityPerson(self.map PersonType(context)); }endif; } mapping NC::TextType::AddressType(context:UML::NamedElement):NC::AddressType{ addressFullText+=self; } mapping PROXY::_String::TelephoneNumberType():NC::TelephoneNumberType{ result.addFullTelephoneNumberType(self.map FullTelephoneNumberType()); } mapping PROXY::_String::FullTelephoneNumberType():NC::FullTelephoneNumberType{ telephoneNumberFullID:=self; } mapping String::ContactEntityType(inout mpdInformationType:NC::ContactInformationType,context:UML::NamedElement):NC::EntityType{ mpdInformationType.contactEntity+=result; self.map ContactOrganizationType(result,context); } mapping String::ContactOrganizationType(inout entityType:NC::EntityType,context:UML::NamedElement):NC::OrganizationType{ // entityRepresentation entityType.addEntityOrganization(result); organizationName+=self.map TextType(context); } mapping String::ProxyAnyURI(context:Stdlib::Element,feature:String):PROXY::AnyURI{ value:=self; } mapping String::ProxyString(context:Stdlib::Element,feature:String):PROXY::_String{ value:=self; } mapping String::ProxyDate(context:Stdlib::Element,feature:String):PROXY::Date{ result.setProxyDateValue(self); } mapping UML::Dependency::ModelPackageDescriptionRelationship(inout md:CAT::MPDInformationType):CAT::RelationshipType@cat when{self.isStereotypeApplied(NIEMModelPackageDescriptionRelationshipStereotype)} { md.relationship+=result; var relationshipType:Stdlib::Element=self.getStereotypeApplication(NIEMModelPackageDescriptionRelationshipStereotype).oclAsType(Stdlib::Element); var descriptionTextValue:String=relationshipType.getDescriptionText(); descriptionText:=descriptionTextValue.map TextType(self); var code:String=relationshipType.getRelationshipCode(); relationshipCode:=switch{ case(code='versionOf') CAT::RelationshipCodeSimpleType::versionOf; case(code='specializes') CAT::RelationshipCodeSimpleType::specializes; case(code='generalizes') CAT::RelationshipCodeSimpleType::generalizes; case(code='supersedes') CAT::RelationshipCodeSimpleType::supersedes; case(code='deprecates') CAT::RelationshipCodeSimpleType::deprecates; case(code='adapts') CAT::RelationshipCodeSimpleType::adapts; case(code='updates') CAT::RelationshipCodeSimpleType::updates; case(code='derives_from') CAT::RelationshipCodeSimpleType::derivesFrom; else CAT::RelationshipCodeSimpleType::conformsTo; }; self.supplier->forEach(supplier){ if(supplier.oclIsKindOf(UML::Package))then{ resourceURI:=supplier.oclAsType(UML::Package).URI; }endif; }; } mapping UML::Usage::AbstractModelPackageDescriptionFile(inout catalog:Stdlib::Element):CAT::FileType disjuncts UML::Usage::ApplicationInfo, UML::Usage::BusinessRulesArtifact, UML::Usage::ConformanceAssertion, UML::Usage::ConformanceReport, UML::Usage::Documentation, UML::Usage::File, UML::Usage::IEPSampleXMLDocument, UML::Usage::MPDChangeLog, UML::Usage::ReadMe, UML::Usage::RelaxNGSchema, UML::Usage::RequiredFile, UML::Usage::SchematronSchema, UML::Usage::Wantlist, UML::Usage::XMLCatalog, UML::Usage::AbstractXMLSchemaDocument, UML::Usage::ModelPackageDescriptionFile {} mapping UML::Usage::AbstractXMLSchemaDocument(inout catalog:Stdlib::Element):CAT::FileType disjuncts UML::Usage::ExtensionSchemaDocumentFile, UML::Usage::ExternalSchemaDocumentFile, UML::Usage::ReferenceSchemaDocumentFile, UML::Usage::SubsetSchemaDocumentFile, UML::Usage::XMLSchemaDocument {} mapping UML::Usage::ExternalSchemaDocumentFile(inout catalog:Stdlib::Element):CAT::FileType@cat inherits UML::Usage::ModelPackageDescriptionFileCommon when{self.stereotypedBy('ExternalSchemaDocument')} { catalog.addExternalSchemaDocument(result); } mapping UML::Usage::ExtensionSchemaDocumentFile(inout catalog:Stdlib::Element):CAT::FileType@cat inherits UML::Usage::ModelPackageDescriptionFileCommon when{self.stereotypedBy('ExtensionSchemaDocument')} { catalog.addExtensionSchemaDocument(result); } mapping UML::Usage::ReferenceSchemaDocumentFile(inout catalog:Stdlib::Element):CAT::FileType@cat inherits UML::Usage::ModelPackageDescriptionFileCommon when{self.stereotypedBy('ReferenceSchemaDocument')} { catalog.addReferenceSchemaDocument(result); } mapping UML::Usage::SubsetSchemaDocumentFile(inout catalog:Stdlib::Element):CAT::FileType@cat inherits UML::Usage::ModelPackageDescriptionFileCommon when{self.stereotypedBy('SubsetSchemaDocument')} { catalog.addSubsetSchemaDocument(result); } mapping UML::Usage::XMLCatalog(inout catalog:Stdlib::Element):CAT::FileType@cat inherits UML::Usage::ModelPackageDescriptionFileCommon when{self.stereotypedBy('XMLCatalog')} { catalog.addXMLCatalog(result); } mapping UML::Usage::XMLSchemaDocument(inout catalog:Stdlib::Element):CAT::FileType@cat inherits UML::Usage::ModelPackageDescriptionFileCommon when{self.stereotypedBy('XMLSchemaDocument')} { catalog.addXMLSchemaDocument(result); } mapping UML::Usage::RequiredFile(inout catalog:Stdlib::Element):CAT::FileType@cat inherits UML::Usage::ModelPackageDescriptionFileCommon when{self.stereotypedBy('RequiredFile')} { catalog.addRequiredFile(result); } mapping UML::Usage::SchematronSchema(inout catalog:Stdlib::Element):CAT::FileType@cat inherits UML::Usage::ModelPackageDescriptionFileCommon when{self.stereotypedBy('SchematronSchema')} { catalog.addSchematronSchema(result); } mapping UML::Usage::Wantlist(inout catalog:Stdlib::Element):CAT::FileType@cat inherits UML::Usage::ModelPackageDescriptionFileCommon when{self.stereotypedBy('Wantlist')} { catalog.addWantlist(result); } mapping UML::Usage::MPDChangeLog(inout catalog:Stdlib::Element):CAT::FileType@cat inherits UML::Usage::ModelPackageDescriptionFileCommon when{self.stereotypedBy('MPDChangeLog')} { catalog.addMPDChangeLog(result); } mapping UML::Usage::ReadMe(inout catalog:Stdlib::Element):CAT::FileType@cat inherits UML::Usage::ModelPackageDescriptionFileCommon when{self.stereotypedBy('ReadMe')} { catalog.addReadMe(result); } mapping UML::Usage::RelaxNGSchema(inout catalog:Stdlib::Element):CAT::FileType@cat inherits UML::Usage::ModelPackageDescriptionFileCommon when{self.stereotypedBy('RelaxNGSchema')} { catalog.addRelaxNGSchema(result); } mapping UML::Usage::Documentation(inout catalog:Stdlib::Element):CAT::FileType@cat inherits UML::Usage::ModelPackageDescriptionFileCommon when{self.stereotypedBy('Documentation')} { catalog.addDocumentation(result); } mapping UML::Usage::File(inout catalog:Stdlib::Element):CAT::FileType@cat inherits UML::Usage::ModelPackageDescriptionFileCommon when{self.stereotypedBy('File')} { catalog.addFile(result); } mapping UML::Usage::IEPSampleXMLDocument(inout catalog:Stdlib::Element):CAT::FileType@cat inherits UML::Usage::ModelPackageDescriptionFileCommon when{self.stereotypedBy('IEPSampleXMLDocument')} { catalog.addIEPSampleXMLDocument(result); } mapping UML::Usage::BusinessRulesArtifact(inout catalog:Stdlib::Element):CAT::FileType@cat inherits UML::Usage::ModelPackageDescriptionFileCommon when{self.stereotypedBy('BusinessRulesArtifact')} { catalog.addBusinessRulesArtifact(result); } mapping UML::Usage::ConformanceAssertion(inout catalog:Stdlib::Element):CAT::FileType@cat inherits UML::Usage::ModelPackageDescriptionFileCommon when{self.stereotypedBy('ConformanceAssertion')} { catalog.addConformanceAssertion(result); } mapping UML::Usage::ConformanceReport(inout catalog:Stdlib::Element):CAT::FileType@cat inherits UML::Usage::ModelPackageDescriptionFileCommon when{self.stereotypedBy('ConformanceReport')} { catalog.addConformanceReport(result); } mapping UML::Usage::ApplicationInfo(inout catalog:Stdlib::Element):CAT::FileType@cat inherits UML::Usage::ModelPackageDescriptionFileCommon when{self.stereotypedBy('ApplicationInfo')} { catalog.addApplicationInfo(result); } mapping UML::Usage::ModelPackageDescriptionFileCommon(inout catalog:Stdlib::Element):CAT::FileType@cat { var schemaPackage:UML::NamedElement=self.supplier->asSequence()->first(); pathURI:=schemaPackage.toRelativePathName(schemaPackage.getNearestPackage().getNearesProfileApplication(niemXsdProfile),result); var pimmpd:Stdlib::Element=self.getStereotypeApplication(NIEMFileType).oclAsType(Stdlib::Element); var explicitRelativePathName:String =pimmpd.getFileTypeRelativePathName(); if(not(explicitRelativePathName.oclIsUndefined()) and (explicitRelativePathName<>''))then{ pathURI:=explicitRelativePathName; }endif; descriptionText:=pimmpd.getDescriptionText().map TextType(self); id:=self.getFileId(); externalURI:=pimmpd.getExternalURI(); mimeMediaTypeText:=pimmpd.getMimeMediaTypeText(); } mapping UML::Usage::ModelPackageDescriptionFile(inout catalog:Stdlib::Element):CAT::FileType@cat inherits UML::Usage::ModelPackageDescriptionFileCommon when{self.stereotypedBy('FileType')} { catalog.addCatalogFile(result); } mapping UML::InstanceSpecification::SchemaDocumentSetType(inout catalog:CAT::MPDType):CAT::SchemaDocumentSetType@cat inherits UML::InstanceSpecification::ModelPackageDescriptionFileSet { catalog.addSchemaDocumentSet(result); var pimmpd:UML::InstanceSpecification=self; pimmpd.getMpdFileUsages().map SubsetSchemaDocument(result); } mapping UML::InstanceSpecification::ModelPackageDescriptionFileSet(inout catalog:CAT::MPDType):CAT::FileSetType@cat{ catalog.addCatalogFileSet(result); self.getMpdFileUsages()->forEach(fileType){result.addFileSetFiles(fileType.getFileId());}; var pimMpdFileSetStereotypeInstance:UML::InstanceSpecification=self.oclAsType(UML::InstanceSpecification); id:='fs_'+self.getFileId(); externalURI:=pimMpdFileSetStereotypeInstance.getExternalURI(); descriptionText:=pimMpdFileSetStereotypeInstance.getDescriptionText().map TextType(self); } ////////////////////////////////////////////////////extra helper XSD::XSDSchema::wantlistAttribute(inout topWantList:WANTLIST::WantListType){// EXTRA var prefix:String=self.getWantlistPrefix(); if(prefix.oclIsUndefined()) then {return;}endif; self.attributeDeclarations->select(a|a.targetNamespace=self.targetNamespace) ->forEach(attribute){ var attributeType:WANTLIST::AttributeType=new WANTLIST::AttributeType@wantlist(); //attributeType.qualifier:=prefix+':'+attribute.name; attributeType.setWantlistAttributeName(self.targetNamespace,attribute.name,prefix); topWantList.attribute+=attributeType; }; return; } helper XSD::XSDSchema::wantlistElement(inout topWantList:WANTLIST::WantListType){// EXTRA var prefix:String=self.getWantlistPrefix(); if(prefix.oclIsUndefined()) then {log("No wantlist for non-reference schema "+self.targetNamespace);return;}endif; self.elementDeclarations ->select(a|a.targetNamespace=self.targetNamespace) ->forEach(element){ if(element.name.oclIsUndefined())then{ log("ERROR:wantlist element has no name in schema "+self.targetNamespace); }else{ var elementType:WANTLIST::ElementType=new WANTLIST::ElementType@wantlist(); elementType.setWantlistElementName(self.targetNamespace,element.name,prefix); elementType.isReference:=element.name.endsWith('Reference'); topWantList.element+=elementType; }endif; }; return; } helper XSD::XSDSchema::wantlistType(inout topWantList:WANTLIST::WantListType){// EXTRA var prefix:String=self.getWantlistPrefix(); if(prefix.oclIsUndefined()) then {return;}endif; self.typeDefinitions ->select(a|a.targetNamespace=self.targetNamespace) ->select(t|not(t.name.oclIsUndefined())) ->forEach(type){ var typeType:WANTLIST::TypeType=new WANTLIST::TypeType@wantlist(); typeType.setWantlistTypeName(self.targetNamespace,type.name,prefix); topWantList.type+=typeType; typeType.isRequested:=false; if(type.oclIsKindOf(XSD::XSDComplexTypeDefinition))then{ var complexType:XSD::XSDComplexTypeDefinition=type.oclAsType(XSD::XSDComplexTypeDefinition); // AttributeInType complexType.attributeContents->forEach(attributeContent){ if(attributeContent.oclIsKindOf(XSD::XSDAttributeUse))then{ var attributeUse:XSD::XSDAttributeUse=attributeContent.oclAsType(XSD::XSDAttributeUse); var resolvedAttribute:XSD::XSDAttributeDeclaration=attributeUse.attributeDeclaration; var prefix2:String=resolvedAttribute.targetNamespace.getWantlistPrefix(); if(not(prefix2.oclIsUndefined()))then{ var attributeTypeType:WANTLIST::AttributeInTypeType=new WANTLIST::AttributeInTypeType@wantlist(); attributeTypeType.setWantlistAttributeTypeName(resolvedAttribute.targetNamespace,resolvedAttribute.name,prefix2); typeType.attributeInType+=attributeTypeType; }endif; }endif; }; // ElementInType var content:XSD::XSDComplexTypeContent=complexType.content; if(not(content.oclIsUndefined()) and content.oclIsKindOf(XSD::XSDParticle))then{ var particle:XSD::XSDParticle=content.oclAsType(XSD::XSDParticle); particle.wantlistElementInType(typeType); }endif; }else{ var simpleType:XSD::XSDSimpleTypeDefinition=type.oclAsType(XSD::XSDSimpleTypeDefinition); // Facet simpleType.facetContents->forEach(facet){ var facetType:WANTLIST::FacetType=new WANTLIST::FacetType@wantlist(); var facetTypeType:WANTLIST::FacetFacetType=switch{ case(facet.facetName='minExclusive')WANTLIST::FacetFacetType::minExclusive; case(facet.facetName='maxExclusive')WANTLIST::FacetFacetType::maxExclusive; case(facet.facetName='maxInclusive')WANTLIST::FacetFacetType::maxInclusive; case(facet.facetName='totalDigits')WANTLIST::FacetFacetType::totalDigits; case(facet.facetName='fractionDigits')WANTLIST::FacetFacetType::fractionDigits; case(facet.facetName='length')WANTLIST::FacetFacetType::length; case(facet.facetName='minLength')WANTLIST::FacetFacetType::minLength; case(facet.facetName='maxLength')WANTLIST::FacetFacetType::maxLength; case(facet.facetName='enumeration')WANTLIST::FacetFacetType::enumeration; case(facet.facetName='whiteSpace')WANTLIST::FacetFacetType::whiteSpace; case(facet.facetName='pattern')WANTLIST::FacetFacetType::pattern; }; facetType.facet:=facetTypeType; facetType.value:=facet.lexicalValue; typeType.facet+=facetType; }; // UnionMember simpleType.memberTypeDefinitions->forEach(member){ var prefix2:String=member.targetNamespace.getWantlistPrefix(); if(not(prefix2.oclIsUndefined()))then{ var unionMemberType:WANTLIST::UnionMemberType=new WANTLIST::UnionMemberType@wantlist(); unionMemberType.setWantlistUnionMemberTypeName(member.targetNamespace,member.name,prefix2); typeType.unionMember+=unionMemberType; }endif; }; }endif; }; return; } helper XSD::XSDParticle::wantlistElementInType(inout typeType:WANTLIST::TypeType){// EXTRA var particleContent:XSD::XSDParticleContent=self.content; if((particleContent=null)or particleContent.oclIsUndefined()) then {return;}endif; if(particleContent.oclIsKindOf(XSD::XSDElementDeclaration))then{ var resolvedElementDeclaration:XSD::XSDElementDeclaration=particleContent.oclAsType(XSD::XSDElementDeclaration).resolvedElementDeclaration; if((resolvedElementDeclaration=null)or resolvedElementDeclaration.oclIsUndefined()) then {return;}endif; var prefix2:String=resolvedElementDeclaration.targetNamespace.getWantlistPrefix(); if(not(prefix2.oclIsUndefined()))then{ var elementTypeType:WANTLIST::ElementInTypeType=new WANTLIST::ElementInTypeType@wantlist(); elementTypeType.setWantlistElementTypeName(resolvedElementDeclaration.targetNamespace,resolvedElementDeclaration.name,prefix2); elementTypeType.isReference:=resolvedElementDeclaration.name.endsWith('Reference'); elementTypeType.minOccurs:=self.minOccurs; elementTypeType.setWantlistElementMaxOccurs(self.maxOccurs); typeType.elementInType+=elementTypeType; }endif; }else{ if(particleContent.oclIsKindOf(XSD::XSDModelGroup))then{ particleContent.oclAsType(XSD::XSDModelGroup).contents.wantlistElementInType(typeType); }endif; }endif; return; } helper String::getWantlistPrefix():String{// EXTRA // add prefixes var targetNamespace:String=self; prefixToNamespace->forEach(p){ if(p.namespace=targetNamespace)then{return p.prefix;}endif; }; return null; } helper XSD::XSDSchema::getWantlistPrefix():String{// EXTRA return self.targetNamespace.getWantlistPrefix(); } helper wantlistPrefixes(inout wantlistDocument:WANTLIST::DocumentRoot){// EXTRA // add prefixes prefixToNamespace->forEach(p){ wantlistDocument.addXmlns(p.prefix,p.namespace); }; return; } // get the FileSet Instances which subset the ArtifactOrArtifactSet property of this Instance query UML::InstanceSpecification::getMpdFileSets():Sequence(UML::InstanceSpecification)= self.getArtifactOrArtifactSetInstances() ->select(i|i.isMpdFileSet()); // get all the instances which are referenced by the ArtifactOrArtifactSet property of this instance query UML::InstanceSpecification::getArtifactOrArtifactSetInstances():Sequence(UML::InstanceSpecification)= self.getArtifactOrArtifactSetList().oclAsType(UML::Slot).value ->select(v|v.oclIsKindOf(UML::InstanceValue)).oclAsType(UML::InstanceValue).instance;