The concept is pretty simple. Anywhere in a document you can declare a 
namespace. The syntax is like an attribute declaration, that is it occurs 
inside a tag, so it looks something like:

<myprefix:mytag xmlns:myprefix="whateveruristringidentifiesthis"/>

In the above example you just put mytag into a namespace identified by a URI 
(which is just anything you want it to be, most authors of XML based 
vocabularies will specify what this URI is for their tag set, since they are 
URI's they SHOULDN'T ever overlap). Note that the URI is NOT a URL and need 
not point to anything that can actually be fetched, it is just a unique 
identifier.

Note that prefixes are optional, but they make it a LOT easier to deal with 
stuff later on. The prefix can be anything you want, and the xmlns= 
declaration binds that prefix to that namespace. More than one prefix can 
bind to the same namespace, and in that case both prefixes are 
interchangeable.

XML processors, such as XSLT, require a matching namespace, that is the 
namespace is PART OF THE TAG's NAME in essence, so an XSLT template would 
have to say something like

<xslt:template match="somprefix:mytag" 
xmlns:someprefix="whateveruristringidentifiesthis">
        ....
</xslt:template>

Notice I used a different prefix in the XSLT, but since the binding is to the 
same namespace URI they are equivalent and the processor should match the 
template to the tag.

Namespace declarations have a scope which includes the tag where they are 
defined and all its children. Thus you commonly see xmlns declarations in the 
root tag of XML documents, especially things like XSLT stylesheets.

The point of namespaces is that if 2 authors utilize the same tag names for 
different purposes it is still possible for a single document to contain 
markup complying with both syntaxes and a processor can tell them apart. Thus 
Fubar Markup Language, with URI 'http://xml.fubar.torpedo.org"; will not 
overlap with Gremlin Markup Language with URI "http://gml.gremlinsareus.org"; 
even though they both have a tag <fubared /> since the author of a document 
combining both languages can simply use a different prefix for each.  

I guess thats the basics of it. Attributes have their own quirks WRT 
namespaces. I can only refer you to books such as the one by Michael Kay 
which go into it in nauseating detail! 

And yes, namespaces are vital for AxKit, each XSP taglib lives in a unique 
namespace, and XSLT depends on them heavily as well. Its hard to do much 
serious XML processing without them really....

On Tuesday 11 February 2003 09:48 am, Eddie Roosenmaallen wrote:
> Hi all!
>
> From reading the documentation on AxKit and XSP, it seems that XML
> namespaces are a must for making full use of AxKit. Problem is, I've been
> totally unable to find any documentation on namespaces.
>
> Can anyone point me to a good tutorial on using and writing XML namespaces,
> or at least give me a quick run-down on how they are built, and the
> internal structure (if any) of a namespace?
>
> Thanks,
>   Eddie
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

-- 
Tod Harter
Giant Electronic Brain

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to