Subject: [xsl] How to declare a namespace From: "frank Stein" <freeposte@xxxxxxxxxxx> Date: Tue, 30 Jan 2001 09:13:05 |
Hi Jeni, many thanks to You for this wonderful answer below. I'm using the Internet Explorer 5.0 with the msxml3 XSL parser version patch.
<msxsl:SCRIPT language="javascript" implements-prefix="foo"><![CDATA[ -----------------------------------------------------------------^"
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> Reply-To: Jeni Tennison <mail@xxxxxxxxxxxxxxxx> To: "frank Stein" <freeposte@xxxxxxxxxxx> CC: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Subject: Re: Date: Mon, 29 Jan 2001 21:19:12 +0000
Hi Frank,
> please, is there any way to affect an xml variable with the output > return of a JavaScript function ?
Yes, but be aware that Javascript isn't incorporated into XSLT until XSLT 1.1 or unless you're using MSXML. The first thing that you need to do is to declare the function within an msxsl:script element:
<msxsl:script language="javascript" implements-prefix="foo"> function retrieveData() { return true; } </msxsl:script>
In order to do this, you need to declare the 'msxsl' namespace (urn:schemas-microsoft-com:xslt) and your own 'foo' namespace. The 'msxsl' namespace needs to be declared as an extension element prefix (using the extension-element-prefixes attribute on xsl:stylesheet) and the 'foo' namespace should be excluded from your result tree (using the exclude-result-prefixes or extension-element-prefixes attribute on xsl:stylesheet).
Once you've declared the Javascript functions like this, you can call them within any XPath expression using, e.g.:
foo:retrieveData()
So, to set $my_var to have the value returned by the function, use:
<xsl:variable name="my_var" select="foo:retrieveData()" />
There's nothing in XSLT that interprets the content of an element as something to run: calls to functions are *always* in attribute values.
I hope that helps,
Jeni
--- Jeni Tennison http://www.jenitennison.com/
_________________________________________________________________________ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Reason for restrictions on RT, steffen . dingel | Thread | Re: [xsl] How to declare a namespac, Jeni Tennison |
[xsl] Reason for restrictions on RT, steffen . dingel | Date | RE: [xsl] "strategy" question, Paul Brown |
Month |