XSLT <xsl:when> అంశం
నిర్వచనం మరియు వినియోగం
<xsl:when> అంశం <xsl:choose> అంశానికి సంబంధించిన చర్యను నిర్దేశిస్తుంది.
<xsl:when> అంశం ఒక అభివ్యక్తిని గణిస్తుంది, అనునది true ఉన్నప్పుడు నిర్దేశించిన చర్యను నిర్వహిస్తుంది.
ప్రకారం:<xsl:when> అంశం <xsl:choose> అంశం మరియు <xsl:otherwise> అంశాలతో సంబంధించిన పరిస్థితులను పరీక్షిస్తుంది.
వినియోగం
<xsl:when test="boolean-expression"> <!-- Content: template --> </xsl:when>
అనునాయకం
అనునాయకం | విలువ | వివరణ |
---|---|---|
పరీక్షించు | boolean-expression | అవసరం. పరీక్షించవలసిన బౌలియన్ అభివ్యక్తిని నిర్దేశిస్తుంది. |
ప్రకారం
ఉదాహరణ 1
దిగువ కోడ్ సిడీ యొక్క price అధికంగా 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> <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:choose>