[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Using Javascript function in XSL causes HTML to be par
I have an XSL file that uses some JavaScript to set an InnerHTML tag with the contents of an XML element when a link is clicked. Previously, I used the following structure within the <body> of the <html>, when setting up the links themselves: <xsl:for-each select="site/main-body/section"> <xsl:variable name="content" select="content" /> ... <a href="#" style="text-decoration:none" onclick="tblBody.innerHTML='{normalize-space($content)}'"> <xsl:value-of select="caption" /> </a> ... </xsl:for-each> Which worked perfectly. tblBody would display the HTML contained in the XML element content, as expected. However, for a number of reasons, I wanted to make onclick call a function instead of directly setting the innerHTML. So I changed it to this: <a href="#" style="text-decoration:none" onclick="SetTblBody({position()})"> The function is contained in the <head> of my <html> as follows: <script language="javascript" type="text/javascript"> function SetTblBody(IDNo){ switch (IDNo){ <xsl:for-each select="site/main-body/section"> <xsl:variable name="content" select="content" /> case <xsl:value-of select="position()" />: document.getElementById("tblBody").innerHTML='<xsl:value-of select="normalize-space($content)" />' break;</xsl:for-each> } } </script> Which also works fine, except, the JavaScript function is output like this by the XSL: function SetTblBody(IDNo) { switch (IDNo) { case 1: document.getElementById("tblBody").innerHTML='<cent er> Some text.<br /> Some more text.<br /> <br /> ^^^ A blank line. </center>' break; case 2: document.getElementById("tblBody").innerHTML='http://a .url.goes.here/' break; case 3: document.getElementById("tblBody").innerHTML='Content goes here' break; case 4: document.getElementById("tblBody").innerHTML='Content goes here' break; case 5: document.getElementById("tblBody").innerHTML='Content goes here' break; } } At what point is the XSL parsing the contents of <content> and replacing all of the < and > symbols in the HTML as lt; and gt; symbols? How do I stop it from doing this? Why is it doing it in the function when it didn't do it in the onclick? -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- nrkn http://www.livejournal.com/users/nrkn -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|