XML Schema and XML Namespaces

We’ll start with the basics of XML Schema and XML Namespaces. It’s assumed that you already understand how to use basic XML elements and attributes. If you don’t, you should probably read a primer on XML before proceeding. We recommend the book Learning XML (O’Reilly). If you already understand how XML Schema and XML Namespaces work, skip ahead to the section on SOAP.

XML Schema

An XML Schema is similar in purpose to a Document Type Definition (DTD), which validates the structure of an XML document. To illustrate some of the basic concepts of XML Schema, let’s start with an XML document with address information:

<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<address>
  <street>800 Langdon Street</street>
  <city>Madison</city>
  <state>WI</state>
  <zip>53706</zip>
</address>

In order to ensure that the XML document contains the proper type of elements and data, the address information must be evaluated for correctness. You measure the correctness of an XML document by determining two criteria: whether the document is well formed and whether it is valid. To be well formed, an XML document must obey the syntactic rules of the XML markup language: it must use proper attribute declarations, the correct characters to denote the start and end of elements, and so on. Most XML parsers based on standards such as SAX and DOM automatically detect documents that aren’t well formed.

In addition to being well formed, the document must use the right types of elements ...

Get Enterprise JavaBeans 3.1, 6th Edition 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.