|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: How to declare a namespace
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.
[snip]
> 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:
xmlns:prefix="namespace-URI"
So, for example, a namespace declaration for the MSXML namespace looks
like:
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
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
namespace.
Your 'foo' namespace should be a URI that you can guarantee no one
else will use, perhaps something like:
xmlns:my="urn:freeposte@xxxxxxxxxxx:2001"
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"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:my="urn:freeposte@xxxxxxxxxxx:2001"
extension-element-prefixes="msxsl"
exclude-result-prefixes="my">
<msxsl:script language="javascript"
implements-prefix="my">
...
</msxsl:script>
...
</xsl:stylesheet>
I hope that helps,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








