Download Sample XSD File Format

Spread the love

To define what attributes and elements may appear in an XML document usually an sample XSD file is used. Moreover, it also play role in defining what data may be stored in them and what is the relationship of the elements. This kind of file is written in the W3C XML Schema language.

To define the shape or the structure of an XML document XML schema is used. All the contents within this file are stored in the plain text in the XML format. This simply means anyone can open and view the data through the text editor. 

For any editing in the XSD file format there is a need of an XML editor. There are many editors like Microsoft XML Notepad, SyncRO Soft Oxygen XML editor and Bare Bones BBEdit. The XML data constraints are known as facets. This also includes rules such as max length and min length.  

Some of the key features of XSD file are as follows:

Sample xsd File

Currently, XSD is a de facto standard for describing XML documents. It is controlled by the World Wide Web Consortium (W3C). Other schema standards are also available such as RELAX and Schematron. 

Here are the some xsd file examples you can download it for testing use

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"

           xmlns:tns="http://tempuri.org/PurchaseOrderSchema.xsd"

           targetNamespace="http://tempuri.org/PurchaseOrderSchema.xsd"

           elementFormDefault="qualified">

 <xsd:element name="BuyOrder" type="tns:BuyOrderType"/>

 <xsd:complexType name="BuyOrderType">

  <xsd:sequence>

   <xsd:element name="ShipTo" type="tns:USAddress" maxOccurs="2"/>

   <xsd:element name="BillTo" type="tns:USAddress"/>

  </xsd:sequence>

  <xsd:attribute name="OrderDate" type="xsd:date"/>

 </xsd:complexType>

 

 <xsd:complexType name="USAddress">

  <xsd:sequence>

   <xsd:element name="name"   type="xsd:string"/>

   <xsd:element name="street" type="xsd:string"/>

   <xsd:element name="city"   type="xsd:string"/>

   <xsd:element name="state"  type="xsd:string"/>

   <xsd:element name="zip"    type="xsd:integer"/>

  </xsd:sequence>

  <xsd:attribute name="country" type="xsd:NMTOKEN" fixed="US"/>

 </xsd:complexType>

</xsd:schema> 

The following sample XSD describes the elements in an XML file

<?xml version="1.0" encoding="UTF-8" ?>

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="shiporder">

  <xs:complexType>

    <xs:sequence>

      <xs:element name="orderperson" type="xs:string"/>

      <xs:element name="shipto">

        <xs:complexType>

          <xs:sequence>

            <xs:element name="name" type="xs:string"/>

            <xs:element name="address" type="xs:string"/>

            <xs:element name="city" type="xs:string"/>

            <xs:element name="country" type="xs:string"/>

          </xs:sequence>

        </xs:complexType>

      </xs:element>

      <xs:element name="item" maxOccurs="unbounded">

        <xs:complexType>

          <xs:sequence>

            <xs:element name="title" type="xs:string"/>

            <xs:element name="note" type="xs:string" minOccurs="0"/>

            <xs:element name="quantity" type="xs:positiveInteger"/>

            <xs:element name="price" type="xs:decimal"/>

          </xs:sequence>

        </xs:complexType>

      </xs:element>

    </xs:sequence>

    <xs:attribute name="orderid" type="xs:string" use="required"/>

  </xs:complexType>

</xs:element>

</xs:schema>