Built-in Simple Types

Welcome to our free XML tutorial. This tutorial is based on Webucator's Introduction to XML Training course.

Contact Us or call 1-877-932-8228
Built-in Simple Types

Built-in Simple Types

XML Schema specifies 44 built-in types, 19 of which are primitive.

19 Primitive Data Types

The 19 built-in primitive types are listed below.

  1. string
  2. boolean
  3. decimal
  4. float
  5. double
  6. duration
  7. dateTime
  8. time
  9. date
  10. gYearMonth
  11. gYear
  12. gMonthDay
  13. gDay
  14. gMonth
  15. hexBinary
  16. base64Binary
  17. anyURI
  18. QName

Built-in Derived Data Types

The other 25 built-in data types are derived from one of the primitive types listed above.

  1. normalizedString
  2. token
  3. language
  6. Name
  7. NCName
  8. ID
  9. IDREF
  10. IDREFS
  11. ENTITY
  13. integer
  14. nonPositiveInteger
  15. negativeInteger
  16. long
  17. int
  18. short
  19. byte
  20. nonNegativeInteger
  21. unsignedLong
  22. unsignedInt
  23. unsignedShort
  24. unsignedByte
  25. positiveInteger

Defining a Simple-type Element

A simple-type element is defined using the type attribute.

Code Sample:

<?xml version="1.0" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
	<xs:element name="Author">
				<xs:element name="FirstName" type="xs:string"/>
				<xs:element name="LastName" type="xs:string"/>

Notice the FirstName and LastName elements in the code sample above. They are not explicitly defined as simple type elements. Instead, the type is defined with the type attribute. Because the value (string in both cases) is a simple type, the elements themselves are simple-type elements.

The Author element is a complex-type element. Complex-type elements will be covered later in the course.


This tutorial is based on Webucator's Introduction to XML Training Course. We also offer many other XML Training courses. Sign up today to get help from a live instructor.