Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / March 2005

Tip: Looking for answers? Try searching our database.

Hwo to do Hello World From XSLT to JavaScript?

Thread view: 
RC - 29 Mar 2005 18:21 GMT
Hello World,
I am try do call a JavaScript function from XSLT, but I got
function not avaible error. See "????" below.
Would someone out there tell me how?
Thank Q!

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
 <xsl:output method="html" />
<xsl:template match="/">

<html><head><title>Hello World</title>
<script type="text/javascript" language="JavaScript1.2">

function hello(w) {
 return ("Hello " + w + "!");
}
//
</script>
</head><body>

<xsl:variable name="w" select='World' />

<!-- How do I call JavaScript function here? -->
<xsl:value-of select="????.hello($w)" />

</body></html>

</xsl:template>
</xsl:stylesheet>
Anton Spaans - 29 Mar 2005 20:58 GMT
> Hello World,
> I am try do call a JavaScript function from XSLT, but I got
[quoted text clipped - 26 lines]
> </xsl:template>
> </xsl:stylesheet>

If you want the *browser* to execute this javascript, based on a
variable-value, do this:

<xsl:variable name="w" select='World' />
...
...
<script language="javascript">
   var someVar = hello("<xsl:value-of select="$w"/>");
   ...
   ...
</script>
...

If you want to execute javascript *from within the XSLT* transformation
itself, you have to use XSLT-extensions for JavaScript.
Go to this site for more info:
http://xml.apache.org/xalan-j/extensions.html
Good luck.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.