在XSLT / XML中将日期显示为DD-MM-YYYY [英] Displaying Date as DD-MM-YYYY within XSLT/XML

查看:67
本文介绍了在XSLT / XML中将日期显示为DD-MM-YYYY的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试将文本格式设置为从XML拉到XSLT 1.0时显示为DD-MM-YYYY,因为我知道在使用xs:date时必须将其布置为XSD / XML中的YYYY-MM-DD。我用过的东西。

Been trying to format the text to display as DD-MM-YYYY when pulled from XML to XSLT 1.0, since I know it has to be laid out as YYYY-MM-DD within XSD/XML when using xs:date which what I have used.

这是我正在处理的代码,有关如何显示此内容的任何建议?

Here is the code I am working working on, Any advice on how I should display this?

XML

<?xml version="1.0" encoding="ISO-8859-1"?>
<events xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="events.xsd">
  <venue id="01" 
         vtitle="ExCeL Exhibition Centre" 
         location="London" 
         telephone="0844 448 7600">
   <event name="Doctor Who 50th Celebration" date="2013-10-22">
    <image>images/doctor50.jpg</image><attribute>Doctor Who Event</attribute>
    <description>A 50th Anniversary musical bonanza for Doctor Who.</description>
    <ticket_price type="adult" status="available">&#163;25.00</ticket_price>
    <ticket_price type="child" status="none">&#163;11.00</ticket_price>
    <ticket_price type="junior" status="available">&#163;0.00</ticket_price>
    <email>info@roundhouselondon.com</email>
</event>
</venue>

XSD

<xs:attribute name="date" type="xs:date"/>

XSLT

<xsl:element name="date"><xsl:value-of select="@date"/></xsl:element>

HTML

<date>2013-10-22</date>


推荐答案

另一种用于生成日期为dd / mm /的简单解决方案yyyy形式

Another simple solution for producing dates in dd/mm/yyyy form

<xsl:value-of select="
  concat(substring(@date, 9, 2), 
         '/', 
         substring(@date, 6, 2),
         '/', 
         substring(@date, 1, 4))"/>

这篇关于在XSLT / XML中将日期显示为DD-MM-YYYY的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