Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » [UML2] Empty list of stereotypes
[UML2] Empty list of stereotypes [message #476688] Thu, 29 November 2007 17:44 Go to next message
No real name is currently offline No real nameFriend
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>
Re: [UML2] Empty list of stereotypes [message #476691 is a reply to message #476688] Fri, 30 November 2007 18:54 Go to previous messageGo to next message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Hi,
Interesting model, it seems you did not create a metamodel reference to uml
(at least I can't see it). My editor is having a hard time showing the kind
of element you want your stereotype to extend but the Ecore representation
seems to be fine (which is what matters). (I also cannot see the metamodel
reference).

It is not immediately obvious why the editor works and your code snippet
doesn't. I believe you are running in a stand-alone application (otherwise
there would be no need to register the items you have registered).
Try looking at the code snippet in this article (near the end):
http://www.eclipse.org/modeling/mdt/uml2/docs/guides/UML2_2. 0_Migration_Guide/guide.html
You might have overlooked registering some goodies.

If after trying the code in the above mentioned article still doesn't work,
then we can go through this step by step.

Cheers,
- James.

"bfeater" <sgebhardt1@gmx.de> wrote in message
news:fimtpb$lq9$1@build.eclipse.org...
> 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>
Re: [UML2] Empty list of stereotypes [message #476693 is a reply to message #476691] Mon, 03 December 2007 10:58 Go to previous message
No real name is currently offline No real nameFriend
Messages: 33
Registered: July 2009
Member
Thanks for your repley.


Changing the instruction

URI.createFileURI("infile.uml");

to

URI.createFileURI(new java.io.File("infile.uml").getAbsolutePath());

makes the code working. The problem seems to be something with the path
resolution. Using the absolute path the profile (in the same file) is found.


James Bruck schrieb:
> Hi,
> Interesting model, it seems you did not create a metamodel reference to uml
> (at least I can't see it). My editor is having a hard time showing the kind
> of element you want your stereotype to extend but the Ecore representation
> seems to be fine (which is what matters). (I also cannot see the metamodel
> reference).
>
> It is not immediately obvious why the editor works and your code snippet
> doesn't. I believe you are running in a stand-alone application (otherwise
> there would be no need to register the items you have registered).
> Try looking at the code snippet in this article (near the end):
> http://www.eclipse.org/modeling/mdt/uml2/docs/guides/UML2_2. 0_Migration_Guide/guide.html
> You might have overlooked registering some goodies.
>
> If after trying the code in the above mentioned article still doesn't work,
> then we can go through this step by step.
>
> Cheers,
> - James.
>
> "bfeater" <sgebhardt1@gmx.de> wrote in message
> news:fimtpb$lq9$1@build.eclipse.org...
>> 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>
>
>
Re: [UML2] Empty list of stereotypes [message #625662 is a reply to message #476688] Fri, 30 November 2007 18:54 Go to previous message
james bruck is currently offline james bruckFriend
Messages: 1724
Registered: July 2009
Senior Member
Hi,
Interesting model, it seems you did not create a metamodel reference to uml
(at least I can't see it). My editor is having a hard time showing the kind
of element you want your stereotype to extend but the Ecore representation
seems to be fine (which is what matters). (I also cannot see the metamodel
reference).

It is not immediately obvious why the editor works and your code snippet
doesn't. I believe you are running in a stand-alone application (otherwise
there would be no need to register the items you have registered).
Try looking at the code snippet in this article (near the end):
http://www.eclipse.org/modeling/mdt/uml2/docs/guides/UML2_2. 0_Migration_Guide/guide.html
You might have overlooked registering some goodies.

If after trying the code in the above mentioned article still doesn't work,
then we can go through this step by step.

Cheers,
- James.

"bfeater" <sgebhardt1@gmx.de> wrote in message
news:fimtpb$lq9$1@build.eclipse.org...
> 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>
Re: [UML2] Empty list of stereotypes [message #625664 is a reply to message #476691] Mon, 03 December 2007 10:58 Go to previous message
No real name is currently offline No real nameFriend
Messages: 33
Registered: July 2009
Member
Thanks for your repley.


Changing the instruction

URI.createFileURI("infile.uml");

to

URI.createFileURI(new java.io.File("infile.uml").getAbsolutePath());

makes the code working. The problem seems to be something with the path
resolution. Using the absolute path the profile (in the same file) is found.


James Bruck schrieb:
> Hi,
> Interesting model, it seems you did not create a metamodel reference to uml
> (at least I can't see it). My editor is having a hard time showing the kind
> of element you want your stereotype to extend but the Ecore representation
> seems to be fine (which is what matters). (I also cannot see the metamodel
> reference).
>
> It is not immediately obvious why the editor works and your code snippet
> doesn't. I believe you are running in a stand-alone application (otherwise
> there would be no need to register the items you have registered).
> Try looking at the code snippet in this article (near the end):
> http://www.eclipse.org/modeling/mdt/uml2/docs/guides/UML2_2. 0_Migration_Guide/guide.html
> You might have overlooked registering some goodies.
>
> If after trying the code in the above mentioned article still doesn't work,
> then we can go through this step by step.
>
> Cheers,
> - James.
>
> "bfeater" <sgebhardt1@gmx.de> wrote in message
> news:fimtpb$lq9$1@build.eclipse.org...
>> 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>
>
>
Previous Topic:UML2 / Sequence diagram / MessageKind
Next Topic:How to make XML simple types available for UML models?.
Goto Forum:
  


Current Time: Fri Apr 26 20:49:00 GMT 2024

Powered by FUDForum. Page generated in 0.03229 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top