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

📄 modes.xtp

📁 解压在c盘
💻 XTP
字号:
<s1 title="XSL Modes"><p>XSL modes are an advanced XSL feature.  Some pages need to evaluatethe same XML twice.  For example, a table of contents needs to createlists of the section titles, but the "normal" printing needs to outputthe section contents.<p>XSL adds <var/modes/> to process XML elements in different ways.If the stylesheet specifies the mode attribute in xsl:apply-templates,the XSL engine will only match templates with the matching mode.<p>The following example has two modes: the default mode and a"summary" mode.  The summary mode is used to generate a table ofcontents.  The &lt;summary/> tag creates the table of contents.  Itcalls xsl:apply-templates with the summary mode.  The only template insummary mode is a section template.  It will add items to the tableof contents.</p><example title='default.xsl'>&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">&lt;xsl:template match="section" mode="summary">  &lt;li>&lt;xsl:value-of select="@title"/>  &lt;xsl:if test="section">    &lt;ol>&lt;xsl:apply-templates mode="summary"/>&lt;/ol>  &lt;/xsl:if>&lt;/li>&lt;/xsl:template>&lt;xsl:template match="summary">&lt;ol>  &lt;xsl:apply-templates select="../section" mode="summary"/>&lt;/ol>&lt;/xsl:template>&lt;template match="section">&lt;/template>&lt;/xsl:stylesheet></example><p>To simplify the example, the template for &lt;section> doesnothing.  So only the summary will be generated from the XTP file.</p><example title='hello.xtp'>&lt;summary/>&lt;section title="First Section">Some text&lt;section title="Subsection A">Subtext&lt;/section>&lt;section title="Subsection B">Subtext&lt;/section>&lt;/section>&lt;section title="Second Section">Draft text&lt;/section></example><results>&lt;ol>  &lt;li>First Section  &lt;ol>    &lt;li>Subsection A&lt;/li>    &lt;li>Subsection B&lt;/li>  &lt;/ol>  &lt;/li>  &lt;li>Second Section&lt;/li>&lt;/ol></results><s2 title="Strict XSL"><p>The StyleScript equivalent shows how to add arbitrary attributesin a StyleScript function. <var/foo/>=><var/bar/> will set the value<var/bar/> to the attribute <var/foo/>.</p><example title='default.xsl'>$template(section, mode=>summary) &lt;&lt;&lt;li>$(@title)  $if (section) <<    &lt;ol>$apply-templates(mode=>summary);&lt;/ol>  >>&lt;/li>>>$template(summary) &lt;&lt;&lt;ol>  $apply-templates(../section, mode=>summary);&lt;/ol>>>$template(section) &lt;&lt;>></example></s2><s2 title="Summary"><ul><li><var/modes/> let stylesheets extract new formats from the same XML.<li><var/name=>value/> specifies named attributes in XTP.<li><var/$if/> conditionally evaluates part of a stylesheet.<li>The XPath pattern <var/../a/> selects all the siblings of a.</ul></s2></s1>

⌨️ 快捷键说明

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