xsl:if and xsl:choose

The xsl:if instruction cannot express an else condition. It has a single input port, and a single output port, as shown in Figure 244.

Figure 244. xsl:if Instruction Block

Once fully defined, the xsl:if block generates code like the following:

<Review>
               
	<xsl:if test="authors/author= 'Minollo'">
               
		<xsl:value-of select="'Recommended'"/>
               
	</xsl:if>
               
	<xsl:if test="contains(authors/author,'Pedruzzi')">
               
		<xsl:value-of select="'A best buy'"/>
               
	</xsl:if>
               
</Review>
               

            

If you need to express an else condition, use the xsl:choose instruction block. This instruction block has two output ports by default, one for the xsl:when test= attribute, and one for the one xsl:otherwise element.

Figure 245. xsl:choose Instruction Block

The xsl:choose instruction block generates code like the following:

<Review>
               
	<xsl:choose>
               
		<xsl:when test="authors/author= 'Minollo'">
               
			<xsl:value-of select="'Recommended'"/>
               
		</xsl:when>
               
		<xsl:when test="contains(authors/author,'Pedruzzi')">
               
			<xsl:value-of select="'authors best buy'"/>
               
		</xsl:when>
               
		<xsl:otherwise>
               
			<xsl:value-of select="'bah...'"/>
               
		</xsl:otherwise>
               
	</xsl:choose>
               
</Review>
               

            

If you need to define more than one xsl:when test= attribute, use the xsl:choose shortcut menu (right click) and select Add When Port.

Note

 

Stylus Studio generates the xsl:otherwise element by default for all xsl:choose instructions.

XML Unicode Encoding

Stylus Studio supports over 300 different file encodings, including UTF-8, UTF-16, EUC-JP, SHIFT-JIS, and more, alowing you to work with any XML document. Robust text editors support standard editing features, and Sense:X intelligent auto-completion.

Convert DTD to XSD

learn how to convert DTD to XML Schema

Sybase

Sybase Adaptive Server Enterprise (ASE) is a powerful high-performance database for recording and retrieving business records. Learn how to develop XML applications for Sybase using Stylus Studio.

Java Web Services

Stylus Studio's Web Service Call Composer simplifies Java Web Service development by making it easy to find, invoke, and test any Java Web Service deployed on any popular Java Web Service framework, such as Apache AXIS.

Stylus Most Wanted

 
Free Stylus Studio XML Training:
W3C Member