xsl:otherwise

Syntax

<xsl:otherwise>
     Template-Body
</xsl:otherwise>


Postition

innerhalb des <xsl:choose> Elements


Attribute
keine

<xsl:otherwise>

erlaubt die Ausführung des Template-Bodys nur dann, wenn keine der Bedingungen zutreffen, die innerhalb des <xsl:choose> Elements mit <xsl:when> definiert worden sind.


Definition

XSLT Kapitel 9.2


Beispiel

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
<xsl:output method="html"/>
    
<xsl:template match="/">
     <HTML>
          <HEAD>
               <TITLE>Element: &lt;xsl:otherwise&gt; / Beispiel 01</TITLE>
          </HEAD>
          <BODY>
               <xsl:apply-templates select="shop"/>
          </BODY>
     </HTML>
</xsl:template>

<xsl:template match="shop">
     <TABLE BORDER="1">
          <TR>
               <TH WIDTH="150">Artikel:</TH>
               <TH WIDTH="150">Auswahl:</TH>
               <TH WIDTH="100">Preis:</TH>
          </TR>
          <xsl:apply-templates select="order/product"/>
     </TABLE>
</xsl:template>

<xsl:template match="product">
     <TR>
          <TD><xsl:value-of select="name"/></TD>
          <TD ALIGN="RIGHT">
               <xsl:for-each select="variation/color">
                    <xsl:if test="@selected='true'">
                         <xsl:choose>
                              <xsl:when test="@name='yellow'">
                                   <xsl:text>gelb</xsl:text>
                              </xsl:when>
                              <xsl:when test="@name='red'">
                                   <xsl:text>rot</xsl:text>
                              </xsl:when>
                              <xsl:when test="@name='blue'">
                                   <xsl:text>blau</xsl:text>
                              </xsl:when>
                              <xsl:otherwise>
                                   <xsl:value-of select="@name"/>
                              </xsl:otherwise>
                         </xsl:choose>
                    </xsl:if>
               </xsl:for-each>
          </TD>
          <TD ALIGN="RIGHT">
               <xsl:value-of select="price"/>
               <xsl:text> </xsl:text>
               <xsl:value-of select="currency"/>
          </TD>
     </TR>
</xsl:template>
    
</xsl:stylesheet>


© 2001 by Timo Schäfer