【发布时间】:2020-03-05 18:57:11
【问题描述】:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="2.0"
exclude-result-prefixes="#all"
>
<xsl:output indent="yes"/>
<xsl:template match="/">
<xsl:variable name="utc-timestamp" select="current-dateTime()"/>
<xsl:variable name="gmt-timestamp" select="adjust-dateTime-to-timezone($utc-timestamp, xs:dayTimeDuration('PT0H'))"/>
<xsl:variable name="eu-timestamp" select="adjust-dateTime-to-timezone($utc-timestamp, xs:dayTimeDuration('PT1H'))"/>
<xsl:variable name="est-timestamp" select="adjust-dateTime-to-timezone($utc-timestamp, xs:dayTimeDuration('-PT5H'))"/>
<xsl:variable name="fcccYear" select="substring($est-timestamp,7,2)"/>
<date timestamp="{$utc-timestamp}">
<gmt str="{$gmt-timestamp}">
<xsl:value-of select="$fcccYear"/>
</gmt>
<est str="{$est-timestamp}">
<xsl:value-of select="format-dateTime($est-timestamp, '[D01][M01][Y0001][h]:[m][PN,*-2] [ZN,*-3]', (), (), 'us')"/>
</est>
</date>
</xsl:template>
</xsl:stylesheet>
我正在尝试获取调整时间的子字符串,但我得到了以下错误,这很好。有人可以告诉我如何将 XS:dateTime 转换为 XS:String
错误:substring() 的第一个参数的必需项类型是 xs:string;提供的值具有项目类型 xs:dateTime
【问题讨论】:
-
请选择XSLT的一个版本标签,而不是全部。
-
当然。我删除了其他标签