19 Short Questions about Namespaces
(With Answers)
Date: Mon, 8 Feb 1999 10:40:44 -0500 (EST) From: David Megginson <david@megginson.com> To: XML Developers' List <xml-dev@ic.ac.uk> Subject: [corrected] 19 Short Questions about Namespaces (with Answers)
19 Short Questions about Namespaces (With Answers)
by
David Megginson
Monday 8 February 1999 (v.2)
Background
For the full specification of XML 1.0, see [1]; for the full specification of Namespaces in XML, see [2]. This brief review uses James Clark's notation for writing names that contain both a URI part and a local part. For example, if the URI part of a name were "http://www.foo.com/" and the local part were "a", the name would be written {http://www.foo.com/}a This is purely a convenience notation for the sake of documentation; it is not defined by any known specification, and is unlikely to be recognised by any processor.
Chapter One: The XML 1.0 Perspective
[Example]
<a b="x" c="y"/>
[Q] What is the name of the element in the example above?
[A] The name is "a".
[Q] What is the name of the first attribute in the example above?
[A] The name is "b".
[Q] What is the name of the second attribute in the example above?
[A] The name is "c".
[Q] What do the names mean?
[A] The application determines the meaning of the names.
[Q] How do you write a DTD declaration describing the structure of
this element?
[A] <!ELEMENT a EMPTY>
<!ATTLIST a
b CDATA #IMPLIED
c CDATA #IMPLIED>
Chapter Two. The Namespaces Perspective
[Example 2a]
<z:a z:b="x" c="y" xmlns:z="http://www.foo.com/"/>
[Q] What is the name of the element in the example above?
[A] The name is "z:a" from the XML 1.0 perspective, or
"{http://www.foo.com/}a" from the Namespaces perspective.
[Q] What is the name of the first attribute in the example above?
[A] The name is "z:b" from the XML 1.0 perspective, or
"{http://www.foo.com/}b" from the Namespaces perspective.
[Q] What is the name of the second attribute in the example above?
[A] The name is "c" from both the XML 1.0 and the Namespaces
perspectives.
[Q] What is the name of the third attribute in the example above?
[A] The name is "xmlns:z" from the XML 1.0 perspective; from the
Namespaces perspective, this attribute is a declaration.
[Q] What do the names mean?
[A] The application determines the meaning of the names.
[Q] What does the namespace URI "http://www.foo.com/" mean?
[A] It has no defined meaning.
[Q] How do you write a DTD declaration describing the structure of
this element?
[A] DTDs use the XML 1.0 perspective:
<!ELEMENT z:a EMPTY>
<!ATTLIST z:a
z:b CDATA #IMPLIED
c CDATA #IMPLIED
xmlns:z CDATA #FIXED "http://www.foo.com">
[Example 2b]
<a b="x" c="y" xmlns="http://www.foo.com/"/>
[Q] What is the name of the element in the example above?
[A] The name is "a" from the XML 1.0 perspective, or
{http://www.foo.com/}a from the Namespaces perspective.
[Q] What is the name of the first attribute in the example above?
[A] The name is "b" from both the XML 1.0 and the Namespaces
perspectives.
[Q] What is the name of the second attribute in the example above?
[A] The name is "c" from both the XML 1.0 and the Namespaces
perspectives.
[Q] What is the name of the third attribute in the example above?
[A] The name is "xmlns" from the XML 1.0 perspective; from the
Namespaces perspective, this attribute is a declaration.
[Q] What do the names mean?
[A] The application determines the meaning of the names.
[Q] What does the namespace URI "http://www.foo.com/" mean?
[A] It has no defined meaning.
[Q] How do you write a DTD declaration describing the structure of
this element?
[A] DTDs use the XML 1.0 perspective:
<!ELEMENT a EMPTY>
<!ATTLIST a
b CDATA #IMPLIED
c CDATA #IMPLIED
xmlns CDATA #FIXED "http://www.foo.com">
References
All the best,
David
David Megginson
Email: david@megginson.com
WWW: http://www.megginson.com/
xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@ic.ac.uk Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1 To (un)subscribe, mailto:majordomo@ic.ac.uk the following message; (un)subscribe xml-dev To subscribe to the digests, mailto:majordomo@ic.ac.uk the following message; subscribe xml-dev-digest List coordinator, Henry Rzepa (mailto:rzepa@ic.ac.uk)
Prepared by Robin Cover for the The SGML/XML Web Page archive. For more on namespaces, see "Namespaces in XML."

