【问题标题】:what's the best way to output the value of several XSL variables?输出几个 XSL 变量值的最佳方法是什么?
【发布时间】:2013-02-04 19:12:48
【问题描述】:

如果您的 XSL 转换代码看起来或多或少如下:

<xsl:variable name="a0" select="some expression"/>
<xsl:variable name="a1" select="some expression"/>
<xsl:variable name="a2" select="some expression"/>
...
<xsl:variable name="an" select="some expression"/>

...并且您想打印与每个变量关联的文本值,有没有比以下任何一种方法更优雅和简洁的方法?

1.

<xsl:value-of select="$a0"/>
<xsl:value-of select="$a1"/>
<xsl:value-of select="$a2"/>
 ...
<xsl:value-of select="$an"/>

2.

<xsl:foreach select="$a0 | $a1 | $a2 | ... | $an>
  <xsl:value-of select="."/>
</xsl:foreach>

【问题讨论】:

    标签: xml variables xslt iterator value-of


    【解决方案1】:

    是的,只需使用concat() 函数:

    <xsl:value-of select="concat($a0, $a1, $a2, ..., $an)" />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-12-17
      • 2010-09-26
      • 1970-01-01
      • 1970-01-01
      • 2020-03-03
      • 2013-04-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多