This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: How can i access a JSP function in XSL?
- From: Suman dot Sathyanarayan at itsindia dot com
- To: xsl-list at lists dot mulberrytech dot com
- Date: Wed, 1 May 2002 15:31:47 +0530
- Subject: Re: [xsl] How can i access a JSP function in XSL?
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hi Peter,
Thanks for the help.
I had a better solution.
My XML is also generated using a JSP.
i.e JSP outputs an XML
and
another JSP ouputs an XSL
But the way i paint my
elements / attribute/values for the XML
in the JSP are purely Java.
So i put in the function there itself in the **XML-JSP**,
so i process the data , before generating the XML-JSP itself
and give it to the XSL to display.
i display an HTML finally.
But i think the cocoon site's really good,
And of course these suggesstion's will be of great help later on.
Cheers,
Suman
Peter Davis
<pdavis152@attbi.com> To: xsl-list@lists.mulberrytech.com
Sent by: cc:
owner-xsl-list@lists.mulber Subject: Re: [xsl] How can i access a JSP
rytech.com function in XSL?
05/01/02 03:57 PM
Please respond to xsl-list
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Wednesday 01 May 2002 02:18, Suman.Sathyanarayan@itsindia.com 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 (http://xml.apache.org/cocoon), 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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQE8z8MmNSZCJx7tYycRAjQaAJwPZ1PqA9/TCJO9tD5NMx3vbUXmjgCg2FBb
dK5TjUQxzYXZRjHT1XhYhwU=
=wB5K
-----END PGP SIGNATURE-----
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
-----------------------Disclaimer------------------------
The views of the author may not necessarily reflect those
of the Company. All liability is excluded to the extent
permitted by law for any claims arising as a result of the
use of this medium to transmit information by or to
IT Solutions (India) Pvt. Ltd.
We have taken precautions to minimize the risk of
transmitting software viruses, but we advise you to
carry out your own virus checks on any attachment to
this message. We cannot accept liability for any loss or
damage caused by software viruses.
------------------------Disclaimer------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list