-- Learning is not only technology, but also dreams!
- Home
- HTML
- JAVASCRIPT
- CSS
- VUE
- REACT
- PYTHON3
- JAVA
- C
- C++
- C#
- AI
- GO
- SQL
- LINUX
- VS CODE
- BOOTSTRAP
- GIT
- Local Bookmark
XSLT Tutorial
- XSLT Tutorial
- XSL Language
- XSLT Introduction
- XSLT Browser
- XSLT Transformation
- XSLT
- XSLT
- XSLT
- XSLT
- XSLT
- XSLT
- XSLT Apply
- XSLT Client-side
- XSLT Server-side
- XSLT Edit XML
- XML Editor
- XSLT Summary
- XSLT Examples
XSLT Elements
XSLT Functions
XSLT Transformation Tools
XSLT Examples
XSLT Functions
Explore More
- Network
- Programming
- Computer Science
- Network Services
- Software
- Development Tools
- Web Service
- Script
- Search
- Web Design & Development
XSLT Element
Complete XSLT Element Reference Manual
Definition and Usage
The element specifies the default behavior of the element. This behavior occurs when none of the conditions apply.
Syntax
<xsl:otherwise>
<!-- Content:template -->
</xsl:otherwise>
Attributes
None
Example 1
The following code will add a pink background color to the artist column if the price of the cd is higher than 10, otherwise it will just output the name of the artist:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<tr>
<td><xsl:value-of select="title"/></td>
<xsl:choose>
<xsl:when test="price>'10'">
<td bgcolor="#ff00ff">
<xsl:value-of select="artist"/></td>
</xsl:when>
<xsl:otherwise>
<td><xsl:value-of select="artist"/></td>
</xsl:otherwise>
</xsl:choose>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
View XML file, View XSL file, View Result.
Example 2
Declare 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, 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
ByteArk Coding Plan
Supports mainstream large models such as Doubao, GLM, DeepSeek, Kimi, MiniMax, etc., directly supplied by the official for stable and reliable service.
Β₯9.9 / month
Xunfei Starry Coding Plan
Includes free model call quota, one-stop experience and deployment platform with DeepSeek, GLM, Kimi, MiniMax.
Β₯3.9 / month
Category Navigation
- Python / Data Science
- AI / Intelligent Development
- Front-end Development
- Back-end Development
- Database
- Mobile Development
- DevOps / Engineering
- Programming Languages
- Computer Basics
- XML / Web Service
- .NET
- Website Construction
Advertisement
XSLT Tutorial
XSLT Tutorial
XSL Language
XSLT Introduction
XSLT Browser
XSLT Transformation
XSLT
Online Examples
- HTML Examples
- CSS Examples
- JavaScript Examples
- Ajax Examples
- jQuery Examples
- XML Examples
- Java Examples
Character Set & 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 Streams
- Dart Asynchronous Programming
Site Information
Follow WeChat
My Favorites
Browsing History
No Records
YouTip