File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes Access xsl variable between pages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Access xsl variable between pages" Watch "Access xsl variable between pages" New topic

Access xsl variable between pages

shanta raja

Joined: Apr 01, 2010
Posts: 8
I have a dropdown in the xsl form. When I select a value from the dropdown, I would like to retain the selected value for further calculations, when the onLoad() function is called. I have tried retrieving the selected value using the onchange function and passing it to onLoad(). But the variable does not get passed. I also tried hidden variables, but nothing works. I'm not sure where I'm going wrong. The following is my code

<xsl:template .................................../>
<script type="text/javascript">
function onLoad() {

function getSelectedYear() {
var yearOptions = document.getElementId('year').options;
dcoument.mainForm.selectedYear.value = selectedYear;

<SELECT NAME="year" id="year" onchange="getSelectedYear()">
<!-- xsl:variable attribute name="selectedYear"><xsl:value-of select="year"



type="hidden" name="selectedYear" value="{selectedYear}" />

Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

First you have to let go of the peculiar concept of an "XSL form". You don't have any such thing. You have -- if I understand your post correctly -- an XSL transformation which generates HTML. And in that HTML you have some Javascript, also generated by the transformation.

Now if I understand your post correctly, you want to pass information from that page (which is HTML, remember) via the form to the next HTML page which is displayed. So when the form is submitted, it has to include that information.

It's impossible to deal with the problem if you only display the XSLT code which generates the page. You have to look at the generated HTML and figure out how to make that HTML do what you need it to do. Then when you have done that, fix the XSLT code to generate HTML which does what you need it to do.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
There is no concept of global state in the eXtensible Stylesheet Language. Only local static variables in a single template element.
wood burning stoves
subject: Access xsl variable between pages
It's not a secret anymore!