日付を表す文字列があり、そのようにフォーマットされています
2010-12-03 = "yyyy-mm-dd"
XSLT を使用して、月を抽出し、その月の省略形を取得する方法を見つけたいと思います。
12 月は 12 番目の月なので、変換後は「DEC 」と表示されます。
ありがとう!
これをインテリジェントかつ効率的に行う方法の短いデモを次に示します。
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:param name="pMonthNames">
<name><short>JAN</short>January</name>
<name><short>FEB</short>February</name>
<name><short>MAR</short>March</name>
<name><short>APR</short>April</name>
<name><short>MAY</short>May</name>
<name><short>JUN</short>June</name>
<name><short>JUL</short>July</name>
<name><short>AUG</short>August</name>
<name><short>SEP</short>September</name>
<name><short>OCT</short>October</name>
<name><short>NOV</short>November</name>
<name><short>DEC</short>December</name>
</xsl:param>
<xsl:variable name="vMonthNames" select=
"document('')/*/xsl:param[@name='pMonthNames']/*"/>
<xsl:template match="t">
<xsl:value-of select="$vMonthNames[position()=substring(current(),6,2)]/short"/>
</xsl:template>
</xsl:stylesheet>
この変換が次のXMLドキュメントに適用される場合:
<t>2010-12-03</t>
必要な正しい結果が生成されます。
DEC