This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "DTD" Watch "DTD" New topic
Author

DTD

j krishnan
Greenhorn

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

Joined: Jul 05, 2001
Posts: 395
Hi,
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/">
<B>abcd</B>
</A>

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/">
<foo:B>abcd</foo:B>
</foo:A>

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/">
<B>abcd<B>
</A>

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.)

Thanks.

------------------
L Goundalkar
lggoundalkar@hotmail.com
Sun Certified Programmer for Java 2 Platform


SCJP, SCWCD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DTD
 
Similar Threads
package
Help: anonymous class
Change Namespace for Axis2
SAX limitations
Mapping several default actions