Sunday, 27 November 2011

Lab 5: DTDs

Quick questions:

This is a smiley. Is it also a well-formed XML document? Say why.
<:-/>

Although it is not recommended to used “:” and “-“ in an XML as they may cause confusion with namespaces and the mathematical subtraction symbol, theoretically this is well formed XML, since it does not break any rules of XML syntax and since it ends with ‘/>’ the XML is closing the element. So this XML is an empty element name ‘:-‘

What is the difference between well-formed and valid XML?

A well-formed XML follows the syntax rules and its elements are properly nested.
A Valid XML is an XML that is well formed and ensures that the DTD or XML Schemas conform with the XML document.

Is it a good idea to start an XML document with a comment, explaining what the document is and what it’s for? Say why.

The comment will make the document easier if it is to be maintained, especially when it is not the original writer of the document. Also comments will not inter fear with the code and thus will not affect the document in anyway such as performance or readability from the parser. The only place a comment should not be placed is before the declaration as some XML parsers do not work correctly if the declaration is not the first line in the code.


 Longer questions:

A set of documents is to be constructed as follows. The type of document is a college textbook. Every college textbook has a title page, on which is a title and an author and the publisher; optionally, there may be an aphorism.  Every college textbook has a title page verso, on which is a publisher’s address, a copyright notice, an ISBN; there may be a dedication, or there may be more than one. Every college textbook has several chapters, and each chapter has several sections, and each section has several bodies of text. A chapter is identified by a chapter number and a chapter title. A section is identified by a section number and a section title. The name of the publisher will always be Excellent Books Ltd. The address of the publisher will always be 21 Cemetry Lane, SE1 1AA, UK. The application that will process the documents can accept Unicode.
Write a .dtd file for this specification.


