jQuery in Action, 3rd edition
The moose likes XML and Related Technologies and the fly likes DTD Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "DTD" Watch "DTD" New topic


j krishnan

Joined: Jul 20, 2001
Posts: 27
what is a namespace
how to create namespaces.
L Goundalkar
Ranch Hand

Joined: Jul 05, 2001
Posts: 395
The purpose of XML namespaces is to distinguish between duplicate element type and attribute names. Such duplication might occur, for example, in an XSLT stylesheet or in a document that contains element types and attributes from two different DTDs.
An XML namespace is a collection of element type and attribute names. The namespace is identified by a unique name, which is a URI. Thus, any element type or attribute name in an XML namespace can be uniquely identified by a two-part name: the name of its XML namespace and its local name. This two-part naming system is the only function of XML namespaces.

XML namespaces are declared with an xmlns attribute, which can associate a prefix with the namespace. The declaration is in scope for the element containing the attribute and all its descendants. For example:
<!-- Declares two XML namespaces. Their scope is the A and B elements. -->
<A xmlns:foo="http://www.foo.org/" xmlns="http://www.bar.org/">

If an XML namespace declaration contains a prefix, you refer to element type and attribute names in that namespace with the prefix. For example:
<!-- A and B are in the http://www.foo.org/ namespace, which is associated with the foo prefix. -->
<foo:A xmlns:foo="http://www.foo.org/">

If an XML namespace declaration does not contain a prefix, the namespace is the default XML namespace and you refer to element type names in that namespace without a prefix. For example:
<!-- This is equivalent to the previous example but uses a default namespace instead of the foo prefix. -->
<A xmlns="http://www.foo.org/">

Who can create an XML namespace?
Anybody can create an XML namespace -- all you need to do is assign a URI as its name and decide what element type and attribute names are in it. The URI must be under your control and should not be being used to identify a different XML namespace, such as by a coworker.
(In practice, most people that create XML namespaces also describe the element types and attributes whose names are in it -- their content models and types, their semantics, and so on. However, this is not part of the process of creating an XML namespace, nor does the XML namespace include or provide a way to discover such information.)


L Goundalkar
Sun Certified Programmer for Java 2 Platform

I agree. Here's the link: http://aspose.com/file-tools
subject: DTD
It's not a secret anymore!