Defining Complex and Simple Types

In W3C XML Schema there are two basic types of element content, simple types and complex types.

Simple types contain only text content and have no child elements or any attributes on the element. If an element has one or more attributes or has one or more child elements, it is said to be of complex type.

Defining Simple Types

Suppose you have a document with the following structure:

<memo> 
<from>John Smith</from> 
<email>JSmith@XMML.com</email> 
<to>Peter Roehampton</to> 
<emailto>Peter@SVGenius.com</emailto> 
<message>Hello Peter. I attach the SVG graphic you wanted to 
  see.</message> 
</memo> 

Several elements have simple string content of type xsd:string. You can define a simple type, such as for the email element, ...

Get Sams Teach Yourself XML in 10 Minutes 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.