gpt4 book ai didi

xslt - 使用 XSLT 在属性中格式化日期

转载 作者:行者123 更新时间:2023-12-04 06:23:37 26 4
gpt4 key购买 nike

我正在考虑将标题标签添加到具有来自属性的格式化日期的元素。输入值是 DateTime UTC 格式,我需要以“漂亮的格式”输出。

我有一个转换值的模板。但是,在将值放入属性时,我无法弄清楚如何调用此模板。

  <xsl:template name="formatDate">
<xsl:param name="dateTime" />
<xsl:variable name="date" select="substring-before($dateTime, 'T')" />
<xsl:variable name="year" select="substring-before($date, '-')" />
<xsl:variable name="month" select="substring-before(substring-after($date, '-'), '-')" />
<xsl:variable name="day" select="substring-after(substring-after($date, '-'), '-')" />
<xsl:value-of select="concat($month, '-', $day, '-', $year)" />
</xsl:template>

最佳答案

<xsl:attribute name="title">
<xsl:call-template name="formatDate">
<xsl:with-param name="dateTime" select="@lastReported" />
</xsl:call-template>
</xsl:attribute>

关于xslt - 使用 XSLT 在属性中格式化日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6283810/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com