XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + sort by variable (11)
-> + [XSLT Recursive Template Help]... (2)
-> + Adding values with document() ... (7)
-> + merging xml files in to single... (2)
-> + Limit description characters i... (2)
-> + problem parsing xml as text in... (2)
-> + Summarize/Distinct (5)
-> + unix epoch seconds to date str... (3)
-> + xml, xslt question (5)
-> + LGCL XSLT transformation (3)
-> + Dynamic include (3)
-> + .rdbxml as XML within Stylus ... (3)
-> + Array of Values From XSL (2)
-> + Problem Saving output (2)
-> + Base 64 encoded data embedded ... (2)
-> + XML-XML Mapping (2)
-> - Parameterized 'Document()' ...... (1)
-> + Newbie prob - Elements with sa... (3)
-> - .net 1.1 incorrectly processin... (1)
-> + xs:key and xs:keyref question (5)
-> - pass xsl-variable to javascrip... (2)
-> ->pass xsl-variable to java...
-- Previous [1321-1340] [1341-1360] [1361-1380] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
morten norgaardSubject: pass xsl-variable to javascript onmouseover_ event
Author: morten norgaard
Date: 23 Sep 2006 05:22 PM
Hello, all,

well, I could use some help with this one. I've been trying to crack it for 2 days but it's no good. I need to pass the result of an xsl variable, whose value is the result of a call-template, to a javascript onmouseover_-event. I can print the result of the call-template call, but I simply cannot pass the resulting string to the javascript function. Try for yourselves, and move the mouse into the filename - the div on top of the filename should write the same text as the text just to the right of the filename, but I just won't... I'm at my wits end. Can anyone help...? :-(


I boiled everything down to the bare minimum:

the xml:

<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE parents []>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<parents>
<parent caption="parent1">
<child>
<childImageName>SCN0001.jpg</childImageName>
<childData>
<denominator name="testData">valueHere</denominator>
</childData>
</child>
</parent>
</parents>


... and the xsl, "test.xsl":


<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="*"/>
<xsl:template match="/">

<html>
<head>
<script language="javascript">
<![CDATA[

function showNode( text )
{
document.getElementById("testDiv").innerHTML = text;
}
]]>

</script>
</head>

<body>
<div id="testDiv">here</div>
<xsl:apply-templates />
</body>
</html>

</xsl:template>
<xsl:template match="parent">
<xsl:apply-templates />
</xsl:template>

<xsl:template match="child">
<xsl:apply-templates select="childImageName"/>
</xsl:template>

<xsl:template match="childImageName">

<xsl:variable name="childDataVariable" select="../childData" />

<xsl:variable name="testVariable">
<xsl:call-template name="giveMeSomeChildDataTemplate">
<xsl:with-param name="nodEdit" select="$childDataVariable"></xsl:with-param>
</xsl:call-template>
</xsl:variable>


<span class="imageSpan">
<xsl:attribute name="onmouseover_">
showNode("<xsl:value-of select="testVariable"></xsl:value-of>")
</xsl:attribute>
<xsl:value-of select="text()"></xsl:value-of>
</span>


<xsl:value-of select="$testVariable"></xsl:value-of>
</xsl:template>


<xsl:template name="giveMeSomeChildDataTemplate">
<xsl:param name="nodEdit"/>
<xsl:for-each select="$nodEdit/denominator">caption: <xsl:value-of select="@name"></xsl:value-of> value:<xsl:value-of select="text()"></xsl:value-of></xsl:for-each>

</xsl:template>

</xsl:stylesheet>


Unknowntest(14).xml
test.xml

Unknowntest(14).xsl
test.xsl

Posttop
morten norgaardSubject: pass xsl-variable to javascript onmouseover__ event
Author: morten norgaard
Date: 25 Sep 2006 05:30 PM
God, my stupidity...

" showNode("<xsl:value-of select="testVariable"></xsl:value-of>")"

Should be

" showNode("<xsl:value-of select="$testVariable"></xsl:value-of>")

I forgot to put the dollar-sign in there with the "testVariable"...

Jesus. Hope this helps some one else, some time. Don't f*** up like I did, 's all I can say!

   
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.