[Tutor] XML parsing

Stefan Behnel stefan_ml at behnel.de
Fri Mar 30 12:51:52 EDT 2018


Neil Cerutti schrieb am 30.03.2018 um 15:50:
> On 2018-03-30, Stefan Behnel wrote:
>> I admit that I'm being a bit strict here, there are certainly
>> cases where parsing the namespace from a tag is a sensible
>> thing to do. I'm really just saying that most of the time, when
>> you feel the need to do that, it's worth reconsidering (or
>> asking) if you are doing the right thing.
> 
> Namespaces hurt my head when I try to imagine a use for them. The
> only one's I've encountered are just applied to an entire
> document, making parsing more inconvenient but providing no other
> benefit I can see.

Actually, namespaces give meaning to data, and they allow combining
different XML languages into one document. Without them, it would be
impossible to tell, for example, that what a document contains is an author
name in Dublin Core metadata and not an image subtitle. Or a base64 encoded
inline image. Or anything. They allow you to cleanly extract an SVG image
from an ODF document without implementing the OpenDocument standard first.

Namespaces enable reuse of well defined semantics, in the same way that you
would structure your code in functions and modules, instead of stuffing
everything in the main module as plain top-level code.

Stefan



More information about the Tutor mailing list