📄 filter-attribute.xtp
字号:
<s1 title="Default Attributes with Filter Patterns"><p>XPath filter patterns can simplify default attributes. Instead of usingsome sort of <var/if/> pattern, an XPath pattern can match elements witha specific attribute. In the CSS class attribute example, thestylesheet can have separate templates for an example with a classattribute and one without it.<p>An XPath filter looks like <var/foo/>[<var/test/>]. The testexpression is evaluated with <var/foo/> as the context node. Thefollowing example uses <var/example/>[<var/@class/>] to match onlyexamples with class attributes.<p>The test expression can be any XPath expression. If it's a nodeexpression like @class, the filter will match if it can select anymatching node.</p><example title='default.xsl'><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="example"> <table class="example"> <tr> <td> <xsl:apply-templates/> </td> </tr> </table></xsl:template><xsl:template match="example[@class]"> <table class="{@class}"> <tr> <td> <xsl:apply-templates/> </td> </tr> </table></xsl:template></xsl:stylesheet></example><p>In the example stylesheet, an <example> tag will match thesecond template if it has a class attribute. It will match the firsttemplate if it has no class attribute.<p>The example XTP does not specify class, so the stylesheet willuse "example" as the default class.</p><example title='hello.xtp'><example>This is an example.</example></example><results><table class="example"><tr> <td>This is an example</td></tr></table></results><s2 title="Summary"><ul><li><var/foo/>[<var/test/>] is an XPath filter pattern.<li>Filter patterns match both the path and the filter expression.<li>If the filter is a selection path, it matches if it selects any node.</ul></s2></s1>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -