我有一個來自我使用的口徑的xml文件,並且在嵌套xsl:for-each時遇到了問題。xsl嵌套循環失敗
XML文件:
<?xml version='1.0' encoding='utf-8'?>
<calibredb>
<record>
<title sort="Demon Under the Microscope, The">The Demon Under the Microscope</title>
<authors sort="Hager, Thomas">
<author>Thomas Hager</author>
</authors>
</record>
<record>
<title sort="101 Things Everyone Should Know About Math">101 Things Everyone Should Know About Math</title>
<authors sort="Zev, Marc & Segal, Kevin B. & Levy, Nathan">
<author>Marc Zev</author>
<author>Kevin B. Segal</author>
<author>Nathan Levy</author>
</authors>
</record>
<record>
<title sort="Biohazard">Biohazard</title>
<authors sort="Alibek, Ken">
<author>Ken Alibek</author>
</authors>
</record>
<record>
<title sort="Infectious Madness">Infectious Madness</title>
<authors sort="WASHINGTON, HARRIET">
<author>Harriet A. Washington</author>
</authors>
</record>
<record>
<title sort="Poetry Will Save Your Life">Poetry Will Save Your Life</title>
<authors sort="Bialosky, Jill">
<author>Jill Bialosky</author>
</authors>
</record>
</calibredb>
XSL:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My Calibre Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Author</th>
</tr>
<xsl:for-each select="calibredb/record">
<tr>
<td><xsl:value-of select="title" /></td>
<td><xsl:for-each select="authors"><xsl:value-of select="author" /></xsl:for-each></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
看來,如果多個作者的存在,循環無法繼續深入。
任何人都可以給我一個關於如何正確格式化xsl的建議嗎?
謝謝!