Skip to main content


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 11:13 Go to next message
Haffi is currently offline HaffiFriend
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 11: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 16:47 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
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?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: The ID of a UML element [message #657817 is a reply to message #657706] Fri, 04 March 2011 08:44 Go to previous messageGo to next message
Rafael Chaves is currently offline Rafael ChavesFriend
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 08: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 14:45 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
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.


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:UML2 and the OMG Model Interchange Working Group (MIWG)
Next Topic:uml diagram question
Goto Forum:
  


Current Time: Thu Apr 25 23:10:15 GMT 2024

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

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

Back to the top