file1:test.xml
<?xml version="1.0" encoding="gb2312"?>
<?xml-stylesheet href="test.xsl" type="text/xsl"?>
<tongxunbu>
<person id="00001">
<name>yvtong</name>
<email>okhello@263.net</email>
</person>
<person id="00002">
<name>wrench</name>
<email></email>
</person>
</tongxunbu>
file2 test.xsl
<?xml version="1.0" encoding="gb2312" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template><xsl:apply-templates/></xsl:template>
<xsl:template match="tongxunbu">
<html>
<head>
<title>通讯簿</title>
<style>
name{background-color:#0fffff;font-size:12pt;}
</style>
</head>
<body>
<table width="500" border="1">
<xsl:for-each match="person">
<xsl:if test="@id[.='00001']">
<xsl:apply-templates />
</xsl:if>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="name">
<tr>
<td>姓名</td><td><xsl:value-of /></td>
</tr>
</xsl:template>
<xsl:template match="email">
<tr><td>电子邮件</td><td><xsl:value-of /></td>
</tr>
</xsl:template>
</xsl:stylesheet>
注释:
可以去掉<xsl:if ....> 实验