HTML XSLT <xsl:choose> ສະມາຊິກ
ການກໍານົດ ແລະ ການນຳໃຊ້
ປະກອບ <xsl:choose> ກັບ <xsl:when> ແລະ <xsl:otherwise> ທີ່ສາມາດສະແດງການກວດສອບຂໍ້ມູນຄວາມງາມຫຼາຍກວ່ານັ້ນ.
ຖ້າບໍ່ມີ <xsl:when> ທີ່ true, ຈະກະທຳຂອງ <xsl:otherwise>.
ຖ້າບໍ່ມີ <xsl:when> ທີ່ true ແລະບໍ່ມີ <xsl:otherwise> ເປັນສະຖານດິນຂອງລະບຸ, ຈະບໍ່ສ້າງເນື້ອຫຼັກໃດ.
ຄຳແນະນຳ:ຄຳແນະນຳ: ສຳລັບການການກວດສອບຂໍ້ມູນຄວາມງາມຫຼາຍກວ່ານັ້ນໃຊ້ <xsl:if> ກ່ຽວກັບ.
ການນຳໃຊ້
<xsl:choose> <!-- Content:(xsl:when+,xsl:otherwise?) --> </xsl:choose>
ປະກອບສ່ວນ
ບໍ່ມີ
ການຕິດຕາມ
ຄູ່ມື 1
ເລື່ອງການຂຽນລະບຸວ່າ CD ມີລາຄາກວ່າ 10 ຈະສ້າງແບບຖານຫຼັງ 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>
ບັນທຶກ XML, XSL, ເບິ່ງຜົນ
ຕົວຢ່າງ 2
ການຖະແຫຼງຊະນວນວ່າ "color". ຄວາມທີ່ມີຂອງຊະນວນນີ້ຈະຕິດຕັ້ງໃຫ້ປະສົມປະກອບ current ສຳລັບບັນດາບາງຄະນະ color. ຖ້າປະສົມປະກອບ current ບໍ່ມີບາງຄະນະ color, ຄວາມທີ່ມີຂອງ color ��� "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>