我有以下输出:
<forms>
<form id="15">
<start>2013-12-09</start>
<end>2014-01-05</end>
</form>
</forms>
我想测试当前日期是否等于或大于&#34;开始&#34;小于或等于&#34;结束&#34;
我将如何进行测试呢?
我的想法是:
<xsl:variable name="fstart">
<xsl:value-of select="start" />
</xsl:variable>
<xsl:variable name="fend">
<xsl:value-of select="end" />
</xsl:variable>
<xsl:choose>
<xsl:when test="$fstart >= currentdate xor currentdate <= $fend ">
<!-- do stuff -->
</xsl:when>
<xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
答案 0 :(得分:4)
我相信它是这样的:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs">
...
<xsl:for-each select="forms/form">
<xsl:choose>
<xsl:when test="xs:date(start) <= current-date()
and
current-date() <= xs:date(end)">
<!-- in progress -->
</xsl:when>
<xsl:otherwise>
<!-- not started yet or already ended-->
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>