0
我的文档是:XML“xsl:for-each”项目的相同名称?
<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="university_style.xsl"?>
<!DOCTYPE library SYSTEM "validator.dtd">
<university>
<total_faculty>13</total_faculty>
<faculty>
<id>1</id>
<name>name 1</name>
<total_chairs>9</total_chairs>
<chairs_list>
<chair>name 1</chair>
<chair>name 2</chair>
<chair>name 3</chair>
...
</chairs_list>
</faculty>
</university>
和XSL
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<table border="1" cellpadding="4" cellspacing="0">
<caption>total_faculty:<xsl:value-of select="university/total_faculty"/></caption>
<tr bgcolor="#999999" align="center">
<th>id</th>
<th>name</th>
<th>total chairs</th>
<th>chairs</th>
</tr>
<xsl:for-each select="university/faculty">
<tr>
<td>
<xsl:value-of select="id"/>
</td>
<td>
<xsl:value-of select="name"/>
</td>
<td>
<xsl:value-of select="total_chairs"/>
</td>
<td>
<!--<p><xsl:value-of select="chairs_list"/></p> -->
<xsl:for-each select="chairs_list">
<p><xsl:value-of select="chair"/> </p>
</xsl:for-each>
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
我要显示在新行(
椅子
)的所有元素。 但我看到第一个元素或全部。如果一个使用全部列在一行中。如果我使用:
<xsl:for-each select="chairs_list">
<p><xsl:value-of select="chair"/> </p>
</xsl:for-each>
我看到名单只是第一个元素。如何解决它? :)