📄 apply-templates.xtp
字号:
<s1 title="xsl:apply-templates"><p>Most stylesheet templates generate HTML elements with content.The previous Hello, World example just replaced an empty tag <hello>with some text. Any content of the <hello> tag was ignored.XSL uses <xsl:apply-templates> to evaluate the children of an element.<p>The following stylesheet creates a <note> tag whose content isevaluated using the normal XSL processing. In the example,every <note> tag is replaced with "Note: " and emphasizes thecontents of the tag.</p><example title='default.xsl'><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="note"> <xsl:text>Note: </xsl:text> <em> <xsl:apply-templates/> </em></xsl:template><xsl:template match="hello"> <xsl:text>Hello, World!</xsl:text></xsl:template></xsl:stylesheet></example><p>Since the XSL engine will evaluate the contents of the <note>,it will replace the <hello> from the previous example withthe "Hello, World" text. By creating tags like <note>, you canchange the look of a page or an entire site by changing the stylesheet.All the <note> instances will be automatically reformatted. With Serif,you can modify the stylesheet and immediately browse the site to see howit looks. The feedback is immediate.</p><example title='hello.xtp'>This is a plain, old description.<note>The first example is <hello/></note></example><results>This is a plain, old description.Note: <em>The first example is Hello, world!</em></results><s2 title="StyleScript equivalent"><p>The StyleScript equivalent is <var/$apply-templates();/>. The functionnotation, $<var/foo/>() expands to an xsl:<var/foo/> element. The ';'tells StyleScript that the tag is empty. For a tag with contents, use <var/<<...>>/>.</p><example title='default.xsl'>$template(note) <<Note: <em>$apply-templates();</em>>>$template(hello) <<Hello, World!>></example></s2><s2 title="Summary"><ul><li><var/xsl:apply-templates/> processes the current node's children.<li>You can add tags, like <var/<em>/>, directly to the stylesheet.<li><var/$apply-templates();/> expands to <var/<xsl:apply-templates/>/></ul></s2></s1>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -