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 5th, 2013, 10:50 AM
Authorized User
 
Join Date: Jun 2013
Posts: 13
Thanks: 0
Thanked 1 Time in 1 Post
Angry Global Variable not working

Hi All, I'm using Win7 64bit and bound to xslt 1.0. 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="357.37405"/>
<Profile name="Cnt" value="4.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="491347703">-2.48798</Point>
<Point Time="491348136">-2.64524</Point>
<Point Time="491348196">-2.66696</Point>
<Point Time="491348256">-1.66871</Point>
<Point Time="491348316">-0.92799</Point>
<Point Time="491348376">0.03788</Point>
<Point Time="491348436">-2.93716</Point>
<Point Time="491349017">0.08978</Point>
<Point Time="491349254">1.99864</Point>
<Point Time="491349494">0.35377</Point>
<Point Time="491349734">-0.36690</Point>
<Point Time="491350078">-0.08624</Point>
<Point Time="491350318">-2.99009</Point>
<Point Time="491350558">-2.87822</Point>
<Point Time="491350798">-3.59886</Point>
<Point Time="491351038">-4.02558</Point>
<Point Time="491351412">0.61559</Point>
<Point Time="491351472">0.97038</Point>
<Point Time="491351567">1.48383</Point>
<Point Time="491351628">2.38179</Point>
<Point Time="491351688">3.36402</Point>
<Point Time="491351748">2.27463</Point>
<Point Time="491351808">2.34239</Point>
<Point Time="491351868">2.22555</Point>
<Point Time="491351928">3.25894</Point>
<Point Time="491351988">2.30689</Point>
<Point Time="491352048">1.43087</Point>
<Point Time="491352349">-3.12652</Point>
<Point Time="491352589">-7.61186</Point>
<Point Time="491353022">-1.21697</Point>
<Point Time="491353503">-9.89016</Point>
<Point Time="491353627">1.77874</Point></Stat></Gather>
<State/>
<Checksum>3A2063E82F9B0C0DD450D8BAD5C81CFA</Checksum></MissionProfile>

Here's my xsl:
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
<xsl:template match="/MissionProfile">
<html>
<h2>Here's your Dead Reckoning results:</h2>
<body>
<xsl:variable name="points"
select="Gather/Stat/Point" />
<xsl:variable name="minNumber"
select="$points[not (. &gt; $points)]" />
<xsl:for-each select="Gather">
<xsl:value-of select ="$minNumber"/>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
This works fine extracting the minimum value (used as a local variable), BUT when I move variables (4 lines of code) up and below xsl stylesheet declaration (to use as a Global Variable), it does NOT work. Can anyone help with the mystery of using a Global Variable in 1.0? Thanks Much for any help as I've exhausted my own resources...
Jake
 
Old November 5th, 2013, 11:00 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

If the variable $points is global then change:
Code:
<xsl:variable name="points"
select="Gather/Stat/Point" />
to

Code:
<xsl:variable name="points"
select="/MissionProfile/Gather/Stat/Point" />
__________________
Joe
http://joe.fawcett.name/
 
Old November 5th, 2013, 04:48 PM
Authorized User
 
Join Date: Jun 2013
Posts: 13
Thanks: 0
Thanked 1 Time in 1 Post
Default

Thanks Joe...It worked like a champ!
Jake





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to declare the global variable in global.asax? calyn_gately ASP.NET 3.5 Basics 0 August 6th, 2008 08:06 PM
comapring global variable value to local variable amhicraig XSLT 6 December 5th, 2007 12:16 PM
Global Variable techfreak123 XSLT 0 August 3rd, 2006 07:45 AM
global variable? milk_vanilla Classic ASP Basics 3 January 8th, 2005 06:50 PM
global variable in c# kobystud C# 3 April 22nd, 2004 05:56 AM





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