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 232.

Figure 232. 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 233. 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.

Java XML Parser

Stylus Studio's support for Java XML Parser is able to Validate XML Using any Java XML Parser, Edit, Debug, Profile and Map XSLT using any Java XSLT Processor, Create PDF files Using Apache FOP, hand have Support for Microsoft XML Parsers as well.

Internet & eBusiness

Internet & eBusiness

MSXML - Microsoft XML Tools

MSXML tools in Stylus Studio feature integrated XML validation, XSLT transformation and XSLT debugging using the Microsoft's COM-based XML processing components: MSXML 3.0, MSXML 4.0 and MSXML 6.0

Learn XML

Learning XML is easy with Stylus Studio. Check out our free XML tutorials, XML whitepapers, online video demonstrations, XML examples and XML references and more.

Stylus Most Wanted

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.