我有一個包含聯繫人信息的XML文件,如下圖所示:XSLT不顯示所有結果
<contact type="individual">
<firstname>Some</firstname>
<surname>Guy</surname>
<organisation>
<name>London School of Espionage</name>
</organisation>
<address>
<line1>Houghton St</line1>
<cityortown>London</cityortown>
<postalcode>WC2A 2AE</postalcode>
<country>UK</country>
</address>
<telephone prefix="+44" type="work">
<areacode>020</areacode>
<number>71239876</number>
</telephone>
<telephone prefix="+44" type="mobile">
<areacode>07123</areacode>
<number>543098</number>
</telephone>
<email type="work">[email protected]</email>
<email type="personal">[email protected]</email>
<fax prefix="+44" type="work">
<areacode>020</areacode>
<number>780</number>
</fax>
<website>www.espionage.co.uk</website>
</contact
>
我有一個XSL模板,應該顯示在一個表中的所有信息,但只有第一個電子郵件地址顯示。請可能有人建議在我做錯了什麼:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template match="/">
<html>
<head>
<link rel="stylesheet" type="text/css" href="contacts.css"/>
</head>
<body>
<div id="main">
<h1 align="center">XML Contact Book</h1>
<table>
<tr><th>Name</th>
<th>Organisation</th>
<th>Address</th>
<th>Email</th>
<th>Telephone</th>
<th>Fax</th>
<th>Website</th></tr>
<xsl:for-each select="contacts/contact/.">
<tr>
<td valign="bottom"><xsl:value-of select="firstname"/> <xsl:value-of select="surname"/></td>
<td valign="bottom"><xsl:value-of select="organisation/name"/></td>
<td valign="bottom" width="200px"><xsl:value-of select="address/line1"/><br/>
<xsl:value-of select="address/line2"/><br/>
<xsl:value-of select="address/line3"/><br/>
<xsl:value-of select="address/cityortown"/><br/>
<xsl:value-of select="address/countyorstate"/><br/>
<xsl:value-of select="address/postalcode"/><br/>
<xsl:value-of select="address/country"/><br/></td>
<!--creates a mailto: link for the email address contained in contacts.xml-->
<td valign="bottom"><a><xsl:attribute name="href">mailto:<xsl:value-of select="email"/></xsl:attribute><xsl:value-of select="email"/></a>
<br/><p><xsl:value-of select="email/@type"/> email</p></td>
<td valign="bottom"><p>Prefix: <xsl:value-of select="telephone/@prefix"/></p> <xsl:value-of select="telephone/areacode"/> <xsl:value-of select="telephone/number"/></td>
<td valign="bottom"><p>Prefix: <xsl:value-of select="fax/@prefix"/></p><xsl:value-of select="fax/areacode"/> <xsl:value-of select="fax/number"/></td>
<!--creates hyperlink to website listed in contact details-->
<td valign="bottom"><a><xsl:attribute name="href">http://<xsl:value-of select="website"/></xsl:attribute><xsl:value-of select="website"/></a></td>
<hr/>
</tr>
</xsl:for-each>
</table>
</div>
</body>
</html>
</xsl:template>