Trademark Logo XSLTC Design
<xsl:if>
Apache Foundation Xalan Project Xerces Project Web Consortium Oasis Open

<xsl:if>

(top)

Contents

(top)

Functionality

This element is cruical to XSL processing, but still very simple both in its use and implementation. The element is used like this:

  <xsl:if test="contains($the-world,'Elvis')">
    <xsl:message>Elvis is still alive!</xsl:message>
  </xsl:if>

The element's contents will only be executed if the test succeeds. There is no <xsl:else> element. One has to use either several <xsl:if>-elements or use a choose-element.

(top)

Implementation

The basic implementation is very simple:

There is onle type of function call that makes this a bit more complicated. The function-available() and element-available() function calls can be used to test for extension elements and functions. A very common use for these is to encapsulate all references to extension elements inside an <xsl:if> element and test for the existance of this element before attempting to use it. XSLTC has to support this. Otherwise we may risk either outputting erronuous error or warning messages about acessing non-existing elements, or even worse, compiling in calls to non-existing methods in the translet, causing the JVM's verifier to prevent the translet from being loaded.

The function-available() and element-available() functions have been updated to perform an evaluation at compile-time, so that the If class can know wether to compile in calls to extensions or not. This is possible because both functions take only literal expressions as parameters. See the getResult() methods of the FunctionAvailableCall and ElementAvailableCall classes for details.

(top)