Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [henshin-user] Node Attribute Self Reference

Hello Jürgen,

 

it is possible to achieve your aim. You are already on the right track.

 

Instead of “attribute = attribute + 5” you should use “attribute = x -> x + 5”.

Additionally the rule have to be extended by the variable x. You can easily achieve this in the graphical editor by editing the rule name: E.g. “ruleName(var x:EDouble)”.

By that your “NodeWithAttribute” is matched and the variable x is set to the attributes value of the matched node. As result of the rule application the new value of the attribute will be “x+1”.  The keyterm “->” disjoins the part for matching (here x), the LHS and the part for the state after the rule application (here x+1), the RHS.

 

You can find an example of that in the rule “transferMoney” in the bank example: https://www.eclipse.org/henshin/examples.php?example=bank

 

If my answer isn’t detailed enough please help me to improve it ;-)

 

Kind regards,

Kristopher

 

 

Von: henshin-user-bounces@xxxxxxxxxxx [mailto:henshin-user-bounces@xxxxxxxxxxx] Im Auftrag von Juergen Freund
Gesendet: Donnerstag, 12. Januar 2017 15:12
An: henshin-user@xxxxxxxxxxx
Betreff: [henshin-user] Node Attribute Self Reference

 

Hi all,

I wanted to ask if it is possible to reference an attribute to itself within a node.

e.g.:

    I have a rule where I search for a specific Node with an attribute and if this node is found I want to add 5 to that attribute
    and I do not matter which value it had before.

     ------------------------------------
    | <<preserve>>                |
    | :NodeWithAttribute          |
     ------------------------------------
    | attribute = attribute + 5 |
     ------------------------------------

Is this somehow possible for example with the _javascript_ Engine?


Regards,
Jürgen



-- 
Dipl.-Ing. Jürgen Freund
Arbeitsgruppe Ähnlichkeitsmechanik
 
Telefon: +49 (0)711 685 69530
E-Mail:  freund@xxxxxxxxxxxxxxxxxxxx
 
Postadresse:
Universität Stuttgart
Institut für Statik und Dynamik der Luft- und Raumfahrtkonstruktionen
Pfaffenwaldring 27 - Zimmer 01.002
70569 Stuttgart

Back to the top