小编No *_*Way的帖子

XSLT 1.0:如何打印第一个非空值为2的两个(见内部)

我想得到第一个非空值为2并将其置于文本输入的"值"属性.所以,我这样做:

<input type="text">
  <xsl:attribute name="value">
    <xsl:choose>
      <xsl:when test="some/@attr != ''">
        <xsl:value-of select="some/@attr" />
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="some/another/@attr" /> <!-- always non-empty, so get it -->
      </xsl:otherwise>
    </xsl:choose>
  </xsl:attribute>
</input>
Run Code Online (Sandbox Code Playgroud)

问题是:有没有办法用较少的代码行来实现它?..也许,就像那样:<input type="text" value="some/@attr or some/another/@attr" />或者其他什么东西?比如说Perl:my $val = 0 || 5;

在此先感谢您的帮助

UPD XSLT 1.0

xslt attributes

3
推荐指数
1
解决办法
1021
查看次数

标签 统计

attributes ×1

xslt ×1