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

Re: NameSpace declarations

Subject: Re: NameSpace declarations
From: Mike Brown <mike@xxxxxxxx>
Date: Thu, 30 Nov 2000 18:15:16 -0700 (MST)
for each xmlns
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

  ...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
'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


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.
First Name
Last Name
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.