0

我正在使用下面的 XSL 代码构建一个跨度标记,在鼠标悬停时调用 javascript 函数。javascipt 的输入应该是一个 html 表。变量“showContent”的输出只给出了文本内容,而不是表格标签。这怎么能解决。

XSL:

          <xsl:variable name="aTable" as="element()*">
        <table border="0" cellspacing="0" cellpadding="0">
        <xsl:for-each select="$capturedTags">
        <tr><td><xsl:value-of select="node()" /></td></tr>
        </xsl:for-each>
        </table>
        </xsl:variable>
        <xsl:variable name="start" select='concat("Tip(&#39;", "")'></xsl:variable>
        <xsl:variable name="end" select='concat("&#39;)", "")'></xsl:variable>
        <xsl:variable name="showContent">
                <xsl:value-of select='concat($start,$aTable,$end)'/> 
        </xsl:variable>
        <span xmlns="http://www.w3.org/1999/xhtml" onmouseout="{$hideContent}" 
              onmouseover="{$showContent}" id="{$textNodeId}"><xsl:value-of select="$textNode"></xsl:value-of></span>

实际输出: <span onmouseout="UnTip()" onmouseover="Tip('content1')" id="d1t14">是我的</span>

预期输出:

   <span onmouseout="UnTip()" onmouseover="Tip('<table><tr><td>content1</td></tr>')" id="d1t14">is my </span>

在上述 XSL 中需要对 table、tr 和 td 标记进行哪些更改才能通过?

4

1 回答 1

2

concat()函数采用其参数的字符串值并将它们连接起来。

$aTable正如定义的那样,没有字符串值。

您可能不想将其定义为,element()*而是定义为xs:string

然后您需要转义其中的文本,或将其包含在CDATA标签中。因为 的值$aTable是动态生成的,CDATA所以无法使用。

您需要自己的 XML 序列化处理来将所有标签标记转换为文本。即使在这种情况下,onmouseover由于属性值规范化,属性的内容也会包含转义字符。

似乎完全不可能。

于 2010-04-27T18:17:05.710 回答