我有一个xml文件,这个充满节点:提取时间1.0
<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"/>
,我需要提取@DepartureDateTime和@ArrivalDateTime的只是时间的HTML输出。到目前为止,我做了一个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>
在此先感谢。
如果你看到一个描述为'fn:anything'的函数,那么它几乎肯定是2.0。 XPath 1.0中默认可用的唯一函数是[theses](http://www.w3.org/TR/xpath/#corelib),本质上是从节点提取信息的函数('namespace-uri','local -name'等),一些基本的字符串操作(没有正则表达式!)和一些数字函数,如'sum'和'round'。而且他们不需要命名空间前缀 - XPath 1.0对于http:// www.w3.org/2005/xpath-functions'命名空间一无所知。 –