XSLT <xsl:otherwise> ਅੰਗ
ਵਿਆਖਿਆ ਅਤੇ ਵਰਤੋਂ
<xsl:otherwise> ਅੰਗ ਨੇ <xsl:choose> ਅੰਗ ਦੀ ਮੂਲਤਬੀ ਵਿਵਹਾਰ ਨਿਰਧਾਰਤ ਕਰਦਾ ਹੈ। ਜਦੋਂ ਕੋਈ <xsl:when> ਪ੍ਰਕਾਰ ਨਹੀਂ ਲਾਗੂ ਹੁੰਦਾ ਹੈ ਤਾਂ ਇਹ ਵਿਵਹਾਰ ਲਾਗੂ ਹੁੰਦਾ ਹੈ。
ਗਰੰਥ
<xsl:otherwise> <!-- Content:template --> </xsl:otherwise>
ਵਿਸ਼ੇਸ਼ਤਾ
ਕੋਈ ਨਹੀਂ
ਮਾਡਲ
ਉਦਾਹਰਣ 1
ਹੇਠ ਦਾ ਕੋਡ ਸਿਰਫ ਜਦੋਂ cd ਦੀ ਕੀਮਤ 30 ਤੋਂ ਉੱਪਰ ਹੋਵੇ ਤਾਂ artist ਲਈ ਗੁਲਾਬੀ ਰੰਗ ਦਾ background color ਦੇਣਗੇ ਹੈ ਅਤੇ ਨਾਲ ਹੀ ਸਿਰਫ artist ਦਾ name ਹੀ ਦਿਖਾਵੇਗਾ:
<?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>
ایکس ایم ال فائل کو دیکھئے،ایکس ایس ل فائل کو دیکھئے،نتائج کو دیکھئے。
مثال 2
ایک نام 'color' والی متغیر کا اعلان کریں. اس کا مرتبہ موجود عنصر کی color اٹیب کو دینا ہوگا. اگر موجود عنصر کی color اٹیب نہیں ہوگی تو 'color' کا مرتبہ 'گرین' ہوگا:
<xsl:variable name="color"> <xsl:choose> <xsl:when test="@color"> <xsl:value-of select="@color"/> </xsl:when> <xsl:otherwise>گرین</xsl:otherwise> </xsl:choose> </xsl:variable>