attributes - XSLT 1.0: how to get print of first non-empty value of two (see inside) -


i want first non-empty value of 2 , put "value" attribute of text input. so, do:

<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" /> <!-- non-empty, -->       </xsl:otherwise>     </xsl:choose>   </xsl:attribute> </input> 

question is: there way make less lines of code?.. maybe, that: <input type="text" value="some/@attr or some/another/@attr" /> or something?.. in, say, perl: my $val = 0 || 5;

thanks in advance help

upd xslt 1.0

the relay magic in answer form @martin honnen. enhancement,to make little shorter can use "attribute value templates"

<input type="text" value="{some/@attr[. != ''] | some/another/@attr}"> </input> 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -