本文介绍了如何在XSLT中更改Dateformate的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我需要更改以下(标签)xml中的日期格式(dateFrom)。 *更改:dd / mm / yyyy < CancellationPolicies > < CancellationPolicy 金额 = 355.500 dateFrom = 20140613 time = 2359 / > < / CancellationPo licies > 为此,我使用这个xslt:在xslt中添加什么? < pre > ; <? xml 版本 = 1.0 encoding = UTF-8 ? > < xsl:stylesheet xmlns:xsl = http://www.w3.org/1999/XSL/转换 xmlns:ms = urn:schemas-microsoft-com:xslt xmlns:dt = urn:schemas-microsoft-com:datatypes version = 1.0 > < xsl:output omit-xml-declaration = 是 缩进 = 是 / > < xsl:template 匹配 = / > < xsl:apply-templates select = @ * | node() / > < / xsl:template > < xsl:template match = ServiceHotel / AvailableRoom / HotelRoom / RoomType > $ b $bPolíticadelalaclación:Tipo Hab。 < xsl:value-of 选择 = @ characteristic / > codigo:< xsl:value-of select = @ code / > < / xsl:template > < xsl:template 匹配 = // CancellationPolicies / CancellationPolicy > Sicancelasdespuésdelas < xsl:value-of 选择 = @时间 / > PM del < ; xsl:value-of select = @ dateFrom / > se aplicaran unos gastos de:< xsl :value-of 选择 = @ amount / > < xsl:value-of 选择 = // * / Currency / @ code / > < / xsl:template > < / xsl:stylesheet > 谢谢。解决方案 < ; xsl:template 匹配 = CancellationPolicy > < xsl:value-of 选择 = concat(substring(@dateFrom,7,2),'/',substring(@ dateFrom,5,2),'/',substring(@dateFrom,1,4)) / > < / xsl:template > Hi,I need to change the date format (dateFrom) in the following (Tag) xml. *change by: dd/mm /yyyy<CancellationPolicies> <CancellationPolicy amount="355.500" dateFrom="20140613" time="2359" /></CancellationPolicies>For that I use this xslt: What to add in the xslt?<pre><?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ms="urn:schemas-microsoft-com:xslt" xmlns:dt="urn:schemas-microsoft-com:datatypes" version="1.0"> <xsl:output omit-xml-declaration="yes" indent="yes"/> <xsl:template match="/"> <xsl:apply-templates select="@*|node()"/> </xsl:template> <xsl:template match="ServiceHotel/AvailableRoom/HotelRoom/RoomType"> Política de cancelación: Tipo Hab. <xsl:value-of select="@characteristic"/> codigo:<xsl:value-of select="@code"/> </xsl:template> <xsl:template match="//CancellationPolicies/CancellationPolicy"> Si cancelas después de las <xsl:value-of select="@time"/> PM del <xsl:value-of select="@dateFrom"/> se aplicaran unos gastos de:<xsl:value-of select="@amount"/> <xsl:value-of select="//*/Currency/@code"/> </xsl:template> </xsl:stylesheet>Thanks. 解决方案 <xsl:template match="CancellationPolicy"> <xsl:value-of select="concat(substring(@dateFrom, 7, 2), '/', substring(@dateFrom, 5, 2), '/', substring(@dateFrom, 1, 4))"/></xsl:template> 这篇关于如何在XSLT中更改Dateformate的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-23 15:19