Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Obtaing Value
Obtaing Value [message #112225] Mon, 11 February 2008 17:50 Go to next message
Raphael is currently offline RaphaelFriend
Messages: 47
Registered: July 2009
Member
Hello my friends,

I have the following XMI code:

<?xml version="1.0" encoding="UTF-8"?>
<Package xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
xmi:id="_L37e0NiWEdyDI-twlSn5BQ" >
<ownedMember xmi:type="uml20:Classe" xmi:id="_NsTmgNiWEdyDI-twlSn5BQ"
name="People" package="_L37e0NiWEdyDI-twlSn5BQ">
</ownedMember>
</Package>

When I use the command <c:get select="Package/ownedMember/@name" /> I got
the result: People

But, IŽm trying to obtain the xmi:id from ownedMember. IŽm using the
following command <c:get select="Package/ownedMember/@xmi:id" /> , but
this return no value.

Has anyone here know what command should I use?!?

Thanks,
Raphael
Re: Obtaing Value [message #112878 is a reply to message #112225] Thu, 21 February 2008 12:55 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Raphael,

Is this a question about JET? It's best to ask on the M2T newsgroup
about it. I've added it to the "to" list of this reply so Paul should
see it.


Raphael wrote:
> Hello my friends,
>
> I have the following XMI code:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <Package xmi:version="2.1"
> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
> xmi:id="_L37e0NiWEdyDI-twlSn5BQ" >
> <ownedMember xmi:type="uml20:Classe" xmi:id="_NsTmgNiWEdyDI-twlSn5BQ"
> name="People" package="_L37e0NiWEdyDI-twlSn5BQ">
> </ownedMember>
> </Package>
>
> When I use the command <c:get select="Package/ownedMember/@name" /> I
> got the result: People
>
> But, IŽm trying to obtain the xmi:id from ownedMember. IŽm using the
> following command <c:get select="Package/ownedMember/@xmi:id" /> , but
> this return no value.
>
> Has anyone here know what command should I use?!?
>
> Thanks,
> Raphael
>
Re: Obtaing Value [message #112990 is a reply to message #112878] Fri, 22 February 2008 14:03 Go to previous message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Raphael:

You'll have to implement a custom XPath function to get the XMI ID - the
XPath engine doesn't know how to extract this directly, and the ID is not
reflected in the EMF-metadata.

The function is pretty simple. Here's its implementation:

/*********************************************************** ********************
* Copyright (c) 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM - Initial API and implementation
* /
************************************************************ *******************/package org.eclipse.jet.examples.functions;import java.util.List;import org.eclipse.emf.ecore.EObject;import org.eclipse.emf.ecore.resource.Resource;import org.eclipse.emf.ecore.util.EcoreUtil;import org.eclipse.jet.xpath.NodeSet;import org.eclipse.jet.xpath.XPathFunction;/** * XPath function implementation that returns the EObject ID of an EObject.For * non-eObjects, it returns the empty string * */public class EObjectIDFunction implements XPathFunction { /* (non-Javadoc) * @see org.eclipse.jet.xpath.XPathFunction#evaluate(java.util.List) */ public Object evaluate(List args) { Object object = null; final Object objectArg = args.get(0); if(objectArg instanceof NodeSet) { NodeSet nodeSet = (NodeSet) objectArg; object = nodeSet.size() > 0 ? nodeSet.iterator().next() : null; } else { object = objectArg; } if(object instanceof EObject) { final EObject eObject = (EObject) object; final Resource resource = eObject.eResource(); return resource != null ? resource.getURIFragment(eObject) :EcoreUtil.getID(eObject); } else { return ""; } }}"Ed Merks" <merks@ca.ibm.com> wrote in messagenews:fpjsd6$crl$1@build.eclipse.org...> Raphael,>> Is this a question about JET? It's best to ask on the M2T newsgroup aboutit. I've added it to the "to" list of this reply so Paul should see it.>>> Raphael wrote:>> Hello my friends,>>>> I have the following XMI code:>>>> <?xml version="1.0" encoding="UTF-8"?>>> <Package xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"xmi:id="_L37e0NiWEdyDI-twlSn5BQ" >>> <ownedMember xmi:type="uml20:Classe" xmi:id="_NsTmgNiWEdyDI-twlSn5BQ"name="People" package="_L37e0NiWEdyDI-twlSn5BQ">>> </ownedMember>>> </Package>>>>> When I use the command <c:get select="Package/ownedMember/@name" /> I gotthe result: People>>>> But, I
Re: Obtaing Value [message #615533 is a reply to message #112225] Thu, 21 February 2008 12:55 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Raphael,

Is this a question about JET? It's best to ask on the M2T newsgroup
about it. I've added it to the "to" list of this reply so Paul should
see it.


Raphael wrote:
> Hello my friends,
>
> I have the following XMI code:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <Package xmi:version="2.1"
> xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"
> xmi:id="_L37e0NiWEdyDI-twlSn5BQ" >
> <ownedMember xmi:type="uml20:Classe" xmi:id="_NsTmgNiWEdyDI-twlSn5BQ"
> name="People" package="_L37e0NiWEdyDI-twlSn5BQ">
> </ownedMember>
> </Package>
>
> When I use the command <c:get select="Package/ownedMember/@name" /> I
> got the result: People
>
> But, IŽm trying to obtain the xmi:id from ownedMember. IŽm using the
> following command <c:get select="Package/ownedMember/@xmi:id" /> , but
> this return no value.
>
> Has anyone here know what command should I use?!?
>
> Thanks,
> Raphael
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Obtaing Value [message #615542 is a reply to message #112878] Fri, 22 February 2008 14:03 Go to previous message
Paul Elder is currently offline Paul ElderFriend
Messages: 849
Registered: July 2009
Senior Member
Raphael:

You'll have to implement a custom XPath function to get the XMI ID - the
XPath engine doesn't know how to extract this directly, and the ID is not
reflected in the EMF-metadata.

The function is pretty simple. Here's its implementation:

/*********************************************************** ********************
* Copyright (c) 2008 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM - Initial API and implementation
* /
************************************************************ *******************/package org.eclipse.jet.examples.functions;import java.util.List;import org.eclipse.emf.ecore.EObject;import org.eclipse.emf.ecore.resource.Resource;import org.eclipse.emf.ecore.util.EcoreUtil;import org.eclipse.jet.xpath.NodeSet;import org.eclipse.jet.xpath.XPathFunction;/** * XPath function implementation that returns the EObject ID of an EObject.For * non-eObjects, it returns the empty string * */public class EObjectIDFunction implements XPathFunction { /* (non-Javadoc) * @see org.eclipse.jet.xpath.XPathFunction#evaluate(java.util.List) */ public Object evaluate(List args) { Object object = null; final Object objectArg = args.get(0); if(objectArg instanceof NodeSet) { NodeSet nodeSet = (NodeSet) objectArg; object = nodeSet.size() > 0 ? nodeSet.iterator().next() : null; } else { object = objectArg; } if(object instanceof EObject) { final EObject eObject = (EObject) object; final Resource resource = eObject.eResource(); return resource != null ? resource.getURIFragment(eObject) :EcoreUtil.getID(eObject); } else { return ""; } }}"Ed Merks" <merks@ca.ibm.com> wrote in messagenews:fpjsd6$crl$1@build.eclipse.org...> Raphael,>> Is this a question about JET? It's best to ask on the M2T newsgroup aboutit. I've added it to the "to" list of this reply so Paul should see it.>>> Raphael wrote:>> Hello my friends,>>>> I have the following XMI code:>>>> <?xml version="1.0" encoding="UTF-8"?>>> <Package xmi:version="2.1" xmlns:xmi="http://schema.omg.org/spec/XMI/2.1"xmi:id="_L37e0NiWEdyDI-twlSn5BQ" >>> <ownedMember xmi:type="uml20:Classe" xmi:id="_NsTmgNiWEdyDI-twlSn5BQ"name="People" package="_L37e0NiWEdyDI-twlSn5BQ">>> </ownedMember>>> </Package>>>>> When I use the command <c:get select="Package/ownedMember/@name" /> I gotthe result: People>>>> But, I
Previous Topic:OCL for Hibernate
Next Topic:OCL for Hibernate
Goto Forum:
  


Current Time: Thu Mar 28 13:41:28 GMT 2024

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

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

Back to the top