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

📄 ref.xtp

📁 resinweb服务器源文件
💻 XTP
📖 第 1 页 / 共 2 页
字号:
<example>&lt;xsl:attribute-set name='font'>  &lt;xsl:attribute name='font-size'>12pt&lt;/xsl:attribute>  &lt;xsl:attribute name='font-weight'>bold&lt;/xsl:attribute>&lt;/xsl:attribute-set>&lt;xsl:template match='a'>  &lt;c xsl:use-attribute-sets='font'/>&lt;/xsl:template></example><results>&lt;c font-size='12pt' font-weight='bold'/></results></defun><defun name=pi title='&lt;xsl:processing-instruction&gt;'><p>Creates a new processing instruction.</p><deftable><tr><th>Attribute<th>Meaning<tr><td>name<td>Processing instruction name.</deftable><example>&lt;xsl:template match='a'>  &lt;xsl:processing-instruction name='foo'>  &lt;xsl:text>Text for the PI&lt;/xsl:text>  &lt;/xsl:processing-instruction/>&lt;/xsl:template></example><results>&lt;?foo Text for the PI?></results></defun><defun name=comment title='&lt;xsl:comment&gt;'><p>Creates a new comment.  The contents of the xsl:comment elementbecome the contents of the comment.</p><example>&lt;xsl:template match='a'>  &lt;xsl:comment>  &lt;xsl:text>Text for the comment&lt;/xsl:text>  &lt;/xsl:processing-instruction/>&lt;/xsl:template></example><results>&lt;!--Text for the comment--></results></defun><defun name=copy title='&lt;xsl:copy&gt;'><p>Copies the current node, but not children or attributes, to theoutput.</p> <p>To copy an element, a stylesheet must copy the attributes as well.<p>The following example is the identity stylesheet. It copies inputto the output including the attributes.</p><example>&lt;xsl:template match='@*|node()'>  &lt;xsl:copy>    &lt;xsl:apply-templates select='@*|node()'/>  &lt;/xsl:copy>&lt;/xsl:template></example></defun><defun name=copy-of title='&lt;xsl:copy-of .../&gt;'><p>Copies a sub-tree into the output.  <code/copy-of/> resembles<code/value-of/>.  <code/value-of/> always converts the value to astring.  <code/copy-of/> will copy subtrees. </p><deftable><tr><th>attribute<th>meaning<tr><td>select<td>An XPath expression to be copied.</deftable></defun><defun name=variable title='&lt;xsl:variable&gt;'><p>Assignes an XSL variable.  Variables can be retrieved usingthe XPath variable syntax.</p><deftable><tr><th>Attribute<th>Meaning<tr><td>name<td>variable name<tr><td>select<td>variable value</deftable><example>&lt;xsl:variable name='foo' select='1+1'/>&lt;xsl:template match='a'>  &lt;xsl:value-of select='$foo'/>&lt;/xsl:template></example><results>2</results></defun><defun name=call-template title='&lt;xsl:call-template&gt;'><p>Calls a named template with the current node.<code/xsl:call-template/> lets stylesheets reuse common code, likefunctions.  It works like <code/xsl:apply-templates select='.'/>except that it calls based on a template name.</p><deftable><tr><th>Attribute<th>Meaning<tr><td>name<td>template name to call<tr><td>mode<td>template mode</deftable></defun><defun name=param title='&lt;xsl:param&gt;'><p>Declares an XSL parameter.  <code/xsl:param/>'s<code/select/> parameter as a default.  If the variable has beenassigned, it uses the old value.</p><deftable><tr><th>Attribute<th>Meaning<tr><td>name<td>variable name<tr><td>select<td>variable value</deftable><example>&lt;xsl:template name='fun'>  &lt;xsl:param name='foo' select='15'/>  &lt;xsl:value-of select='$foo'/>&lt;/xsl:template>&lt;xsl:template match='a'>  &lt;xsl:call-template name='foo'>    &lt;xsl:with-param name='foo' select='1+2'/>  &lt;/xsl:call-template>&lt;/xsl:template></example><results>3</results></defun><defun name=apply-imports title='&lt;xsl:apply-imports&gt;'><p>Like Java's <code/super/>, calls the overridden template.</p></defun><defun name=sort title='&lt;xsl:sort&gt;'><p>Sorts nodes in xsl:apply-templates orxsl:for-each.</p><deftable><tr><th>Attribute<th>Meaning<tr><td>select<td>value to sort on (default = '.')<tr><td>order<td>ascending or descending  (default = ascending)<tr><td>data-type<td>text or number (default = text)</deftable><note>case-order is not implemented</note></defun><defun name=choose title='&lt;xsl:choose ...&gt; ...'><p>Implements an if-elsif-else block.  The <code/xsl:when/>statements are tested in order.  The first matching one is executed.If none match, the <code/xsl:otherwise/> block is executed.</p><deftable><tr><th>Attribute<th>Meaning<tr><td>test<td>XPath expression evaluating to a boolean.</deftable><example>&lt;xsl:template match='a'>  &lt;xsl:choose>  &lt;xsl:when test='@color="red"'>    &lt;xsl:text>stop&lt;/xsl:text>  &lt;/xsl:when>  &lt;xsl:when test='@color="green"'>    &lt;xsl:text>go&lt;/xsl:text>  &lt;/xsl:when>  &lt;xsl:otherwise>    &lt;xsl:text>yield&lt;/xsl:text>  &lt;/xsl:otherwise>  &lt;/xsl:choose>&lt;/xsl:template></example></defun></s2><s2 title='Resin extensions'><!--<defun name=copy-element title='&lt;xtp:copy-element&gt;' version='resin1.0'><p>Copies the element to the output.</p><p><code/xtp:copy-element/> is extremely useful as a default rule.With <code/xtp:copy-element/> as the default, the input gets copied tothe output.  Using the usual default, all tags get stripped.<p>The standard default rule produces the following,</p><example>&lt;a&gt;A text&lt;/a&gt;&lt;b&gt;B text&lt;/b&gt;</example><results>A textB text</results><p>Using <code/xtp:copy-element/>, XSL stylesheets can copy elementsit doesn't understand.</p><example>&lt;xsl:template match='*'&gt;  &lt;xtp:copy-element&gt;    &lt;xsl:apply-templates/&gt;  &lt;/xtp:copy-element&gt;&lt;/xsl:template&gt;</example><example>&lt;a&gt;A text&lt;/a&gt;&lt;b&gt;B text&lt;/b&gt;</example><results>&lt;a&gt;A text&lt;/a&gt;&lt;b&gt;B text&lt;/b&gt;</results></defun>--><defun name=expression title='&lt;xtp:expression>expression ...'       version='resin1.0'><p>Executes <var/expression/> and prints it to the output. Stylesheets can use any JavaScript expression.  The followingvariables are pre-defined in stylesheets.</p><deftable><tr><th>Variable<th>Meaning<tr><td>node<td>The current org.w3c.dom.Node.<tr><td>out<td>The com.caucho.xsl.XslWriter.</deftable><p>In addition, the <var/out/> variable gives access to the servletPageContext with the <var/page/> property.</p><example>&lt;xsl:template match='welcome-user'&gt;  &lt;xsl:text>Welcome back, &lt;/xsl:text>  &lt;xtp:expression>    out.page.session.value.user  &lt;xtp:expression>&lt;/xsl:template&gt;</example></defun><defun name=scriptlet title='&lt;xtp:scriptlet> statement_list'       version='resin1.0'><p>Executes the <var/statement_list/> scriptlet.  TheJavaScript code can be any statement list.  The same implicitvariables are allowed in scriptlets as in expressions.</p><p>The following example creates a number of stars:<example>&lt;@# page language='javascript' #>&lt;xsl:template match='ct:stars'&gt;  &lt;xtp:scriptlet&gt;    for (var i = 0; i < node.attribute.count; i++)      out.write('*');  &lt;/xtp:scriptlet&gt;&lt;/xsl:template&gt;</example><example>1 = &lt;ct:stars count='1'/><br>9 = &lt;ct:stars count='9'/><br></example><results>1 = *9 = *********</results></defun><defun name=declaration title='&lt;xtp:declaration>'       index='declaration'><p>Adds declaration code, i.e. code outside of any function.</p><example>&lt;xtp:declaration>function dist(x1, y1, x2, y2){  return Math.sqrt((x1 - x2) * (x1 - x2) +                   (y1 - y2) * (y1 - y2));}&lt;/xtp:declaration></example></defun><defun name=page title='&lt;xtp:directive.page attributes />'><p>Sets page directives.</p><deftable><tr><th>name<th>meaning<tr><td>language<td>script language, default Java<tr><td>session<td>use sessions, default false<tr><td>errorPage<td>page to display for errors<tr><td>errorPage<td>page to display for errors<tr><td>import<td>imports Java packages <tr><td>contentType<td>content-type of the generated page</deftable></defun><!--<defun name=cache title='&lt;xtp:directive.cache attributes/>'><p>Caches the generated JSP file by default.</p><p>Caching for XSL is more complicated than for JSP because only sometemplates may be used in a page.  Caching is based on the generatedpage, not simply on the stylesheet.<p/>A page that just uses statictemplates is automatically cached.  Pages that use scripts just forsimple calculation can also be cached.  But pages that use scriptsbased on the request cannot be cached.<deftable><tr><th>name<th>meaning<tr><td>file<td>the JSP file depends on <var/file/>.<tr><td>no-cache<td>do not cache the generated JSP.</deftable></defun>--></s2></s1>

⌨️ 快捷键说明

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