Clarifying: Your document is xhtml
document, and has set that as its default namespace (xmlns="http://www.w3c.org/xhtml
) What the xmlns=""
attribute does is to say that this default no longer applies, and that the element it appears on and its children are not to be understood as xhtml
but as raw xml with no default namespace.
Yes, this syntax is widely used wherever it is necessary to cancel a default namespace (though arguably it'd be slightly better form to not set the default namespace in the first place and use prefixes on your names to bind them to namespaces).
As to whether you should be using "no namespace" in the first place: That's up to you. Namespaces are recommended for any nontrivial document type because they make it possible at some point in the future to intermix elements from that document type with elements from another document type and make sense out of the combination. Basically, if you don't use namespaces then there's a risk that your use of <name>
for a hotel will get entangled with someone else's use of <name>
for a human or a variable or gods-know-what.
Without namespaces, you'd have to seriously consider always writing something like <TRAVEL_AGENT_DATA_HOTEL_name>
to avoid that hazard. Being able to just write <hotel:name>
, and bind the hotel:
prefix to the namespace for travel-agent documents really is a huge improvement.
XML Namespaces were created because they were needed. You will use them, because you will need to use them.