Re: [xsl] How to declare a namespace

Subject: Re: [xsl] How to declare a namespace
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Wed, 31 Jan 2001 12:07:53 +0000
Hi Frank,

> 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.
> Could You please explain me how and where to declare these two namespaces ?

You declare namespaces with namespace declarations, which are
attributes of the form:


So, for example, a namespace declaration for the MSXML namespace looks


You can give any prefix that you want (msxsl, ms, m or whatever) as
long as you're not using that prefix for another namespace. The
namespace URI is fixed, though - that's what the processor uses to
identify whether a particular element/function is in a particular

Your 'foo' namespace should be a URI that you can guarantee no one
else will use, perhaps something like:


It doesn't particularly matter what it is - a lot of people use URLs,
but that can be a bit tricky if you don't have a personal domain name.

You should place these namespace declarations on an element that
contains *all* the places where you want to use that namespace
declaration.  Most often in XSLT stylesheets, this will be the
xsl:stylesheet element because it contains everything.  So your
stylesheet will look something like:

<xsl:stylesheet version="1.0"

<msxsl:script language="javascript"



I hope that helps,


Jeni Tennison

 XSL-List info and archive:

Current Thread