昨天没人解决,今天再问

在IE 6.0中显示book.xml,结果select框只显示“selected”,而不是希望的"usa",而且只显示了一个option,非常奇怪。

book.xml文件:

1<country_list>
2<country name="France"></country>
3<country name="China"></country>
4<country name="USA" selected="yes"></country>
5<country name="Canada"></country>
6</country_list>

style.xsl文件:

 1<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3c.org/1999/XSL/Transform">
 2<html>
 3<body>
 4<h1>Please select a country:</h1>
 5<select id="country">
 6<xsl:for-each select="//country">
 7<option value="{@name}">
 8<xsl:if test="@selected='yes'">
 9<xsl:attribute name="selected">selected</xsl:attribute>
10</xsl:if>
11</option>
12</xsl:for-each>
13</select>
14</body>
15</html>
16</xsl:stylesheet>

---------------------------------------------------------------

 1<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 2<xsl:template match="/">
 3<html>
 4<body>
 5<h1>Please select a country:</h1>
 6<select id="country">
 7<xsl:for-each select="/country_list/country">
 8<option value="{@name}">
 9<xsl:if test="@selected='yes'">
10<xsl:attribute name="selected"></xsl:attribute>
11</xsl:if>
12<xsl:value-of select="@name"></xsl:value-of>
13</option>
14</xsl:for-each>
15</select>
16</body>
17</html>
18</xsl:template>
19</xsl:stylesheet>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus