Jump to content

Newbie Question About Namespaces


Guest TJaze

Recommended Posts

I have just started learning about schemas, and though I'm familiar with namespaces (being a programmer), I'm still a little unclear on how they are used in XML & schemas.Are these just a named reference used to identify a namespace, or do the URL addresses (often used in identifying namespaces), actually contain information that is referenced by the XML or schema file?

Link to comment
Share on other sites

  • 2 weeks later...

The URI of a namespace doesn't provide any information, it is just used as an identifier.The namespace just allows two elements of the same name, with different meanings, to be in the same document.

Link to comment
Share on other sites

... or as you said it yourself, it's

just a named reference used to identify a namespace
Keep in mind that unlike languages like PHP, C and C#, namespaces in XML are not inhereted. Each URI is treated literaly, without any processing, and is therefore considered as the full namespace. That is, in
<a xmlns="http://example.com"><b/><c xmlns="/ns"/></a>

The <a/> and <b/> elements are in the "http://example.com" namespace, and the <c/> element is in the "/ns" namespace (NOT in the http://example.com/ns" namespace). In fact, to avoid such kind of confusion, recent editions of the XML namespaces specification deprecated relative URIs, and implementations are therefore encouraged to give warnings if you use such URIs.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...