[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

How to declare a namespace

Subject: How to declare a namespace
From: "frank Stein" <freeposte@xxxxxxxxxxx>
Date: Tue, 30 Jan 2001 09:13:05
declare namespace

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.

I've followed your instructions and I've declared a couple of functions
within the msxsl:script element but I did not declare the 'msxsl' namespace(urn:schemas-microsoft-com:xslt) and my own 'foo' namespace.


While the interpretation the IE.5 outputs the following error :

"Reference to undeclared namespace prefix: 'msxsl'. Error processing resource 'file:///D:/Ovide/test.xsl'. Line 10, Position 66

<msxsl:SCRIPT language="javascript" implements-prefix="foo"><![CDATA[
-----------------------------------------------------------------^"

Could You please explain me how and where to declare these two namespaces ?

Thank-You again Jeni.

Ovide

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.


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.