How do I extract a single value representing greatest absolute value?
Hi All and MANY thanks for all the valuable help I and others receive from this forum. I'm using Win7, 64bit and xsl 1.0, as all MS FlightSim Users are locked in to 1.0.
Here's my xml, which I'm sure you've seen b4:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type='text/xsl' href='MissionProfile.xsl'?>
<MissionProfile>
<Profile name="BHP" value="290000"/>
<Profile name="EOT" value="356.51129"/>
<Profile name="Cnt" value="0"/>
<Profile name="Fire" value="0"/>
<Profile name="SIMVAR_VERSION" value="V1.0.3537.0"/>
<Profile name="PROFILEPATH" value="c:\program files (x86)\microsoft games\microsoft flight simulator x\missions\Backcountry\USAMSL2RP2\Elko2Reno_profil e.xml"/>
<Gather>
<Stat ID="" Name="GPS WP CROSS TRK" Unit="decimile">
<Point Time="491347723">-0.67273</Point>
<Point Time="491347783">-0.83152</Point>
<Point Time="491347843">-2.00702</Point>
<Point Time="491347903">-2.66593</Point>
<Point Time="491347963">-2.71417</Point>
<Point Time="491348023">-2.40000</Point></Stat></Gather>
<State/>
<Checksum>19919658618FB888498D1D0A95C59705</Checksum></MissionProfile>
Here's my xsl which, gets me the Min and Max values of "Point"...Now I need to extract the greatest Absolute value of the two, but obviously can't use the abs() function due to 1.0 vs. Can anyone help? I've nearly worn out my keyboard trying to make a global variable work...NO Joy! Thanks...
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
<xsl:variable name="points"
select="/MissionProfile/Gather/Stat/Point" />
<xsl:variable name="minNumber"
select="$points[not (. > $points)]" />
<xsl:variable name="maxNumber"
select="$points[not (. < $points)]" />
<xsl:template match="/MissionProfile">
<html>
<h2>Here's your Dead Reckoning results:</h2>
<body>
<xsl:text>Course Maximum Variations = </xsl:text>
<xsl:for-each select="Gather/Stat/Point">
<xsl:sort select="." data-type="number"/>
<xsl:if test="position()=last()">
<xsl:value-of select="format-number(.,'#.00')"/>
<xsl:text> Deci-Miles Right, </xsl:text>
</xsl:if>
<xsl:if test="position()=1">
<xsl:value-of select="format-number(-1*.,'#.00')"/>
<xsl:text> Deci-Miles Left, </xsl:text>
</xsl:if>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Last edited by JakeRogers; November 5th, 2013 at 04:53 PM..
|