📄 xsl.xtp
字号:
<xsl:template match='a'> <c xsl:use-attribute-sets='font'/></xsl:template></example><results><c font-size='12pt' font-weight='bold'/></results></example></defun><defun name=pi title='<xsl:processing-instruction>'><sum>Creates a new processing instruction.</sum><deftable><tr><th>Attribute<th>Meaning<tr><td>name<td>Processing instruction name.</deftable><example><example><xsl:template match='a'> <xsl:processing-instruction name='foo'> <xsl:text>Text for the PI</xsl:text> </xsl:processing-instruction/></xsl:template></example><results><?foo Text for the PI?></results></example></defun><defun name=comment title='<xsl:comment>'><sum>Creates a new comment.</sum> The contents of the xsl:comment elementbecome the contents of the comment.<example><example><xsl:template match='a'> <xsl:comment> <xsl:text>Text for the comment</xsl:text> </xsl:processing-instruction/></xsl:template></example><results><!--Text for the comment--></results></example></defun><defun name=copy title='<xsl:copy>'><sum>Copies the current node, but not children or attributes, to theoutput.</sum> <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.<example><example><xsl:template match='@*|node()'> <xsl:copy> <xsl:apply-templates select='@*|node()'/> </xsl:copy></xsl:template></example></example></defun><defun name=copy-of title='<xsl:copy-of .../>'><sum>Copies a sub-tree into the output.</sum> <code/copy-of/> resembles<code/value-of/>. <code/value-of/> always converts the value to astring. <code/copy-of/> will copy subtrees. <deftable><tr><th>attribute<th>meaning<tr><td>select<td>An XPath expression to be copied.</deftable></defun><defun name=variable title='<xsl:variable>'><sum>Assignes an XSL variable.</sum> Variables can be retrieved usingthe XPath variable syntax.<deftable><tr><th>Attribute<th>Meaning<tr><td>name<td>variable name<tr><td>select<td>variable value</deftable><example><example><xsl:variable name='foo' select='1+1'/><xsl:template match='a'> <xsl:value-of select='$foo'/></xsl:template></example><results>2</results></example></defun><defun name=call-template title='<xsl:call-template>'><sum>Calls a named template with the current node.</sum><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.<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='<xsl:param>'><sum>Declares an XSL parameter.</sum> <code/xsl:param/>'s<code/select/> parameter as a default. If the variable has beenassigned, it uses the old value.<deftable><tr><th>Attribute<th>Meaning<tr><td>name<td>variable name<tr><td>select<td>variable value</deftable><example><example><xsl:template name='fun'> <xsl:param name='foo' select='15'/> <xsl:value-of select='$foo'/></xsl:template><xsl:template match='a'> <xsl:call-template name='foo'> <xsl:with-param name='foo' select='1+2'/> </xsl:call-template></xsl:template></example><results>3</results></example></defun><defun name=apply-imports title='<xsl:apply-imports>'><sum>Like Java's <code/super/>, calls the overridden template.</sum></defun><defun name=sort title='<xsl:sort>'><sum>Sorts nodes in xsl:apply-templates orxsl:for-each.</sum><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='<xsl:choose ...> ...'><sum>Implements an if-elsif-else block.</sum> 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.<deftable><tr><th>Attribute<th>Meaning<tr><td>test<td>XPath expression evaluating to a boolean.</deftable><example><example><xsl:template match='a'> <xsl:choose> <xsl:when test='@color="red"'> <xsl:text>stop</xsl:text> </xsl:when> <xsl:when test='@color="green"'> <xsl:text>go</xsl:text> </xsl:when> <xsl:otherwise> <xsl:text>yield</xsl:text> </xsl:otherwise> </xsl:choose></xsl:template></example></example></defun></section><section name='xsl' title='Resin extensions'><!--<defun name=copy-element title='<xtp:copy-element>' version='resin1.0'><sum>Copies the element to the output.</sum><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><example><a>A text</a><b>B text</b></example><results>A textB text</results></example><p>Using <code/xtp:copy-element/>, XSL stylesheets can copy elementsit doesn't understand.</p><example><example><xsl:template match='*'> <xtp:copy-element> <xsl:apply-templates/> </xtp:copy-element></xsl:template></example><example><a>A text</a><b>B text</b></example><results><a>A text</a><b>B text</b></results></example></defun>--><defun name=expression title='<xtp:expression>expression ...' version='resin1.0'><sum>Executes <var/expression/> and prints it to the output.</sum> Stylesheets can use any JavaScript expression. The followingvariables are pre-defined in stylesheets.<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>In addition, the <var/out/> variable gives access to the servletPageContext with the <var/page/> property.<example><xsl:template match='welcome-user'> <xsl:text>Welcome back, </xsl:text> <xtp:expression> out.page.session.value.user <xtp:expression></xsl:template></example></defun><defun name=scriptlet title='<xtp:scriptlet> statement_list' version='resin1.0'><sum>Executes the <var/statement_list/> scriptlet.</sum> TheJavaScript code can be any statement list. The same implicitvariables are allowed in scriptlets as in expressions.<p>The following example creates a number of stars:<example><example><@# page language='javascript' #><xsl:template match='ct:stars'> <xtp:scriptlet> for (var i = 0; i < node.attribute.count; i++) out.write('*'); </xtp:scriptlet></xsl:template></example><example>1 = <ct:stars count='1'/><br>9 = <ct:stars count='9'/><br></example><results>1 = *9 = *********</results></example></defun><defun name=declaration title='<xtp:declaration>' index='declaration'><sum>Adds declaration code, i.e. code outside of any function.</sum><example><xtp:declaration>function dist(x1, y1, x2, y2){ return Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));}</xtp:declaration></example></defun><defun name=page title='<xtp:directive.page attributes />'><sum>Sets page directives</sum><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='<xtp:directive.cache attributes/>'><sum>Caches the generated JSP file by default.</sum><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>--></section>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -