如何在工具提示中显示表格:XSL

时间:2012-08-14 10:20:07

标签: xslt tooltip jquery-tooltip

我在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">&lt;table style='color:#efefef; background:none !important;'>
    <tr>
      <td><xsl:value-of select="source"/>&lt;/td>
      <td><xsl:value-of select="destination"/>&lt;/td>
      <td><xsl:value-of select="vlan"/>&lt;/td>
      <td><xsl:value-of select="date"/>&lt;/td>
      <td><xsl:value-of select="count"/>&lt;/td>
    </tr>
  </table></xsl:attribute>
    more details
</a>

它也不起作用。 第二种方式的结果是:

        

我真的需要你的帮助,任何答案都会非常感激。 thanx很多

1 个答案:

答案 0 :(得分:1)

您不能在HTML title属性中拥有表格。这是不可能的,停止尝试。

你能做什么:

  1. 使用其中一个可用的JavaScript库来生成自定义工具提示。例如,jQuery有插件,但还有很多其他插件。这些库可以在鼠标悬停时显示任何类型的HTML,因此表格不会成为问题。
  2. 只需在您的属性中添加换行符即可。大多数浏览器都支持title属性中的换行符并在屏幕上显示它们。不像桌子那么漂亮,但可能就足够了。
  3. 我只会详细介绍第二种选择。第一个问题超出了这个问题。

    <a href="">
      <xsl:attribute name="title">
         <xsl:value-of select="concat('Source: ', source, '&#10;')" />
         <xsl:value-of select="concat('Destination: ', destination, '&#10;')" />
         <xsl:value-of select="concat('VLAN: ', source, '&#10;')" />
         <xsl:value-of select="concat('Date: ', date, '&#10;')" />
         <xsl:value-of select="concat('Count: ', count)" />
      </xsl:attribute>
      <xsl:text>more details</xsl:text>
    </a>