Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do XML Namespaces usually start with http://...?

Tags:

xml

wpf

For example, the WPF namespace is:

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

If I define my own namespace, should it also start with http? Isn't http misleading?

like image 746
willem Avatar asked Aug 05 '09 10:08

willem


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 the correct way of declaring XML namespace?

XML Namespaces - The xmlns Attribute When using prefixes in XML, a namespace for the prefix must be defined. The namespace can be defined by an xmlns attribute in the start tag of an element. The namespace declaration has the following syntax. xmlns:prefix="URI".

What is the default namespace in XML?

When you use multiple namespaces in an XML document, you can define one namespace as the default namespace to create a cleaner looking document. The default namespace is declared in the root element and applies to all unqualified elements in the document. Default namespaces apply to elements only, not to attributes.

What is the default namespace in HTML?

HTML is being defined in terms of the DOM and during parsing of a text/html all HTML elements will be automatically put in the HTML namespace, http://www.w3.org/1999/xhtml . However, unlike the XHTML serialization, there is no real namespace syntax available in the HTML serialization (see previous question).


1 Answers

Namespaces doesn't have any meaning in their value, except for that value to be unique to avoid nameclashing. This is why you see a lot of companies putting in the URL for their own website as the namespace. URLs serve the same purpose, to be unique. Over the years it's just become good practice to use an URL, because if everyone does that, no nameclashing should occur :)

like image 106
cwap Avatar answered Oct 06 '22 01:10

cwap