我有一个充满这些节点的 xml 文件:
<FlightSegment DepartureDateTime="2014-05-02T14:24:00" ArrivalDateTime="2014-05-02T15:42:00"/>
<FlightSegment DepartureDateTime="2014-05-02T16:24:00" ArrivalDateTime="2014-05-02T17:42:00"/>
Run Code Online (Sandbox Code Playgroud)
我只需要在 html 输出中提取 @DepartureDateTime 和 @ArrivalDateTime 的时间。到目前为止,我制作了一个 xsl:for-each 和一个返回完整字符串的 xsl:value-of,但我尝试使用 fn:hours-from-dateTime 并且它不起作用。要么我做错了什么,要么只在 2.0 中有效。我怎样才能从这个字符串中获得时间?
这是我的代码:
<table>
<xsl:for-each select="FlightSegment">
<tr>
<td>
Departure:
</td>
<td>
<fn:hours-from-dateTime(xsl:value-of select="@DepartureDateTime")/>:<fn:minutes-from-dateTime(xsl:value-of select="@DepartureDateTime")/>:<fn:seconds-from-dateTime(xsl:value-of select="@DepartureDateTime")/>
</td>
</tr>
<tr>
<td>
Arrival:
</td>
<td>
<fn:hours-from-dateTime(xsl:value-of select="@ArrivalDateTime")/>:<fn:minutes-from-dateTime(xsl:value-of select="@ArrivalDateTime")/>:<fn:seconds-from-dateTime(xsl:value-of select="@ArrivalDateTime")/>
</td>
</tr>
</xsl:for-each>
</table>
Run Code Online (Sandbox Code Playgroud)
提前致谢。
我需要在变量中定义的给定日期之前和之后3天获取,并将它们中的每一个存储在xsl 1.0中的新单个变量中.我不能使用任何扩展或第三方工具.
通过论坛中的答案,我发现:在XSLT 1.0中扩展日期时间范围以 解决类似的问题,但我不完全理解它是否以及如何适用于我的代码.
Mi日期变量采用标准的dateTime格式,如下所示:
<xsl:variable name="Date" select="2014-05-13T00:00:00"/>
Run Code Online (Sandbox Code Playgroud)
我需要输出类似于此的html:
<table>
<tr>
<td>
2014-05-10
<td>
</tr>
<!---some rows with pricing information -->
</table>
<table>
<tr>
<td>
2014-05-11
<td>
</tr>
<!---some rows with pricing information -->
</table>
<table>
<tr>
<td>
2014-05-12
<td>
</tr>
<!---some rows with pricing information -->
</table>
<!-- etc -->
Run Code Online (Sandbox Code Playgroud)
在具有定价信息的行中,我将必须使用每个单独的日期来执行其他操作,因此每天必须存储在变量中以供进一步使用.
有没有办法实现这一点,只使用xslt 1.0?
提前致谢.