XSLT <xsl:when> Element
Complete XSLT Element Reference
Definition and Usage
The <xsl:when> element is used to specify an action for the <xsl:choose> element. The <xsl:when> element evaluates an expression, and if it returns true, the specified action is performed.
Note: The <xsl:when> element is used in conjunction with the <xsl:choose> and <xsl:otherwise> elements to express multiple conditional tests.
Syntax
<xsl:when
test="boolean-expression">
</xsl:when>Attributes
| Attribute | Value | Description |
|---|---|---|
| test | boolean-expression | Required. Specifies the boolean expression to be tested. |
Example 1
The following code will add a pink background color to the artist column when the price of the cd is higher than 10.
My CD Collection
Title
Artist
View XML file, view XSL file, view result.
Example 2
Declared a variable named "color". Assign its value to the color attribute of the current element. If the current element does not have a color attribute, then the value of "color" will be "green":
<xsl:variable name="color">
<xsl:choose>
<xsl:when test="@color">
<xsl:value-of select="@color"/>
</xsl:when>
<xsl:otherwise>green</xsl:otherwise>
</xsl:choose>
</xsl:variable>Complete XSLT Element Reference Manual
XSLT Examples
XSLT Functions
Byte Ark Coding Plan
Supports mainstream large models including Doubao, GLM, DeepSeek, Kimi, MiniMax, etc., with official direct supply for stable and reliable service.
Β₯9.9 / month Subscribe Now
iFlytek Star Coding Plan
Includes free model call quota, DeepSeek, GLM, Kimi, MiniMax, one-stop experience and deployment platform.
Β₯3.9 / month Subscribe Now
Category Navigation
- Python / Data Science
- AI / Intelligent Development
- Front-end Development
- Back-end Development
- Databases
- Mobile Development
- DevOps / Engineering
- Programming Languages
- Computer Fundamentals
- XML / Web Service
- .NET
- Website Building
Advertisement
XSLT Tutorial
XSLT Tutorial
XSL Language
XSLT Introduction
XSLT Browsers
XSLT Transformation
XSLT Online Examples
- HTML Examples
- CSS Examples
- JavaScript Examples
- Ajax Examples
- jQuery Examples
- XML Examples
- Java Examples
Character Sets & Tools
- HTML Character Set Settings
- HTML ASCII Character Set
- JS Obfuscation/Encryption
- PNG/JPEG Image Compression
- HTML Color Picker
- JSON Formatter Tool
- Random Number Generator
Latest Updates
- docker compose ...
- GraphRAG Getting Started Tutorial
- Dart Enums and Symbols
- Dart Unit Testing
- Dart Concurrency and Iso...
- Dart Stream
- Dart Asynchronous Programming
Site Information
- Feedback
- Disclaimer
- About Us
- Article Archive
Follow WeChat
YouTip