XML Tutorial/XSLT stylesheet/format time — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 08:26, 26 мая 2010
Extracting the timezone from an xs:time
File: Data.xml
File: Transform.xslt
<?xml version="1.0"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:text>Extracting the timezone from an xs:time:</xsl:text>
<xsl:variable name="currentTime" as="xs:time" select="current-time()"/>
<xsl:text>The current time is: </xsl:text>
<xsl:value-of select="$currentTime"/>
<xsl:text>The current timezone is: </xsl:text>
<xsl:value-of select="timezone-from-time($currentTime)"/>
<xsl:text>
 The timezone is also known as </xsl:text>
<xsl:value-of select="format-time($currentTime, "[ZN]")"/>
</xsl:template>
</xsl:stylesheet>
Output:
Extracting the timezone from an xs:time:The current time is: 13:11:37.593-08:00The current timezone is: -PT8H
The timezone is also known as -08:00