Mistype
(1)
Midpoint
(1)
Quadrant
(1)
XSL
(1)
XML
(1)

XSL Math

Asked By Eric
30-Jan-10 05:41 PM
How do I use XSL to calculate a value relative to other values?
I start with XML fields that look something like this:

Then I start on processing at the A level and process each lower item
recursively:

()" />
$total_amount) * 100,'##0.00')" />

Now, on each I have the amount, and the total for all B, and the
percentage of the total, and the position.
This is the simple version, hopefully enough to figure out what I am
doing.  There is a lot more code in this stylesheet.  Now, I am using
these values to build a pie.  I have the calculated values to draw the
pie, with the start and end points of each percentage around the edge
of the pie.  First, if I take the midpoint of each pie piece, I want
to know which quadrant it is in (0-25%,25-50%,50-75%,75-100%).  Then
the tricky part.  I want to know how many midpoints of other pie
pieces fall before and after the current pie piece in that quadrant
(if quadrant 1 or 3 get count of pieces in quadrant 3 with lower
percentage, if quadrant 2 or 4 get count of pieces in quadrant 2 or 4
with higher percentage).

Eric wrote:With above XML input, with a template matching "A" elements,

Martin Honnen replied to Eric
29-Jan-10 12:31 PM
With above XML input, with a template matching "A" elements, the
expression "A/D/text()" does not select anything at all as your "A"
element does not contain any "A" child elements. So the sum would give
zero. Is that what you want to achieve?

--

Martin Honnen --- MVP XML
http://msmvps.com/blogs/martin_honnen/

Mistype:<xsl:variable name=3D"total_amount" select=3D"sum(A/D/text())"

Eric replied to Martin Honnen
30-Jan-10 05:41 PM
Mistype:
should be:

(which should have been obvious since I said we are at the A level, and
A does not contain any D elements)
Post Question To EggHeadCafe