[xsl] Re: Reading Cookies During XSL Transformation (problems)...

Subject: [xsl] Re: Reading Cookies During XSL Transformation (problems)...
From: Michael <msell@xxxxxxxxxxxxxxx>
Date: Sat, 23 Oct 2004 07:17:18 +1000
The document.cookie property returns a string of all cookie values. If two cookie existed, let's say cookie's 'A' and 'B', then the cookie string would read something like 'A=Result; B=AnotherResult' I haven't bothered to cut the returned string up yet, because I can't read the cookie data at all during the XSL transformation.

The official MSXSL error reads as follows:

Microsoft JScript runtime error 'document' is undefined line = 5, col = 6 (line is offset from the start of the script block). Error returned from property or method call.

Note that 'document' is undefined. Doh!

However, your idea of manually returning the result was brilliant though Jim. There have been a few issues in the XSLT list pertaining to type casting problems with JavaScript and XSLT. You just shot that problem down in flames with a quick suggestion. (grin). Well done.

jfuller@xxxxxxxxxxxxxx wrote:

ok....I am not a javascript expert dont u need to return something ? for example......


function readCookie(name) { var nameEQ = name + "="; var ca = document.cookie.split(';'); for(var i=0;i < ca.length;i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length); } return null; }

note the return c.substring and return null;

currently your examples dont return anything ...also is there instant type conversion...why not just stick a return result; in the below ?

Current Thread