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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access