Workshop 3

For internal DTD XML

I created an internal DTD XML file, airportsDTD.xml, as follows:

And I executed the file in IE with positive result.

 

 

<?xml version=”1.0″ encoding=”UTF-8″ standalone=”yes”?>

<!DOCTYPE airports [

<!ELEMENT airports (airport+)>

<!ELEMENT airport (name, city, alt, lat, long, runway+) >

<!ATTLIST airport code CDATA #REQUIRED>

<!ELEMENT name (#PCDATA) >

<!ELEMENT city (#PCDATA) >

<!ELEMENT alt (#PCDATA) >

<!ELEMENT lat (#PCDATA) >

<!ELEMENT long (#PCDATA) >

<!ELEMENT runway (heading, length, width?) >

<!ATTLIST runway number (en1|en2|..) #REQUIRED>

<!ELEMENT heading (#PCDATA) >

<!ELEMENT length (#PCDATA) >

<!ELEMENT width (#PCDATA) >

]>

 

<airports>

 <airport code=”AKL”>

           <city>Auckland</city>

          <name>Auckland International</name>

          <runway number=”en1″> 

                     <heading>05/23</heading>

                     <length>3,635m</length>

           </runway>

          

 </airport>

 <airport code=”BKK”>

           <city>Bangkok</city>

          <name>Don Muang International</name>

          <runway number=”en1″>

                     <heading>03L/21R</heading>

                     <length>3,700m</length>

           </runway>

          <runway number=”en2″>

                     <heading>03R/21L</heading>

                     <length>3,500m</length>

           </runway>

 

 </airport>

 <airport code =”BOM”>

           <city>Mumbai</city>

          <name>Chhatarpati Shivaji</name>

          <runway number =”en1″>

                     <heading>09/27</heading>

                     <length>3,489m</length>

           </runway>

          <runway number =”en2″>

                     <heading>14/32</heading>

                     <length>2,925m</length>

           </runway>

 

 </airport>

</airports>

 

 

 

For external DTD XML

As per instruction, I created 2 files, airport.dtd and airport.xml, with the coding as below. Then I saved them at the same directory as airport.py. Then I executed airport.py by IDLE with positive result.

 

Code of airport.dtd

 

<!ELEMENT airport (name, city, alt, lat, long, runway+) >

 

<!ATTLIST airport code CDATA #REQUIRED>

 

<!ELEMENT name (#PCDATA) >

 

<!ELEMENT city (#PCDATA) >

 

<!ELEMENT alt (#PCDATA) >

 

<!ELEMENT lat (#PCDATA) >

 

<!ELEMENT long (#PCDATA) >

 

<!ELEMENT runway (heading, length, width?) >

 

<!ATTLIST runway number (en1|en2|..) #IMPLIED >

 

<!ELEMENT heading (#PCDATA) >

 

<!ELEMENT length (#PCDATA) >

 

<!ELEMENT width (#PCDATA) >

 

Code of airport.xml

<?xml version=”1.0″ encoding=”iso-8859-1″ standalone=”no” ?>

<!DOCTYPE airports SYSTEM “airport.dtd”>

 

<airports>

<airport code=”AKL”>

   <city>Auckland</city>

   <name>Auckland International</name>

   <alt>10</alt>

   <lat>37 0’6″S</lat>

   <long>174?7?9″E</long>

   <runway number=”1″>

      <heading>05/23</heading>

      <length>3635</length>

      <width>…</width>

   </runway>

</airport>

 

<airport code=”BKK”>

   <city>Bangkok</city>

   <name>Don Muang International</name>

   <alt>3</alt>

   <lat>13 4’2″N</lat>

   <long>100 6’0″E</long>

   <runway number=”1″>

      <heading>03L/21R</heading>

      <length>3700</length>

      <width>…</width>

   </runway>

   <runway number=”2″>

      <heading>03R/21L</heading>

      <length>3500</length>

      <width>…</width>

   </runway>

</airport>

 

<airport code=”HKG”>

   <city>Hong Kong</city>

   <name>Hong Kong</name>

   <alt>6</alt>

   <lat>22 18’32″N</lat>

   <long>113 54’53″E</long>

   <runway number=”1″>

      <heading>07/25</heading>

      <length>3800</length>

      <width>…</width>

   </runway>

   <runway number=”2″>

      <heading>07/25</heading>

      <length>3800</length>

      <width>…</width>

   </runway>

</airport>

</airports>

 

 

 

Result:

 

   Auckland

   Auckland International

   10

   37 0’6″S

   174?7?9″E

  

      05/23

      3635

     

  

 

 

 

   Bangkok

   Don Muang International

   3

   13 4’2″N

   100 6’0″E

  

      03L/21R

      3700

     

  

  

      03R/21L

      3500

     

  

 

 

 

   Hong Kong

   Hong Kong

   6

   22 18’32″N

   113 54’53″E

  

      07/25

      3800

     

  

  

      07/25

      3800

     

 

 

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s


Follow

Get every new post delivered to your Inbox.