Multiple colons in namespace names?

G

Grant Robertson

I am relatively new to XML, though I have taught myself a lot in the past
month. I keep seeing namespace names with multiple colons in them such
as:

"urn:eek:asis:names:tc:entity:xmlns:xml:catalog"

but I can't find any information on exactly what that means. Is that a
namespace defined within a namespace defined within a namespace? Are they
all nested within the same XML file? Or if I know the URI for "urn"
(which I presume is the commonly known URI for the Universal Resource
Number schema) and look at that schema will I find a namespace
declaration for "oasis"? I presume it will be something like:

xmlns:eek:asis="wherever the heck some default schema for OASIS is located"

Then if I look there I'm guessing I will find yet another schema with the
"names" namespace specified. Etc, etc, till I get to the declaration for
the catalog schema? It sure seems like a lot of hopping around when they
could have just specified the URI for the catalog schema in the first
place.

Thanks.


P.S. I understand that, technically, URIs don't need to point to any
actual file or even an actual server. However, I have found that all of
the ones I have explored actually do. We can discuss URIs later.
 
R

Richard Tobin

Grant Robertson said:
I am relatively new to XML, though I have taught myself a lot in the past
month. I keep seeing namespace names with multiple colons in them such
as:

"urn:eek:asis:names:tc:entity:xmlns:xml:catalog"

but I can't find any information on exactly what that means. Is that a
namespace defined within a namespace defined within a namespace?

Colons are used to separate the prefix from the local part in an XML
element name, but colons in the URI associated with the prefix have no
meaning as far as XML is concerned.

<foo:bar xmlns:foo="urn:b:c:d"/>

The colons in "foo:bar" and "xmlns:foo" mean something to the XML
processor, but the ones in "urn:b:c:d" don't.

-- Richard
 
G

Grant Robertson

<foo:bar xmlns:foo="urn:b:c:d"/>

The colons in "foo:bar" and "xmlns:foo" mean something to the XML
processor, but the ones in "urn:b:c:d" don't.


So when I see something like

"urn:eek:asis:names:tc:entity:xmlns:xml:catalog"

defined as the namespace name for an Entity Catalog in the OASIS spec for
catalogs found at

http://www.oasis-open.org/committees/entity/specs/cs-entity-xml-catalogs-
1.0.html#s.entity.catalog

then what am I to make of all those colons? How would I specify that
namespace in an XML document?

xmlns:catalog="urn:eek:asis:names:tc:entity:xmlns:xml:catalog" ??

How the heck is my XML parser supposed to identify and find the DTD or
schema for that namespace and validate against it? Or is my software just
supposed to have the schema for that namespace hard-coded into it and
already know how to parse any elements or attributes scoped as belong to
that catalog namespace? This seems counter to the spirit of XML.
 
R

Richard Tobin

Grant Robertson said:
then what am I to make of all those colons? How would I specify that
namespace in an XML document?

xmlns:catalog="urn:eek:asis:names:tc:entity:xmlns:xml:catalog" ??
Yes.

How the heck is my XML parser supposed to identify and find the DTD or
schema for that namespace and validate against it?

Namespace URIs are not primarily to identify schemas and DTDs, though
they can be used for that.
Or is my software just
supposed to have the schema for that namespace hard-coded into it and
already know how to parse any elements or attributes scoped as belong to
that catalog namespace?

You don't need a schema to parse it, only to validate it.

You can give a schema location with xsi:schemaLocation in your document.

Of course, one to to find DTDs and schemas is to use a catalogue.
Presumably you know about that, since the URI you are asking about is
the namespace URI for catalogues!

-- Richard
 
G

Grant Robertson

Of course, one to to find DTDs and schemas is to use a catalogue.
Presumably you know about that, since the URI you are asking about is
the namespace URI for catalogues!

Actually, I don't. That's why I was reading the spec. But I get your
point. They have an "official" name they want you to use and it is
supposed to be globally unique but I have to just trust them on that.
Then I can use a catalog file to allow my software to find the actual URI
of the schema or even just a mirror of that schema somewhere else.

You are correct, I improperly used "parse" as a synonym for "validate."
To me, it doesn't make much sense to parse without validation. It is very
important to me to ensure that data is correct before attempting to load
it into a memory structure for use by a program.
 
R

Richard Tobin

Grant Robertson said:
To me, it doesn't make much sense to parse without validation. It is very
important to me to ensure that data is correct before attempting to load
it into a memory structure for use by a program.

Obviously data from unreliable sources has to be validated somehow.
But it doesn't have to be done with a general-purpose validator. It
can be done by your application as you use it to build the
structures, and typically it *has* to be done at least partly that
way, since schema languages can't express all the constraints
required.

And in many cases the data comes from a reliable source, and
validation is only useful for debugging. We run pipelines with
of the order of 100 steps; performing schema validation at every
stage would be very expensive.

-- Richard
 
J

Joe Kesselman

Since XML itself never actually interprets/dereferences the namespace
name, this isn't really an XML question. But:

Namespace names are URIs. After the scheme identifier (which is
delimited by the first colon), the permissibility and meaning of the
rest of the line is defined by that specific scheme.

XML doesn't care. As far as we're concerned, a namespace is just a
literal string that happens to be expressed in absolute-URI-reference
syntax because we know how to manage that set of values to avoid
unintended conflict/reuse.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,007
Messages
2,570,266
Members
46,865
Latest member
AveryHamme

Latest Threads

Top