Skip Navigation

Understanding XML Schemas

An XML schema is a template for an XML file. The schema describes what elements the XML file can contain, what sub elements it can contain, and constraints described in types and attributes. XML schemas can contain the following:

The following is an example of a schema:

The red plus symbol + shows that there are more parts under that tag, but the example is collapsed to show a small portion.

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

       <xs:schema xmlns="" xmlns:xs="" elementFormDefault="qualified">

               <xs:element name=" OTA_AirLowFareSearchRQ">


                            + <xs:sequence>

                            + <xs:attribute name="EchoToken" use="optional">

                            + <xs:attribute name="TimeStamp" type="xs:string" use="optional">

                            + <xs:attribute name="Target" use="optional" default="Production">

                            + <xs:attribute name="Version" type="xs:string" use="required">

                            + <xs:attribute name="SequenceNmbr" type="xs:string" use="optional">

                            + <xs:attribute name="SequenceNmbr" type="xs:string" use="optional">

                            + <xs:attribute name="PrimaryLangID" type="xs:language" use="optional">

                            + <xs:attribute name="AltLangID" type="xs:language" use="optional">






Elements are the main building blocks of XML files. The element definition within a schema must contain a name, which will appear in the final XML file. Elements can also contain types, simple types, and complex types that describe what can be contained within an element in the final XML file.

Elements must appear between start and end tags. In the following example, the yellow highlighted area shows the start tag, and the orange shows the end tag. The content area shows the value for the element.

<name attribute="value">content</name>

XML provides special syntax for representing an element with empty content. Instead of a start tag followed immediately by an end tag, a document may contain an empty element tag. An empty-element tag resembles a start tag, but contains a forward slash (/) immediately before the closing angle bracket (>). The following example from the Bargain Finder Max Response illustrates an element with empty content.

<FareBasisCodes />


Some elements or complex types contain child elements within the start (yellow) and end (orange) tags. A child element is an element within an element. Multiple child elements are referred to as children. The following example from the Bargain Finder Max Response contains child elements (children).

<FlightSegment DepartureDateTime="2008-05-01T11:40:00" ArrivalDateTime="2008-05-01T13:10:00" StopQuantity="0" FlightNumber="2775" ResBookDesigCode="O">

        <DepartureAirport LocationCode="KRK" />

        <ArrivalAirport LocationCode="LGW" />

        <OperatingAirline Code="K0" FlightNumber="2775" />

        <Equipment AirEquipType="734" />

        <MarketingAirline Code="K0" />




Attributes provide extra information within an element. Attribute values are always between quotes ("value") and can appear only once in each element. In the following example, the green area highlights the attribute. The value area shows the value for the attribute.

<name attribute="value">content</name>

Simple Types 

Simple types specify the constraints and information about the values of attributes or text-only elements. Simple types do not contain children.

The following example shows the OriginDestinationInformation element (blue) from the Bargain Finder Max request. This element contains the RPH attribute (green) defined by RPH_Type, which is a simple. RPH_Type provides the constraints on what you can enter for the RPH attribute.

To see the relationship between the element, simple type, and attribute, click OriginDestinationInformation.

<OriginDestinationInformation RPH="1">

Common Types

Common types are simple types that apply to all the schemas described in Bargain Finder Max XML Help.

Complex Types

Complex types contain other element definitions and describe which children an element can contain. Complex types can contain both children and attributes.

The following example is from the Bargain Finder Max request. The POS element has the POS_Type, which is a complex type that describes what the POS element can contain. The POS_Type contains Source, which is a child element. The Source element also has a complex type that also contains children and attributes.

To see the children, attributes, and constraints that exist for these elements and types, click the links.


        <Source PseudoCityCode="PCC0">

                <RequestorID Type="0.AAA.X" ID="REQ.ID">

                        <CompanyName Code="CUSTOMER" />