if.xtp

来自「resinweb服务器源文件」· XTP 代码 · 共 71 行

XTP
71
字号
<title>XTP: xsl:if</title><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;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><example title='hello.xtp'><example>&lt;example class="special-example">This is an example.&lt;/example></example><results>&lt;table class="special-example">&lt;tr>  &lt;td>This is an example&lt;/td>&lt;/tr>&lt;/table></results></example><section title="StyleScript"><example title='default.xsl'>$template(example) &lt;&lt;&lt;table>  $attribute("class") <<$(if(@class,@class,"example"))>>&lt;tr>  &lt;td>    $apply-templates();  &lt;/td>&lt;/tr>&lt;/table>>></example></section><section title="Summary"><ul><li>Tags in stylesheets are parsed, not raw text.  So you can add attributesto elements.<li><var/$attribute(my-name)/> adds an attribute to an element.<li><var/$attribute(my-name)/> expands to <var/xsl:attribute name="my-name"/>.<li>The XPath pattern <var/if(test,if-true,if-false)/> selects a valuebased on a boolean.<li><var/if(test,if-true,if-false)/> is a Resin extension.<li><var/xsl:if/> evaluates conditionally.</ul></section>

⌨️ 快捷键说明

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