xsl-list
[Top] [All Lists]

Re: [xsl] Selecting from a sequence

2015-02-05 12:36:50
If $a and $b have cardinality zero-or-one then ($a, $b)[1] does what you want 
(and is a common programming idiom).

But be careful, it doesn't work if either $a or $b can contain more than one 
item.

Also, it tests whether $a exists, which isn't the same as your example of 
testing the effective boolean value of string(@a).

Michael Kay
Saxonica
mike(_at_)saxonica(_dot_)com
+44 (0) 118 946 5893




On 5 Feb 2015, at 18:32, Mailing Lists Mail daktapaal(_at_)gmail(_dot_)com 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:

Hey All,
I have a logic that says :

if $a found , then use it, else use $b.
I can do this like

<xsl:value-of select = "if(string($a)) then $a else $b"/>

Can I do something like
<xsl:value-of select = "($a,$b)[1]"/>

Not sure , when this will work and when it wont. Or will it work at all..

--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>