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