views:

38

answers:

1

I am using the below piece of XSL code to construct a span tag calling a javascript function on mouseover. The input to the javascipt should be a html table. The output from the variable "showContent" gives just the text content but not along with the table tags. How can this be resolved.

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>

Actual Output: <span onmouseout="UnTip()" onmouseover="Tip('content1')" id="d1t14">is my </span>

Expected output:

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

What is the change that needs to done in the above XSL for the table, tr and td tags to get passed?

+2  A: 

The concat() function takes the string values of its arguments and concatenates them.

$aTable as defined has no string value.

You may want to define it not as element()* but as xs:string.

Then you'd need to escape the text in it, or to include it in a CDATA tag. Because the value of $aTable is dynamically generated, using CDATA isn't possible.

You'll need your own XML serialization processing to turn all tags markup into text. Even in this case, the contents of the onmouseover attribute will contain escaped characters, due to attribute value normalization.

Seems quite impossible.

Dimitre Novatchev