XSLT函数 [英] XSLT Functions
问题描述
嗨
我正在做一个处理(例如)酒店列表的XSLT。
每家酒店都有一个属性@StarRating,它是一个以下
值:
*
**
*** >
****
*****
是否可以将我的属性传递给可以
然后对它们实际上做一个案例陈述,用图像替换
代表星级评级?
我相信它是,但如果没有,你是如何解决这个问题的?
非常感谢
Darren
daz_oldham写道:
每家酒店都有属性@StarRating是以下
值之一:
*
**
***
****
*****
是否可以将我的属性传递给可以随后执行的自定义函数实际上是一个关于它们的案例陈述,用图像替换它来代表星级?
您使用的是XSLT 1.0还是2.0?
只有XSLT 2.0允许您使用XSLT本身编写自定义函数。
使用XSLT 1.0,您需要编写一个命名模板,例如
< ; xsl:template name =" get-image">
< xsl:param name =" stars" />
< xsl:variable name =" starCount"选择= QUOT;字符串长度(
分)" />
< img alt =" {
starCount} stars"
src =" starsImage {
Hi
I am doing an XSLT that processes (for example) a list of hotels.
Each hotel has the attribute @StarRating which is one of the following
values:
*
**
***
****
*****
Is it possible to pass my attribute to a custom function that could
then do in effect a case statement on them, replacing it with an image
to represent the star rating?
I am sure that it is, but if not, how do you work around this?
Many thanks
Darren
daz_oldham wrote:
Each hotel has the attribute @StarRating which is one of the following
values:
*
**
***
****
*****
Is it possible to pass my attribute to a custom function that could
then do in effect a case statement on them, replacing it with an image
to represent the star rating?
Are you using XSLT 1.0 or 2.0?
Only XSLT 2.0 allows you to write custom functions with XSLT itself.
With XSLT 1.0 you need to write a named template e.g.
<xsl:template name="get-image">
<xsl:param name="stars" />
<xsl:variable name="starCount" select="string-length(
stars)" />
<img alt="{
starCount} stars"
src="starsImage{
这篇关于XSLT函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!