KBD

Keith Devens .com

Monday, May 21, 2012 Flag waving
*What in our history together makes you think I'm capable of something like that?* – Owen Wilson's character in Shanghai Knights
← FirebirdPerl inflexible with abstractions →

Daily link icon Tuesday, June 3, 2003

Why I don't grok (XML) namespaces

Here's why I don't grok namespaces. First, some context:

"Sam Ruby didn't get everything he wants in RSS 2.0, neither did Tim Bray. They both want the same thing, the ability to include elements of RSS in other XML formats.

As I understand it, namespaces were intended to make possible exactly this.

So, supposedly you have some standard XML-based markup language (SXBML), and you want to include a document of some other standard XML-based markup language (SOSXBML) inside an SXBML document. So as to not "pollute" your pure SXBML, you distance yourself from that foreign markup by saying "Hey, he's not with me", and you partition it within your document using a namespace.

You'll never want to include some XML that isn't part of some standard and therefore has no namespace, you see. And naturally, each of your standards has been defined by some magnificent schema that encapsulates all the semantics (meaning) about every tag. This lets you use automated tools that magically know what to do with your document.

Yeah, right.

Well, if a computer can't divine what to do with a piece of XML without having code written by a human process it -- the human's mind is the only place where the "meaning" of the XML can be said to be known, not in some "schema" -- then what does the namespace give us (besides a headache)? I say nothing.

If I nest one document within another, the human programmer understands this. It doesn't matter that a tag is preceded by some alphanumeric characters and a colon, which form a string that the XML document says is used a certain way within the document and points the reader towards some globally, interplanetarilly, universally unique string that... well, what does that string do for us?

I'm just sick of everybody trying to write some labels down (that's all an XML document is) and claim that it has some "meaning" apart from a mind understanding it. A mind can understand the document just fine whether the label it's understanding is xhtml:body or xhtml-body. And therefore the code that a programmer writes with that understanding can work with either equally well.

E-mail headers, MIME, HTTP, etc. have gotten along fine by using X- headers for non standardized extensions. And in practice you can make up whatever you want and it doesn't matter. But what if two people use the same name? A standards body is supposed to make the official list to keep that from happening for anything that counts. I probably wouldn't get the standards organizations to recognize a Keith-is-awesome: e-mail header. Nor Slashdot's Futurama quote http header. So the developers of XML wanted to distribute this authority. XML lets people define their own namespaces for their custom name, and then the person putting together the final "document" can associate each piece with a namespace so that there's no conflict

The problem is that XML has gone and distributed both ends, which is just silly. XML makes it possible for anyone to be their own standards body for their own personal SXBML, and at the same time anyone else can make a tag for that standard. But what kind of standard is it anyway if anyone can go making his own tags? How can he expect his tags to magically work without a community consensus? A community has to decide collectively what something means for there to be interoperable software written. It seems like people are trying to have a "schema" decide meaning, rather than what works: "rough consensus and working code".

Update: Keep in mind that namespaces in programming languages serve a very different purpose than they do in markup languages like XML.

In source code, the authority to name things is distributed only on one end, not two. So, anyone can write code, but if another person wants to use that code he has no control over what names were used. It's sort of the opposite of the HTTP and MIME example. Namespaces in programming languages are an important feature, so it seems that distribution of authority on one side works, just not two.

Namespaces serve a significant function in programming languages. They help prevent name conflicts, and that's important when you want to include code that (possibly many) others have written along with your own code, since, unlike with SXBML and unlike with HTTP or MIME, there's no central standards body defining what names you can use for things. That's why Java's convention is to provide code in packages identified by globally unique strings. Everyone can have their own namespace.

Namespaces aren't always called that, however. Some languages call them "modules", some "packages", others simply use classes as the basic form of namespace, and some provide "namespaces" explicitly.

Namespaces in programming languages are especially important for another reason as well. Source code is generally very flat, often just one level of functions, and maybe one level of classes. Markup languages like XML, on the other hand, can nest to any depth. That's why languages like C++ and PHP have explicit namespaces, or are getting them. Both languages don't have any higher level packaging mechanism other than the class, and both also allow plain functions outside of a class.

← FirebirdPerl inflexible with abstractions →

Comments XML gif

Robajz (http://www.robajz.info/) wrote:

Aw dear, you just made me read this crappy useless blah blah. Why did you bother to waste your and mine time? You don't even have any adds on the site Smiley (big smile) that would make one guess... Poor old sclerotic google brought me here to finish my day in the office. I'm so annoyed I had to tell you.

Name spaces are good, with their implementation it is worse.

Read some stuff before you bother writing something next time. Here's a good one: http://www.sitepoint.com/print/xml-namespaces-explained/

The thing is xhtml-body is pretty much the same as xhtml:body, that's just a standardised convention. It's just much more probable, that if you take a longer string, that it will be more or less unique in the given context, but you wouldn't want to write elements like <this-is-my-bloody-wicked-lovable-element />, then want other people to use it in their documents, if you were not ready for a suicide. And hence namespaces coz even though a table is a table, xhtml:table is not a furniture:table while it still can be my:table

Damn you really got me started...

never mind, best of luck, Robert

∴ Robajz | 2-Sep-2009 10:21am est | http://www.robajz.info/ | #11364

Feel free to post a comment below. Please see my comment policy.

Formatting Rules (No HTML):

  • **bold**, *italic*, _underlined_, --strikeout--
  • "text"="url" creates a link, and URLs are auto-highlighted
  • Blockquote: Like e-mail, begin paragraph with > (greater-than sign)
  • Lists: begin paragraph with *,-, or + (unordered), or # (ordered)
  • Code block: ?!code:language=perl|php|sql|javascript|etc.{\n}...{\n}?!/code

:
(will be your IP address if blank)
: (optional)
(Will not be shown on site)

: (optional)
:

May 2012
SunMonTueWedThuFriSat
 12345
6789101112
13141516171819
20212223242526
2728293031 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 5 posts

Recent comments XML

new⇒What is your favorite quote, passage, or idea in all of philosophy? Why? : philosophy

I have just made the mistake of​checking the Reddit thread you​linked to, a...

Revence: May 21, 1:51am

Acknowledging the Arrival of Peak Government

In many ways, Peak Oil is​responsible for this new​uselessness of the big g...

Revence: May 16, 6:35am

Tab EXSPLOSION

Right now, I, too, have too many​tabs open. A rough count says​25.
Right. ...

Revence: May 16, 6:21am

George W. Bush: ‘I’m for Mitt Romney’ - ABC News

A marked difference (departure,​even) from the KBD of eight--yea,​even four...

Revence: May 15, 1:55pm

WebOb — WSGI request and response objects

Google App Engine forces one to​learn these....

Revence: May 15, 1:52pm

Generated in about 0.223s.

(Used 8 db queries)