Re: [xsl] How can i access a JSP function in XSL?

Subject: Re: [xsl] How can i access a JSP function in XSL?
From: Peter Davis <pdavis152@xxxxxxxxx>
Date: Wed, 1 May 2002 03:27:48 -0700
Hash: SHA1

On Wednesday 01 May 2002 02:18, Suman.Sathyanarayan@xxxxxxxxxxxx wrote:
> <% getTelephoneNumber(" %>
> <xsl:value-of select="value"></xsl:value-of>
> <%   ");  %>

When the JSP is executed and when the XSLT is executed are *totally* 
different.  You can't use a value returned from the XSLT while the JSP is 
running, because the JSP *outputs* the XSLT -- which means the XSLT is 
executed after the JSP.

What you have here will essentially be the same as:

<% getTelephoneNumber("\n <xsl:value-of select=\"value\"/> \n"); %>

which is probably not what you want.  You will have to do one of three things: 

* If you are making an HTML page, then you will have to do something like this 
in your XSLT:

<input type="hidden" name="phone" value="{value}"/>

which uses an Attribute Value Template that will output the phone number into 
the <input value="..."/>.  You then have to put that into a <form> and make 
the user click "submit" to return the value to the server where you can do 
more processing -- pretty ugly.

* Check out the Cocoon project (, and convert all 
of your .jsp files to .xsp.  This is a totally new language, so converting 
won't be easy, but it *might* be able to do what you want (emphasis on 
*might*, since you still won't be able to use XSLT directly in the page)

* Use your processor's extension mechanism to be able to access 
getPhoneNumber() in the XSLT, so you can do something like:

<xsl:value-of select="xx:getPhoneNumber(value)"/>

This is probably the best way to go, but it depends on a lot of other factors 
such as the processor, where getPhoneNumber is defined, and whether 
getPhoneNumber relies on non-static state that is innaccessible from where it 
is called by the extension.

- -- 
Peter Davis
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see


 XSL-List info and archive:

Current Thread