Inconsistent formula

Inconsistent formula

Postby jokro » Sat Oct 05, 2013 12:30 pm

Handling formula in node-attribute is different from node.text. In the latter printing node.text displays the formula. In the former printing node-attribute displays formula result. Example:
suppose
1. node1 with
* node.text="test"
* node["attr"]= "myAttribute"
* id=ID_12345

2. node2 with
* node2.text='=ID_12345.text' --> value displaying is "test" This is ok
* node2["attr"]='=ID_12345["attr"]' --> value displaying is "myAttribute" This is ok

When printing following result:
* println node2.text --> =ID_12345.text
* println node2["attr"] --> myAttribute

Question 1: shouldn't both behave the same ?
Question 2: is there an easy way to get in both cases either either the formula or the formula result as an outcome and could this be set in the formula ?

Regards
Jodi
jokro
 
Posts: 486
Joined: Sun Jul 24, 2011 2:56 pm

Re: Inconsistent formula

Postby boercher » Sun Oct 13, 2013 12:33 am

Hi Jodi,

- to refer to the text of a node use its 'text' property: node.text
- to refer to the value (evaluation result) of a node use its 'value' property: node.value
- to refer to the text of an attribute use node.attributes.get(<attributename>)
- to refer to the value of an attribute use node[<attributename>]

That's not essentially inconsistent. One might argue that we should have a node.attributes.get[First]Value(<attributename>) method. You could already use node.attributes.getValues([Closure])

I regret that [<attributename>] in the meanwhile but I won't sacrify backward compatibility in favor of a more pleasent interface. So unless you have a really good solution I'm afraid that we have to live with the current API in this respect.

Best regards, Volker
boercher
 
Posts: 644
Joined: Tue Jul 26, 2011 7:13 am

Re: Inconsistent formula

Postby jokro » Mon Oct 14, 2013 6:31 am

Hi Volker,
I agree that backward comatibility is important. A developer-friendly work around might be to define a generic method which in both cases will present the user value.
E.g. node2.text.value ==" test" ( in stead of ID or formula)
node2.["attr"].value ==" myAttribute" (unchanged)

Regards
Jodi
jokro
 
Posts: 486
Joined: Sun Jul 24, 2011 2:56 pm


Return to Developers

Who is online

Users browsing this forum: No registered users and 1 guest