Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 1st, 2013, 06:20 PM
Authorized User
 
Join Date: Jun 2013
Posts: 13
Thanks: 0
Thanked 1 Time in 1 Post
Default Min/Max from a node set

I'm back!!! Can't use xslt 2.0 because FlightSimulatorX uses 1.0. Can't use min or max functions or Sort since they aren't in 1.0....
Is there any way to use Variables to extract min or max from a nodeset? I've hacked for 2 days now but no luck...here's my xml:
<?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="5.00000"/>
<Profile name="Fire" value="1"/>
<Profile name="SIMVAR_VERSION" value="V1.0.3537.0"/>
<Gather>
<Stat ID="" Name="GPS WP CROSS TRK" Unit="decimile">
<Point Time="491347698">-0.04583</Point>
<Point Time="491347938">-2.67923</Point>
<Point Time="491348254">-0.55264</Point>
<Point Time="491348494">3.31936</Point>
<Point Time="491348719">0.35047</Point>
<Point Time="491348852">-1.95970</Point>
<Point Time="491349006">-0.96952</Point>
<Point Time="491349066">-0.47092</Point>
<Point Time="491349126">0.45476</Point>
<Point Time="491349186">0.89227</Point>
<Point Time="491349246">1.18413</Point>
<Point Time="491349306">1.03627</Point>
<Point Time="491350034">6.56656</Point>
<Point Time="491350274">9.36668</Point>
<Point Time="491350514">11.00141</Point>
<Point Time="491350754">13.37342</Point>
<Point Time="491350994">10.43424</Point>
<Point Time="491351200">-4.00423</Point>
<Point Time="491351260">-3.10856</Point>
<Point Time="491351490">-1.00002</Point>
<Point Time="491351890">2.23850</Point>
<Point Time="491351974">3.05697</Point>
<Point Time="491352033">2.95752</Point>
<Point Time="491352092">2.22562</Point>
<Point Time="491352152">4.54936</Point>
<Point Time="491352212">2.08890</Point>
<Point Time="491352435">0.52381</Point>
<Point Time="491352676">4.52694</Point>
<Point Time="491352915">10.33114</Point>
<Point Time="491353204">13.74132</Point>
<Point Time="491353264">4.11866</Point>
<Point Time="491353324">-6.53613</Point>
<Point Time="491353384">-5.67728</Point></Stat></Gather>
<State/>
<Checksum>A1F673D1EB6CFB0C0B1A957B6BEB5A05</Checksum></MissionProfile>
...and my xslt

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
<xsl:variable name="max1" select="string(.)"/>
<xsl:template match="/MissionProfile">
<html>
<h2>Here's your maximum Dead Reckoning course variation in decimiles:</h2>
<body>
<br/>
<xsl:text>Max Course Variation = </xsl:text>
<xsl:for-each select="Gather/Stat">
<xsl:sort select="Point"/>
<xsl:if test="position()=last()">
<last>"."</last>
</xsl:if>
<!-- <xsl:value-of select="Point"/><xsl:text>, </xsl:text> -->
</xsl:for-each>
<br/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

Thanks for any help, as I'm approaching burnout, but I know I'm so close to a solution.

Last edited by JakeRogers; November 2nd, 2013 at 02:57 AM..
 
Old November 2nd, 2013, 07:08 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

You do have the right approach with a for-each, a sort and a check for position(). I suspect you want to change the selection of the for-each:
Code:
<xsl:for-each select="Gather/Stat/Point"> 
     <xsl:sort select="." data-type="number"/>
   <xsl:if test="position()=last()">
        <last><xsl:value-of select="."/></last>
     </xsl:if>
</xsl:for-each>
That would compute the maximum value of the values inside of the Point elements.
__________________
Martin Honnen
Microsoft MVP (XML, Data Platform Development) 2005/04 - 2013/03
My blog
 
Old November 2nd, 2013, 10:36 AM
Authorized User
 
Join Date: Jun 2013
Posts: 13
Thanks: 0
Thanked 1 Time in 1 Post
Default

Martin, Thank you very much...This is the most user surly language I have ever dealt with! I obviously don't fully understand the structure in spite of hours of reading...Any recommendations? Thanks again, Martin...saved my day!
Jake





Similar Threads
Thread Thread Starter Forum Replies Last Post
How does one get the Max or Min Filename? crabjoe ASP.NET 1.0 and 1.1 Basics 4 January 15th, 2008 04:48 PM
MAX/MIN Value Help slbibs SQL Server 2005 4 November 6th, 2007 04:00 AM
MIN( MAX( UPDATE Stuart Stalker SQL Language 3 February 21st, 2007 07:10 AM
How to set of Min/Max values of Line chart . Sanjay.Verma BOOK: Professional Crystal Reports for VS.NET 0 November 20th, 2006 11:35 PM
Min / Max followup danbush XSLT 2 August 31st, 2005 12:02 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.