日期:2014-05-19  浏览次数:20544 次

请教一个简单的xsl的问题
<xsl:value-of   select= "pubDate "/>   这个字段显示出来的值是 <pubDate> Sat,   28   Apr   2007   08:29:33   GMT </pubDate>
我想显示成 <pubDate> 2007年4月28日   08:29:33 </pubDate>

请问怎么实现?

------解决方案--------------------
楼主的xml文件里是这样的格式,所以就显示成这样了,你可以在生成xml的时候就把时间先转换成需要的格式


------解决方案--------------------
可参考这个xsl文件:

<xsl:stylesheet version= "1.0 " xmlns:xsl= "http://www.w3.org/1999/XSL/Transform ">
<xsl:template match= "/ ">
<html xmlns:o= "urn:schemas-microsoft-com:office:office " xmlns:x= "urn:schemas-microsoft-com:office:excel " xmlns= "http://www.w3.org/TR/REC-html40 ">
<head>
<meta http-equiv= "Content-Type " content= "text/html;charset=utf-8 " />
<style>
.xlHeader
{
padding-left: 15px;
padding-right: 10px;
font-family: Arial;
font-size: 9.0pt;
}
.xlNumberField
{
padding-left:15px;
padding-right:10px;
vnd.ms-excel.numberformat:#,###.00;
font-family:Arial;
font-size:9.0pt;
white-space:normal;
}
.xlTitle
{
padding-left:15px;
padding-right:10px;
font-size:20px;
font-family:Arial;
font-weight:bold;
background:#FFFF99;
height:30px;
white-space:normal;
}
.xlMoney
{
padding-left:15px;
padding-right:10px;
font-size:9.0pt;
font-family:Arial, sans-serif;
mso-number-format: "\0022$\0022\#\,\#\#0\.00 ";
text-align:left;
white-space:normal;
}

.xlTextField
{
padding-left:15px;
padding-right:10px;
mso-number-format: '\@ ';
text-align:left;
font-family:Arial;
font-size:9.0pt;
white-space:normal;
}
<!--日期型样式-->
.xlShortDateField
{
padding-left:15px;
padding-right:10px;
mso-number-format: 'Short Date ';
text-align:left;
font-family:Arial;
font-size:9.0pt;
white-space:normal;
}
</style>
<xml>
<x:ExcelWorkbook>
<x:ExcelWorksheets>
<x:ExcelWorksheet>
<x:Name> Role Info </x:Name>
<x:WorksheetOptions>
<x:ProtectContents> False </x:ProtectContents>
<x:ProtectObjects> False </x:ProtectObjects>
<x:ProtectScenarios> False </x:ProtectScenarios>
</x:WorksheetOptions>
</x:ExcelWorksheet>
</x:ExcelWorksheets>
</x:ExcelWorkbook>
</xml>
</head>
<body>
<table border= "0 " cellpadding= "0 " cellspacing= "0 ">
<!-- 此處是為了導出復合表頭時用到的,如合并欄等, select 後為欄位名,區分大小寫-->
<!--
<xsl:for-each select= "NewDataSet/title ">
<tr>
<td colspan= "7 " align= "Center " class= "xlTitle "> <xsl:value-of select= "Title "/> </td>
</tr>
</xsl:for-each>
-->
<!-- 此處為導出EXCEL的表頭部分,不區分大小寫-->
<tr>
<th class= "xlHeader "> date </th>
<th class= "xlHeader "> description </th>

</tr>
<!-- 以下為導出數據欄位名,區分大小寫,必須與調用的查詢語句中的欄位名相同,并且欄