Latest web development tutorials

XSLT <XSL : 경우> 요소

<xsl : if> 요소는 XML 파일 내용에 대한 조건부 검사를 배치하는 데 사용됩니다.


<XSL : 경우> 요소

XML 파일의 내용을 검사하기위한 조건을 배치 <XSL : 경우>는 XSL 문서를 추가 소자.

문법

<xsl:if test="expression">
...如果条件成立则输出...
</xsl:if>


요소 : 여기서 <경우 XSL>를 배치

XSL 파일에서 조건부 테스트를 추가하려면 <xsl : for-each> 요소는 내부에 추가됩니다 <XSL : 경우> 요소 :

<?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">
<xsl:if test="price &gt; 10">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>

</xsl:stylesheet>

»시도

참고 : 테스트속성의 값은 식을 평가하는 중요한 필요성을 포함합니다.

위의 코드 것 CD 타이틀 및 아티스트 소자 (10)보다 더 높은 전용 출력 가격.