2012-08-14 42 views
0

我在XML文件中的以下标签:我怎么能显示工具提示表:XSL

<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很多

+0

在HTML'title'属性中不能有表格。 HTML(也是XML)仅支持属性值中的字符串。 – Tomalak 2012-08-14 11:42:04

+0

嗯......但是当我把这个代码放在HTML文件(不是xsl)中的的标题属性中时,工具提示显示了一个表格。 – user1597122 2012-08-14 11:49:25

+0

什么浏览器?你能为此做一个jsFiddle吗? – Tomalak 2012-08-14 12:00:18

回答

1

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

你可以做什么:

  1. 使用可用来生成自定义工具提示的JavaScript库之一。例如,jQuery有插件,但还有很多其他插件。这些库可以在鼠标悬停时显示任何类型的HTML,因此表格不会成为问题。
  2. 只需为您的属性添加换行符。大多数浏览器支持title属性中的换行符并将其显示在屏幕上。不如桌子漂亮,但可能就够了。

我只会详细介绍第二个选项。第一个超出了这个问题的范围。

<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> 
+0

谢谢你亲爱的Tomalak.now它具有更好的结构(每个标签是单独的一行) 结果是: 来源: 目的地: VLAN: 日期: 计数: 的问题是,它不显示标签的价值。 – user1597122 2012-08-15 05:19:55

+0

我有问题:为什么下面的行不能在xsl中工作?: more details 它不显示值 !!这意味着在的标题属性里我们不允许使用xsl或html标签?那么解决方案是什么? – user1597122 2012-08-15 05:45:21

+0

真的很对! 现在它工作:) – user1597122 2012-08-15 09:30:48