This section describes a tutorial example on how to declare a simple element that accepts only text content using a built-in datatype or a user defined simpleType datatype.
What is a simple element? A simple element is an XML element that does not have
any attributes or any sub (child) elements. A simple element can be declared with a simple datatype.
In other word, a simple element is an element with text content, no sub (child) element, and no attribute.
This type of element can be declared with a built-in datatype or a "simleType" derived from a built-in datatype.
Here is a sample schema, simple_element.xsd, that declares a simple element using "simpleType":
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!--simple_element.xsd
- Copyright (c) 2007 by Dr. Herong Yang. All rights reserved.
-->
<xs:element name="title">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="256"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:schema>
For more tutorial examples, see the built-in datatype chapter in this book.