Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set up my own XML namespace?

How can I setup my own XML namespace?

like image 621
Freek Avatar asked Feb 21 '11 22:02

Freek


1 Answers

Just define a namespace in the root tag (or wherever you need the namespace). Example:

<root xmlns:ns="some_identifier">

ns and the identifier can be (nearly) anything. See this quote:

What Do Namespace Names Point At?

One of the confusing things about all this is that namespace names are URLs; it's easy to assume that since they're Web addresses, they must be the address of something. They're not; these are URLs, but the namespace draft doesn't care what (if anything) they point at. Think about the example of the XML.com programmer looking for book titles; that works fine without the namespace name pointing at anything.

The reason that the W3C decided to use URLs as namespace names is that they contain domain names (e.g. www.xml.com), which work globally across the Internet.

The Wikipedia article is also quite informative.

I hope you know that you need namespaces just for distinguishing tags with the same name.

like image 150
Felix Kling Avatar answered Oct 16 '22 17:10

Felix Kling