To add an xsl:choose statement using the context menu:

  1. Right-click the target node and select Add XSL Instruction -> choose from the context menu that appears.

    A choose statement is added as the parent node of the target node along with an xsl:when statement. Figure 41-15 shows the result of adding the xsl:choose statement to the AccountNumber node.

    Figure 41-15 Adding an xsl:choose Statement

    Description of Figure 41-15 follows
    Description of "Figure 41-15 Adding an xsl:choose Statement"

    An xsl:choose statement can contain multiple xsl:when statements followed by an optional xsl:otherwise statement.

  2. To add an xsl:otherwise node to the xsl:choose node, right-click xsl:choose in the target tree and select Add XSL Instruction -> otherwise from the context menu that appears.

    Figure 41-16 shows the result of adding the xsl:otherwise statement to the xsl:choose statement. Note that the AccountNumber node is copied to each section of the xsl:choose statement.

    Figure 41-16 Adding an xsl:otherwise Statement to an xsl:choose Statement

    Description of Figure 41-16 follows
    Description of "Figure 41-16 Adding an xsl:otherwise Statement to an xsl:choose Statement"
  3. Map the xsl:when node to the source node whose existence is to be tested. In our current example, you drag a line from the HQAccount node in the source to the xsl:when node in the target.

  4. Map the xsl:when and xsl:otherwise cases. In the current example, you drag a line from the HQAccount/AccountNumber node to the xsl:choose/xsl:when/AccountNumber node. Similarly, you drag a line from the BranchAccount/AccountNumber node to the xsl:choose/xsl:otherwise/AccountNumber node.

    Figure 41-17 shows the completed xsl:choose construct.

    Figure 41-17 Sample xsl:choose Construct

    Description of Figure 41-17 follows
    Description of "Figure 41-17 Sample xsl:choose Construct"