<xsl:template>元素定义了用于匹配节点的规则(match,其中\”/\”匹配整个文档),在apply-template使用 语法规则为: <xsl:template name=\”name\” match=\”pattern\” mode=\”mode\” priority=\”number\”> <!–Content:(<xsl:param>*,template)–> </xsl:template> 其中: name模板名称 matchXpath语句,指定条件 mode模式,例如红,蓝等样式 priority优先级,为数字 例如如下的xml文件:<?xmlversion=\”1.0\”encoding=\”GB2312\”?> <?xml:stylesheettype=\”text/xsl\”href=\”UserList_template.xsl\”?> <Users> <UserIsAdmin=\’OK\’> <Name>5do8</Name> <ID>1</ID> <Contact> <QQ>369987789</QQ> <EMAIL>service@163.com</EMAIL> </Contact> </User> <User> <Name>cjjer</Name> <ID>2</ID> <Contact> <QQ>369987789</QQ> <EMAIL>service@163.com</EMAIL> </Contact> </User> <User> <Name>Admin</Name> <ID>3</ID> <Contact> <QQ>369987789</QQ> <EMAIL>service@163.com</EMAIL> </Contact> </User> </Users> 其中使用的模板(UserList_template.xsl)为: <?xmlversion=\”1.0\”encoding=\”GB2312\”?> <xsl:stylesheetversion=\”1.0\”xmlns:xsl=\”http://www.w3.org/1999/XSL/Transform\”> <xsl:templatematch=\”/\”> <html> <body> <h2>AllUserList</h2> <xsl:apply-templates/> </body> </html> </xsl:template> <xsl:templatematch=\”User\”> <p> <xsl:apply-templatesselect=\”Name\”/> <xsl:apply-templatesselect=\”ID\”/> </p> </xsl:template> <xsl:templatematch=\”Name\”> Name:<spanstyle=\”color:#BB0000\”> <xsl:value-ofselect=\”.\”/></span> <br/> </xsl:template> <xsl:templatematch=\”ID\”> ID:<spanstyle=\”color:#808000\”> <xsl:value-ofselect=\”.\”/></span> <br/> </xsl:template> </xsl:stylesheet> 可以以列表的方式显示用户信息。