Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » The ID of a UML element
The ID of a UML element [message #657583] Thu, 03 March 2011 06:13 Go to next message
Haffi is currently offline Haffi
Messages: 39
Registered: November 2010
Member
Hi,

Does the UML metamodel provide any way to access the ID of an element? They often look like this in the XML:
<element xmi:type="uml:OpaqueAction" href="SomeModel.uml#_dmKHMDjwEeCH9LLYtylVBA"/>

The ID being the part after the '#'.

I'm trying to access the ID in a QVTo transformation, isn't it the metamodel that provides the methods for accessing data like this, rather than the transformation language itself?

[Updated on: Thu, 03 March 2011 06:16]

Report message to a moderator

Re: The ID of a UML element [message #657706 is a reply to message #657583] Thu, 03 March 2011 11:47 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26010
Registered: July 2009
Senior Member
Haffi,

eObject.eResource().getURIFragment(eObject) should return the ID.


Haffi wrote:
> Hi,
>
> Does the UML metamodel provide any way to access the ID of an element?
> They often look like this in the XML: <element
> xmi:type="uml:OpaqueAction"
> href="SomeModel.uml#_dmKHMDjwEeCH9LLYtylVBA"/>
>
> I'm trying to access the ID in a QVTo transformation, isn't it the
> metamodel that provides the methods for accessing data like this,
> rather than the transformation language itself?
Re: The ID of a UML element [message #657817 is a reply to message #657706] Fri, 04 March 2011 03:44 Go to previous messageGo to next message
Rafael Chaves is currently offline Rafael Chaves
Messages: 161
Registered: July 2009
Senior Member
I think that may be true for cross resource references only, right?

Doesn't this work for all cases?

((XMIResource) resource).getID(eObject)


Rafael
http://abstratt.com/blog

[Updated on: Fri, 04 March 2011 03:45]

Report message to a moderator

Re: The ID of a UML element [message #657907 is a reply to message #657817] Fri, 04 March 2011 09:45 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26010
Registered: July 2009
Senior Member
Rafael,

Comments below.

Rafael Chaves wrote:
> I think that may be true for cross resource references only, right?
The code eObject.eResource().getURIFragment(eObject) doesn't even care
whether anything references that object... Note however, that it will
return the ID if there's an ID but will always return a non-null result
such that
eObject.eResource().getEObject(eObject.eResource().getURIFra gment(eObject))
== eObject.
>
> Doesn't this work for all cases?
>
> ((XMIResource) resource).getID(eObject)
This only works in cases where you're contained in an XMIResource. It
will return null if the eObject doesn't have an ID.
Previous Topic:UML2 and the OMG Model Interchange Working Group (MIWG)
Next Topic:uml diagram question
Goto Forum:
  


Current Time: Thu Aug 28 01:23:22 EDT 2014

Powered by FUDForum. Page generated in 0.26448 seconds