What is XML Schema (XSD)?

Posted: (EET/GMT+2)

 

The XML format is becoming increasingly popular. If XML is used for exchanging information between applications, it is important to ensure that XML documents follow an agreed structure. XML Schema (XSD) is a W3C standard that defines the elements, attributes, and data types that are allowed in an XML document.

Unlike Document Type Definitions (DTDs), XML Schema is itself written in XML and supports strong data typing. Here is an example:

<xs:element name="CustomerID" type="xs:string" />
<xs:element name="OrderDate" type="xs:date" />
<xs:element name="Amount" type="xs:decimal" />

Applications can validate XML documents against an XML Schema before processing them. This helps detect missing elements, invalid values, and incorrect document structures.

XML Schema is commonly used together with SOAP (XML Web Services), allowing clients and servers to exchange strongly typed XML messages. As XML-based applications continue to grow, XML Schema is becoming the preferred method for describing XML document formats.

Happy hacking!