IBM®
Skip to main content
    United States [change]      Terms of use
 
 
   
     Home      Products      Services & solutions      Support & downloads      My account     
     
  XML on TPF: A Short Tutorial IBM

XML on TPF: A Short Tutorial — Page 5 of 10
Create a Sample XML Schema

Using an XML Schema is another method of defining the acceptable tags for an XML document. An XML Schema is written in XML syntax and typically resides in a file that is separate from the XML document. The XML document must refer to the specific XML Schema document on which it is written.

Paul decides to create an XML Schema that coincides with the DTD for a PNR that he wrote previously. He knows that the organization of data in an XML document is the key to its success. However, Paul is less focused on an actual implementation of this XML Schema and more focused on demonstrating the various ways to write XML data:

  • Elements:
                    <xs:element name="FirstName"/>
                    
  • Nested Elements:
    		<xs:element name="FormOfPayment">
    		  <xs:complexType>
    		    <xs:sequence>
    		      <xs:element name="ccIssuer"/>
    		      <xs:element ref="ccNumber"/>
    		      <xs:element name="ccExpiration"/>
    		      </xs:sequence>
    		    </xs:complexType>
    		</xs:element>
                    
  • Attributes:
    		<xs:element name="PhoneNumber">
    		  <xs:complexType>
    		    <xs:attribute name="countryCode" />
    		    <xs:attribute name="areaCode" />
    		    <xs:attribute name="pNumber"/>
    		  </xs:complexType>
    		</xs:element>
                    

When he has written the XML Schema document, Paul ensures that he has included the following namespace declaration:

<xs:schema  xmlns:xs="http://www.w3.org/2001/XMLSchema">
and then saves it to his workstation as pnrs.xsd.

To view the full document, open Paul's XML Schema in another browser window. See how Paul uses elements, nested elements, and attributes. When you are done, close the window by clicking the X in the upper-right corner.

For More Information
See the TPF XML User's Guide for the following:

  • A list of books and Web sites for learning about XML Schema and its syntax
  • More information about XML Schema, namespaces, and specifying the encoding of your documents on the TPF 4.1 system.

PreviousNext

Back to the Beginning
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10

 

Close This Window.

 

    About IBM Privacy Contact