⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 if-attribute.xtp

📁 解压在c盘
💻 XTP
字号:
<s1 title="Default Attributes with xsl:if"><p>Often, elements should have a default attribute value if none isspecified in the XTP file.  An &lt;example> tag might have a default CSSclass of "example", but let the XTP change the default.  In a template,xsl:if will conditionally produce XML depending on an XPath expression.<p>The following example adds the class attribute to the tabledepending on the class value in the &lt;box> element.  If the XTP filespecifies the class, the stylesheet will use it.  The the XTP file doesn'tspecify the class, the stylesheet will use "example" as a default.</p><example title='default.xsl'>&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">&lt;xsl:template match="example">  &lt;table>    &lt;xsl:attribute name="class">      &lt;xsl:if test="@class">        &lt;xsl:value-of select="@class"/>      &lt;/xsl:if>      &lt;xsl:if test="not(@class)">example&lt;/xsl:if>    &lt;/xsl:attribute>    &lt;tr>      &lt;td>        &lt;xsl:apply-templates/>      &lt;/td>    &lt;/tr>  &lt;/table>&lt;/xsl:template>&lt;/xsl:stylesheet></example><p>The example XTP does not specify class, so the stylesheet willuse "example" as the default class.</p><example title='hello.xtp'>&lt;example>This is an example.&lt;/example></example><results>&lt;table class="example">&lt;tr>  &lt;td>This is an example&lt;/td>&lt;/tr>&lt;/table></results><s2 title="StyleScript"><p>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.</p><example title='default.xsl'>$template(example) &lt;&lt;&lt;table>  $attribute("class") &lt;&lt;    $if(@class) &lt;&lt;@class>>    $else &lt;&lt;example>>  >>&lt;tr>  &lt;td>    $apply-templates();  &lt;/td>&lt;/tr>&lt;/table>>></example></s2><s2 title="Summary"><ul><li><var/xsl:if/> evaluates conditionally.<li><var/not(expr)/> negates a boolean.</ul></s2></s1>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -