O'Reilly logo

Enterprise JavaBeans, Fourth Edition by Richard Monson-Haefel, Bill Burke, Sacha Labourey

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

XML Schema and XML Namespaces

We’ll start with the basics of XML Schemas 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. I recommend the book Learning XML by Erik T. Ray (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 DTD (Document Type Definition), 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>3243 West 1st Ave.</street>
  <city>Madison</city>
  <state>WI</state>
  <zip>53591</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 . There are two ways that the correctness of an XML document can be measured: if it is well formed and if 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 like SAX and DOM detect documents that aren’t well formed automatically.

In addition to being well formed, it’s sometimes important to check that the document ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required