Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditionals on Attributes

Status
Not open for further replies.

Azhrarn

Programmer
Oct 28, 2003
2
US
Please help, I know that this isn't challenging or interesting like other posts, but I ve been stuck on it for days!!!

I ve been trying this in several ways but to no avail.
I have the following:

[...]
<finance>
<incomes>
<account name=&quot;X&quot; value=&quot;-84&quot; />
<account name=&quot;Y&quot; value=&quot;12&quot; />
<account name=&quot;Z&quot; value=&quot;-98&quot; />
<account name=&quot;S&quot; value=&quot;-10&quot; />
</incomes>
<costs>
<account name=&quot;A&quot; value=&quot;7&quot; />
</costs>
</finance>

how do I sum together the positive &quot;value&quot; values of <incomes> with the positive of <costs> and vice versa the negative value with the negative?
have tried
<xsl:variable name=&quot;sumOfIncomes&quot;>
<xsl:value-of select=&quot;sum(//incomes/account[@value][@value > 0])&quot; />
</xsl:variable>

and something like using a recursive sum with
<xsl:value-of select=&quot;sum(//incomes/account[$position]/@value[(//incomes/account[$position]/@value > 0])&quot; />

Thanks a million in advance
Regards
Azh
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top