Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are XML namespaces for?

This is something that I always find a bit hard to explain to others: Why do XML namespaces exist? When should we use them and when should we not? What are the common pitfalls when working with namespaces in XML?

Also, how do they relate to XML schemas? Should XSD schemas always be associated with a namespace?

like image 875
Doron Yaacoby Avatar asked Sep 24 '08 17:09

Doron Yaacoby


People also ask

Why are XML namespaces urls?

Just like namespaces in . NET, namespaces in XML documents are designed to help prevent and resolve name collisions, especially if XML documents are from different organizations and/or domains of knowledge.

What is an XML namespace A set of names?

[Definition:] An XML namespace is a collection of names, identified by a URI reference [RFC2396], which are used in XML documents as element types and attribute names.

What is XML namespaces and what its importance in the context of application integration?

XML namespaces are used for providing uniquely named elements and attributes in an XML document. They are defined in a W3C recommendation. An XML instance may contain element or attribute names from more than one XML vocabulary.


1 Answers

They're for allowing multiple markup languages to be combined, without having to worry about conflicts of element and attribute names.

For example, look at any bit of XSLT code, and then think what would happen if you didn't use namespaces and were trying to write an XSLT where the output has to contain "template", "for-each", etc, elements. Syntax errors, is what.

I'll leave the advice and pitfalls to others with more experience than I.

like image 96
Steve Jessop Avatar answered Oct 12 '22 16:10

Steve Jessop