The <xsl:template> element defines the rules for matching nodes (match, where "/" matches the entire document), used in Apply-template
The syntax rules are:
<xsl:template
name="name"
match="pattern"
mode="mode"
priority="number">
<!--Content:(<xsl:param>*,template)-->
</xsl:template>
which
Name template names
Matchxpath statement, specifying criteria
Mode mode, such as red, blue and other styles
Priority priority, for numbers
For example, the following XML file:
<?xml version="1.0" encoding="GB2312"?>
<?xml:stylesheet type="text/xsl" href="UserList_template.xsl"?>
<Users>
<User IsAdmin='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>
The template used (userlist_template.xsl) is:
<?xml version="1.0" encoding="GB2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<body>
<xsl:apply-templates/>
</body>
</xsl:template>
<xsl:template match="User">
<p>
<xsl:apply-templates select="Name"/>
<xsl:apply-templates select="ID"/>
</p>
</xsl:template>
<xsl:template match="Name">
Name: <span style="color:#BB0000">
<xsl:value-of select="."/></span>
<br />
</xsl:template>
<xsl:template match="ID">
ID: <span style="color:#808000">
<xsl:value-of select="."/></span>
<br />
</xsl:template>
</xsl:stylesheet>
You can display user information as a list.