About XML Schemas

Microsoft Office InfoPath

Show All Show All

About XML Schemas

An XML Schema is an XML file with an .xsd file name extension. An XML Schema is used to define the structure and type of data that an XML document can contain. It specifies the elements, attributes, and data types that can be used in an XML document, along with the structure that must be followed for the XML document to be valid for that particular XML Schema.

Schema files have a root element named schema, and all of the element, attribute, and data type definitions are nested within it.

The XML Schema can also be used to validate the data contained in the elements and attributes. The following is a list of some of the types of data validation that can be performed by an XML Schema:

  • Data types    Control the types of data that an element or attribute can contain. Examples include string, Boolean, float, integer, date, and time.
  • Constraining facets    Place limits on the value space of data types. Examples include length, pattern, enumeration, minimum and maximum ranges, and precision.
  • Cardinality    Controls the number of permitted occurrences. Examples include one, zero or one, zero or more, and one or more.
  • Choice    Limits values to those contained in a list of values.
  • Sequence    Defines the order in which elements may be used.
  • Defaults    Provide values that are used when no other value is specified.

The namespace for XML Schemas is: xmlns:xsd="http://www.w3.org/2001/XMLSchema"