On a very basic level, you use <xsl:apply-templates>
when you want to let the processor handle nodes automatically, and you use <xsl:call-template/>
when you want finer control over the processing. So if you have:
<foo>
<boo>World</boo>
<bar>Hello</bar>
</foo>
And you have the following XSLT:
<xsl:template match="foo">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="bar">
<xsl:value-of select="."/>
</xsl:template>
<xsl:template match="boo">
<xsl:value-of select="."/>
</xsl:template>
You will get the result WorldHello
. Essentially, you've said "handle bar and boo this way" and then you've let the XSLT processor handle these nodes as it comes across them. In most cases, this is how you should do things in XSLT.
Sometimes, though, you want to do something fancier. In that case, you can create a special template that doesn't match any particular node. For example:
<xsl:template name="print-hello-world">
<xsl:value-of select="concat( bar, ' ' , boo )" />
</xsl:template>
And you can then call this template while you're processing <foo>
rather than automatically processing foo
's child nodes:
<xsl:template match="foo">
<xsl:call-template name="print-hello-world"/>
</xsl:template>
In this particular artificial example, you now get "Hello World" because you've overriden the default processing to do your own thing.
相关推荐
<xsl:template name="writeCssFile"> <xsl:result- document href="{testng:absolutePath('style.css')}" format="text"> <xsl:choose> <xsl:when test="testng:isFilterSelected('CONF') = 'true'"> ....
针对于xml个人简历,附有xsl文档代码:<?xml version="1.0" encoding="gb2312"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">...
比较有用的关于xml的命令, xsl:import元素 xsl:import元素用于导入外部的样式单,也是一个顶级元素。...<xsl:template match=”node”> <xsl:apply-impotres/> </xsl:template> ……… </xsl:stylesheet>
<UL>{PE.DataSource id="InfoList<XSL:VALUE-OF select="NodeID" />" datasource="图片栏目循环列表信息" nodeArray="<XSL:VALUE-OF select="arrChildID" />" parentId="<XSL:VALUE-OF select="$parentId" />" ...
<sno>1067001516</sno> <name>汤柳清</name> <sex>男</sex> <age>22</age> <address>江西师范大学</address> <tel>15270861237</tel> </student> <student> <sno>1067001517</sno> <name>张三</...
-- 定义了输出文档的格式、<xsl:output> 是顶层元素(top-level element),必须是 <xsl:stylesheet> 或 <xsl:transform> 的子节点。定义输出的格式html、设置输出格式的 W3C 版本号(仅在 method=...
xsl:value-of select="$currentId"/>" depth="1"/}" num="1" /} </div> <div id="nav"> <a class="home" href="{PE.SiteConfig.SitePath /}">返回首页</a> {PE.Label id="多级导航菜单" nodeid="{PE.Label id=...
编写文件名为student2.xsl的XSL文件,其中,用<xsl:sort>对学生信息数据按照专业进行排序,并用<xsl:if>筛选出专业为“计算机”的学生信息。要求显示出的计算机专业的学生信息记录单元格背景色为黄色,字符为加粗的...
<TITLE>Empire Burlesque</TITLE> <ARTIST>Bob Dylan</ARTIST> <COUNTRY>USA</COUNTRY> <COMPANY>Columbia</COMPANY> <PRICE>10.90</PRICE> <YEAR>1985</YEAR> </CD> <CD> <TITLE>Hide your heart</TITLE> <ARTIST>...
<!-- XBRL 2.1 Tests --> <!... All Rights Reserved.... ...xml-stylesheet type="text/xsl" href="testcases.xsl"?...<testcases name="XBRL 2.1 Tests" date="12/14/2009"> <testcase uri="Common/300-...</testcases>
hadoop,spark,hbase,zookeeper,kafka配置文件。 例如: <?xml version="1.0" encoding="UTF-8"?>... <value>file:/home/bigData/bigdata/hadoop/tmp</value> </property> </configuration>
<name>io.compression.codecs</name> <value> org.apache.hadoop.io.compress.GzipCodec, org.apache.hadoop.io.compress.DefaultCodec, org.apache.hadoop.io.compress.BZip2Codec, org.apache.hadoop.io....
基本结构标签: <HTML>,表示该文件为HTML文件 ...</HEAD>,<HEAD>的结束标志 <BODY>,放置浏览器中显示信息的所有标志和属性,其中内容在浏览器中显示. </BODY>,<BODY>的结束标志 </HTML>,<HTML>的结束标志
<project name="myproject" basedir="."> <property name="lib.dir" value="lib"/> <path id="test.classpath"> <!-- adding the saxon jar to your classpath --> <fileset dir="${lib.dir}" includes="*.jar...
<xsl:if test="count(MenuItem) > 0"> <!-- 这里用来存储子菜单的xml数据 --> <xml> <xsl:copy-of select="."/> </xml> </xsl:if> </td> <td width="20" align="right" valign...
docx-xslt docx-xslt是一个 Python 库,用于为没有 XML 或 XSLT 编码的 ... ::= <command> <command> ::= <command> | <command> <command> ::= 'xsl' ':' <context> <xsl> <xsl> <context> ::= ':' <context> | <
<result type="velocity">/HelloWorld.vm</result> </action> 例3 classes/struts.xml中VMHelloWorld Action的配置 新建HelloWorld.vm,内容如下所示: <html> <head> <title>Velocity</title> <meta ...
复制代码代码如下: <xsl select=”trtim”> <tr> <td class=””> <xsl select=”titel/@color”/><xsl select=”titel”></td> <td><xsl select=”border”></td> </tr> </xsl> 我想给class中写一个值,如下面的...
xerces xalan taglibs-xsl是JSP中调用<xsl:apply xml="result.xml" xsl="result.xsl"></xsl:apply>的xslt标签所必须的包。 还需要另外一个文件到http://download.csdn.net/source/655756下载。