XML

Putting Namespaces to Use

Although it's true that namespaces have caused their fair share of confusion in the XML community, they nonetheless represent a reasonable solution to a tricky problem that is inherent in XML. As you know, XML allows you to create custom markup languages, which are languages that contain elements and attributes of your own creation.

XML is incredibly flexible in this regard, but there is nothing stopping two people from creating markup languages with very similar, if not identical, elements and attributes. What happens if you need to use both of these markup languages in a single document? There would obviously be a clash between identically named elements and attributes in the languages. Fortunately, as you will learn in this tutorial, namespaces provide an elegant solution to this problem.

In this tutorial, you'll learn
  • Why namespaces are important to XML
  • How namespace names are guaranteed to be unique
  • How to declare and reference namespaces in XML documents
  • How to use namespaces to merge schemas