O'Reilly logo

Sams Teach Yourself XML in 10 Minutes by Andrew H. Watt

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

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, ...

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