XML Schema Tutorial



Simple Element


A simple element that is not <complexType> can't have any child elements or attributes.


A simple element can contain only its value.


The following declaration of a simple element represents that an element '<power>' with its integer value must appear.

<xs:element name="power" type="xs:integer"/>


Data Types

  • xs:string

    <name>Wooden Sword</name>

  • xs:normalizedString - removes leading and trailing spaces, tabs, line feed(LF), carrage return(CR) and can have multiple spaces between.

    <name> Wooden Sword </name>

  • xs:token - removes leading and trailing spaces, tabs, line feed(LF), carrage return(CR) and can have a single space between.

    <name> Wooden Sword </name>

  • other string data types - xs:ENTITIES, xs:ENTITY, xs:ID, xs:IDREF, xs:IDREFS, xs:language, xs:Name, xs:NCName, xs:NMTOKEN, xs:NMTOKENS, xs:QName
  • xs:decimal

    <price>99.95</price>

  • xs:integer

    <power>100</power>

  • xs:boolean

    <human>true</human>

  • xs:base64Binary
  • xs:hexBinary
  • xs:anyURI

    <uri>http://www.elventek.com</uri>

  • xs:date

    <appointment>2021-08-25</appointment>

  • xs:time

    <alarm>09:00:00</alarm>

  • xs:dateTime

    <schedule>2021-08-25T13:00:00</schedule>

  • xs:duration - start with 'P' and then 'Y', 'M', 'D', 'T', 'H', 'M', or 'S'

    <vacation>P5D</vacation> - 5 days

    <rest>PT5M</rest> - 5 minutes

  • and more


Default Value


A default value is assigned when no value was specified.


<xs:element name="target" type="xs:string" default="single"/>



Fixed Value


A simple element with a fixed value can't have any other value.


<xs:element name="target" type="xs:string" fixed="single"/>