解压在c盘

源代码在线查看: if-attribute.xtp

软件大小: 4683 K
上传用户: xufengping716
关键词: 解压
下载地址: 免注册下载 普通下载 VIP

相关代码

												Often, elements should have a default attribute value if none is				specified in the XTP file.  An <example> tag might have a default CSS				class of "example", but let the XTP change the default.  In a template,				xsl:if will conditionally produce XML depending on an XPath expression.								The following example adds the class attribute to the table				depending on the class value in the <box> element.  If the XTP file				specifies the class, the stylesheet will use it.  The the XTP file doesn't				specify the class, the stylesheet will use "example" as a default.												<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">								<xsl:template match="example">				  <table>				    <xsl:attribute name="class">				      <xsl:if test="@class">				        <xsl:value-of select="@class"/>				      </xsl:if>				      <xsl:if test="not(@class)">example</xsl:if>				    </xsl:attribute>				    <tr>				      <td>				        <xsl:apply-templates/>				      </td>				    </tr>				  </table>				</xsl:template>								</xsl:stylesheet>												The example XTP does not specify class, so the stylesheet will				use "example" as the default class.												<example>				This is an example.				</example>												<table class="example">				<tr>				  <td>This is an example</td>				</tr>				</table>																				StyleScript's $if uses the test expression for its first argument.				If the expression is true, the block is used as a value.   If false,				the block after the $else will be used for the value.												$template(example) <<				<table>				  $attribute("class") <<				    $if(@class) <<@class>>				    $else <<example>>				  >>				<tr>				  <td>				    $apply-templates();				  </td>				</tr>				</table>				>>																																 evaluates conditionally.				 negates a boolean.																							

相关资源