[UML2] Empty list of stereotypes [message #625659] |
Thu, 29 November 2007 17:44 |
No real name Messages: 33 Registered: July 2009 |
Member |
|
|
Hi,
I have a model and a profile, both stored together in one file. In the
UML Model Editor inside Eclipse, I can browse the file like intended.
But when I try to load the file programmaticaly, I can not see the
applied stereotype. The following code produces no exceptions or warnings:
EPackage.Registry.INSTANCE.put(UMLPackage.eNS_URI,
UMLPackage.eINSTANCE);
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap( ).
put(UMLResource.FILE_EXTENSION,
UMLResource.Factory.INSTANCE);
ResourceSet resourceSet = new ResourceSetImpl();
Resource resource =
resourceSet.getResource(URI.createFileURI(
"models/example.uml"), true);
Object obj = EcoreUtil.getObjectByType(resource.getContents(),
UMLPackage.Literals.MODEL);
Model model = (Model) obj;
if(model != null) {
System.out.println(model.toString());
System.out.println(model.getAppliedStereotypes().toString()) ;
}
What's wrong with the code? I think the model/profile file must be
correct, because the UML Model Editor shows the expected structure.
Best regards,
Sebastian
My model/profile file:
<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.1"
xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:SysML=" http://saab_approach1/schemas/SysML/_lUh30524EdytSYwcMVoawA/ 0"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore"
xmlns:uml="http://www.eclipse.org/uml2/2.1.0/UML"
xsi:schemaLocation=" http://saab_approach1/schemas/SysML/_lUh30524EdytSYwcMVoawA/ 0
#_lXz26J24EdytSYwcMVoawA">
<uml:Model xmi:id="_lXqEUJ24EdytSYwcMVoawA" name="Model1">
<packagedElement xmi:type="uml:Package"
xmi:id="_lXz1p524EdytSYwcMVoawA" name="Package1"/>
<packagedElement xmi:type="uml:Profile"
xmi:id="_lXz25p24EdytSYwcMVoawA" name="SysML"
metaclassReference="_lXz27J24EdytSYwcMVoawA">
<eAnnotations xmi:id="_lXz25524EdytSYwcMVoawA"
source="http://www.eclipse.org/uml2/2.0.0/UML">
<contents xmi:type="ecore:EPackage"
xmi:id="_lXz26J24EdytSYwcMVoawA" name="SysML"
nsURI=" http://saab_approach1/schemas/SysML/_lUh30524EdytSYwcMVoawA/ 0"
nsPrefix="SysML">
<eClassifiers xmi:type="ecore:EClass"
xmi:id="_lXz26Z24EdytSYwcMVoawA" name="SysML">
<eAnnotations xmi:id="_lXz26p24EdytSYwcMVoawA"
source="http://www.eclipse.org/uml2/2.0.0/UML"
references="_lXz27Z24EdytSYwcMVoawA"/>
<eStructuralFeatures xmi:type="ecore:EReference"
xmi:id="_lXz26524EdytSYwcMVoawA" name="base_Model" ordered="false"
lowerBound="1">
<eType xmi:type="ecore:EClass"
href="http://www.eclipse.org/uml2/2.1.0/UML#//Model"/>
</eStructuralFeatures>
</eClassifiers>
</contents>
</eAnnotations>
<packagedElement xmi:type="uml:Extension"
xmi:id="_lXz4Yp24EdytSYwcMVoawA" name="Model_SysML"
memberEnd="_lXz4Y524EdytSYwcMVoawA _lXz27p24EdytSYwcMVoawA">
<ownedEnd xmi:type="uml:ExtensionEnd"
xmi:id="_lXz4Y524EdytSYwcMVoawA" name="extension_SysML"
type="_lXz27Z24EdytSYwcMVoawA" aggregation="composite"
association="_lXz4Yp24EdytSYwcMVoawA"/>
</packagedElement>
<elementImport xmi:id="_lXz27J24EdytSYwcMVoawA">
<importedElement xmi:type="uml:Class"
href="http://www.eclipse.org/uml2/2.1.0/UML#Model"/>
</elementImport>
<packagedElement xmi:type="uml:Stereotype"
xmi:id="_lXz27Z24EdytSYwcMVoawA" name="SysML">
<ownedAttribute xmi:id="_lXz27p24EdytSYwcMVoawA"
name="base_Model" association="_lXz4Yp24EdytSYwcMVoawA">
<type xmi:type="uml:Class"
href="http://www.eclipse.org/uml2/2.1.0/UML#Model"/>
</ownedAttribute>
</packagedElement>
</packagedElement>
<profileApplication xmi:id="_lXz4n524EdytSYwcMVoawA"
appliedProfile="_lXz25p24EdytSYwcMVoawA">
<eAnnotations xmi:id="_lXz4oJ24EdytSYwcMVoawA"
source="http://www.eclipse.org/uml2/2.0.0/UML"
references="_lXz26J24EdytSYwcMVoawA"/>
</profileApplication>
</uml:Model>
<SysML:SysML xmi:id="_lXz4pZ24EdytSYwcMVoawA"
base_Model="_lXqEUJ24EdytSYwcMVoawA"/>
</xmi:XMI>
|
|
|
Powered by
FUDForum. Page generated in 0.02451 seconds