From an XSL file, what is the best way to process a cookie?

slacker

Usenet Archive
Joined
Feb 9, 2006
Messages
7
Reaction score
0
By clicking a link on a website I set a USERINFO cookie and then I redirect to a program which ultimately executes an XSL file which dynamically builds an input form. The input form, while having some non

dynamic hidden INPUT tags, has one hidden INPUT tag that is dynamic. In

the XSL file I attempt to bring this dynamic hidden INPUT tag in via the following statements:

<xsl:template match="/">
<xsl:value-of select="document('http://localhost/getcookie.jsp')"/>

</xsl:template>

Unfortunately, the XSLT processor produces the following errors:

obhtmlpage.cpp:146: Error: Exception rethrown in
ObHTMLPage::GenerateHTML.
obdgxtxsl.cpp:213: Error: ObDgxtTransform
obdgxtxsl.cpp:153: Error: ObCallDgxtTransform
obdgxtxsl.cpp:32: Error: 0: syntax error at line 1, col 49: syntax error obdgxtxsl.cpp:32: Error: 0: xpl_document: error parsing http://localhost/getcookie.jsp

Below is the getcookie.jsp. I thought I was being straight forward with

this. But I'm confused as to what the processor is talking about; the XSL above or the JSP below? What does it mean line 1 column 49? Any and

all help is appreciated, thanks.

P.S. - I know I removed " + cookievalue + " below in lieu of the non dynamic which you see, but even that failed. :-( I also tried xsl:copy-to and import with this fixed code, but to no avail. Again, any and all help is appreciated.

<%@ page import="javax.servlet.http.Cookie"
%><%

Cookie info = null;
Cookie cookies = request.getCookies;
for (int i=0; i < cookies.length; i++) {
info = cookies;
String cookiename = info.getName;
String cookievalue = info.getValue;
if (cookiename.equals("USERINFO")) {
%>
<input type="hidden" name="varuserinfo" id="varuserinfo" value="cookievalue"></input> <% } } %>

I'm not really fluent in XML/XSL/XSLT but need to come up with a way of removing a set of radio buttons on an XSL produced form. I thought, good, I'll set a cookie and somehow use that value in the value clause of a hidden HTML INPUT tag. Hence the so called "dynamically" generated HTML tag which I tought would be considered well formed because I gave it an ending INPUT tag.

I also thought initially that maybe I could just have a javascript extract the cookie value via an ONLOAD statement in a BODY tag, but then I couldn't figure out the XSL like syntax I would need to make use

of this javascript variable. So more poking around on the internet led me to the XSL:value-of statement below and copy-of and import statements with the document parameter and I thought, okay, this looks promising. But no such luck.

Nelson
 

slacker

Usenet Archive
Joined
Feb 9, 2006
Messages
7
Reaction score
0
This is what I had tried the Javascript way which also doesn't seem to work.
The XSL file has:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:eek:blix="http://www.oblix.com/">

....

<script language="JavaScript" xml:space="preserve"
src="../../common/bin/functions.js"></script>

....

<xsl:variable name="cookie"
select="cookie:getUserInfo"></xsl:variable>

(The transformer barfs on the above, but loves everything else about the XSl file if I comment out the above).

....

<xsl:if test="@cookie = 'uservalue'">
<input type="hidden" name="userinfo" id="userinfo" value="uservalue"/> </xsl:if>

....

and the javascript which returns the cookie looks like this:

function getUserInfo {
var arrayofcookies = document.cookie.split(";");

var i = 0;
var userinfo = "USERINFO";
var nocookie = 1; // Set for later
//document.write(arrayofcookies.length);
while (i<arrayofcookies.length)
{

//Split the current cookie into name=pairs.
//Index 0 should be the name, and Index 1
//should be the value.

var cookiename = arrayofcookies.split("=")[0];
var cookievalue = arrayofcookies.split("=")[1];

if (cookiename == userinfo)
{
nocookie = 0;
return(cookievalue);
// userrole.setAttribute("select",""+cookievalue+""); } i = i + 1;

}

Any and all help is appreciated.

Nelson
 

Joe Kesselman

Usenet Archive
Joined
Feb 3, 2006
Messages
1,229
Reaction score
0
slacker said:
<xsl:variable name="cookie"
select="cookie:getUserInfo"></xsl:variable>

Did you define the cookie: namespace for that extension function invocation? Correctly?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,049
Messages
3,104,246
Members
248,133
Latest member
DujonT

Latest Threads

Top