[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Variables in XSLT

Subject: Re: Variables in XSLT
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 27 Jan 2006 15:54:41 GMT
Re:  Variables in XSLT
  With my conventional programming background, I want to define a $maxeffdt
  variable BEFORE I call the template below and this do some kind of <xsl:if
  test="EFFDT = $maxeffdt> but I'm not sure this is doable/appropriate in the
  new XSLT world.

You have two options if $maxeffdt is a global parameter 
set by
<xsl:param name="maxeffdt"/>
at the top level of your stylesheet and passed in (in a system-dependant
manner) when you start the program then it's globally available and you
can reference it directly in your template.

If it is set within the template (eg if it is a value from some other
element in the source document) then it;s a local parameter so you need
to declare it in this template and pass it in.

<xsl:template match="VENDOR_LOC">
  <xsl:param name="maxeffdt"/>


then call it as

  <xsl:apply-templates select="VENDOR_LOC">
    <xsl:with-param name="maxeffdt" select="....something

Once you have your two dates the problem is comparing them. XSLT1
doesn't have string or date comparison operators (XSLT2 will have both)
so the easiest thing is to get rid of the - and compare as numbers
<xsl:if test="translate($maxeffdt,'-','') &lt; translate(EFFDT,'-','')">
 ...

so this compares 2006-01-26 against 1901-01-01 by comparing 
 20060126  19010101 

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.