Re: NameSpace declarations

Subject: Re: NameSpace declarations
From: Mike Brown <mike@xxxxxxxx>
Date: Thu, 30 Nov 2000 18:15:16 -0700 (MST)
Brian Jones wrote:
> I have tried the following namespace as defined by xmlspy but heck it does
> not work at all either in xmlspy or MS XSLDebugger.
> <xsl:stylesheet version="1.0"
> xmlns:xsl="";
> xmlns:fo="";>
> I am not sure how the name spaces work inside of parsers. Where can I find a
> resource on namespaces, what they truly define and what pasers understand
> them?  Thanks
  ...particularly sections 1, 2, 5.1, 5.2.
  this may be more useful. looks like it has been expanded recently.
  this provides practical examples.

Here's my own summary:

Namespaces are identified with URIs that don't have to point to anything.
They are used to differentiate between XML element names. The classic
example is an element type of 'title'. In your document it might mean book
title, and in mine it might mean job title. If we want to avoid confusion
we need to bind your 'title' elements to one URI and mine to another. The
nice backward-compatible way of doing this in XML is to use a special kind
of attribute called a namespace declaration to either establish a default
namespace URI for the element and its descendant elements, or to associate
a namespace URI with a prefix that can then be tacked on to the beginning
of an element name.

So let's say you have an element called 'for-each' and you want your XSL
processor to know that this is an XSLT instruction, not just something you
happened to call 'for-each'. The processor, if it supports XSLT, will know
that elements associated with the namespace URI
'' are XSLT instructions and will
process them appropriately. The typical way to designate the 'for-each'
element as an XSLT instruction is to first bind the prefix 'xsl' (or any
other prefix) to the XSLT namespace URI, and then tack that on the element
name, like this:
   <xsl:for-each xmlns:xsl="";>

The magic is not in the placement of the xmlns:xsl (well, for the most
part, anyway), nor in the choice of 'xsl' as the prefix, nor in the fact
that a prefix was used at all; it is merely the fact that this particular
element is associated with the URI ''.

If the XSL processor only recognizes a certain other namespace URI as
being special, it will treat your xsl:whatever element as being just an
ordinary element, which in the world of XSL is interpreted as a 'literal
result element' you want copied to the result tree.

The FAQ should answer your questions about parser support.

Also see

I don't know the answers to your other questions about XML Spy, etc.

Personally I don't see why you would continue using MSXML 2.x and the old
namespace and its associated syntax. If XML Spy does happen to support it
today, it probably won't for much longer. That syntax has been dead since
April 1999. It only lives on because MSXML 3.0 isn't deployed with IE5,
and there is almost no effort on the part of Microsoft to encourage people
to upgrade.

   - Mike
Mike J. Brown, software engineer at            My XML/XSL resources: in Denver, Colorado, USA    

 XSL-List info and archive:

Current Thread