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 December 3rd, 2007, 04:57 PM
Authorized User
 
Join Date: Jun 2007
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default comparison using a sequence

I have a series of dates

<date>2008-12-03T04:00:00-06:00</date>
<date>2008-12-04T04:00:00-06:00</date>
<date>2008-12-05T04:00:00-06:00</date>

I am trying to build an input check box for the current week +1 (8 days starting with the current day) where if one of the <date>s falls within the current week, then the input check box is selected.

I have built the series of checkboxes, but I am having a difficult time determining when an input box should be 'checked'. What I have done so far:

<xsl:template name="operating_days">


  <xsl:param name="schedule"/>


  <xsl:variable name="date" select="current-dateTime()"/>

  <xsl:for-each select="0 to 7">
    <input type="checkbox" name="checkbox" value="checkbox">

       <xsl:if test="
                 day-from-dateTime(eb:date-add($date,.))
                   eq
                 day-from-dateTime($schedule//date)">
          <xsl:attribute name="checked">checked</xsl:attribute>
       </xsl:if>
    </input>
      <xsl:value-of select="value"/>
  </xsl:for-each>

</xsl:template>

This is not working because I cannot test over a sequence of items. Any ideas on how to determine if the current date equals one of the define <date>s?
 
Old December 3rd, 2007, 07:33 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

I think you want

<xsl:variable name="date" select="current-date()" as="xs:date"/>
<xsl:variable name="oneDay" select="xs:dayTimeDuration('P1D')" as="xs:dayTimeDuration"/>
<xsl:variable name="scheduleDates" as="xs:date*" select="$schedule//date/xs:date(xs:dateTime(.))"/>
 then
test="($date + .*$oneDay) = $scheduleDates"

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
how to create sequence no in c# bettiahamit .NET Framework 3.5 1 November 6th, 2008 06:25 AM
Number Sequence Generator Peso SQL Server 2000 4 May 11th, 2006 01:36 PM
Processing first node in a sequence djmarquette XSLT 3 November 15th, 2005 01:05 PM
value from a sequence suhabassam JSP Basics 0 September 27th, 2005 01:33 AM
Sequence of For-each elements? brendonsmith XSLT 2 January 14th, 2004 05:17 PM





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