Я работаю над домашней задачей, чтобы создать таблицу стилей XSL, которая извлекает данные из файла XML, предоставленного моим учителем, и использует функцию форматирования даты в XSLT.
Я пытаюсь отформатировать датув следующем формате:
четверг, 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 для проверки своей таблицы стилей.Чтобы увидеть погоду, она отображает правильную информацию.
Вот результат, к которому я стремлюсь:
Я сделал разныеGoogle ищет, как реализовать и использовать функцию форматирования даты, но я все еще не понимаю, что я делаю неправильно.