Namespaces in XML

As markup languages proliferate, markup language designers will want to reuse portions of languages instead of reinventing the wheel. This poses the problem of naming collisions. For example, what if we mixed HTML tags with our own Book Review Markup Language that also had a <TITLE> tag?

For example:

<HTML>
<HEAD>
      <TITLE> Book Review Page </TITLE>
</HEAD>
<BODY>
      <BOOK>
            <TITLE>  Developing XML in Java </TITLE>
            <AUTHOR>  Michael C. Daconta   </AUTHOR>
     </BOOK>
</BODY>
</HTML>

If a program were to parse this document, how would the programmer know which TITLE was the book title? In order to accomplish this, element and attribute names must be universal. To create a universal name, an XML name is separated into two parts: a namespace ...

Get XML Development with Java™ 2 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.