我正在做一项家庭作业,以创建一个 XSL 样式表,该样式表从我老师提供的 XML 文件中检索数据,并使用 XSLT 中的 format-date 函数。
我正在尝试以这种格式格式化日期:
4月26日星期四
这是我的 xml 的样子:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="weather-1.xsl"?>
<product version="1.7" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.bom.gov.au/schema/v1.7/product.xsd">
<forecast>
<area aac="NSW_FA001" description="New South Wales" type="region">
<forecast-period start-time-local="2018-04-26T04:30:02+10:00" end-time-local="2018-04-26T04:30:02+10:00" start-time-utc="2018-04-25T18:30:02Z" end-time-utc="2018-04-25T18:30:02Z">
<text type="synoptic_situation">
<p>A low pressure trough off the New South Wales north coast is weakening as a high pressure system south of the Bight moves very slowly east extending a ridge along the coast. The high is expected to move over the southern Tasman by Wednesday maintaining the ridge to the north.</p>
</text>
<text type="warning_summary_footer">Details of warnings are available on the Bureau's website www.bom.gov.au, by telephone 1300-659-218* or through some TV and radio broadcasts.</text>
<text type="product_footer">* Calls to 1300 numbers cost around 27.5c incl. GST, higher from mobiles or public phones.</text>
</forecast-period>
<forecast-period index="0" start-time-local="2018-04-26T05:00:00+10:00" end-time-local="2018-04-27T00:00:00+10:00" start-time-utc="2018-04-25T19:00:00Z" end-time-utc="2018-04-26T14:00:00Z">
<text type="fire_danger">Very High: Northwestern fire area.</text>
<text type="forecast">Medium chance of showers along the northern half of the coast with the risk of thunderstorms. The chance of afternoon thunderstorms in the northern inland. Early fog in the east. Partly cloudy elsewhere. Daytime temperatures close to average. Winds south to southwesterly, freshening along the coast and about the central west slopes.</text>
</forecast-period>
<forecast-period index="1" start-time-local="2018-04-27T00:00:00+10:00" end-time-local="2018-04-28T00:00:00+10:00" start-time-utc="2018-04-26T14:00:00Z" end-time-utc="2018-04-27T14:00:00Z">
<text type="forecast">A shower or two in the east, more likely about the north coast. The chance of a thunderstorm in the far northeast. Early frost patches about the southern ranges. Fine and mostly sunny in the west. Daytime temperatures below average, especially in the southeast. South to southeasterly winds, freshening about the northeast and along the coast.</text>
</forecast-period>
<forecast-period index="2" start-time-local="2018-04-28T00:00:00+10:00" end-time-local="2018-04-29T00:00:00+10:00" start-time-utc="2018-04-27T14:00:00Z" end-time-utc="2018-04-28T14:00:00Z">
<text type="forecast">Showers in the east, more likely about the central and northern coastal fringe. Fine and mostly sunny elsewhere. Early frost patches about the southern ranges. Daytime temperatures below average in the east and about average elsewhere. South to southeasterly winds, freshening about the north coast.</text>
</forecast-period>
<forecast-period index="3" start-time-local="2018-04-29T00:00:00+10:00" end-time-local="2018-04-30T00:00:00+10:00" start-time-utc="2018-04-28T14:00:00Z" end-time-utc="2018-04-29T14:00:00Z">
<text type="forecast">Showers in the east, more likely about the central and north coast. Fine and mostly sunny elsewhere. Early frost patches about the southern ranges. Daytime temperatures below average in the east, about average elsewhere. South to southeasterly winds.</text>
</forecast-period>
</area>
</forecast>
</product>
这是我目前拥有的 XSL 样式表:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
<xsl:template match="product[1]">
<html>
<head>
<title>State Weather</title>
</head>
<body>
<h3>NSW and ACT Weather</h3>
<p>Forecast for the rest of <xsl:value-of select="format-date(forecast/area/forecast-period[@start-time-local],'[FNn] [D1] [MNn]')"/></p>
<p><xsl:value-of select="forecast/area/forecast-period[2]/text[2]"/></p>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
我正在使用 http python 服务器来测试我的样式表。要查看天气,它会显示正确的信息。
这是我想要达到的结果:
我对如何实现和使用格式日期功能进行了各种谷歌搜索,但我仍然对自己做错了什么感到困惑。