Search

I'm trying to figure out the difference in digits between two numbers with XSLT.

I had an xPath that did it for the Reflection Field

(((entry/transaction-total >= 0) * entry/transaction-total) - (not(entry/transaction-total >= 0) * entry/transaction-total)) - (((sum(entry/transaction-splits/item/amount) >= 0) * sum(entry/transaction-splits/item/amount)) - (not(sum(entry/transaction-splits/item/amount) >= 0) * sum(entry/transaction-splits/item/amount)))

As you can see, that's very difficult to read, so I want to use the new XSLT Reflection Field to do it, but I can't for the life of me figure out the best way.

The above xPath creates absolute numbers, as some of the numbers might be negative.

Does anyone have any insight to this? Maths is not my strong point.

Eh, what? :-D

abs(entry/transaction-total - entry/transaction-splits/item/amount)
abs(entry/transaction-total) - abs(entry/transaction-splits/item/amount)

Wich one of those are you trying to do?

Isn't abs() xslt 2 only though?

I'm trying to find where I read that and got that xpath from...

Yeah, I'm just trying to understand your lengthy expression.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details