Skip to main content



      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
Eclipse UserFriend
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] by 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
Eclipse UserFriend
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
Eclipse UserFriend
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] by 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
Eclipse UserFriend
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: Sun Jul 06 12:19:44 EDT 2025

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

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

Back to the top