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 September 19th, 2008, 04:06 PM
Authorized User
 
Join Date: Sep 2008
Posts: 56
Thanks: 0
Thanked 1 Time in 1 Post
Default passing javascript variable in xsl:value-of select

This is the script I have in my XSL

<script type="text/javascript">

<![CDATA[

function test(){
var pageLink2="ABC123";

document.write(']]><xsl:for-each select="//node[node/@id ='+pageLink2+']/node"><![CDATA[');]]>

<![CDATA[document.write(']]><xsl:value-of select="label"/><![CDATA[');]]>

<![CDATA[document.write(']]></xsl:for-each><![CDATA[');
}
]]>

</script>



This code currently ofcourse is not functioning I wanted to know if there is any way on this planet I can make this code work so it gets the value of page link from the variable? At the moment if I remove +pageLink2+ and place ABC123 it works just fine but I want to get this value from the variable pageLink2.

 
Old September 19th, 2008, 04:48 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Oh dear, you're still confused. Well I suppose it's not surprising - programs that generate programs often are confusing.

The XSLT code is generating the Javascript code. The XSLT code cannot possibly have access to the value of a variable computed by the Javascript code that it is generating - unless of course you think that Escher's famous drawing reflects a possible reality:

http://en.wikipedia.org/wiki/Drawing_Hands



Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
 
Old September 19th, 2008, 05:23 PM
Authorized User
 
Join Date: Sep 2008
Posts: 56
Thanks: 0
Thanked 1 Time in 1 Post
Default

Thanks. I understand it now its not possible :)






Similar Threads
Thread Thread Starter Forum Replies Last Post
how to pass javascript variable to xsl eruditionist XSLT 4 September 8th, 2008 08:37 AM
Populating a Select Control from an XSL:Variable pcahaus XSLT 1 October 31st, 2007 04:21 AM
XSL:Variable SELECT=sum(condictions) andreracco XSLT 3 August 15th, 2007 08:51 AM
Problems passing xsl parameters from javascript mxxz XSLT 4 November 3rd, 2006 11:21 AM
<xsl:for-each> with a variable select="attribute" BeneathClouds XSLT 1 August 1st, 2005 03:36 AM





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