Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 17th, 2008, 09:54 AM
Authorized User
 
Join Date: Sep 2008
Posts: 56
Thanks: 0
Thanked 1 Time in 1 Post
Default javascript in CDATA doesnt escape html

I have a javascript function in CDATA that loops through XML and prints the node but its failing. I just looked at the source and found that the XSL for some reason doesnt escape html for instance

for (var i = 0; i < colLabels.length; i++)

BECOMES

for (var i = 0; i < colLabels.length; i++)



document.write("<a href=" +olabelLink.childNodes[0].nodeValue+ " >"+olabelValue.childNodes[0].nodeValue + " </a><br>");


BECOMES

document.write("<a href=" +olabelLink.childNodes[0].nodeValue+ " >"+olabelValue.childNodes[0].nodeValue + " </a><br>");
becomes

any help as to what I can do to fix it would be greatly appreciated.

thanks.

 
Old September 17th, 2008, 10:01 AM
Authorized User
 
Join Date: Sep 2008
Posts: 56
Thanks: 0
Thanked 1 Time in 1 Post
Default

I apologize I didnt realize that this forum would replace (& l t ;) to ( < ) but this is whats happening.

 
Old September 17th, 2008, 10:04 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

What exactly is the problem? Can you post your XML input and your XSLT stylesheet and explain which result you want to get?


--
  Martin Honnen
  Microsoft MVP - XML
 
Old September 17th, 2008, 10:24 AM
Authorized User
 
Join Date: Sep 2008
Posts: 56
Thanks: 0
Thanked 1 Time in 1 Post
Default

this is the javascript I have in XSL.

<script>
<![CDATA[

var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");

function loadXML(xmlFile)
{

         alert('loadXML function reached');
    xmlDoc.async="false";
    xmlDoc.onreadystatechange=verify;
    xmlDoc.load(xmlFile);
    xmlObj=xmlDoc.documentElement;

    var colLabels = xmlDoc.selectNodes("//node[node/@id ='jjkuh99']/node");

         for (var i = 0; i < colLabels.length; i++)
            {
                var olabels = colLabels[i];
                var olabelValue = olabels.selectNodes("label")[0];
                var olabelLink = olabels.selectNodes("link/value")[0];

                document.write("<a href=" +olabelLink.childNodes[0].nodeValue+ " >"+olabelValue.childNodes[0].nodeValue + " </a><br>");
            }

 }


when I look at the source on the preview page it sbstitutes all ( < ) to ( & l t ;) so where ever you see < in for loop and document.write. It replaces them into & l t ; I want to know if there is a way around it where it can place < (less than ) instead of & l t ; I hope im making sense.

 
Old September 17th, 2008, 10:32 AM
Friend of Wrox
 
Join Date: Nov 2007
Posts: 1,243
Thanks: 0
Thanked 245 Times in 244 Posts
Default

Which output method do you use? Does
Code:
<xsl:output method="html"/>
improve things?

--
  Martin Honnen
  Microsoft MVP - XML
 
Old September 17th, 2008, 01:07 PM
Authorized User
 
Join Date: Sep 2008
Posts: 56
Thanks: 0
Thanked 1 Time in 1 Post
Default

no I am basically calling function loadXML from my XSL like this.

<div>
<script type="text/javascript">
loadXML('testing.xml');
</script>

</div>






Similar Threads
Thread Thread Starter Forum Replies Last Post
Don't escape the whole thing with CDATA. akentanaka XSLT 2 December 4th, 2008 09:22 PM
escape double quote inside JavaScript mister_mister XSLT 5 January 23rd, 2008 01:56 PM
Render HTML inside CDATA with XSL c2c XSLT 0 September 10th, 2006 11:10 AM
Escape sequences for HTML olambe BOOK: ASP.NET Website Programming Problem-Design-Solution 2 July 28th, 2004 08:54 AM
CDATA in XML - convert to HTML suri XSLT 1 July 31st, 2003 08:22 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.