<?xml version=”1.0″ encoding=”utf-8″ ?>
<!DOCTYPE collegeTextbooks [

<!ELEMENT collegeTextbook (titlePage, titlePageVerso, chapter+)>

<!ELEMENT titlePage (title, author, publisher, aphorism?)>
<!ELEMENT title (#PCDATA)>
<!ELEMENT author (#PCDATA)>
<!ELEMENT publisher (#PCDATA)>
<!ELEMENT aphorism (#PCDATA)>

<!ELEMENT titlePageVerso (publisherAddress, copyrightNotice, ISBN, dedication*)>
<!ELEMENT address (#PCDATA)>
<!ELEMENT copyrightNotice (#PCDATA)>
<!ELEMENT ISBN (#PCDATA)>
<!ELEMENT dedication (#PCDATA)>

<!ELEMENT chapter (section+)>
<!ELEMENT section (bodyOfText+)>
 <!ELEMENT bodyOfText (#PCDATA)>
<!ATTLIST chapter
chapterNumber CDATA #REQUIRED
chapterTitle CDATA #REQUIRED
> 

<!ATTLIST section
sectionNumber CDATA #REQUIRED
sectionTitle CDATA #REQUIRED
> 

<!ENTITY publisherName "Excellent Books Ltd">
<!ENTITY publisherAddress "21, Cemetery Lane, SE1 1AA, UK"> 
]>



Write an XML document that contains the following information: the name of a London tourist attraction. The name of the district it is in. The type of attraction it is (official building, art gallery, park etc). Whether it is in-doors or out-doors. The year it was built or founded [Feel free to make this up if you don’t know]. Choose appropriate tags. Use attributes for the type of attraction and in-doors or out-doors status.

<attraction type = “Gallery” indoorOrOutdoor = “Indoor”>
            <name>TheAttraction</name>
            <district>District Name</district>
            <yearFounded>2000</yearFounded>
</attraction>



The following is the document element (root element) of an XML document.



<phraseBook targLang=”Russian”>
<section><sectionTitle>Greetings</sectionTitle>
<phraseGroup><engPhrase>Hi! </engPhrase><translitPhrase>privEt </translitPhrase><targLangPhrase>Привет! <phraseGroup><engPhrase>Good morning! dObraye Utra Доброе утро! <phraseGroup><engPhrase>Good evening! </engPhrase><translitPhrase>dObriy dEn/ vEcher <gloss>(day/evening) </gloss> </translitPhrase><targLangPhrase>Добрый день/ вечер! <phraseGroup><engPhrase>Welcome! <gloss>(to greet someone)</gloss></engPhrase><translitPhrase>dabrO pazhAlavat’ </translitPhrase><targLangPhrase>Добро пожаловать! <phraseGroup><engPhrase>How are you? </engPhrase><translitPhrase>kak dela? </translitPhrase><targLangPhrase>Как дела? <phraseGroup><engPhrase>I'm fine, thanks! </engPhrase><translitPhrase>harashO! Spasiba </translitPhrase><targLangPhrase>Хорошо, спасибо! <phraseGroup><engPhrase>And you? </engPhrase><translitPhrase>a u tibyA? А у тебя? <phraseGroup><engPhrase>Good/ So-So. </engPhrase><translitPhrase>harashO/ tAk sibe </translitPhrase><targLangPhrase>Хорошо/Так себе <phraseGroup><engPhrase>Thank you <gloss>(very much)</gloss>! </engPhrase><translitPhrase>spasiba </translitPhrase><targLangPhrase>Спасибо! <phraseGroup><engPhrase>You're welcome! <gloss>(for "thank you")</gloss> </engPhrase><translitPhrase>pazhAlusta </translitPhrase><targLangPhrase>пожалуйста! <phraseGroup><engPhrase>Hey! Friend! </engPhrase><translitPhrase>Ey, drug! </translitPhrase><targLangPhrase>Эй, друг\ Эй, приятель. <phraseGroup><engPhrase>I missed you so much! </engPhrase><translitPhrase>Ya tak sil'no skuchAl/a <gloss>(female)</gloss> pa tibE
</translitPhrase><targLangPhrase>Я так сильно скучал/a по тебе <phraseGroup><engPhrase>What's new? </engPhrase><translitPhrase>Chto nOvava? </translitPhrase><targLangPhrase>Что нового? <phraseGroup><engPhrase>Nothing much </engPhrase><translitPhrase>NiplOha/ NichivO </translitPhrase><targLangPhrase>Неплохо\ Ничего. <phraseGroup><engPhrase>Good night! </engPhrase><translitPhrase>spakOynay nOchi </translitPhrase><targLangPhrase>спокойной ночи <phraseGroup><engPhrase>See you later! </engPhrase><translitPhrase>da vstrEchi/ da svidAn’ya </translitPhrase><targLangPhrase>до встречи/ до свидания <phraseGroup><engPhrase>Good bye! </engPhrase><translitPhrase>pakA/ da svidAn’ya </translitPhrase><targLangPhrase>Пока/до свидания </targLangPhrase></phraseGroup>  </section>
<section><sectionTitle>Asking for Help and Directions</sectionTitle>  <phraseGroup><engPhrase>  I'm lost </engPhrase><translitPhrase>ya zabludils’a </translitPhrase><targLangPhrase>Я заблудился </targLangPhrase></phraseGroup><phraseGroup>  <engPhrase>  Can I help you? </engPhrase><translitPhrase>Ya magU vam pamOch? </translitPhrase><targLangPhrase>Я могу вам помочь? </targLangPhrase></phraseGroup><phraseGroup>  <engPhrase>  Can you help me? </engPhrase><translitPhrase>Vy mOzhite mne pamOch? </translitPhrase><targLangPhrase>Вы можете мне помочь? </targLangPhrase></phraseGroup><phraseGroup>  <engPhrase>  Where is the (bathroom/ pharmacy)? </engPhrase><translitPhrase>Gde nahOditsa (vAnnaya/ aptEka)?
</translitPhrase><targLangPhrase>Где находится (Ванная/ Аптека) </targLangPhrase></phraseGroup><phraseGroup>  <engPhrase>  Go straight! then turn left/ right! </engPhrase><translitPhrase>idite pryAmo, patOm nalEva/ naprAva
</translitPhrase><targLangPhrase>Идите прямо, потом налево/направо </targLangPhrase></phraseGroup><phraseGroup>  <engPhrase>  I'm looking for john. </engPhrase><translitPhrase>Ya ichU DzhOna </translitPhrase><targLangPhrase>Я ищу Джона. </targLangPhrase></phraseGroup><phraseGroup>  <engPhrase>  One moment please! </engPhrase><translitPhrase>MinUtu, pazhAlusta </translitPhrase><targLangPhrase>Минуту, пожалуйста. </targLangPhrase></phraseGroup><phraseGroup>  <engPhrase>  Hold on please! <gloss>(phone)</gloss> </engPhrase><translitPhrase>PadazhdIte, pazhAlusta! </translitPhrase><targLangPhrase>Подождите, пожалуйста! </targLangPhrase></phraseGroup><phraseGroup>  <engPhrase>  How much is this? </engPhrase><translitPhrase>SkOl'ka Eta stOit? </translitPhrase><targLangPhrase>Сколько это стоит? </targLangPhrase></phraseGroup><phraseGroup>  <engPhrase>  Excuse me ...! <gloss>(to ask for something)</gloss> </engPhrase><translitPhrase>izvinite! / prastite </translitPhrase><targLangPhrase>Извините\Простите </targLangPhrase></phraseGroup><phraseGroup>  <engPhrase>  Excuse me! <gloss>(to pass by)</gloss> </engPhrase><translitPhrase>izvinite! </translitPhrase><targLangPhrase>Извините! Come with me! </engPhrase><translitPhrase>PaidyOmte sa mnOy! </translitPhrase><targLangPhrase>Пойдемте со мной! </targLangPhrase></phraseGroup>  </section> </PhraseBook>




It’s clear that it’s concerned with English phrases and their Russian translations. One of the start tags is <targLangPhrase> with </targLangPhrase> as its end tag. Why do you suppose this isn’t <russianPhrase> with </russianPhrase>?
This is to make the document more flexible so that it can be used to for other languages as well and not only Russian.

Write a suitable prolog for this document.
<?xml version=”1.0” encoding=”UTF-8”?>
<!DOCTYPE phraseBook SYSTEM “translation.dtd”>

Write a .dtd file to act as the Document Type Description for this document.

<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT phraseBook (section)>
<!ATTLIST phrasebook
        targLang CDATA #REQUIRED
>
<!ELEMENT section (sectionTitle, phraseGroup+)>
<!ELEMENT sectionTitle (#PCDATA)>
<!ELEMENT phraseGroup (engPhrase, translitPhrase, targLangPhrase)>
<!ELEMENT engPhrase (#PCDATA | gloss)*>
<!ELEMENT translitPhrase (#PCDATA | gloss)*>
<!ELEMENT targLangPhrase (#PCDATA)>
<!ELEMENT gloss (#PCDATA)>



The application that is to use this document runs on a Unix system, and was written some years ago. Is that likely to make any difference to the XML declaration?

This will not make a difference as UTF-8 fully supports the Cyrillic characters which are used in the Russian language.

Wednesday, 23 November 2011

Lab 4: Well-Formed XML

Here are the Questions given in the 4th Lab session of this course. These questions mostly dealt with well-formness of XML


Quick questions:

  1. What does XML stand for? And CSS?

XML stands for Extensible Markup Language and is designed to transport and store data.
CSS stands for  Cascading Style Sheets which is used to store formatting information of HTML pages.


  1. Is this XML line well-formed? Say why.

<b><i>This text is bold and italic</b></i>

No, this is not a well-formed XML line as the closing tags do not match well with the opening tags. To be well-formed this XML line must be changed to:

<b><i>This text is bold and italic</i></b>


  1. Is this XML document well-formed? Say why.

<?xml version= “1.0” ?>
<greeting>
Hello, world!
</greeting>
<greeting>
Hello Mars too!
</greeting>

No, this isn’t a well formed XML document either as there is no root element in this XML. For the document to be well formed it has to be changed to something like:

<?xml version= “1.0” ?>
<differentGreetings>
<greeting>Hello, world!</greeting>
<greeting>Hello Mars too!</greeting>
</differentGreetings>



Longer questions:

1.     Write an XML document that contains the following information: the name of this course. The name of this building. The name of this room. The start and end times of this session. Choose appropriate tags. Use attributes for the start and end times.

<course>
     <name>Advanced Web Technologies</name>
<building>STC</building>
     <session starttime=”18:00” endtime=”21:00”>
         <room>1</room>
     </session>
</course>

  
2.        Have a look at the XML document below. Identify all the syntax errors.

<?xml version= “1.0” ?>
<!DOCTYPE bookStock SYSTEM "bookstock.dtd">
<bookstore>
  <book category="Cooking">
    <title lang="en">Everyday Italian</title>
    <author>Giada De Laurentiis</author>
    <1stEdition>2005</1stEdition >
    <2ndEdition>2007</2ndEdition >
    <price>19.99</price currency=”pounds sterling”>
  </book>
  <book category="Children’>
    <title lang="en">Harry Potter and the enormous pile of money</title>
  <!—best selling children’s book of the year --2009 -->
    <author>J K. Rowling</author>
   <1stEdition>2005</1stEdition>
    <price>29.99</Price>
  </book>
  <book category="Web">
    <title lang="en">Learning XML</title>
    <author>Erik T. Ray</author>
   <1stEdition>2003</1stEdition>
   <2ndEdition >2008</2ndEdition >
    <price>29.95</discount>
    <discount>15%</price>
  </book>
  <book category="Computing">
    <title lang=en>Insanely great – the life and times of Macintosh, the computer that changed everything </title>
    <author 
<!—other authors not listed -->>Steven Levy</author>
   <1stEdition>1994</1stEdition>
    <price>9.95</discount>
    <discount>15%</price>
  </book>



Error 1: Tags cannot start with a numeric value
Ex: <1stEdition>2005</1stEdition >

Error 2:  Attributes cannot be placed at closing tags
Ex: <price>19.99</price currency=”pounds sterling”>

Error 3:     XML tags are Case sensitive
Ex:<price>29.99</Price>

Error 4 :   Tags are not correctly matched
Ex:  <price>29.95</discount>
       <discount>15%</price>

Error 5 : Attributes must be declared in qoutes
Ex :<title lang=en >Insanely great – the life and times of Macintosh, the computer that changed everything </title>

Error 6:   A comment cannot be place inside a tag
Ex: <author <!—other authors not listed -->>Steven Levy</author>

Error 7: There is no closing tag for <bookstore>


3. You are asked to produce a Document Type Declaration for a class of XML documents called “memo”. You come up with this .dtd file:

<!DOCTYPE memo
[
<!ELEMENT memo (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>

Your client says “That’s all very well, but every memo has to have a date. And some of them have to have a security classification too (you might want to write “Secret” at the top). And a memo has a serial number – I think that’s what you’d call an attribute, isn’t it?” How would you amend this .dtd file so that it did what the client wanted?

Basically we have to add 3 things to the DTD provided:

First we have to add another element for the Date, so this:

<!ELEMENT memo (to,from,heading,body)>

Has to be changed to:

<!ELEMENT memo (to,from,heading,body,date)>

Also after the last element we have to add:

<!ELEMENT date (#PCDATA)>


The 2nd item to add is the serial number attribute. This is acheived by creating an ATTLIST after declaring all the Elements as follow:

<!ATTLIST memo
     serialNumber ID #REQUIRED
> 


The last item to add is the classification attribute to know if the memo is a secret. Again we have to add this in the ATTLIST but this attribute will be an enumerator, so only specific values will be accepted:

Classification (Secret|Public) “Security”

So the final DTD will look like this:

<!DOCTYPE memo
[
<!ELEMENT memo (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
<!ELEMENT date (#PCDATA)>
<!ATTLIST memo
     serialNumber ID #REQUIRED
     classification (Secret|Public) “Security”
>
]>

Monday, 21 November 2011

Lab 3: XML Syntax

Here are the questions given for the 3rd Lab session which focused on XML syntax:


Question 1: Write an XML document that contains the following information: your name. Your email address. Your student number. Your home town. Your date of birth. Choose appropriate tags. Use Attributes for the date of birth.



<class>
<personaldetails  dateOfBirth=”16th August 1992”>
<name>Daniel Sammut</name>
<email>anemail@emailaddress.com</email>
<studentNumber>M001234567890</studentNumber>
<homeTown>San Gwann </homeTown>
</personaldetails>
</class>




Question 2: Have a look at the XML document below. Identify all the syntax errors:





<?xml version= “1.0” ?>
<!DOCTYPE countryCollection SYSTEM "countryList.dtd">
<CountryList>
<Nations TotalNations =”3”/>
<!--Data from CIA --Year Book -->
<Country CountryCode=”1”> 
<OfficialName>United States of America</officialName> 
<Label>Common Names:</label>
<CommonName>United States</commonName>
<CommonName>U.S.</commonName>
<Label>Capital:</capital>
<Capital cityNum=”1”>Washington, D.C. </label>
<2ndCity cityNum=”2”>New York </2ndCity> <Label>Major Cities:</label>
<MajorCity cityNum=”3”>Los Angeles </majorCity>
<MajorCity cityNum=”4”>Chicago </majorCity>
<MajorCity cityNum=”5’>Dallas </majorCity>
<Label>Bordering Bodies of Water:</label>
<BorderingBodyOfWater> Atlantic Ocean </borderingBodyOfWater>
<BorderingBodyOfWater> Pacific Ocean </borderingBodyOfWater>
<BorderingBodyOfWater> Gulf of Mexico </borderingBodyOfWater>
<Label>Bordering Countries:</label>
<BorderingCountry CountryCode=”1”> Canada </borderingCountry>
<BorderingCountry CountryCode =”52”> Mexico </borderingCountry>
</country>
<Country CountryCode=”81”>
<OfficialName> Japan </officialName>
<Label>Common Names:</label>
<CommonName> Japan </commonName>
<Label>Capital:</label>
<Capital>Tokyo</capital cityNum=”1”>
<2ndCity cityNum=”2”>Osaka </2ndCity>
<Label>Major Cities:</label>
<MajorCity cityNum=”3”>Nagoya </majorCity>
<MajorCity cityNum=”4”>Osaka </majorCity>
<MajorCity cityNum=”5’>Kobe </majorCity>
<Label>Bordering Bodies of Water:</label>
<BorderingBodyOfWater>Sea of Japan </borderingBodyOfWater>
<BorderingBodyOfWater>Pacific Ocean </borderingBodyOfWater>
</country>
<Country CountryCode=”254”>
<OfficialName> Republic of Kenya </officialName>
<Label>Common Names:</label>
<CommonName> Kenya </commonName>
<Label>Capital:</label>
<Capital cityNum=’1’>Nairobi </capital>
<2ndCity cityNum=’2’>Mombasa</2ndCity>
<Label>Major Cities:</label>
<MajorCity cityNum=’3’>Mombasa </majorCity>
<MajorCity cityNum=’4’>Lamu </majorCity>
<MajorCity cityNum=’5’>Malindi </majorCity>
<MajorCity cityNum=’6’ cityNum=’7’>Kisumu-Kericho </majorCity>
<Label>Bordering Bodies of Water:</label>
<BorderingBodyOfWater <!--Also Lake Victoria --> > Indian Ocean </borderingBodyOfWater>
</country>







Error 1: XML tags are case sensitive, most opening tags here start with uppercase letter and most closing tags start with lower case letters.
Ex: <Label>Common Names:</label>                 


Error 2:  There are some cases that the tags are not matching well
Ex:      <Label>Capital:</capital>              
            <Capital cityNum=”1”>Washington, D.C. </label>

Error 3: There are tags that start with a Numeric Value:
Ex:       <2ndCity cityNum=”2”>New York </2ndCity>

Error 4: This Attribute must be enclosed within double quotes not single quotes:
Ex: <MajorCity cityNum=”5’>

Error 5: Attributes can only be declared within the opening tag not the closing tag like this case
Ex: <Capital>Tokyo</capital cityNum=”1”>

Error 6: The Same attribute cannot be declared twice in the same tag
Ex: <MajorCity cityNum=’6’ cityNum=’7’>Kisumu-Kericho </majorCity>      

Error 7: A comment cannot be included in a tag
Ex: <BorderingBodyOfWater <!--Also Lake Victoria --> > Indian Ocean </borderingBodyOfWater>

Error 8: The Opening tag <CountryList> does not have a closing tag.

Monday, 7 November 2011

Lab 2 - XML Vs. HTML

Questions:

  1. Have a look at the documents below. Some are XML documents, some are HTML documents, some may be neither. See if you can decide which are which.
  
Document 1 is an HTML file which is indicated with the used of the <head> and <body> tags. Also it uses metdata which is used by search engines.

Document 2 is an XML file as it has a <DOCTYPE> which is an XML declaration to point to a DTD. Also it contains an XSL document linked to it which means that data in it will contain some formatting


Document 3 is an HTML file as it is also making use of the <head> tag. Also there is a declaration for an Input form, which will contain a drop down and a button. Also the document has some Javascript declared in the


Document 4 is an XML file again containg a <DOCTYPE> pointing to a dtd. This particular XML does not contain any XSL for formatting.

            Document 5 is again another XML file pointing to a DTD.


            Document 6 is yet another XML file pointing to a DTD.


Document 7 is an HTML file containing Javascript again having the same characteristics as the other HTML files


  1. Make a list of the distinctive characteristics of an XML document, in terms of things that you can spot when looking at the code.

  1. An XML document should have an XML declaration
  2. An XML document should be an assignment of a DTD or XSL schema
  3. All opening tags must be closed
  4. Attributes are placed within quotes
  5. An XML document contains only one root element. 

  1. Assume that (with suitable changes) all these documents could become XML documents. Imagine, and describe, applications that could use these documents.

Document 1 can hold a list of surgical procedures of Ancient Egyptian time

Document 2 is used for data and list regarding adverts

Document 3 is used to select files and load them.

Document 4 is holding all the information and structure of a story and/or a book

Document 5 is holding all the information and structure of a poem

Document 6 is storing specific information on every country

Document 7 holds various information about people and then specific information form it can be displayed depending on what the user chooses



Appendix: XML and HTML documents for identification:

NB I’ve removed one or more lines from each document to stop it being too easy.


<head>
<title>The Edwin Smith Surgical Papyrus</title>
<meta name="Keywords" content="Egypt, egypt, egypt travel, medical, Egyptian, egyptian, Papyrus, Edwin Smith, Surgical, literature, stories, instructions, Memphis, Nile, Cairo, Alexandria, Admonitions of Ipuwer, pharaoh,  pharaonic">
<meta name="Description" content="The Edwin Smith Surgical Papyrus on ancient Egyptian medical treatments">
</head>
<body background="Back25.jpg" bgcolor="#FFFFFF" text="#000000"
link="#808000" vlink="#008080">
<table border="0" cellspacing="1" width="565">
  <tr>
    <td><center>
<!-- START ADCYCLE IFRAME RICH MEDIA CACHE-BUST CODE for Top of Member Pages -->
<script language="javascript"><!--
var id=305; var jar=new Date();var s=jar.getSeconds();var m=jar.getMinutes();
var flash=s*m+id;var cgi='http://ads.touregypt.net/cgi-bin/adcycle';
var p='<iframe src="'+cgi+'/adcycle.cgi?gid=1&t=_top&id='+flash+'&type=iframe" ';
p+='height=60 width=468 border=0 marginwidth=0 marginheight=0 hspace=0 ';
p+='vspace=0 frameborder=0 scrolling=no>';
p+='<a href="'+cgi+'/adclick.cgi?gid=1&id='+flash+'" target="_top">';
p+='<img src="'+cgi+'/adcycle.cgi?gid=1&id='+flash+'" width=468 height=60 ';
p+='border=1 alt="Click to Visit"></a></iframe>'; document.write(p); // -->
</script><noscript><a href="http://ads.touregypt.net/cgi-bin/adcycle/adclick.cgi?gid=1&id=305" target="_top">
<img src="http://ads.touregypt.net/cgi-bin/adcycle/adcycle.cgi?gid=1&id=305" width=468 height=60 border=1></a></noscript>
<!-- END ADCYCLE IFRAME RICH MEDIA CODE -->
</center>
   </td>
  </tr>
</table>
<table border="0" width="570">
    <tr>
 <td>
 <p align="center">
 <font size="3">
 <b>The Edwin Smith Surgical Papyrus</b>
 </font>
 <p>
 <font size="3">
 The Edwin Smith Surgical Papyrus, dating from the seventeenth century B.C., is one of the oldest of all known medical papyri. Its differs fundamentally from the others in the following ways:
 </font>
 <font face="verdana,arial,helvetica" size="3">
 <P>
 </font>
 <ol>
 <li>
 <font size="3">
 The seventeen columns on the recto comprise part of a surgical treatise, the first thus far discovered in the ancient Orient, whether in Egypt or Asia. It is therefore the oldest known surgical treatise.
 </font>
 <li>
 <font size="3">



<!DOCTYPE advertisement SYSTEM "advertisement.dtd">
<?xml-stylesheet type="text/xsl" href="ad1.xsl" ?>
<advertisement action="update">
                <id version="2">
                                NYT.19980701.12345.107
                </id>
                <status value="accepted"></status>
                <expiration>
                                19980731
                </expiration>
                <reference>
                                Ad to sell Linda's car.
                </reference>
                <comment>
                                Up sold to add Friday repeat.
                </comment>
                <contact id="contact1">
                                <name>
                                                John Smyth
                                </name>
                                <address>
                                                <address_line>c/o Bat Accessories, Inc.</address_line>
                                                <address_line>Hitchcock Building, 80th Floor</address_line>
                                                <address_line>1313 Mockingbird Lane</address_line>
                                                <city>New York</city>,
                                                <state>NY</state> 
                                                <postal>10000-1234</postal>
                                                <country>USA</country>
                                </address>
                                <phone>
                                                19085551212
                                </phone>
                                <fax>
                                                19085551213
                                </fax>
                                <email>
                                                jsymth@batacc.com
                                </email>
                                <url>
                                                http://www.batacc.com/~smyth
                                </url>
                </contact>
                <source>
                                <updated>
                                                <timestamp>
                                                                19980701 12290200
                                                </timestamp>
                                                <userid>
                                                                JK1892
                                                </userid>
                                </updated>
                                <created>
                                                <timestamp>
                                                                19980701 12225800
                                                </timestamp>
                                                <userid>
                                                                JK1892
                                                </userid>
                                </created>
                                <base version="1">
                                                NYT.19980621.90810.98
                                </base>
                </source>
                <advertiser>
                                <account type="transient">
                                                19085551212-1
                                </account>
                                <contact_ref link="contact1"></contact_ref>
                                <payment>
                                                <charge>
                                                                <charge_card brand="amex"></charge_card>
                                                                <charge_account>3710-111111-99995</charge_account>
                                                                <charge_expiration>19991231</charge_expiration>
                                                                <contact_ref link="contact1"></contact_ref>
                                                                <charge_authorization status="allowed">4561</charge_authorization>
                                                </charge>
                                </payment>
                </advertiser>
                <coding>
                                <automotive>
                                                <auto_side value="sell">sell</auto_side>
                                                <auto_category value="used">used</auto_category>
                                                <auto_year>1991</auto_year>
                                                <auto_make>Saab</auto_make>
                                                <auto_model>900 Convertible</auto_model>
                                                <auto_mileage>72000</auto_mileage>
                                                <auto_price>$13,900</auto_price>
                                                <auto_exterior>white</auto_exterior>
                                                <auto_interior>gray leather</auto_interior>
                                                <auto_body value="convertible">convertible</auto_body>
                                                <auto_vin>372AB918098910X</auto_vin>
                                </automotive>
                                <contact>
                                                <name></name>
                                                <phone>19085551212</phone>
                                </contact>
                </coding>
                <text>
                                <font size="10">
                                                <center>
                                                                <keyword name="auto_make" punct=" ">SAAB </keyword>
                                                                <keyword name="auto_model" punct=" ">900SE </keyword>
                                                </center>
                                </font>
                                <keyword name="auto_year" punct=" ">1997 </keyword>
                                <keyword name="auto_exterior" punct=" ">yellow </keyword>
                                <keyword name="auto_body" punct=", ">convertible, </keyword>
                                <keyword name="auto_mileage" format="9'k miles'" scale="1000"
                                                                                                punct=", ">14k miles, </keyword>
                                Auto, PL, PW, AC, power leather Seats
                                Showroom cond. Assume lease.
                                <center>
                                                Call
                                                <keyword name="phone" format="T999-999-9999" punct=" ">
                                                                212-333-3333
                                                </keyword>
                                </center>
                </text>
                <publication name="nytimes">
                                <pub_alias>
                                                981011301
                                </pub_alias>
                                <pub_price>
                                                $128.00
                                </pub_price>
                                <pub_options>
                                                <claim>
                                                                7
                                                </claim>
                                                <columns>
                                                                1
                                                </columns>
                                                <forwarding collect="email">
                                                                Please email replies to <mailbox>T1234</mailbox>@nytimes.com
                                                                <rate basis="Email forwarding service charge--Full run"
                                                                                                unit="ad">$25.00
                                                                </rate>
                                                </forwarding>
                                                <tearsheet>
                                                                <rate basis="Tear sheet service charge" unit="recipient">$20.00</rate>
                                                </tearsheet>
                                                <shading>
                                                                <rate basis="Shading premium" unit="standard">20%</rate>
                                                </shading>
                                </pub_options>
                                <class>
                                                3720
                                                <title>Autos/Vans/Sports Utilities</title>
                                                <classword>Automotive</classword>
                                                <classword>For Sale</classword>
                                                <classword>Used</classword>
                                                <lines>
                                                                4
                                                </lines>
                                                <sortkey>
                                                                SAAB91900
                                                </sortkey>
                                                <zone>
                                                                M
                                                                <title>Full Run</title>
                                                </zone>
                                                <rundate>
                                                                19980719
                                                                <rate basis="Automotive, Open, Sunday NY Region"
                                                                                                unit="line">$23.10
                                                                </rate>
                                                                <instance>
                                                                                <edition>BASE</edition>
                                                                                <section>12</section>
                                                                                <page>22</page>
                                                                                <column>9</column>
                                                                                <offset>17.85</offset>
                                                                </instance>
                                                                <instance>
                                                                                <edition>LI</edition>
                                                                                <section>12</section>
                                                                                <page>18</page>
                                                                                <column>9</column>
                                                                                <offset>17.85</offset>
                                                                </instance>
                                                                <instance>
                                                                                <edition>NJ</edition>
                                                                                <section>12</section>
                                                                                <page>18</page>
                                                                                <column>9</column>
                                                                                <offset>17.85</offset>
                                                                </instance>
                                                                <instance>
                                                                                <edition>NY/LI</edition>
                                                                                <section>12</section>
                                                                                <page>18</page>
                                                                                <column>9</column>
                                                                                <offset>17.85</offset>
                                                                </instance>
                                                                <instance>
                                                                                <edition>WC</edition>
                                                                                <section>12</section>
                                                                                <page>18</page>
                                                                                <column>9</column>
                                                                                <offset>17.85</offset>
                                                                </instance>
                                                </rundate>
                                                <rundate>
                                                                19980724
                                                                <rate basis="Automotive, Open, Weekday NY Region--
                                                                                                Sunday ad repeated on Friday (within 7 days)"
                                                                                                unit="line">$8.90
                                                                </rate>
                                                                <rate basis="Automotive, Open, Weekday NY Region"
                                                                                                unit="line" type="comparison">$15.20
                                                                </rate>
                                                                <instance>
                                                                                <edition>METRO</edition>
                                                                                <section>6</section>
                                                                                <page>14</page>
                                                                                <column>6</column>
                                                                                <offset>5.15</offset>
                                                                </instance>
                                                </rundate>
                                </class>
                </publication>
</advertisement>




<head>
                <title>Display</title>

<script language="JavaScript">

function loadFile ()

                {

                var filename
               
                var selectionValue
               
                selectionValue = document.forms[0].selectList.selectedIndex
               
                filename = document.forms[0].selectList.options[selectionValue].value
               
                parent.rightFrame.location = filename           
               
                }



</script>

</head>

<body>

<H4>XML File Chooser</H4>

<P>Select the file you wish to see displayed in the right-hand frame.

<FORM NAME="selectForm">

<P>

<SELECT NAME="selectList">

<OPTION VALUE="countryList/countryList.xml"> Country Data

<OPTION VALUE="playerList/playerList.xml"> Baseball Player Data

</SELECT>

<P>

<INPUT TYPE="BUTTON" VALUE="Load Document" onClick="loadFile()">

</FORM>

</body>




<!DOCTYPE story SYSTEM "storyxsl.dtd">
<story>
<title>Freedom's Dream</title>
<author>by Charles White</author>
<copyright>Copyright 1996, 1999 by Charles White</copyright>
<section>
<para>Had it been a dream, Antron Crimea's memory of the clenched fist piercing the
sky of a tumultuous, thundering crowd would have been bearable solitude. As
it was though, the reality brought him to another place, to a distance only
something like a dream could take him.</para>
<para>&quot;The crowd forgot everything,&quot; is how Antron described the situation to his
psychiatrist, <link id="ChesapeakeLink">
Chesapeake Alert.</link>
Antron remembered the rhythm, the pulse,
everything. After all this time the energy of the crowd still seemed to reverberate through
his head.</para>
<para>Chesapeake Alert was nothing but a large bulbous mass of jelly-like flesh; a
brain plopped down on an empty, expensive slice of carpet. And though he
had no legitimate locomotive capabilities of his own, he was aware of the
movements of a billion others.</para>
<para>Antron's hundred legs crawled around what was left of the carpet in the kind of
pace unknown to you or I. His earlier confusion had long ago been dissolved
by the righteous events of what he had seen during the course of events Billy
Freedom had ignited.</para>
<para>&quot;Sometimes betrayal is a necessity,&quot;said Chesapeake. &quot;Startling. And
expensive. It must be weighed carefully.&quot;</para>
</section>
<auto-link
                xml:link="simple"
                actuate="user"
                href="sec_2.xml"
                show="replace">click here to continue</auto-link>
</story>


<!DOCTYPE my.dtd [
    <!ELEMENT anthology      - -  (poem+)>
    <!ELEMENT poem           - -  (title?, stanza+)>
    <!ELEMENT title          - O  (#PCDATA) >
    <!ELEMENT stanza         - O  (line+)   >
    <!ELEMENT line           O O  (#PCDATA) >
]>
<my.dtd>
<anthology>
         <poem><title>The SICK ROSE
         <stanza>
              <line>O Rose thou art sick.
              <line>The invisible worm,
              <line>That flies in the night
              <line>In the howling storm:
         <stanza>
              <line>Has found out thy bed
              <line>Of crimson joy:
              <line>And his dark secret love
              <line>Does thy life destroy.
          <poem>
              <!-- more poems go here    -->
 
    </anthology>
</my.dtd>



<!DOCTYPE countryCollection SYSTEM "countryList.dtd">
<countryList>
                <country>
                                <officialName>United States of America</officialName>
                                <label>Common Names:</label>                  
                                <commonName>United States</commonName>
                                <commonName>U.S.</commonName>
                                <label>Capital:</label>                
                                <capital>Washington, D.C.</capital>
                                <label>Major Cities:</label>                                                         
                                <majorCity> Los Angeles </majorCity>
                                <majorCity> New York </majorCity>                             
                                <majorCity> Chicago </majorCity>                               
                                <majorCity> Dallas </majorCity>                  
                                <label>Bordering Bodies of Water:</label>                                                     
                                <borderingBodyOfWater> Atlantic Ocean </borderingBodyOfWater>
                                <borderingBodyOfWater> Pacific Ocean </borderingBodyOfWater>                   
                                <borderingBodyOfWater> Gulf of Mexico </borderingBodyOfWater>  
                                <label>Bordering Countries:</label>                                              
                                <borderingCountry> Canada </borderingCountry>                                                           
                                <borderingCountry> Mexico </borderingCountry>
</country>
                <country>
                                <officialName> Japan </officialName>
                                <label>Common Names:</label>                                                  
                                <commonName> Japan </commonName>
                                <label>Capital:</label>                
                                <capital>Tokyo</capital>
                                <label>Major Cities:</label>                                                         
                                <majorCity> Nagoya </majorCity>
                                <majorCity> Osaka </majorCity>                  
                                <majorCity> Kobe </majorCity>                    
                                <label>Bordering Bodies of Water:</label>
                                <borderingBodyOfWater> Sea of Japan </borderingBodyOfWater>
                                <borderingBodyOfWater> Pacific Ocean </borderingBodyOfWater>                   
                </country>
                <country>
                                <officialName> Republic of Kenya </officialName>
                                <label>Common Names:</label>                                                  
                                <commonName> Kenya </commonName>
                                <label>Capital:</label>                
                                <capital> Nairobi </capital>
                                <label>Major Cities:</label>                                                         
                                <majorCity> Mombasa </majorCity>
                                <majorCity> Lamu </majorCity>
                                <majorCity> Malindi </majorCity>                 
                                <majorCity> Kisumu </majorCity>                
                                <label>Bordering Bodies of Water:</label>
                               
                                <borderingBodyOfWater> Indian Ocean </borderingBodyOfWater>
                </country>
</countryList>


<head>
<script LANGUAGE="JavaScript">
//The global variable containing the XML string we'll examine. Normally, global variables are to be avoided. But here, it's the easiest way to
//approach the problem, since it would be easy to have a server-side script include the contents of the XML file as a single line here.
gXMLString = " <officialName> United States of America </officialName> <commonName> United States </commonName> <commonName> U.S. </commonName> <capital> Washington, D.C. </capital> <majorCity> Los Angeles </majorCity> <majorCity> New York </majorCity> <majorCity> Chicago </majorCity> <majorCity> Dallas </majorCity> <borderingBodyOfWater> Atlantic Ocean </borderingBodyOfWater> <borderingBodyOfWater> Pacific Ocean </borderingBodyOfWater> <borderingBodyOfWater> Gulf of Mexico </borderingBodyOfWater> <borderingCountry> Canada </borderingCountry> <borderingCountry> Mexico </borderingCountry>"

function findTagsPresent()
{
var arrayOfPieces = new Array()
arrayOfPieces = gXMLString.split(" ")
numberOfPieces = arrayOfPieces.length
var tagsPresent = new Array()
var tagsPresentCounter
tagsPresentCounter = 0
for (i=0; i<numberOfPieces; i++)
                {
               
                if ((arrayOfPieces[i].indexOf("<") == 0) && (arrayOfPieces[i].indexOf(">") == (arrayOfPieces[i].length-1)) && (arrayOfPieces[i].indexOf("</") == -1))
                                // If that's the case, then we've found an opening tag.
                                {
                                var arrayLength
                                arrayLength = tagsPresent.length
                                var foundIt
                                foundIt = false
                                for (j=0; j<arrayLength; j++)
                                                {
                                                                if (tagsPresent[j] == arrayOfPieces[i])
                                                                                {
                                                                                foundIt = true            
                                                                                break
                                                                                }
                                                }
                                if (foundIt != true)
                                                //And if that's the case, it's not already in tagsPresent
                                                {              
                                                tagsPresent[tagsPresentCounter] = arrayOfPieces[i]
                                                tagsPresentCounter++
                                                }
                                }
                }
return tagsPresent
}
function writeListOfTagsPresentWithCheckboxes()
{
var listOfTags
listOfTags = findTagsPresent()
var listLength
listLength = listOfTags.length
var numberOfCheckBoxes
numberOfCheckBoxes = 0
for (i=0; i<listLength; i++)
                {
                var tagStringLength
                tagStringLength = listOfTags[i].length
                var strippedTagString
                strippedTagString = listOfTags[i].substring(1, (tagStringLength-1))
                document.write("<BR>")
                document.write("<INPUT TYPE='checkbox' NAME='box" + i + "' VALUE='" + strippedTagString + "'> &nbsp;")
                document.write(strippedTagString)
                numberOfCheckBoxes++
                }
document.write("<P>")
document.write("<INPUT TYPE='button' value='Display' onClick='displaySelectedXMLData(" + numberOfCheckBoxes + ")'>")
}              
function contentsTaggedThisWay(tagString)
{
var arrayOfPieces = new Array()
arrayOfPieces = gXMLString.split(" ")
var numberOfPieces
numberOfPieces = arrayOfPieces.length       
var taggedData
taggedData = ""
var i
i = 0
while (i<numberOfPieces)
                {              
                if (arrayOfPieces[i] == ("<" + tagString + ">"))
                                {
                                var foundEndTag
                                taggedData += "<BR>"
                                foundEndTag = false
                                var j
                                j = 1
                                while (!(foundEndTag))
                                                {
                                                if (arrayOfPieces[(i + j)] == ("</" + tagString + ">"))
                                                                {                              
                                                                foundEndTag = true                    
                                                                }                              
                                                                                else                                         
                                                                                                {                                              
                                                                                                taggedData += arrayOfPieces[(i + j)]                                             
                                                                                                taggedData += " "
                                                                                                j++
                                                                                                }
                                                }
                                }
                i++
                }              
return taggedData      
}
function displaySelectedXMLData(numberOfBoxes)
{
var stringToWrite
stringToWrite = ""
parent.rightFrame.location.reload()
stringToWrite = "<HTML> <HEAD> </HEAD> <BODY>"
var i
i=0
while (i<numberOfBoxes)
                {
                currentBoxName = "box" + i
                if (document.selectionForm.elements[currentBoxName].checked)
                                {
                                stringToWrite += "<P><B>" + document.selectionForm.elements[currentBoxName].value + "</B>"
                                stringToWrite += contentsTaggedThisWay(document.selectionForm.elements[currentBoxName].value)
                                }
                i++
                }
stringToWrite += "</BODY> </HTML>"
parent.rightFrame.document.write(stringToWrite)
}              
</script>
</head>
<body>
<H4>Data Chooser</H4>
<P>Choose the tags whose data you want to display.
<FORM NAME="selectionForm">
<SCRIPT LANGUAGE="JavaScript">
writeListOfTagsPresentWithCheckboxes()
</SCRIPT>
<P>
</FORM>
</body>