Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XMLNS and prefixes

Status
Not open for further replies.

gacaccia

Technical User
May 15, 2002
258
US
hey all,

i've tried researching this on my own, but i'm still a little confused by the following. i have an XML document with a root tag that looks like the following, and i'm wondering whether or not it is valid.

Code:
<ContinuityOfCareRecord xmlns="urn:astm-org:CCR">

questions:

1. is "urn:astm-org" a valid namespace? doesn't this need to be something like " (not the specific address, but that it would be a valid address)

2. what does the ":CCR" at the end represent? i see on w3.org the concept of a prefex, but that would look like
Code:
 xmlns:CCR="urn:astm-org"
. no?

thanks,

glenn
 
The namespace value is a URI, which merely is a unique string used to differentiate it from other namespace values. It looks to me like ASTM has decided as a standardizing organization on what ASTM URIs will look like.

Now when you specify [tt]xmlns="..."[/tt] you are specifying the default namespace value which will be used as the namespace on the ContinuityofCareRecord element as well as all elements subordinate to the ContinuityofCareRecord element.

When you specify a namespace prefix as in your second example, that namespace only applies where you apply that namespace prefix (CCR in your second example).

So, as an example, if you have
Code:
<ContinuityOfCareRecord xmlns="urn:astm-org:CCR">
then the namespace component of this element is "urn:astm-org:CCR".

To achieve the same effect when you use a namespace prefix, you would have to use:
Code:
<ccr:ContinuityOfCareRecord xmlns:ccr="urn:astm-org:CCR">
This differs from the first example, using the default namespace, however because subordinate elements would also require the [tt]ccr:[/tt] prefix in order to apply the namespace.

Does this help? Namespaces can really cause some confusion.

Tom Morrison
 
thanks for the response. i have one last question. i was reading about URI's and found the following description for URN's.
A URN looks something like this:

urn:foo:a123,456

First comes the string urn, upper- or lowercase, and a colon. After the first colon comes the Namespace Identifier, or NID, (foo in this case) followed by another colon. And finally comes the Namespace Specific String, or NSS (a123,456, for example).

is there any significance to the "NSS" in terms of parsers? in other words, if i have a urn of "foo:CRR", is this parsed differently than "foo.CRR" (or something similar)?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top