Click to See Complete Forum and Search --> : Invoking a JavaScript f() in XSLT


holly
08-01-2000, 05:51 PM
How do you invoke a javascript function - specifically sending tag values
as parameters - in XSLT?

I've tried:
<script language="JavaScript" src="OneToOne.js"><![CDATA[
displayLastLogOn(<xsl:value-of select="date"/>,<xsl:value-of select="time"/>);
]]></script>

Thanks!

Alex
08-04-2000, 01:11 PM
Try this:

<xsl:eval language="javascript">fixString(this)</xsl:eval>

this is the current context. Then:

<xsl:script language="javascript"><![CDATA[
function fixString(node){
//do something more interesting
str = node.text;
return str;
}
]]></xsl:script>

"holly" <holly@tigers.com> wrote:
>
>How do you invoke a javascript function - specifically sending tag values
>as parameters - in XSLT?
>
>I've tried:
><script language="JavaScript" src="OneToOne.js"><![CDATA[
> displayLastLogOn(<xsl:value-of select="date"/>,<xsl:value-of select="time"/>);
>]]></script>
>
>Thanks!

sean
08-05-2000, 03:26 AM
Alex, thats XSL and not XSLT.(Which I believe Holly is using). The xsl:eval
was a microsoft only extension that has since been dropped in XSLT(even by
microsofts implementation). You have to do the following in XSLT.(Excuse
syntax errors as written from memory)

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="http://SEAN.com/SEANS namespace" version="1.0">
<msxsl:script language="JScript" implements-prefix="user">
function fixString(node){
//do something more interesting
str = node.text;
return str;
}
</msxsl:script>

Usage
<xsl:value-of select="user:fixString(.)"/>

hope this helps
Sean

"Alex" <apeake@comac.com> wrote:
>
>Try this:
>
><xsl:eval language="javascript">fixString(this)</xsl:eval>
>
>this is the current context. Then:
>
><xsl:script language="javascript"><![CDATA[
>function fixString(node){
> //do something more interesting
> str = node.text;
> return str;
>}
>]]></xsl:script>
>
>"holly" <holly@tigers.com> wrote:
>>
>>How do you invoke a javascript function - specifically sending tag values
>>as parameters - in XSLT?
>>
>>I've tried:
>><script language="JavaScript" src="OneToOne.js"><![CDATA[
>> displayLastLogOn(<xsl:value-of select="date"/>,<xsl:value-of select="time"/>);
>>]]></script>
>>
>>Thanks!
>