我在xml文件中有以下标记:
<more_details>
<source>192.168.1.1</source>
<destination>10.10.10.10</destination>
<vlan>192.168.0.0/24</vlan>
<date>29/3/1391</date>
<count>24</count>
</more_details>
我想使用xsl在工具提示中设计一个表;(我希望当鼠标遍历页面中的特定链接时,它表示表中的数据。数据来自xml文件)
我在xsl文件中写下以下几行来实现这个目标:
<a href="">
<xsl:attribute name="title"><table style='color:#efefef; background:none !important;'>
<tr>
<td><xsl:value-of select="source"/></xsl:value-of><td>
<td><xsl:value-of select="destination"/></xsl:value-of></td>
<td><xsl:value-of select="vlan"/></xsl:value-of></td>
<td><xsl:value-of select="date"/></xsl:value-of></td>
<td><xsl:value-of select="count"/></xsl:value-of></td>
</tr>
</table></xsl:attribute>
more details
</a>
它适用于html文件,但不适用于xsl文件; XSL会自动删除所有html标记。
像这样:<a href="" title="192.168.2.1125.45.24.5192.168.0.0/2429/2/1390 - 12:1424">
link
</a>
这意味着当鼠标翻过“更多细节”字样时,工具提示中显示的结果是:
192.168.2.1125.45.24.5192.168.0.0/2429/2/1390 - 12:1424
我想在表格的一列中显示上述每个标签。 (待定) 但是当我运行程序时,它显示的数据不是结构化格式(不在表格中)
我也是第二种方式:
<a href="">
<xsl:attribute name="title"><table style='color:#efefef; background:none !important;'>
<tr>
<td><xsl:value-of select="source"/></td>
<td><xsl:value-of select="destination"/></td>
<td><xsl:value-of select="vlan"/></td>
<td><xsl:value-of select="date"/></td>
<td><xsl:value-of select="count"/></td>
</tr>
</table></xsl:attribute>
more details
</a>
它也不起作用。 第二种方式的结果是:
我真的需要你的帮助,任何答案都会非常感激。 thanx很多
答案 0 :(得分:1)
您不能在HTML title
属性中拥有表格。这是不可能的,停止尝试。
你能做什么:
title
属性中的换行符并在屏幕上显示它们。不像桌子那么漂亮,但可能就足够了。我只会详细介绍第二种选择。第一个问题超出了这个问题。
<a href="">
<xsl:attribute name="title">
<xsl:value-of select="concat('Source: ', source, ' ')" />
<xsl:value-of select="concat('Destination: ', destination, ' ')" />
<xsl:value-of select="concat('VLAN: ', source, ' ')" />
<xsl:value-of select="concat('Date: ', date, ' ')" />
<xsl:value-of select="concat('Count: ', count)" />
</xsl:attribute>
<xsl:text>more details</xsl:text>
</a>