2011-12-11 105 views
1

我是用于日期格式转换的开源xslt软件包。XSLT - 将参数从一个模板传递到另一个模板

链接#http://xsltsl.sourceforge.net/

这是我为了做我的日期格式转换,并以下列格式获取日期怎么称呼 - 4月4日,2011年

<xsl:variable name="date.format">%B %d, %Y</xsl:variable> 
<xsl:variable name="someDate"> 
    <xsl:call-template name="dt:format-date-time"> 
     <xsl:with-param name="xsd-date-time" select="//someDate"/> 
     <xsl:with-param name="format" select="$date.format"/> 
    </xsl:call-template> 
</xsl:variable> 

我检索结果通过调用 - <xsl:value-of select="$checkindate"/>

我想更新我的上面的代码传递一个额外的参数,这是语言,并能够得到翻译值没有运气。

任何帮助!

回答

0

我想更新我上面的代码中的附加 参数,即语言来传递,并能得到翻译值与 没有运气。

dt:format-date-time模板并不打算接受任何其他参数,而不是目前的参数。

有达到上述指定的任务不止一种方法:PARAM NAME =“郎”和相应的代码:

  1. 通过加入`XSL修改dt:format-date-time模板的代码处理新的参数。

  2. 添加一个新模板(说dt:format-date-time-NL)。在这个模板中有一个xsl:param name="lang" and, if appropriate, call the existing dt:format-date-time`模板。

我推荐的第二种方法作为重用代码和实现灵活性的正例。 XSLT使用标准xsl:importxsl:include指令为此编写风格提供了全面的支持。

请注意,直接编辑别人的代码并不总是可能的,理想的或道德的。即使如此,这可能导致众多不相容的“版本”(更确切地说,“突变”)与所有不良后果

相关问题