[ATL] Problem with an atl rule [message #55751] |
Thu, 02 August 2007 10:46 |
Eclipse User |
|
|
|
Originally posted by: NewsgroupSPAM.iKupp.de
Hi,
ive got another problem ;-(
ive got a xml file like
<children xsi:type="Element" name="Document" value="">
<children xsi:type="Element" name="Entity" value="">
<children xsi:type="Element" name="id" value="123"/>
<children xsi:type="Element" name="name" value="my name"/>
<children xsi:type="Element" name="is_a" value="345"/>
</children>
<children xsi:type="Element" name="Entity" value="">
<children xsi:type="Element" name="id" value="345"/>
<children xsi:type="Element" name="name" value="my other name"/>
<children xsi:type="Element" name="is_a" value="789"/>
</children>
....
</children>
and a target file like
<relation from_id="123" to_id="345" from_name="my name" to_name="my
other name">
....
but how do i get the to_name value from the other element?
i ve got a rule like:
rule entity{
from i : XML!Element (
i.name='Entity'
)outr0 : relation!relation(
from_id <-i.getvalue('id'),
to_id <-i.getvalue('is_a'),
from_name <-i.getvalue('name'),
to_name <-?????????????
),
with the helper
helper context XML!Element def : getvalue(finder : String) : String =
if self.children->select(c | c.oclIsKindOf(XML!Element) and
c.name=finder)->size()=0 then '' else self.children->select(c |
c.oclIsKindOf(XML!Element) and c.name=finder)->first().value endif;
Many thanks
Ina
|
|
|
Re: [ATL] Problem with an atl rule [message #55778 is a reply to message #55751] |
Thu, 02 August 2007 11:24 |
Eclipse User |
|
|
|
Originally posted by: Hugo.Bruneliere.univ-nantes.fr
Ina Kupp a écrit :
> Hi,
Hi Ina,
> ive got another problem ;-(
> ive got a xml file like
> <children xsi:type="Element" name="Document" value="">
> <children xsi:type="Element" name="Entity" value="">
> <children xsi:type="Element" name="id" value="123"/>
> <children xsi:type="Element" name="name" value="my name"/>
> <children xsi:type="Element" name="is_a" value="345"/>
> </children>
>
> <children xsi:type="Element" name="Entity" value="">
> <children xsi:type="Element" name="id" value="345"/>
> <children xsi:type="Element" name="name" value="my other name"/>
> <children xsi:type="Element" name="is_a" value="789"/>
> </children>
> ...
> </children>
> and a target file like
> <relation from_id="123" to_id="345" from_name="my name" to_name="my
> other name">
> ...
>
> but how do i get the to_name value from the other element?
> i ve got a rule like:
> rule entity{
> from i : XML!Element (
> i.name='Entity'
> )outr0 : relation!relation(
> from_id <-i.getvalue('id'),
> to_id <-i.getvalue('is_a'),
> from_name <-i.getvalue('name'),
> to_name <-?????????????
> ),
>
> with the helper
> helper context XML!Element def : getvalue(finder : String) : String =
> if self.children->select(c | c.oclIsKindOf(XML!Element) and
> c.name=finder)->size()=0 then '' else self.children->select(c |
> c.oclIsKindOf(XML!Element) and c.name=finder)->first().value endif;
You can define this helper:
helper def: getEntityNameFromId(entityId : String) : String =
XML!Element.allInstances()->select(e | e.name = 'Entity' and
e.children->select(c | c.name='id' and c.value= entityId)->notEmpty())
->first().children->select(c | c.name='name')->first().value;
And call it like this:
to_name <- getEntityNameFromId(i.getvalue('is_a'))
> Many thanks
> Ina
Best regards,
Hugo
--
--------------------------------------------------------
Hugo Bruneliere - R&D Engineer
ATLAS Group (INRIA & LINA) - University of Nantes
2, rue de la Houssiniere
44322 Nantes Cedex 3 - France
office +33 2 51 12 58 10 /\ cell.+33 6 07 42 45 30
EMail: Hugo.Bruneliere@univ-nantes.fr
http://www.sciences.univ-nantes.fr/lina/atl/
--------------------------------------------------------
|
|
|
Re: [ATL] Problem with an atl rule [message #55805 is a reply to message #55778] |
Thu, 02 August 2007 11:25 |
Eclipse User |
|
|
|
Originally posted by: Hugo.Bruneliere.univ-nantes.fr
Hugo Bruneliere a écrit :
> Ina Kupp a écrit :
>> Hi,
>
> Hi Ina,
>
>> ive got another problem ;-(
>> ive got a xml file like
>> <children xsi:type="Element" name="Document" value="">
>> <children xsi:type="Element" name="Entity" value="">
>> <children xsi:type="Element" name="id" value="123"/>
>> <children xsi:type="Element" name="name" value="my name"/>
>> <children xsi:type="Element" name="is_a" value="345"/>
>> </children>
>>
>> <children xsi:type="Element" name="Entity" value="">
>> <children xsi:type="Element" name="id" value="345"/>
>> <children xsi:type="Element" name="name" value="my other name"/>
>> <children xsi:type="Element" name="is_a" value="789"/>
>> </children>
>> ...
>> </children>
>> and a target file like
>> <relation from_id="123" to_id="345" from_name="my name" to_name="my
>> other name">
>> ...
>>
>> but how do i get the to_name value from the other element?
>> i ve got a rule like:
>> rule entity{
>> from i : XML!Element (
>> i.name='Entity'
>> )outr0 : relation!relation(
>> from_id <-i.getvalue('id'),
>> to_id <-i.getvalue('is_a'),
>> from_name <-i.getvalue('name'),
>> to_name <-?????????????
>> ),
>>
>> with the helper
>> helper context XML!Element def : getvalue(finder : String) : String =
>> if self.children->select(c | c.oclIsKindOf(XML!Element) and
>> c.name=finder)->size()=0 then '' else self.children->select(c |
>> c.oclIsKindOf(XML!Element) and c.name=finder)->first().value endif;
>
> You can define this helper:
>
> helper def: getEntityNameFromId(entityId : String) : String =
> XML!Element.allInstances()->select(e | e.name = 'Entity'
> and e.children->select(c | c.name='id' and c.value=
> entityId)->notEmpty())
> ->first().children->select(c | c.name='name')->first().value;
>
> And call it like this:
>
> to_name <- getEntityNameFromId(i.getvalue('is_a'))
Sorry:
to_name <- thisModule.getEntityNameFromId(i.getvalue('is_a'))
:-)
>
>> Many thanks
>> Ina
>
> Best regards,
>
> Hugo
>
--
--------------------------------------------------------
Hugo Bruneliere - R&D Engineer
ATLAS Group (INRIA & LINA) - University of Nantes
2, rue de la Houssiniere
44322 Nantes Cedex 3 - France
office +33 2 51 12 58 10 /\ cell.+33 6 07 42 45 30
EMail: Hugo.Bruneliere@univ-nantes.fr
http://www.sciences.univ-nantes.fr/lina/atl/
--------------------------------------------------------
|
|
|
Re: [ATL] Problem with an atl rule [message #55963 is a reply to message #55805] |
Fri, 03 August 2007 13:03 |
Eclipse User |
|
|
|
Originally posted by: NewsgroupSPAM.iKupp.de
Hi,
Hugo Bruneliere schrieb:
> Hugo Bruneliere a écrit :
>> Ina Kupp a écrit :
>>> Hi,
>>
>> Hi Ina,
>>
>>> ive got another problem ;-(
>>> ive got a xml file like
>>> <children xsi:type="Element" name="Document" value="">
>>> <children xsi:type="Element" name="Entity" value="">
>>> <children xsi:type="Element" name="id" value="123"/>
>>> <children xsi:type="Element" name="name" value="my name"/>
>>> <children xsi:type="Element" name="is_a" value="345"/>
>>> </children>
>>>
>>> <children xsi:type="Element" name="Entity" value="">
>>> <children xsi:type="Element" name="id" value="345"/>
>>> <children xsi:type="Element" name="name" value="my other name"/>
>>> <children xsi:type="Element" name="is_a" value="789"/>
>>> </children>
>>> ...
>>> </children>
>>> and a target file like
>>> <relation from_id="123" to_id="345" from_name="my name" to_name="my
>>> other name">
>>> ...
>>>
>>> but how do i get the to_name value from the other element?
>>> i ve got a rule like:
>>> rule entity{
>>> from i : XML!Element (
>>> i.name='Entity'
>>> )outr0 : relation!relation(
>>> from_id <-i.getvalue('id'),
>>> to_id <-i.getvalue('is_a'),
>>> from_name <-i.getvalue('name'),
>>> to_name <-?????????????
>>> ),
>>>
>>> with the helper
>>> helper context XML!Element def : getvalue(finder : String) : String =
>>> if self.children->select(c | c.oclIsKindOf(XML!Element) and
>>> c.name=finder)->size()=0 then '' else self.children->select(c |
>>> c.oclIsKindOf(XML!Element) and c.name=finder)->first().value endif;
>>
>> You can define this helper:
>>
>> helper def: getEntityNameFromId(entityId : String) : String =
>> XML!Element.allInstances()->select(e | e.name = 'Entity'
>> and e.children->select(c | c.name='id' and c.value=
>> entityId)->notEmpty())
>> ->first().children->select(c | c.name='name')->first().value;
>>
>> And call it like this:
>>
>> to_name <- getEntityNameFromId(i.getvalue('is_a'))
>
> Sorry:
>
> to_name <- thisModule.getEntityNameFromId(i.getvalue('is_a'))
>
> :-)
with this helper i get an error if the id isnt found, so i added an if
clause to the helper:
now it works but it isnt very fast.
helper def: getEntityNameFromId(entityId : String) : String =
if XML!Element.allInstances()->select(e | e.name = 'Entity' and
e.children->select(c | c.name='id' and c.value=
entityId)->notEmpty())->notEmpty()
then XML!Element.allInstances()->select(e | e.name = 'Entity' and
e.children->select(c | c.name='id' and c.value= entityId)->notEmpty())
->first().children->select(c | c.name='name')->first().value
else ''endif;
many thanks for your contemporary help, this helper saved my day ;-)
Ina
|
|
|
Re: [ATL] Problem with an atl rule [message #56023 is a reply to message #55963] |
Fri, 03 August 2007 13:34 |
Eclipse User |
|
|
|
Originally posted by: quentin.glineur.obeo.fr
This is a multi-part message in MIME format.
--------------080609050208010708070904
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 8bit
Hi,
Concerning your helper performances, you should try to use a let
statement so that your time consuming request is evaluated only once.
Regards,
Quentin GLINEUR
Ina Kupp a
|
|
|
Re: [ATL] Problem with an atl rule (solved) [message #56347 is a reply to message #55963] |
Mon, 06 August 2007 08:56 |
Eclipse User |
|
|
|
Originally posted by: NewsgroupSPAM.iKupp.de
Ina Kupp schrieb:
> Hi,
> Hugo Bruneliere schrieb:
>> Hugo Bruneliere a écrit :
>>> Ina Kupp a écrit :
>>>> Hi,
>>>
>>> Hi Ina,
>>>
>>>> ive got another problem ;-(
>>>> ive got a xml file like
>>>> <children xsi:type="Element" name="Document" value="">
>>>> <children xsi:type="Element" name="Entity" value="">
>>>> <children xsi:type="Element" name="id" value="123"/>
>>>> <children xsi:type="Element" name="name" value="my name"/>
>>>> <children xsi:type="Element" name="is_a" value="345"/>
>>>> </children>
>>>>
>>>> <children xsi:type="Element" name="Entity" value="">
>>>> <children xsi:type="Element" name="id" value="345"/>
>>>> <children xsi:type="Element" name="name" value="my other name"/>
>>>> <children xsi:type="Element" name="is_a" value="789"/>
>>>> </children>
>>>> ...
>>>> </children>
>>>> and a target file like
>>>> <relation from_id="123" to_id="345" from_name="my name" to_name="my
>>>> other name">
>>>> ...
>>>>
>>>> but how do i get the to_name value from the other element?
>>>> i ve got a rule like:
>>>> rule entity{
>>>> from i : XML!Element (
>>>> i.name='Entity'
>>>> )outr0 : relation!relation(
>>>> from_id <-i.getvalue('id'),
>>>> to_id <-i.getvalue('is_a'),
>>>> from_name <-i.getvalue('name'),
>>>> to_name <-?????????????
>>>> ),
>>>>
>>>> with the helper
>>>> helper context XML!Element def : getvalue(finder : String) : String =
>>>> if self.children->select(c | c.oclIsKindOf(XML!Element) and
>>>> c.name=finder)->size()=0 then '' else self.children->select(c |
>>>> c.oclIsKindOf(XML!Element) and c.name=finder)->first().value endif;
>>>
>>> You can define this helper:
>>>
>>> helper def: getEntityNameFromId(entityId : String) : String =
>>> XML!Element.allInstances()->select(e | e.name = 'Entity'
>>> and e.children->select(c | c.name='id' and c.value=
>>> entityId)->notEmpty())
>>> ->first().children->select(c | c.name='name')->first().value;
>>>
>>> And call it like this:
>>>
>>> to_name <- getEntityNameFromId(i.getvalue('is_a'))
>>
>> Sorry:
>>
>> to_name <- thisModule.getEntityNameFromId(i.getvalue('is_a'))
>>
>> :-)
> with this helper i get an error if the id isnt found, so i added an if
> clause to the helper:
> now it works but it isnt very fast.
>
> helper def: getEntityNameFromId(entityId : String) : String =
> if XML!Element.allInstances()->select(e | e.name = 'Entity' and
> e.children->select(c | c.name='id' and c.value=
> entityId)->notEmpty())->notEmpty()
> then XML!Element.allInstances()->select(e | e.name = 'Entity' and
> e.children->select(c | c.name='id' and c.value= entityId)->notEmpty())
> ->first().children->select(c | c.name='name')->first().value
> else ''endif;
>
> many thanks for your contemporary help, this helper saved my day ;-)
> Ina
fyi:
i changed it to this:
helper def: getEntityNameFromId(entityId : String, outname : String,
inname : String) : String =
XML!Element.allInstances()->select(e | e.name = 'Entity' and
e.children->select(c | if c.oclIsUndefined() then false else
c.name=inname and c.value= entityId endif)->notEmpty())
->first().children->select(c | if c.oclIsUndefinded() then false
else c.name=outname endif )->first().value;
(the outname and inname are only for being more flexible)
this changed the speed from over 25h (i canceld it after 10h and after
that it needed another 15h to end the process (it seems like it did the
transformation till the end) to 2h. (the input file is only 276KB big)
;-)
many thanks for your help
Ina
|
|
|
Powered by
FUDForum. Page generated in 0.03752 seconds