我有一个地址簿,其XML由
给出<addressbook>
<entry>
<name prefix="Mr.">
Zack Black</name>
<address>
<street>101 Main St</street>
<city>Searcy</city>
<state>AR</state>
<zip>12345</zip>
</address>
<phone location="home"
number="501-279-9999" />
<phone location="work"
number="501-279-1111" />
</entry>
<entry>
<name>John Brown</name>
<phone number="501-305-2222" />
</entry>
<entry>
<name>Susan White</name>
<address>
<street>2000 Center Rd</street>
<city>Dallas</city>
<state>TX</state>
<zip>67790</zip>
</address>
<phone location="home"
number="501-279-0000" />
</entry>
</addressbook>
现在,有一些空单元格。我想识别它们,然后用一些特定的颜色为它们着色,比如红色。我怎么能这样做?
答案 0 :(得分:0)
假设您正在讨论输出HTML表格,请尝试以下几点:
...
<td>
<xsl:choose>
<xsl:when test="@prefix">
<xsl:value-of select="@prefix"/>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="style">background-color: red;</xsl:attribute>
<xsl:value-of select="' '"/>
</xsl:otherwise>
</xsl:choose>
</td>
...
您还应该探索空表格单元格的CSS格式。