Jump to content
Sign in to follow this  
Guest TJaze

Newbie Question About Namespaces

Recommended Posts

Guest TJaze

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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.

Edited by boen_robot

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...