viv:if-else

provides a simple if-else statement for XSL

Synopsis

object
	viv:if-else
	(cond, object1, object2);
boolean    cond;
object    object1;
object    object2;

Description

Simple if-else statement (which does not exist in XPath 1.0). Allows less verbose XSL as it can be used instead of xsl:choose. It is also more flexible than xsl:choose because it returns an object (xsl:choose forces the conversion of objects to strings).

Arguments

  • cond: test condition
  • object1: object (string, node-set, etc) to return if the condition is true.
  • object2: object to return if the condition is false.

Returns

  • object1 if cond is verified
  • object2 if not.

Example

    <xsl:value-of select="count(viv:if-else(@count-dup, //document, //document[not(@duplicate-of)]))"/>