Xml xslt命名模板编号始终进入xsl:otherwise块
我有一个日期后缀函数,它将st、nd、rd、th后缀与日期相加Xml xslt命名模板编号始终进入xsl:otherwise块,xml,xslt,xpath,Xml,Xslt,Xpath,我有一个日期后缀函数,它将st、nd、rd、th后缀与日期相加 <xsl:template name="date_suffix"> <xsl:param name="date" /> <xsl:choose> <xsl:when test="$date > 10 and $date < 14">th</xsl:when> <xsl:when test="(
<xsl:template name="date_suffix">
<xsl:param name="date" />
<xsl:choose>
<xsl:when test="$date > 10 and $date < 14">th</xsl:when>
<xsl:when test="($date mod 10) = 1">st</xsl:when>
<xsl:when test="($date mod 10) = 2">nd</xsl:when>
<xsl:when test="($date mod 10) = 3">rd</xsl:when>
<xsl:otherwise>th</xsl:otherwise>
</xsl:choose>
</xsl:template>
th
圣
钕
研发部
th
我这样称呼它
<xsl:template match="date">
<xsl:value-of select="." />
<xsl:call-template name="date_suffix">
<xsl:with-param name="date" seelect="." />
</xsl:call-template>
</xsl:template>
这是我的XAML片段
<dob>
<date>23</date>
<month>Dec</month>
<year>1987</year>
</dob>
23
12月
1987
问题是我看到的是
23次
,而我预期的是23次
。这个选择,当我直接在
块中使用时,它可以正常工作,但当被称为命名模板时,它不能正常工作尝试将seelect
更改为选择?如果您不受XSL版本1.0的限制,使用具有强类型参数的函数而不是命名模板可能会有所帮助:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xyz="urn:mystuff"
version="2.0">
<xsl:output encoding="utf-8" indent="yes" method="xml" />
<xsl:template match="date">
<xsl:value-of select="." />
<xsl:value-of select="xyz:date_suffix(.)" />
</xsl:template>
<xsl:function name="xyz:date_suffix" as="xs:string">
<xsl:param name="date" as="xs:integer"/>
<xsl:choose>
<xsl:when test="($date mod 10) = 1">st</xsl:when>
<xsl:when test="($date mod 10) = 2">nd</xsl:when>
<xsl:when test="($date mod 10) = 3">rd</xsl:when>
<xsl:otherwise>th</xsl:otherwise>
</xsl:choose>
</xsl:function>
</xsl:stylesheet>
圣
钕
研发部
th
对于诊断,使用xsl:message显示$date的值。