我想得到第一个非空值为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