Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Which query language is it and how to change it?
Which query language is it and how to change it? [message #431856] Tue, 28 July 2009 10:25 Go to next message
Eclipse UserFriend
Originally posted by: formatzeh.gmx.de

I'm curious about the query language which is used in the xml of
metamodel instances created with an emf generated editor. For example,
look at the following line:

<column locate="//@model.0/@component.5" unit="percent" width="33"/>

The attribute "locate" references another element in the model/xml. You
can read from the reference that my model contains several elements
called "model" and it is located in the first one (index 0). There it is
the sixth component (index 5). The syntax reminds a little bit on xpath
but it isn't. So I'm interested in the query language. That was the
first issue. The second one is that those references, as they are used
now, are not very readable for human. That's why I'm interested in
changing it anyhow. For example the first model has the type
"ccm:ConceptualModel" and the sixth component has the type "ccm:Service"
and name="BuildingMap" - it would be nice that those more expressive
data of the elements could be used as references. I imagine that I have
to identify some kind of primary key? And if yes, is it possible to
specify those keys hierarchically? I mean it would be nice if two
elements contained in different branches in the model can have the same
key as the can be identified unique by the parent id. Is this issue
possible at all?

best regards,
Gilbert
Re: Which query language is it and how to change it? [message #431858 is a reply to message #431856] Tue, 28 July 2009 10:38 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6457
Registered: July 2009
Senior Member
Gilbert,

Isn't that XPath?

Cheers
/Eike

----
http://thegordian.blogspot.com
http://twitter.com/eikestepper



Gilbert Mirenque schrieb:
> I'm curious about the query language which is used in the xml of
> metamodel instances created with an emf generated editor. For example,
> look at the following line:
>
> <column locate="//@model.0/@component.5" unit="percent" width="33"/>
>
> The attribute "locate" references another element in the model/xml. You
> can read from the reference that my model contains several elements
> called "model" and it is located in the first one (index 0). There it is
> the sixth component (index 5). The syntax reminds a little bit on xpath
> but it isn't. So I'm interested in the query language. That was the
> first issue. The second one is that those references, as they are used
> now, are not very readable for human. That's why I'm interested in
> changing it anyhow. For example the first model has the type
> "ccm:ConceptualModel" and the sixth component has the type "ccm:Service"
> and name="BuildingMap" - it would be nice that those more expressive
> data of the elements could be used as references. I imagine that I have
> to identify some kind of primary key? And if yes, is it possible to
> specify those keys hierarchically? I mean it would be nice if two
> elements contained in different branches in the model can have the same
> key as the can be identified unique by the parent id. Is this issue
> possible at all?
>
> best regards,
> Gilbert
>


Re: Which query language is it and how to change it? [message #431863 is a reply to message #431858] Tue, 28 July 2009 12:38 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: formatzeh.gmx.de

Hi Eike,

Eike Stepper wrote:
> Gilbert,
>
> Isn't that XPath?
not really. In XPath the example reference would look like this:

/model[0]/component[5]
Re: Which query language is it and how to change it? [message #431864 is a reply to message #431856] Tue, 28 July 2009 12:45 Go to previous messageGo to next message
Derek Palma is currently offline Derek PalmaFriend
Messages: 141
Registered: July 2009
Senior Member
Hi,

If you like XPath you can try: http://www.eclipticalsoftware.com/emf/xpath/.
It seems to work well. EMF modes are accessible with XPath queries.

Derek

"Gilbert Mirenque" <formatzeh@gmx.de> wrote in message
news:h4mjm2$k1m$1@build.eclipse.org...
> I'm curious about the query language which is used in the xml of
> metamodel instances created with an emf generated editor. For example,
> look at the following line:
>
> <column locate="//@model.0/@component.5" unit="percent" width="33"/>
>
> The attribute "locate" references another element in the model/xml. You
> can read from the reference that my model contains several elements
> called "model" and it is located in the first one (index 0). There it is
> the sixth component (index 5). The syntax reminds a little bit on xpath
> but it isn't. So I'm interested in the query language. That was the
> first issue. The second one is that those references, as they are used
> now, are not very readable for human. That's why I'm interested in
> changing it anyhow. For example the first model has the type
> "ccm:ConceptualModel" and the sixth component has the type "ccm:Service"
> and name="BuildingMap" - it would be nice that those more expressive
> data of the elements could be used as references. I imagine that I have
> to identify some kind of primary key? And if yes, is it possible to
> specify those keys hierarchically? I mean it would be nice if two
> elements contained in different branches in the model can have the same
> key as the can be identified unique by the parent id. Is this issue
> possible at all?
>
> best regards,
> Gilbert
Re: Which query language is it and how to change it? [message #431884 is a reply to message #431856] Tue, 28 July 2009 16:06 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30692
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------040203070905080700030008
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Gilbert,

Comments below.

Gilbert Mirenque wrote:
> I'm curious about the query language which is used in the xml of
> metamodel instances created with an emf generated editor. For example,
> look at the following line:
>
> <column locate="//@model.0/@component.5" unit="percent" width="33"/>
>
It's not a query language. It's just an EMF path with segments
documented like this in InternalEObject.


String
< eclipse-javadoc:%E2%98%82=org.eclipse.emf.ecore/src%3Corg.ec lipse.emf.ecore%7BInternalEObject.java%E2%98%83InternalEObje ct%7EeURIFragmentSegment%7EQEStructuralFeature;%7EQEObject;% E2%98%82String >
org.eclipse.emf.ecore.InternalEObject
< eclipse-javadoc:%E2%98%82=org.eclipse.emf.ecore/src%3Corg.ec lipse.emf.ecore%7BInternalEObject.java%E2%98%83InternalEObje ct >.eURIFragmentSegment(EStructuralFeature
< eclipse-javadoc:%E2%98%82=org.eclipse.emf.ecore/src%3Corg.ec lipse.emf.ecore%7BInternalEObject.java%E2%98%83InternalEObje ct%7EeURIFragmentSegment%7EQEStructuralFeature;%7EQEObject;% E2%98%82EStructuralFeature >
eFeature, EObject
< eclipse-javadoc:%E2%98%82=org.eclipse.emf.ecore/src%3Corg.ec lipse.emf.ecore%7BInternalEObject.java%E2%98%83InternalEObje ct%7EeURIFragmentSegment%7EQEStructuralFeature;%7EQEObject;% E2%98%82EObject >
eObject)

Returns the fragment segment that, when passed to
|eObjectForURIFragmentSegment
< eclipse-javadoc:%E2%98%82=org.eclipse.emf.ecore/src%3Corg.ec lipse.emf.ecore%7BInternalEObject.java%E2%98%83InternalEObje ct%7EeURIFragmentSegment%7EQEStructuralFeature;%7EQEObject;% E2%98%82%E2%98%82eObjectForURIFragmentSegment >|,
will resolve to the given object in this object's given feature.

The feature argument may be |null| in which case it will be deduced, if
possible. The default result will be of the form:

"@<feature-name>[.<index>]"


> The attribute "locate" references another element in the model/xml. You
> can read from the reference that my model contains several elements
> called "model" and it is located in the first one (index 0). There it is
> the sixth component (index 5). The syntax reminds a little bit on xpath
> but it isn't. So I'm interested in the query language. That was the
> first issue. The second one is that those references, as they are used
> now, are not very readable for human. That's why I'm interested in
> changing it anyhow.
You can specialize eObjectForURIFragmentSegment and eURIFragmentSegment
in your AbcImpl. EModelElementImpl shows a good example. You might
also want to take advantage of EReference.eKeys so you get thing like
@model[name='value] instead of an index.
> For example the first model has the type
> "ccm:ConceptualModel" and the sixth component has the type "ccm:Service"
> and name="BuildingMap" - it would be nice that those more expressive
> data of the elements could be used as references. I imagine that I have
> to identify some kind of primary key?
Yes, you can do that by identifying an attribute on the referenced type
as being unique within that containment EReference.
> And if yes, is it possible to
> specify those keys hierarchically? I mean it would be nice if two
> elements contained in different branches in the model can have the same
> key as the can be identified unique by the parent id. Is this issue
> possible at all?
>
Keys must be unique only within one given reference, unlike IDs which
must be unique for the whole resource.
> best regards,
> Gilbert
>

--------------040203070905080700030008
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Gilbert,<br>
<br>
Comments below.<br>
<br>
Gilbert Mirenque wrote:
<blockquote cite="mid:h4mjm2$k1m$1@build.eclipse.org" type="cite">
<pre wrap="">I'm curious about the query language which is used in the xml of
metamodel instances created with an emf generated editor. For example,
look at the following line:

&lt;column locate=<a class="moz-txt-link-rfc2396E" href="mailto://@model.0/@component.5">"//@model.0/@component.5"</a> unit="percent" width="33"/&gt;
</pre>
</blockquote>
It's not a query language.  It's just an EMF path with segments
documented like this in InternalEObject.<br>
<br>
<h5>
<div style="margin-top: 0px; margin-left: 22px;"><a class="header"
href=" eclipse-javadoc:%E2%98%82=org.eclipse.emf.ecore/src%3Corg.ec lipse.emf.ecore%7BInternalEObject.java%E2%98%83InternalEObje ct%7EeURIFragmentSegment%7EQEStructuralFeature;%7EQEObject;% E2%98%82String ">String</a>
org.eclipse.emf.ecore.<a class="header"
href=" eclipse-javadoc:%E2%98%82=org.eclipse.emf.ecore/src%3Corg.ec lipse.emf.ecore%7BInternalEObject.java%E2%98%83InternalEObje ct ">InternalEObject</a>.eURIFragmentSegment(<a
class="header"
href=" eclipse-javadoc:%E2%98%82=org.eclipse.emf.ecore/src%3Corg.ec lipse.emf.ecore%7BInternalEObject.java%E2%98%83InternalEObje ct%7EeURIFragmentSegment%7EQEStructuralFeature;%7EQEObject;% E2%98%82EStructuralFeature ">EStructuralFeature</a>
eFeature, <a class="header"
href=" eclipse-javadoc:%E2%98%82=org.eclipse.emf.ecore/src%3Corg.ec lipse.emf.ecore%7BInternalEObject.java%E2%98%83InternalEObje ct%7EeURIFragmentSegment%7EQEStructuralFeature;%7EQEObject;% E2%98%82EObject ">EObject</a>
eObject)</div>
</h5>
<p>Returns the fragment segment that, when passed to <code><a
href=" eclipse-javadoc:%E2%98%82=org.eclipse.emf.ecore/src%3Corg.ec lipse.emf.ecore%7BInternalEObject.java%E2%98%83InternalEObje ct%7EeURIFragmentSegment%7EQEStructuralFeature;%7EQEObject;% E2%98%82%E2%98%82eObjectForURIFragmentSegment ">eObjectForURIFragmentSegment</a></code>,
will resolve to the given object in this object's given feature. </p>
<p>The feature argument may be <code>null</code> in which case it will
be deduced, if possible. The default result will be of the form: </p>
<pre> "@&lt;feature-name&gt;[.&lt;index&gt;]"
</pre>
<br>
<blockquote cite="mid:h4mjm2$k1m$1@build.eclipse.org" type="cite">
<pre wrap="">
The attribute "locate" references another element in the model/xml. You
can read from the reference that my model contains several elements
called "model" and it is located in the first one (index 0). There it is
the sixth component (index 5). The syntax reminds a little bit on xpath
but it isn't. So I'm interested in the query language. That was the
first issue. The second one is that those references, as they are used
now, are not very readable for human. That's why I'm interested in
changing it anyhow.</pre>
</blockquote>
You can specialize eObjectForURIFragmentSegment and eURIFragmentSegment
in your AbcImpl.  EModelElementImpl shows a good example.  You might
also want to take advantage of EReference.eKeys so you get thing like
@model[name='value] instead of an index.<br>
<blockquote cite="mid:h4mjm2$k1m$1@build.eclipse.org" type="cite">
<pre wrap=""> For example the first model has the type
"ccm:ConceptualModel" and the sixth component has the type "ccm:Service"
and name="BuildingMap" - it would be nice that those more expressive
data of the elements could be used as references. I imagine that I have
to identify some kind of primary key? </pre>
</blockquote>
Yes, you can do that by identifying an attribute on the referenced type
as being unique within that containment EReference.<br>
<blockquote cite="mid:h4mjm2$k1m$1@build.eclipse.org" type="cite">
<pre wrap="">And if yes, is it possible to
specify those keys hierarchically? I mean it would be nice if two
elements contained in different branches in the model can have the same
key as the can be identified unique by the parent id. Is this issue
possible at all?
</pre>
</blockquote>
Keys must be unique only within one given reference, unlike IDs which
must be unique for the whole resource.<br>
<blockquote cite="mid:h4mjm2$k1m$1@build.eclipse.org" type="cite">
<pre wrap="">
best regards,
Gilbert
</pre>
</blockquote>
</body>
</html>

--------------040203070905080700030008--
Re: Which query language is it and how to change it? [message #431890 is a reply to message #431884] Tue, 28 July 2009 17:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: formatzeh.gmx.de

Nice, that sounds promising,

Ed Merks wrote:
> You can specialize eObjectForURIFragmentSegment and eURIFragmentSegment
> in your AbcImpl. EModelElementImpl shows a good example.
where do I get this class? From the svn repository?


> Yes, you can do that by identifying an attribute on the referenced type
> as being unique within that containment EReference.

> Keys must be unique only within one given reference, unlike IDs which
> must be unique for the whole resource.
You mean the property "Unique" on the elements? This is true by default.
Re: Which query language is it and how to change it? [message #431899 is a reply to message #431890] Tue, 28 July 2009 23:08 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30692
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------060206020101010806010101
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Gilbert,

Comments below.

Gilbert Mirenque wrote:
> Nice, that sounds promising,
>
> Ed Merks wrote:
>
>> You can specialize eObjectForURIFragmentSegment and eURIFragmentSegment
>> in your AbcImpl. EModelElementImpl shows a good example.
>>
> where do I get this class? From the svn repository?
>
If you have the EMF SDK installed you can get at it that way. Ctrl-Shift-T.
>
>
>> Yes, you can do that by identifying an attribute on the referenced type
>> as being unique within that containment EReference.
>>
>
>
>> Keys must be unique only within one given reference, unlike IDs which
>> must be unique for the whole resource.
>>
> You mean the property "Unique" on the elements? This is true by default.
>
No, I mean that within the objects being referenced by that one
reference, only one object has that key value. E.g., in an EPackage,
the name of the eClassifiers must be unique, but different packages can
have classifiers with the same name.

--------------060206020101010806010101
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Gilbert,<br>
<br>
Comments below.<br>
<br>
Gilbert Mirenque wrote:
<blockquote cite="mid:h4nbda$o0n$1@build.eclipse.org" type="cite">
<pre wrap="">Nice, that sounds promising,

Ed Merks wrote:
</pre>
<blockquote type="cite">
<pre wrap="">You can specialize eObjectForURIFragmentSegment and eURIFragmentSegment
in your AbcImpl. EModelElementImpl shows a good example.
</pre>
</blockquote>
<pre wrap=""><!---->where do I get this class? From the svn repository?
</pre>
</blockquote>
If you have the EMF SDK installed you can get at it that way. 
Ctrl-Shift-T.<br>
<blockquote cite="mid:h4nbda$o0n$1@build.eclipse.org" type="cite">
<pre wrap="">

</pre>
<blockquote type="cite">
<pre wrap="">Yes, you can do that by identifying an attribute on the referenced type
as being unique within that containment EReference.
</pre>
</blockquote>
<pre wrap=""><!---->
</pre>
<blockquote type="cite">
<pre wrap="">Keys must be unique only within one given reference, unlike IDs which
must be unique for the whole resource.
</pre>
</blockquote>
<pre wrap=""><!---->You mean the property "Unique" on the elements? This is true by default.
</pre>
</blockquote>
No, I mean that within the objects being referenced by that one
reference, only one object has that key value.  E.g., in an EPackage,
the name of the eClassifiers must be unique, but different packages can
have classifiers with the same name.<br>
</body>
</html>

--------------060206020101010806010101--
Re: Which query language is it and how to change it? [message #431906 is a reply to message #431899] Wed, 29 July 2009 08:14 Go to previous message
Eclipse UserFriend
Originally posted by: formatzeh.gmx.de

Ed Merks wrote:
> If you have the EMF SDK installed you can get at it that way.
> Ctrl-Shift-T.
Thanks

> No, I mean that within the objects being referenced by that one
> reference, only one object has that key value. E.g., in an EPackage,
> the name of the eClassifiers must be unique, but different packages can
> have classifiers with the same name.
>
I got it :) looks nicer now. The aforementioned example now looks so:

<column locate="//@model.0/@component[name='TestService']"/>

Thank you a lot Ed.

best regards,
Gilbert
Previous Topic:Controlling eSuperTypes URI in XMI Serialization
Next Topic:Document metaclasses?
Goto Forum:
  


Current Time: Fri Dec 13 12:44:01 GMT 2019

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

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

Back to the top