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="http://www.w3.org/1999/XSL/Transform";
> xmlns:fo="http://www.w3.org/1999/XSL/Format";>
> 
> 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

http://www.w3.org/TR/REC-xml-names/
  ...particularly sections 1, 2, 5.1, 5.2.

http://www.rpbourret.com/xml/NamespacesFAQ.htm
  this may be more useful. looks like it has been expanded recently.

http://www.zvon.org/xxl/NamespaceTutorial/Output/index.html
  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
'http://www.w3.org/1999/XSL/Transform' 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="http://www.w3.org/1999/XSL/Transform";>

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 'http://www.w3.org/1999/XSL/Transform'.

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 http://www.netcrucible.com/xslt/msxml-faq.htm
and http://www.dpawson.co.uk/xsl/N5536.html

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: 
webb.net in Denver, Colorado, USA              http://skew.org/xml/


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


Current Thread