Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 22nd, 2007, 02:26 PM
Registered User
 
Join Date: May 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to passed an xsl parameter to a javascript fun

Hi:

I am having problem passing an xsl param variable as a parameter to a javascript function inside an
xsl styelsheet.

Here is my xsl stylesheet.

Quote:
quote:
 <xsl:param name="numberOfRecordsFromDatabase" select="search-result/rec-num" />
<xsl:template name="Body">
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0"
onLoad="cloneHeader();window.parent.shrinkIFrame(< xsl:value-of select='$numberOfRecordsFromDatabase'/>);"
onresize="cloneHeaderResize();window.parent.shrink IFrame(<xsl:value-of select='$numberOfRecordsFromDatabase'/>);">
</body>
</xsl:template>
I am trying to pass a variable called numberOfRecordsFromDatabase to
a javascript function called window.parent.shrinkIFrame(<xsl:value-of select='$numberOfRecordsFromDatabase'/>).


Is this possible?
If not, is there a way to do this.
Any hint would be greatly appreciated.

Yours,

Frustrated.

desperate
 
Old June 22nd, 2007, 02:51 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Firstly, don't think of your XSLT code as calling the Javascript or passing parameters to it. That's not what's happening. The XSLT code is generating an HTML page and the HTML page happens to have some Javascript in it. As far as the XSLT code is concerned, you're just outputting HTML text.

A stylesheet has to be well-formed XML, so you can't write

<elem attr="abc<xsl:value-of select="x"/>xyz"/>

Instead, you write

<elem attr="abc{x}xyz"/>

It's called an attribute value template.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
newbie question (javascript passed in xml) mitre7 XSLT 4 December 11th, 2008 11:23 PM
Pass link values as xsl:parameter to php5 then xsl pauljr8 XSLT 1 July 2nd, 2007 10:32 PM
Divs, Gridviews and Javascript != fun mikeymikey ASP.NET 2.0 Professional 1 January 26th, 2007 02:10 PM
XSL Parameter xsl:param Harinath Chikoti XSLT 1 May 6th, 2005 03:15 AM
wrong passed parameter apek PHP How-To 1 January 11th, 2004 01:08 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.