XML Schema Definition Introduction

What is an XML schema? It defines the blueprint or grammar of an XML document. The schema is a separate file that has an XSD file extension. The W3C (World-wide web consortium) defines the XSD file. If an XML document has a schema definition and the XML file follows the schema definition, then it is called a valid XML file. Valid is not the same thing as well-formed. The schema definition covers the following items.

  • Elements
  • Attributes
  • Namespaces
  • Order
  • Number of Occurrences
  • Restrictions

An XSD is a contract between two XML users.

Schema Data Types

What types of data types our elements and attributes can carry? W3C specification defines them. There are Numeric types, Date types, and String types. These are called inbuilt types.

  • byte
  • short
  • int
  • long
  • decimal
  • other types
  • date
  • dateTime
  • time
  • gDay, gMonth and so on
  • string

Simple Types

We can take the above inbuilt types to build our own simple types by extending them. We can also create complex types. For example, we can take an inbuilt type and extend it to create a simple type. Our new simple type can have restrictions on it. For example, we can limit the length of a string. The syntax for creating simple types is provided by W3C.

Complex Types

Complex types are elements that can have other elements inside them. We can build them by using inbuilt types, simple types or other complex types, or any combination of these three. Complex types are analogous to classes in other programming languages.

Series NavigationXML Schema Definition Part 2 >>

Leave a comment

Your email address will not be published. Required fields are marked *