Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [JET2] Custom XPath to access stereotypes.
[JET2] Custom XPath to access stereotypes. [message #30840] Tue, 14 August 2007 12:41 Go to next message
Juan Pedro Silva is currently offline Juan Pedro SilvaFriend
Messages: 258
Registered: July 2009
Senior Member
Hi everybody. I know Paul is on holidays, but as there is a lot of very
capable people around, I felt encouraged to ask this question anyhow.

I read in some post (also available as "JET FAQ Can JET handle UML
models as input?" in
http://wiki.eclipse.org/JET_FAQ_Can_JET_handle_UML_models_as _input%3F)
that although JET cannot access stereotypes or stereotype properties,
custom XPath functions could be created to access these.

This is exactly what I need, so I started making my own XPath function,
according to "JET FAQ How do I create custom XPath Function?"
( http://wiki.eclipse.org/JET_FAQ_How_do_I_create_custom_XPath _Function%3F).
However, I am stuck in the part of accessing the stereotypes while
coding the java class.

I know Ecore has no notion of stereotypes. Meanwhile, .emx and .uml2
models do. I thought of using UML2 metamodel/API to be able to access
the stereotypes. Therefore, I placed "org.eclipse.uml2" as a required
plugin (in the manifest). However, when trying to import this package in
my java class, I get a "org.eclipse.uml2 cannot be resolved" message. I
tried re-building the project from scratch, with the same result.

Am I missing something here?, did I make wrong assumptions?, if so,
which is the line to follow?.
I would really appreciate your help on this one,
Thanks in advance,
Juan Pedro Silva
Re: [JET2] Custom XPath to access stereotypes. [message #30875 is a reply to message #30840] Tue, 14 August 2007 13:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

This is a multi-part message in MIME format.
--------------000603080600000506060908
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Juan,

Did you add org.eclipse.uml2.*uml *to the dependencies? Note that if
you use Ctrl-Shift-T to open a class you need to use, you can then use
the little left right arrow in the package explorer to locate which
plugin that class appears in and use that to help ensure that the right
plugin dependencies get added.



Juan Pedro Silva wrote:
> Hi everybody. I know Paul is on holidays, but as there is a lot of very
> capable people around, I felt encouraged to ask this question anyhow.
>
> I read in some post (also available as "JET FAQ Can JET handle UML
> models as input?" in
> http://wiki.eclipse.org/JET_FAQ_Can_JET_handle_UML_models_as _input%3F)
> that although JET cannot access stereotypes or stereotype properties,
> custom XPath functions could be created to access these.
>
> This is exactly what I need, so I started making my own XPath
> function, according to "JET FAQ How do I create custom XPath
> Function?"
> ( http://wiki.eclipse.org/JET_FAQ_How_do_I_create_custom_XPath _Function%3F).
>
> However, I am stuck in the part of accessing the stereotypes while
> coding the java class.
>
> I know Ecore has no notion of stereotypes. Meanwhile, .emx and .uml2
> models do. I thought of using UML2 metamodel/API to be able to access
> the stereotypes. Therefore, I placed "org.eclipse.uml2" as a required
> plugin (in the manifest). However, when trying to import this package
> in my java class, I get a "org.eclipse.uml2 cannot be resolved"
> message. I tried re-building the project from scratch, with the same
> result.
>
> Am I missing something here?, did I make wrong assumptions?, if so,
> which is the line to follow?.
> I would really appreciate your help on this one,
> Thanks in advance,
> Juan Pedro Silva
>


--------------000603080600000506060908
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Juan,<br>
<br>
Did you add org.eclipse.uml2.<b>uml </b>to the dependencies?&nbsp; Note
that if you use Ctrl-Shift-T to open a class you need to use,&nbsp; you can
then use the little left right arrow in the package explorer to locate
which plugin that class appears in and use that to help ensure that the
right plugin dependencies get added.<br>
<br>
<br>
<br>
Juan Pedro Silva wrote:
<blockquote cite="mid:f9s7uj$fhv$1@build.eclipse.org" type="cite">Hi
everybody. I know Paul is on holidays, but as there is a lot of very
<br>
capable people around, I felt encouraged to ask this question anyhow.
<br>
<br>
I read in some post (also available as "JET FAQ Can JET handle UML
<br>
models as input?" in
<br>
<a class="moz-txt-link-freetext" href=" http://wiki.eclipse.org/JET_FAQ_Can_JET_handle_UML_models_as _input%3F"> http://wiki.eclipse.org/JET_FAQ_Can_JET_handle_UML_models_as _input%3F</a>)
<br>
that although JET cannot access stereotypes or stereotype properties,
<br>
custom XPath functions could be created to access these.
<br>
<br>
This is exactly what I need, so I started making my own XPath function,
according to "JET FAQ How do I create custom XPath Function?"
(<a class="moz-txt-link-freetext" href=" http://wiki.eclipse.org/JET_FAQ_How_do_I_create_custom_XPath _Function%3F"> http://wiki.eclipse.org/JET_FAQ_How_do_I_create_custom_XPath _Function%3F</a>).
<br>
However, I am stuck in the part of accessing the stereotypes while
coding the java class.
<br>
<br>
I know Ecore has no notion of stereotypes. Meanwhile, .emx and .uml2
models do. I thought of using UML2 metamodel/API to be able to access
the stereotypes. Therefore, I placed "org.eclipse.uml2" as a required
plugin (in the manifest). However, when trying to import this package
in my java class, I get a "org.eclipse.uml2 cannot be resolved"
message. I tried re-building the project from scratch, with the same
result.
<br>
<br>
Am I missing something here?, did I make wrong assumptions?, if so,
which is the line to follow?.
<br>
I would really appreciate your help on this one,
<br>
Thanks in advance,
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Juan Pedro Silva
<br>
<br>
</blockquote>
<br>
</body>
</html>

--------------000603080600000506060908--
Re: [JET2] Custom XPath to access stereotypes. [message #31086 is a reply to message #30875] Tue, 14 August 2007 18:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Juan,

Unfortunately I'm not familiar with all the cool things Paul has done to
support XPaths and my XPath knowledge is very rusty. Hopefully someone
can jump in and answer these. I would expect the basic docs would have
covered these issues...


Juan Pedro Silva wrote:
> Thank you, Ed, that was a silly mistake (importing org.eclipse.uml2
> instead of org.eclipse.uml2.uml).
>
> I wrote these questions below some time ago, I think I got them
> (almost) clear now, but I leave them just to be sure and for
> documentation purposes (someone may have these same questions later in
> time).
>
> Referring to the fundamental issue, I'm having problems figuring out
> the type of the elements I'm dealing with.
>
> Lets say, when I use in XPath "/contents" against a uml2 model, what I
> get are EObjects (to be precise, an EList<EObject>), am I right?.
> Which is the type of "contents" itself?.
>
> If I try to pass a reference of the root of the model, the outermost
> container, what should I use?. If I use "/*", what I get is an element
> named "content", which (as I see it) must be a mapping of the
> Resource.getContents() method into a tree to be able to use the XPath
> expression "/contents" instead. If I get a hold of any "Element" from
> the model, and then do "element.getModel()", would that do?. How would
> I do that in XPath?.
>
> Thank you very much in advance.
> Regards,
> Juan Pedro
>
> Ed Merks escribió:
>> Juan,
>>
>> Did you add org.eclipse.uml2.*uml *to the dependencies? Note that if
>> you use Ctrl-Shift-T to open a class you need to use, you can then
>> use the little left right arrow in the package explorer to locate
>> which plugin that class appears in and use that to help ensure that
>> the right plugin dependencies get added.
>>
>>
>>
>> Juan Pedro Silva wrote:
>>> Hi everybody. I know Paul is on holidays, but as there is a lot of very
>>> capable people around, I felt encouraged to ask this question anyhow.
>>>
>>> I read in some post (also available as "JET FAQ Can JET handle UML
>>> models as input?" in
>>> http://wiki.eclipse.org/JET_FAQ_Can_JET_handle_UML_models_as _input%3F)
>>> that although JET cannot access stereotypes or stereotype properties,
>>> custom XPath functions could be created to access these.
>>>
>>> This is exactly what I need, so I started making my own XPath
>>> function, according to "JET FAQ How do I create custom XPath
>>> Function?"
>>> ( http://wiki.eclipse.org/JET_FAQ_How_do_I_create_custom_XPath _Function%3F).
>>>
>>> However, I am stuck in the part of accessing the stereotypes while
>>> coding the java class.
>>>
>>> I know Ecore has no notion of stereotypes. Meanwhile, .emx and .uml2
>>> models do. I thought of using UML2 metamodel/API to be able to
>>> access the stereotypes. Therefore, I placed "org.eclipse.uml2" as a
>>> required plugin (in the manifest). However, when trying to import
>>> this package in my java class, I get a "org.eclipse.uml2 cannot be
>>> resolved" message. I tried re-building the project from scratch,
>>> with the same result.
>>>
>>> Am I missing something here?, did I make wrong assumptions?, if so,
>>> which is the line to follow?.
>>> I would really appreciate your help on this one,
>>> Thanks in advance,
>>> Juan Pedro Silva
>>>
>>
Re: [JET2] Custom XPath to access stereotypes. [message #31121 is a reply to message #30875] Tue, 14 August 2007 18:46 Go to previous messageGo to next message
Juan Pedro Silva is currently offline Juan Pedro SilvaFriend
Messages: 258
Registered: July 2009
Senior Member
Thank you, Ed, that was a silly mistake (importing org.eclipse.uml2
instead of org.eclipse.uml2.uml).

I wrote a message a few moments ago and had to cancel it, as I realized
I was mistaken, sorry.

An update: if I try to pass an element to my XPath function, I am really
passing a org.eclipse.jet.internal.xpath.NodeSetImpl (a set of nodes).

How can I get a reference of an "Element" to pass it to the XPath
function?. I was trying to get a hold of any "Element" from
the model, and then do "element.getModel()" to get the outermost element
of the model.

I believe I may be loosing my north. Am I going in the right direction,
o should I use a completely different strategy to try to get the
stereotypes?.

Thank you,
Juan Pedro

Ed Merks escribió:
> Juan,
>
> Did you add org.eclipse.uml2.*uml *to the dependencies? Note that if
> you use Ctrl-Shift-T to open a class you need to use, you can then use
> the little left right arrow in the package explorer to locate which
> plugin that class appears in and use that to help ensure that the right
> plugin dependencies get added.
>
>
>
> Juan Pedro Silva wrote:
>> Hi everybody. I know Paul is on holidays, but as there is a lot of very
>> capable people around, I felt encouraged to ask this question anyhow.
>>
>> I read in some post (also available as "JET FAQ Can JET handle UML
>> models as input?" in
>> http://wiki.eclipse.org/JET_FAQ_Can_JET_handle_UML_models_as _input%3F)
>> that although JET cannot access stereotypes or stereotype properties,
>> custom XPath functions could be created to access these.
>>
>> This is exactly what I need, so I started making my own XPath
>> function, according to "JET FAQ How do I create custom XPath
>> Function?"
>> ( http://wiki.eclipse.org/JET_FAQ_How_do_I_create_custom_XPath _Function%3F).
>>
>> However, I am stuck in the part of accessing the stereotypes while
>> coding the java class.
>>
>> I know Ecore has no notion of stereotypes. Meanwhile, .emx and .uml2
>> models do. I thought of using UML2 metamodel/API to be able to access
>> the stereotypes. Therefore, I placed "org.eclipse.uml2" as a required
>> plugin (in the manifest). However, when trying to import this package
>> in my java class, I get a "org.eclipse.uml2 cannot be resolved"
>> message. I tried re-building the project from scratch, with the same
>> result.
>>
>> Am I missing something here?, did I make wrong assumptions?, if so,
>> which is the line to follow?.
>> I would really appreciate your help on this one,
>> Thanks in advance,
>> Juan Pedro Silva
>>
>
Re: [JET2] Custom XPath to access stereotypes. [message #31261 is a reply to message #31121] Thu, 16 August 2007 08:17 Go to previous messageGo to next message
Aleks Dworak is currently offline Aleks DworakFriend
Messages: 8
Registered: July 2009
Junior Member
Hi,

I'm pretty new to Jet but, as Paul is not there, here is my little
contribution.

I think that you should get your Element in the body of the XPath Function.

public Object evaluate(List args) {
// Get the first argument of the function - it is a NodeSet, because
of XPath
NodeSet arg = (NodeSet) args.get(0);

// Get the "Element" in your argument
Element element = (Element) arg.iterator().next();
...
}

If Element is in a known API. For example, it works very well on an Ecore
model to get its elements.

I'm sorry I never tried this with an UML input, so it is maybe not the
right way.

Hope it helps,

Aleks Dworak.
Re: [JET2] Custom XPath to access stereotypes. [message #31609 is a reply to message #30840] Mon, 27 August 2007 15:39 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Juan Pedro:

Your approach is consistent with that of others. Thanks to Ed and Aleks for
helping out with the technical problems.

I would probably create one of two XPath functions:

getStereotypeValue( object, 'myprofile::myStereoType', 'stPropertyName')

and

isStereotypeApplied( object, 'myprofile::myStereoType')

This would use Element.getValue() and element.isStereotypeApplied()
respectively as their key funcions.

On the technical side, XPath functions will receive arguments in the form of
NodeSet, Number, String or Boolean.

You can return any of the above for types or an object that JET knows how to
handle (EObject's fall into this category).

There is no public NodeSet implementation, but something as simple as:

class MyNodeSet extends java.util.HashSet implements NodeSet {

}

will do.

Paul

"Juan Pedro Silva" <jpsilvagallino@gmail.com> wrote in message
news:f9s7uj$fhv$1@build.eclipse.org...
> Hi everybody. I know Paul is on holidays, but as there is a lot of very
> capable people around, I felt encouraged to ask this question anyhow.
>
> I read in some post (also available as "JET FAQ Can JET handle UML
> models as input?" in
> http://wiki.eclipse.org/JET_FAQ_Can_JET_handle_UML_models_as _input%3F)
> that although JET cannot access stereotypes or stereotype properties,
> custom XPath functions could be created to access these.
>
> This is exactly what I need, so I started making my own XPath function,
> according to "JET FAQ How do I create custom XPath Function?"
> ( http://wiki.eclipse.org/JET_FAQ_How_do_I_create_custom_XPath _Function%3F).
> However, I am stuck in the part of accessing the stereotypes while coding
> the java class.
>
> I know Ecore has no notion of stereotypes. Meanwhile, .emx and .uml2
> models do. I thought of using UML2 metamodel/API to be able to access the
> stereotypes. Therefore, I placed "org.eclipse.uml2" as a required plugin
> (in the manifest). However, when trying to import this package in my java
> class, I get a "org.eclipse.uml2 cannot be resolved" message. I tried
> re-building the project from scratch, with the same result.
>
> Am I missing something here?, did I make wrong assumptions?, if so, which
> is the line to follow?.
> I would really appreciate your help on this one,
> Thanks in advance,
> Juan Pedro Silva
>
Re: [JET2] Custom XPath to access stereotypes. [message #31850 is a reply to message #31609] Wed, 29 August 2007 08:21 Go to previous messageGo to next message
Juan Pedro Silva is currently offline Juan Pedro SilvaFriend
Messages: 258
Registered: July 2009
Senior Member
Thanks Paul, Alex, Ed..
I'm sorry it took me so long to answer, but I had to travel abroad and
lost touch.
Paul, I was thinking of two very similar functions, thank for your advice.
One further question about this subject: the different elements (I mean
each Item, not referring to the 'Element' class in particular) in the
NodeSet, correspond to which class?, are they 'Element', 'NamedElement',
or something else?. I need to know this in order to be able to deal with
them.
Thank you all for your answers.
Regards,
Juan Pedro



Paul Elder escribió:
> Juan Pedro:
>
> Your approach is consistent with that of others. Thanks to Ed and Aleks for
> helping out with the technical problems.
>
> I would probably create one of two XPath functions:
>
> getStereotypeValue( object, 'myprofile::myStereoType', 'stPropertyName')
>
> and
>
> isStereotypeApplied( object, 'myprofile::myStereoType')
>
> This would use Element.getValue() and element.isStereotypeApplied()
> respectively as their key funcions.
>
> On the technical side, XPath functions will receive arguments in the form of
> NodeSet, Number, String or Boolean.
>
> You can return any of the above for types or an object that JET knows how to
> handle (EObject's fall into this category).
>
> There is no public NodeSet implementation, but something as simple as:
>
> class MyNodeSet extends java.util.HashSet implements NodeSet {
>
> }
>
> will do.
>
> Paul
>
> "Juan Pedro Silva" <jpsilvagallino@gmail.com> wrote in message
> news:f9s7uj$fhv$1@build.eclipse.org...
>> Hi everybody. I know Paul is on holidays, but as there is a lot of very
>> capable people around, I felt encouraged to ask this question anyhow.
>>
>> I read in some post (also available as "JET FAQ Can JET handle UML
>> models as input?" in
>> http://wiki.eclipse.org/JET_FAQ_Can_JET_handle_UML_models_as _input%3F)
>> that although JET cannot access stereotypes or stereotype properties,
>> custom XPath functions could be created to access these.
>>
>> This is exactly what I need, so I started making my own XPath function,
>> according to "JET FAQ How do I create custom XPath Function?"
>> ( http://wiki.eclipse.org/JET_FAQ_How_do_I_create_custom_XPath _Function%3F).
>> However, I am stuck in the part of accessing the stereotypes while coding
>> the java class.
>>
>> I know Ecore has no notion of stereotypes. Meanwhile, .emx and .uml2
>> models do. I thought of using UML2 metamodel/API to be able to access the
>> stereotypes. Therefore, I placed "org.eclipse.uml2" as a required plugin
>> (in the manifest). However, when trying to import this package in my java
>> class, I get a "org.eclipse.uml2 cannot be resolved" message. I tried
>> re-building the project from scratch, with the same result.
>>
>> Am I missing something here?, did I make wrong assumptions?, if so, which
>> is the line to follow?.
>> I would really appreciate your help on this one,
>> Thanks in advance,
>> Juan Pedro Silva
>>
>
>
Re: [JET2] Custom XPath to access stereotypes. [message #31886 is a reply to message #31850] Wed, 29 August 2007 10:44 Go to previous messageGo to next message
Juan Pedro Silva is currently offline Juan Pedro SilvaFriend
Messages: 258
Registered: July 2009
Senior Member
I just found the answer to my last question browsing the newsgroup. As a
reference, it's in a post from Paul and Zsolt Parocziz titled "Xpath
node" in 19/07/2007. According to this, as I'm using the emf loader, I
get a NodeSet of EObject's. That's fine.

As already discussed, it's desirable to work with
org.eclipse.uml2.uml.Element since it provides a lot of useful methods
(for instance, means to access stereotypes, or the 'Model' itself).
Regretfully, if I try to cast the EObject to Element, I get a:

Error: Error executing tag handler: java.lang.ClassCastException:
org.eclipse.emf.ecore.impl.DynamicEObjectImpl cannot be cast to
org.eclipse.uml2.uml.Element

Which would be the right approach here?.
Thank you all, again,
Juan Pedro

Juan Pedro Silva escribió:
> Thanks Paul, Alex, Ed..
> I'm sorry it took me so long to answer, but I had to travel abroad and
> lost touch.
> Paul, I was thinking of two very similar functions, thank for your advice.
> One further question about this subject: the different elements (I mean
> each Item, not referring to the 'Element' class in particular) in the
> NodeSet, correspond to which class?, are they 'Element', 'NamedElement',
> or something else?. I need to know this in order to be able to deal with
> them.
> Thank you all for your answers.
> Regards,
> Juan Pedro
>
>
>
> Paul Elder escribió:
>> Juan Pedro:
>>
>> Your approach is consistent with that of others. Thanks to Ed and
>> Aleks for helping out with the technical problems.
>>
>> I would probably create one of two XPath functions:
>>
>> getStereotypeValue( object, 'myprofile::myStereoType', 'stPropertyName')
>>
>> and
>>
>> isStereotypeApplied( object, 'myprofile::myStereoType')
>>
>> This would use Element.getValue() and element.isStereotypeApplied()
>> respectively as their key funcions.
>>
>> On the technical side, XPath functions will receive arguments in the
>> form of NodeSet, Number, String or Boolean.
>>
>> You can return any of the above for types or an object that JET knows
>> how to handle (EObject's fall into this category).
>>
>> There is no public NodeSet implementation, but something as simple as:
>>
>> class MyNodeSet extends java.util.HashSet implements NodeSet {
>>
>> }
>>
>> will do.
>>
>> Paul
>>
>> "Juan Pedro Silva" <jpsilvagallino@gmail.com> wrote in message
>> news:f9s7uj$fhv$1@build.eclipse.org...
>>> Hi everybody. I know Paul is on holidays, but as there is a lot of very
>>> capable people around, I felt encouraged to ask this question anyhow.
>>>
>>> I read in some post (also available as "JET FAQ Can JET handle UML
>>> models as input?" in
>>> http://wiki.eclipse.org/JET_FAQ_Can_JET_handle_UML_models_as _input%3F)
>>> that although JET cannot access stereotypes or stereotype properties,
>>> custom XPath functions could be created to access these.
>>>
>>> This is exactly what I need, so I started making my own XPath
>>> function, according to "JET FAQ How do I create custom XPath
>>> Function?"
>>> ( http://wiki.eclipse.org/JET_FAQ_How_do_I_create_custom_XPath _Function%3F).
>>>
>>> However, I am stuck in the part of accessing the stereotypes while
>>> coding the java class.
>>>
>>> I know Ecore has no notion of stereotypes. Meanwhile, .emx and .uml2
>>> models do. I thought of using UML2 metamodel/API to be able to access
>>> the stereotypes. Therefore, I placed "org.eclipse.uml2" as a required
>>> plugin (in the manifest). However, when trying to import this package
>>> in my java class, I get a "org.eclipse.uml2 cannot be resolved"
>>> message. I tried re-building the project from scratch, with the same
>>> result.
>>>
>>> Am I missing something here?, did I make wrong assumptions?, if so,
>>> which is the line to follow?.
>>> I would really appreciate your help on this one,
>>> Thanks in advance,
>>> Juan Pedro Silva
>>>
>>
>>
Re: [JET2] Custom XPath to access stereotypes. [message #31921 is a reply to message #31886] Wed, 29 August 2007 12:42 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Juan Pedro:

This is weird. You should not be getting DynamicEObjectImpl's, you should be
getting actual UML2 objects (like ClassImpl, PackageImpl, ...)

I suspect you are not using the correct model loader. Try the following:

1) open plugin.xml in your JET transformation
2) Click on the Extensions tab, and expand org.eclipse.jet.transform, and
then click on transform.
3) Set the 'modelLoader' property to 'org.eclipse.jet.emf'

Save, and try again.

Paul

"Juan Pedro Silva" <jpsilvagallino@gmail.com> wrote in message
news:fb3iml$6v5$2@build.eclipse.org...
>I just found the answer to my last question browsing the newsgroup. As a
>reference, it's in a post from Paul and Zsolt Parocziz titled "Xpath node"
>in 19/07/2007. According to this, as I'm using the emf loader, I get a
>NodeSet of EObject's. That's fine.
>
> As already discussed, it's desirable to work with
> org.eclipse.uml2.uml.Element since it provides a lot of useful methods
> (for instance, means to access stereotypes, or the 'Model' itself).
> Regretfully, if I try to cast the EObject to Element, I get a:
>
> Error: Error executing tag handler: java.lang.ClassCastException:
> org.eclipse.emf.ecore.impl.DynamicEObjectImpl cannot be cast to
> org.eclipse.uml2.uml.Element
>
> Which would be the right approach here?.
> Thank you all, again,
> Juan Pedro
>
> Juan Pedro Silva escribi
Re: [JET2] Custom XPath to access stereotypes. [message #32025 is a reply to message #31921] Wed, 29 August 2007 13:33 Go to previous messageGo to next message
Juan Pedro Silva is currently offline Juan Pedro SilvaFriend
Messages: 258
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------050703030105070908010201
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Paul, I'm attaching my plugin.xml.
In it you can see that the model loader is in fact org.eclipse.jet.emf
What else could it be?
I'm attaching the java code of the hasSterotype() function class, as
well as its plugin xml. I'm also attaching the model which I use to try
it, just in case.
I'm trying it out with this simple JET code:

<c:iterate select="/contents" var="container">

ServiceProviders:

<c:iterate select="$container" var="elem">
Element <c:get select="name($elem)" />
<c:choose> <c:when test="hasStereotype($elem,
'Perfil_SOA::serviceProvider')">
<c:get select="name($reference)"/> es ServiceProvider.
</c:when> </c:choose>
</c:iterate>

</c:iterate>

I realize I may have other errors (for instance, I'm not completely sure
that the workspace found the particular profile that was applied), but
I'm tackling them one at a time.
Thank you.

Paul Elder escribi
Re: [JET2] Custom XPath to access stereotypes. [message #32372 is a reply to message #32025] Tue, 04 September 2007 09:06 Go to previous messageGo to next message
Juan Pedro Silva is currently offline Juan Pedro SilvaFriend
Messages: 258
Registered: July 2009
Senior Member
I tried re-stating the model loader as 'org.eclipse.jet.emf' and I keeo
getting the same results.
At this time I don't know what to do next.
Regards,
Juan Pedro

Juan Pedro Silva escribió:
> Paul, I'm attaching my plugin.xml.
> In it you can see that the model loader is in fact org.eclipse.jet.emf
> What else could it be?
> I'm attaching the java code of the hasSterotype() function class, as
> well as its plugin xml. I'm also attaching the model which I use to try
> it, just in case.
> I'm trying it out with this simple JET code:
>
> <c:iterate select="/contents" var="container">
>
> ServiceProviders:
>
> <c:iterate select="$container" var="elem">
> Element <c:get select="name($elem)" />
> <c:choose> <c:when test="hasStereotype($elem,
> 'Perfil_SOA::serviceProvider')">
> <c:get select="name($reference)"/> es ServiceProvider.
> </c:when> </c:choose>
> </c:iterate>
>
> </c:iterate>
>
> I realize I may have other errors (for instance, I'm not completely sure
> that the workspace found the particular profile that was applied), but
> I'm tackling them one at a time.
> Thank you.
>
> Paul Elder escribió:
>> Juan Pedro:
>>
>> This is weird. You should not be getting DynamicEObjectImpl's, you
>> should be getting actual UML2 objects (like ClassImpl, PackageImpl, ...)
>>
>> I suspect you are not using the correct model loader. Try the following:
>>
>> 1) open plugin.xml in your JET transformation
>> 2) Click on the Extensions tab, and expand org.eclipse.jet.transform,
>> and then click on transform.
>> 3) Set the 'modelLoader' property to 'org.eclipse.jet.emf'
>>
>> Save, and try again.
>>
>> Paul
>>
>> "Juan Pedro Silva" <jpsilvagallino@gmail.com> wrote in message
>> news:fb3iml$6v5$2@build.eclipse.org...
>>> I just found the answer to my last question browsing the newsgroup.
>>> As a reference, it's in a post from Paul and Zsolt Parocziz titled
>>> "Xpath node" in 19/07/2007. According to this, as I'm using the emf
>>> loader, I get a NodeSet of EObject's. That's fine.
>>>
>>> As already discussed, it's desirable to work with
>>> org.eclipse.uml2.uml.Element since it provides a lot of useful
>>> methods (for instance, means to access stereotypes, or the 'Model'
>>> itself). Regretfully, if I try to cast the EObject to Element, I get a:
>>>
>>> Error: Error executing tag handler: java.lang.ClassCastException:
>>> org.eclipse.emf.ecore.impl.DynamicEObjectImpl cannot be cast to
>>> org.eclipse.uml2.uml.Element
>>>
>>> Which would be the right approach here?.
>>> Thank you all, again,
>>> Juan Pedro
>>>
>>> Juan Pedro Silva escribió:
>>>> Thanks Paul, Alex, Ed..
>>>> I'm sorry it took me so long to answer, but I had to travel abroad
>>>> and lost touch.
>>>> Paul, I was thinking of two very similar functions, thank for your
>>>> advice.
>>>> One further question about this subject: the different elements (I
>>>> mean each Item, not referring to the 'Element' class in particular)
>>>> in the NodeSet, correspond to which class?, are they 'Element',
>>>> 'NamedElement', or something else?. I need to know this in order to
>>>> be able to deal with them.
>>>> Thank you all for your answers.
>>>> Regards,
>>>> Juan Pedro
>>>>
>>>>
>>>>
>>>> Paul Elder escribió:
>>>>> Juan Pedro:
>>>>>
>>>>> Your approach is consistent with that of others. Thanks to Ed and
>>>>> Aleks for helping out with the technical problems.
>>>>>
>>>>> I would probably create one of two XPath functions:
>>>>>
>>>>> getStereotypeValue( object, 'myprofile::myStereoType',
>>>>> 'stPropertyName')
>>>>>
>>>>> and
>>>>>
>>>>> isStereotypeApplied( object, 'myprofile::myStereoType')
>>>>>
>>>>> This would use Element.getValue() and element.isStereotypeApplied()
>>>>> respectively as their key funcions.
>>>>>
>>>>> On the technical side, XPath functions will receive arguments in
>>>>> the form of NodeSet, Number, String or Boolean.
>>>>>
>>>>> You can return any of the above for types or an object that JET
>>>>> knows how to handle (EObject's fall into this category).
>>>>>
>>>>> There is no public NodeSet implementation, but something as simple as:
>>>>>
>>>>> class MyNodeSet extends java.util.HashSet implements NodeSet {
>>>>>
>>>>> }
>>>>>
>>>>> will do.
>>>>>
>>>>> Paul
>>>>>
>>>>> "Juan Pedro Silva" <jpsilvagallino@gmail.com> wrote in message
>>>>> news:f9s7uj$fhv$1@build.eclipse.org...
>>>>>> Hi everybody. I know Paul is on holidays, but as there is a lot of
>>>>>> very
>>>>>> capable people around, I felt encouraged to ask this question anyhow.
>>>>>>
>>>>>> I read in some post (also available as "JET FAQ Can JET handle UML
>>>>>> models as input?" in
>>>>>> http://wiki.eclipse.org/JET_FAQ_Can_JET_handle_UML_models_as _input%3F)
>>>>>>
>>>>>> that although JET cannot access stereotypes or stereotype properties,
>>>>>> custom XPath functions could be created to access these.
>>>>>>
>>>>>> This is exactly what I need, so I started making my own XPath
>>>>>> function, according to "JET FAQ How do I create custom XPath
>>>>>> Function?"
>>>>>> ( http://wiki.eclipse.org/JET_FAQ_How_do_I_create_custom_XPath _Function%3F).
>>>>>>
>>>>>> However, I am stuck in the part of accessing the stereotypes while
>>>>>> coding the java class.
>>>>>>
>>>>>> I know Ecore has no notion of stereotypes. Meanwhile, .emx and
>>>>>> .uml2 models do. I thought of using UML2 metamodel/API to be able
>>>>>> to access the stereotypes. Therefore, I placed "org.eclipse.uml2"
>>>>>> as a required plugin (in the manifest). However, when trying to
>>>>>> import this package in my java class, I get a "org.eclipse.uml2
>>>>>> cannot be resolved" message. I tried re-building the project from
>>>>>> scratch, with the same result.
>>>>>>
>>>>>> Am I missing something here?, did I make wrong assumptions?, if
>>>>>> so, which is the line to follow?.
>>>>>> I would really appreciate your help on this one,
>>>>>> Thanks in advance,
>>>>>> Juan Pedro Silva
>>>>>>
>>>>>
>>
>>
Re: [JET2] Custom XPath to access stereotypes. [message #32990 is a reply to message #32025] Thu, 06 September 2007 14:32 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Juan Pedro:

Can you tell me what version of UML2 features/plug-ins you are using. Also,
what tool are you using to generate your UML models?

We'll get to the bottom of this yet! That a you are finding a DynamicEObject
is an indication (I think) that EMF did not find an implementation of the
UML2 EPackage. One thing to try is loading the UML model using the Java
API's yourself, and seeing whether you get DynamicEObjects or not. If you
do, then this is not a JET problem (and we can ask a question on the UML
news group).

Paul

"Juan Pedro Silva" <jpsilvagallino@gmail.com> wrote in message
news:fb3sjv$7fv$2@build.eclipse.org...
> Paul, I'm attaching my plugin.xml.
> In it you can see that the model loader is in fact org.eclipse.jet.emf
> What else could it be?
> I'm attaching the java code of the hasSterotype() function class, as
> well as its plugin xml. I'm also attaching the model which I use to try
> it, just in case.
> I'm trying it out with this simple JET code:
>
> <c:iterate select="/contents" var="container">
>
> ServiceProviders:
>
> <c:iterate select="$container" var="elem">
> Element <c:get select="name($elem)" />
> <c:choose> <c:when test="hasStereotype($elem,
> 'Perfil_SOA::serviceProvider')">
> <c:get select="name($reference)"/> es ServiceProvider.
> </c:when> </c:choose>
> </c:iterate>
>
> </c:iterate>
>
> I realize I may have other errors (for instance, I'm not completely sure
> that the workspace found the particular profile that was applied), but
> I'm tackling them one at a time.
> Thank you.
>
Re: [JET2] Custom XPath to access stereotypes. [message #33201 is a reply to message #32990] Fri, 07 September 2007 08:45 Go to previous messageGo to next message
Juan Pedro Silva is currently offline Juan Pedro SilvaFriend
Messages: 258
Registered: July 2009
Senior Member
Hi Paul.
Let me see, the model I'm using as input was developed in RSA 7.0.0.3,
which has UML2 plugin version 2.0.3v200702141227
I'm using Eclipse with UML2 plugin 2.1.0v200706251652

The input model was transformed into a UML2 (from .emx) model in RSA
before importing it into eclipse. It also uses a profile that has not
been imported yet into eclipse.

I will load the model in java and get back to you with the results.
Thank you,
Juan Pedro


Paul Elder escribió:
> Juan Pedro:
>
> Can you tell me what version of UML2 features/plug-ins you are using. Also,
> what tool are you using to generate your UML models?
>
> We'll get to the bottom of this yet! That a you are finding a DynamicEObject
> is an indication (I think) that EMF did not find an implementation of the
> UML2 EPackage. One thing to try is loading the UML model using the Java
> API's yourself, and seeing whether you get DynamicEObjects or not. If you
> do, then this is not a JET problem (and we can ask a question on the UML
> news group).
>
> Paul
>
> "Juan Pedro Silva" <jpsilvagallino@gmail.com> wrote in message
> news:fb3sjv$7fv$2@build.eclipse.org...
>> Paul, I'm attaching my plugin.xml.
>> In it you can see that the model loader is in fact org.eclipse.jet.emf
>> What else could it be?
>> I'm attaching the java code of the hasSterotype() function class, as
>> well as its plugin xml. I'm also attaching the model which I use to try
>> it, just in case.
>> I'm trying it out with this simple JET code:
>>
>> <c:iterate select="/contents" var="container">
>>
>> ServiceProviders:
>>
>> <c:iterate select="$container" var="elem">
>> Element <c:get select="name($elem)" />
>> <c:choose> <c:when test="hasStereotype($elem,
>> 'Perfil_SOA::serviceProvider')">
>> <c:get select="name($reference)"/> es ServiceProvider.
>> </c:when> </c:choose>
>> </c:iterate>
>>
>> </c:iterate>
>>
>> I realize I may have other errors (for instance, I'm not completely sure
>> that the workspace found the particular profile that was applied), but
>> I'm tackling them one at a time.
>> Thank you.
>>
>
>
Re: [JET2] Custom XPath to access stereotypes. [message #33272 is a reply to message #32990] Fri, 07 September 2007 10:21 Go to previous messageGo to next message
Juan Pedro Silva is currently offline Juan Pedro SilvaFriend
Messages: 258
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------070803000408010303030309
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Hi Paul, back again.
After loading the model with this Java code:

Resource.Factory rscFact = XMI2UMLResource.Factory.INSTANCE;
Resource rsc = rscFact.createResource(
org.eclipse.emf.common.util.URI.createURI("file://" + filepath)
);
System.out.println(rsc.getURI().toString());
try {
rsc.load(null);
} catch (Throwable t) { }

and then printing to the console with

System.out.println(eachEObject.eClass());

for each element.

A summary of the result is attached. I got a lot of "AnyType" elements,
and some "Class", "Component", "Epackage", "Collaboration", etc.

Hope this helps for figuring something out.
Thanks again,
Juan Pedro






Paul Elder escribi
Re: [JET2] Custom XPath to access stereotypes. [message #33376 is a reply to message #33201] Fri, 07 September 2007 14:09 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Hmmm.

I'm suspecting it has something to do with move from UML2 2.0.x to 2.1.x.

I have done some tests (in RSA 7.0.0.x), and a JET transform gets actual
UML2 implementations. I have tried with:

..emx files
..uml files (created by using the Export > UML Model wizard)
..xmi files (created by using the Export > UML XMI Interchange Model wizard)

I'll have to move on over to a Eclipse 3.3/UML 2.1 based install to test
under that, but at this point, it appears that this is UML2 behavior not
JETs.

I'm attaching my test projects as a ZIP, there are two projects:
* juan.pedro.jet contains a simple JET transformation that dumps information
about the loaded model to the JET execution console.
* juan.pedro contains a the EMX, UML and XMI files, plus JET launch
configurations to run juan.pedro.jet on them.

Paul

"Juan Pedro Silva" <jpsilvagallino@gmail.com> wrote in message
news:fbr342$959$1@build.eclipse.org...
> Hi Paul.
> Let me see, the model I'm using as input was developed in RSA 7.0.0.3,
> which has UML2 plugin version 2.0.3v200702141227
> I'm using Eclipse with UML2 plugin 2.1.0v200706251652
>
> The input model was transformed into a UML2 (from .emx) model in RSA
> before importing it into eclipse. It also uses a profile that has not
> been imported yet into eclipse.
>
> I will load the model in java and get back to you with the results.
> Thank you,
> Juan Pedro
>
>
> Paul Elder escribi
Re: [JET2] Custom XPath to access stereotypes. [message #33417 is a reply to message #33272] Fri, 07 September 2007 14:11 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Juan Pedro:

More interesting than the eClass.getName() is simply
eachEObject.getClass().getName(), that will tell you the actual Java class
loaded.

Paul

"Juan Pedro Silva" <jpsilvagallino@gmail.com> wrote in message
news:fbr8no$ouk$1@build.eclipse.org...
> Hi Paul, back again.
> After loading the model with this Java code:
>
> Resource.Factory rscFact = XMI2UMLResource.Factory.INSTANCE;
> Resource rsc = rscFact.createResource(
> org.eclipse.emf.common.util.URI.createURI("file://" + filepath)
> );
> System.out.println(rsc.getURI().toString());
> try {
> rsc.load(null);
> } catch (Throwable t) { }
>
> and then printing to the console with
>
> System.out.println(eachEObject.eClass());
>
> for each element.
>
> A summary of the result is attached. I got a lot of "AnyType" elements,
> and some "Class", "Component", "Epackage", "Collaboration", etc.
>
> Hope this helps for figuring something out.
> Thanks again,
> Juan Pedro
>
>
>
>
>
>
> Paul Elder escribi
Re: [JET2] Custom XPath to access stereotypes. [message #33447 is a reply to message #33417] Fri, 07 September 2007 14:27 Go to previous messageGo to next message
Juan Pedro Silva is currently offline Juan Pedro SilvaFriend
Messages: 258
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------060805030106040809060202
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Sorry..
Your wishes are my commands...
I'm attaching the new output.
Regards,
Juan Pedro

Paul Elder escribi
Re: [JET2] Custom XPath to access stereotypes. [message #33481 is a reply to message #33376] Fri, 07 September 2007 14:33 Go to previous messageGo to next message
Juan Pedro Silva is currently offline Juan Pedro SilvaFriend
Messages: 258
Registered: July 2009
Senior Member
As soon as I get home I'll give them a try.
Thanks.

Paul Elder escribió:
> Hmmm.
>
> I'm suspecting it has something to do with move from UML2 2.0.x to 2.1.x.
>
> I have done some tests (in RSA 7.0.0.x), and a JET transform gets actual
> UML2 implementations. I have tried with:
>
> .emx files
> .uml files (created by using the Export > UML Model wizard)
> .xmi files (created by using the Export > UML XMI Interchange Model wizard)
>
> I'll have to move on over to a Eclipse 3.3/UML 2.1 based install to test
> under that, but at this point, it appears that this is UML2 behavior not
> JETs.
>
> I'm attaching my test projects as a ZIP, there are two projects:
> * juan.pedro.jet contains a simple JET transformation that dumps information
> about the loaded model to the JET execution console.
> * juan.pedro contains a the EMX, UML and XMI files, plus JET launch
> configurations to run juan.pedro.jet on them.
>
> Paul
>
> "Juan Pedro Silva" <jpsilvagallino@gmail.com> wrote in message
> news:fbr342$959$1@build.eclipse.org...
>> Hi Paul.
>> Let me see, the model I'm using as input was developed in RSA 7.0.0.3,
>> which has UML2 plugin version 2.0.3v200702141227
>> I'm using Eclipse with UML2 plugin 2.1.0v200706251652
>>
>> The input model was transformed into a UML2 (from .emx) model in RSA
>> before importing it into eclipse. It also uses a profile that has not
>> been imported yet into eclipse.
>>
>> I will load the model in java and get back to you with the results.
>> Thank you,
>> Juan Pedro
>>
>>
>> Paul Elder escribió:
>>> Juan Pedro:
>>>
>>> Can you tell me what version of UML2 features/plug-ins you are using.
>>> Also,
>>> what tool are you using to generate your UML models?
>>>
>>> We'll get to the bottom of this yet! That a you are finding a
>>> DynamicEObject
>>> is an indication (I think) that EMF did not find an implementation of the
>>> UML2 EPackage. One thing to try is loading the UML model using the Java
>>> API's yourself, and seeing whether you get DynamicEObjects or not. If you
>>> do, then this is not a JET problem (and we can ask a question on the UML
>>> news group).
>>>
>>> Paul
>>>
>>> "Juan Pedro Silva" <jpsilvagallino@gmail.com> wrote in message
>>> news:fb3sjv$7fv$2@build.eclipse.org...
>>>> Paul, I'm attaching my plugin.xml.
>>>> In it you can see that the model loader is in fact org.eclipse.jet.emf
>>>> What else could it be?
>>>> I'm attaching the java code of the hasSterotype() function class, as
>>>> well as its plugin xml. I'm also attaching the model which I use to try
>>>> it, just in case.
>>>> I'm trying it out with this simple JET code:
>>>>
>>>> <c:iterate select="/contents" var="container">
>>>>
>>>> ServiceProviders:
>>>>
>>>> <c:iterate select="$container" var="elem">
>>>> Element <c:get select="name($elem)" />
>>>> <c:choose> <c:when test="hasStereotype($elem,
>>>> 'Perfil_SOA::serviceProvider')">
>>>> <c:get select="name($reference)"/> es ServiceProvider.
>>>> </c:when> </c:choose>
>>>> </c:iterate>
>>>>
>>>> </c:iterate>
>>>>
>>>> I realize I may have other errors (for instance, I'm not completely sure
>>>> that the workspace found the particular profile that was applied), but
>>>> I'm tackling them one at a time.
>>>> Thank you.
>>>>
>>>
>
>
Re: [JET2] Custom XPath to access stereotypes. [message #33515 is a reply to message #33376] Fri, 07 September 2007 16:26 Go to previous messageGo to next message
Juan Pedro Silva is currently offline Juan Pedro SilvaFriend
Messages: 258
Registered: July 2009
Senior Member
Paul, I tried your code with my model and the result was empty:

templates/main.jet(57,1): <ws:file template="templates/dump.jet"
path="{$org.eclipse.jet.resource.project.name}/dump.xml">
Writing file: /juan.pedro/dump.xml
Successful Execution

So it most probably the problem that you figured out, something related
with migration from UML 2.0.X to UML 2.1.X

So is an RSA problem, let's say, because I cannot update it so that it
uses UML 2.1, am I right?. I had a similar problem when I ran into a bug
in OCL's plugin and couldn't update it to a newer version which had
fixed it.

An alternative?, using Eclipse with UML 2.0.X instead?.
Regards,
Juan Pedro


Paul Elder escribió:
> Hmmm.
>
> I'm suspecting it has something to do with move from UML2 2.0.x to 2.1.x.
>
> I have done some tests (in RSA 7.0.0.x), and a JET transform gets actual
> UML2 implementations. I have tried with:
>
> .emx files
> .uml files (created by using the Export > UML Model wizard)
> .xmi files (created by using the Export > UML XMI Interchange Model wizard)
>
> I'll have to move on over to a Eclipse 3.3/UML 2.1 based install to test
> under that, but at this point, it appears that this is UML2 behavior not
> JETs.
>
> I'm attaching my test projects as a ZIP, there are two projects:
> * juan.pedro.jet contains a simple JET transformation that dumps information
> about the loaded model to the JET execution console.
> * juan.pedro contains a the EMX, UML and XMI files, plus JET launch
> configurations to run juan.pedro.jet on them.
>
> Paul
>
> "Juan Pedro Silva" <jpsilvagallino@gmail.com> wrote in message
> news:fbr342$959$1@build.eclipse.org...
>> Hi Paul.
>> Let me see, the model I'm using as input was developed in RSA 7.0.0.3,
>> which has UML2 plugin version 2.0.3v200702141227
>> I'm using Eclipse with UML2 plugin 2.1.0v200706251652
>>
>> The input model was transformed into a UML2 (from .emx) model in RSA
>> before importing it into eclipse. It also uses a profile that has not
>> been imported yet into eclipse.
>>
>> I will load the model in java and get back to you with the results.
>> Thank you,
>> Juan Pedro
>>
>>
>> Paul Elder escribió:
>>> Juan Pedro:
>>>
>>> Can you tell me what version of UML2 features/plug-ins you are using.
>>> Also,
>>> what tool are you using to generate your UML models?
>>>
>>> We'll get to the bottom of this yet! That a you are finding a
>>> DynamicEObject
>>> is an indication (I think) that EMF did not find an implementation of the
>>> UML2 EPackage. One thing to try is loading the UML model using the Java
>>> API's yourself, and seeing whether you get DynamicEObjects or not. If you
>>> do, then this is not a JET problem (and we can ask a question on the UML
>>> news group).
>>>
>>> Paul
>>>
>>> "Juan Pedro Silva" <jpsilvagallino@gmail.com> wrote in message
>>> news:fb3sjv$7fv$2@build.eclipse.org...
>>>> Paul, I'm attaching my plugin.xml.
>>>> In it you can see that the model loader is in fact org.eclipse.jet.emf
>>>> What else could it be?
>>>> I'm attaching the java code of the hasSterotype() function class, as
>>>> well as its plugin xml. I'm also attaching the model which I use to try
>>>> it, just in case.
>>>> I'm trying it out with this simple JET code:
>>>>
>>>> <c:iterate select="/contents" var="container">
>>>>
>>>> ServiceProviders:
>>>>
>>>> <c:iterate select="$container" var="elem">
>>>> Element <c:get select="name($elem)" />
>>>> <c:choose> <c:when test="hasStereotype($elem,
>>>> 'Perfil_SOA::serviceProvider')">
>>>> <c:get select="name($reference)"/> es ServiceProvider.
>>>> </c:when> </c:choose>
>>>> </c:iterate>
>>>>
>>>> </c:iterate>
>>>>
>>>> I realize I may have other errors (for instance, I'm not completely sure
>>>> that the workspace found the particular profile that was applied), but
>>>> I'm tackling them one at a time.
>>>> Thank you.
>>>>
>>>
>
>
Re: [JET2] Custom XPath to access stereotypes. [message #33616 is a reply to message #33515] Tue, 11 September 2007 12:11 Go to previous messageGo to next message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Juan Pedro:

Based on your results in message news:fbrn5a$msm$1@build.eclipse.org,

I'd say that is the problem. If you want to stay compatible with RSA
7.0.0.x, then I think your Eclipse shell will have to use UML 2.0.X. I'll go
ask the UML development lead (who are just a leisurely stroll across my
building) - I'll post another reply if I get anything useful.

Paul

"Juan Pedro Silva" <jpsilvagallino@gmail.com> wrote in message
news:fbru43$rqu$1@build.eclipse.org...
> Paul, I tried your code with my model and the result was empty:
>
> templates/main.jet(57,1): <ws:file template="templates/dump.jet"
> path="{$org.eclipse.jet.resource.project.name}/dump.xml">
> Writing file: /juan.pedro/dump.xml
> Successful Execution
>
> So it most probably the problem that you figured out, something related
> with migration from UML 2.0.X to UML 2.1.X
>
> So is an RSA problem, let's say, because I cannot update it so that it
> uses UML 2.1, am I right?. I had a similar problem when I ran into a bug
> in OCL's plugin and couldn't update it to a newer version which had fixed
> it.
>
> An alternative?, using Eclipse with UML 2.0.X instead?.
> Regards,
> Juan Pedro
>
>
> Paul Elder escribi
Re: [JET2] Custom XPath to access stereotypes. [message #33679 is a reply to message #33616] Wed, 12 September 2007 09:47 Go to previous message
Juan Pedro Silva is currently offline Juan Pedro SilvaFriend
Messages: 258
Registered: July 2009
Senior Member
Paul, good and bad news: after fixing minor details, your code works
fine on my uml2 model in the Eclipse environment set up with exactly the
same plugins that RSA uses.Thank you all very much for your help.

However, I keep getting the "java.lang.ClassCastException:
org.eclipse.emf.ecore.impl.DynamicEObjectImpl cannot be cast to
org.eclipse.uml2.uml.Element" error message.
I will try to find out on which elements in particular (it seems to me
the problem is not among all elements).

Regards,
Juan Pedro

Paul Elder escribió:
> Juan Pedro:
>
> Based on your results in message news:fbrn5a$msm$1@build.eclipse.org,
>
> I'd say that is the problem. If you want to stay compatible with RSA
> 7.0.0.x, then I think your Eclipse shell will have to use UML 2.0.X. I'll go
> ask the UML development lead (who are just a leisurely stroll across my
> building) - I'll post another reply if I get anything useful.
>
> Paul
>
> "Juan Pedro Silva" <jpsilvagallino@gmail.com> wrote in message
> news:fbru43$rqu$1@build.eclipse.org...
>> Paul, I tried your code with my model and the result was empty:
>>
>> templates/main.jet(57,1): <ws:file template="templates/dump.jet"
>> path="{$org.eclipse.jet.resource.project.name}/dump.xml">
>> Writing file: /juan.pedro/dump.xml
>> Successful Execution
>>
>> So it most probably the problem that you figured out, something related
>> with migration from UML 2.0.X to UML 2.1.X
>>
>> So is an RSA problem, let's say, because I cannot update it so that it
>> uses UML 2.1, am I right?. I had a similar problem when I ran into a bug
>> in OCL's plugin and couldn't update it to a newer version which had fixed
>> it.
>>
>> An alternative?, using Eclipse with UML 2.0.X instead?.
>> Regards,
>> Juan Pedro
>>
>>
>> Paul Elder escribió:
>>> Hmmm.
>>>
>>> I'm suspecting it has something to do with move from UML2 2.0.x to 2.1.x.
>>>
>>> I have done some tests (in RSA 7.0.0.x), and a JET transform gets actual
>>> UML2 implementations. I have tried with:
>>>
>>> .emx files
>>> .uml files (created by using the Export > UML Model wizard)
>>> .xmi files (created by using the Export > UML XMI Interchange Model
>>> wizard)
>>>
>>> I'll have to move on over to a Eclipse 3.3/UML 2.1 based install to test
>>> under that, but at this point, it appears that this is UML2 behavior not
>>> JETs.
>>>
>>> I'm attaching my test projects as a ZIP, there are two projects:
>>> * juan.pedro.jet contains a simple JET transformation that dumps
>>> information about the loaded model to the JET execution console.
>>> * juan.pedro contains a the EMX, UML and XMI files, plus JET launch
>>> configurations to run juan.pedro.jet on them.
>>>
>>> Paul
>>>
>>> "Juan Pedro Silva" <jpsilvagallino@gmail.com> wrote in message
>>> news:fbr342$959$1@build.eclipse.org...
>>>> Hi Paul.
>>>> Let me see, the model I'm using as input was developed in RSA 7.0.0.3,
>>>> which has UML2 plugin version 2.0.3v200702141227
>>>> I'm using Eclipse with UML2 plugin 2.1.0v200706251652
>>>>
>>>> The input model was transformed into a UML2 (from .emx) model in RSA
>>>> before importing it into eclipse. It also uses a profile that has not
>>>> been imported yet into eclipse.
>>>>
>>>> I will load the model in java and get back to you with the results.
>>>> Thank you,
>>>> Juan Pedro
>>>>
>>>>
>>>> Paul Elder escribió:
>>>>> Juan Pedro:
>>>>>
>>>>> Can you tell me what version of UML2 features/plug-ins you are using.
>>>>> Also,
>>>>> what tool are you using to generate your UML models?
>>>>>
>>>>> We'll get to the bottom of this yet! That a you are finding a
>>>>> DynamicEObject
>>>>> is an indication (I think) that EMF did not find an implementation of
>>>>> the
>>>>> UML2 EPackage. One thing to try is loading the UML model using the Java
>>>>> API's yourself, and seeing whether you get DynamicEObjects or not. If
>>>>> you
>>>>> do, then this is not a JET problem (and we can ask a question on the
>>>>> UML
>>>>> news group).
>>>>>
>>>>> Paul
>>>>>
>>>>> "Juan Pedro Silva" <jpsilvagallino@gmail.com> wrote in message
>>>>> news:fb3sjv$7fv$2@build.eclipse.org...
>>>>>> Paul, I'm attaching my plugin.xml.
>>>>>> In it you can see that the model loader is in fact org.eclipse.jet.emf
>>>>>> What else could it be?
>>>>>> I'm attaching the java code of the hasSterotype() function class, as
>>>>>> well as its plugin xml. I'm also attaching the model which I use to
>>>>>> try
>>>>>> it, just in case.
>>>>>> I'm trying it out with this simple JET code:
>>>>>>
>>>>>> <c:iterate select="/contents" var="container">
>>>>>>
>>>>>> ServiceProviders:
>>>>>>
>>>>>> <c:iterate select="$container" var="elem">
>>>>>> Element <c:get select="name($elem)" />
>>>>>> <c:choose> <c:when test="hasStereotype($elem,
>>>>>> 'Perfil_SOA::serviceProvider')">
>>>>>> <c:get select="name($reference)"/> es ServiceProvider.
>>>>>> </c:when> </c:choose>
>>>>>> </c:iterate>
>>>>>>
>>>>>> </c:iterate>
>>>>>>
>>>>>> I realize I may have other errors (for instance, I'm not completely
>>>>>> sure
>>>>>> that the workspace found the particular profile that was applied), but
>>>>>> I'm tackling them one at a time.
>>>>>> Thank you.
>>>>>>
>
Previous Topic:How to abort a transformation from a custom tag?
Next Topic:Merging of import statements not working?
Goto Forum:
  


Current Time: Fri Apr 19 18:08:38 GMT 2024

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

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

Back to the top