Tuesday, 13 December 2011

Week 7 - Questions

Quick Questions
Question 1
People who prepare XML documents sometimes put part of the document in a CDATA section
a) Why would they do that?
b) How is the CDATA section indicated?
c)If CDATA sections hadn’t been invented, would there be any other way to achieve the same effect?

Answer 1 a
CDATA is used so that people can put code in this section, any code in this section is not parsed but is read as any other character. Any text  placed here is "dumped".

Answer 1b
<![CDATA [content-this won't be parsed]]>

Answer1c 
One can also use another technique like UTF-8. This is only possible if illegal characters are escaped. If you want to use the '&' sign this should be done using '&amp'


Question 2
What is a parser and what does it have to do with validity?

Answer
A parser is a program that passes through the code fragments it and understands the sytnax in order to be able to do something with it. 
Example
dbname = cynthia
username = cyn
password = cyncyn

The program which goes through this document to gather this data is a parser. An XML parses understands XML syntax.

Question 3
You write a .dtd file to accompany a class of XML documents. You want one of the elements, with the tag <trinity>, to appear exactly three times within the document element of every document in this class. Is it possible for the .dtd file to specify this?

Answer
With XML, displaying the <trinity> for several times cannot be done, however it can be done with the use of XSD.

Longer Questions:
Question 1
The following is one of the documents that featured in last week’s exercises. As mentioned before, this is to be “Chapter 2: Volcanic winter” in a book.
a) Write a suitable prolog for this document.
b)Write a .dtd file to act as the Document Type Description for this document. Or modify the one you wrote last week.
c) Put tags into the document. Obviously, there must be a document element. But also, the poem needs special treatment (because of the way it will be displayed) and, in fact, each line of the poem needs special treatment (you can spot the places where the lines start, by the capital letters). The mention of the poets at Geneva needs to be identified, because it will feature in the index, and so do the pyroclastic flows and Mount Tambora and Sumbawa and the year without a summer and the famines.

Answer 1a
<?xml version = “1.0”  encoding = “UTF-8”?>
<!DOCTYPE section2 SYSTEM “section2.dtd”

Answer 1b
<!DOCTYPE section2
[
<!ELEMENT chapter (paragraphs)>
<!ATTLIST chapter chapterId CDATA #REQUIRED chapterTitle CDATA #REQUIRED>
<!ELEMENT paragraphs (section+)>
<!ELEMENT section (poem, image*)>
<!ELEMENT section (#PCDATA)>
<!ELEMENT poem (stanza+)>
<!ELEMENT stanza (#PCDATA)>
<!ELEMENT image EMPTY>
<!ATTLIST image caption CDATA #REQUIRED src CDATA #REQUIRED>
]>


Answer 1c
<?xml version ="1.0" encoding="UTF-8"?>
<!DOCTYPE section2 SYSTEM "section2.dtd">
      <chapter chapterID="2" chapterTitle ="Chapter2: Volcanic Winter">
        <paragraphs>
            <paragraph> 
            A volcanic winter is very bad news. The worst eruption in recorded history happened at Mount Tambora in 1815. It killed about 71 000 people locally, mainly because the pyroclastic flows killed everyone on the island of Sumbawa and the tsunamis drowned the neighbouring islands, but also because the ash blanketed many other islands and killed the vegetation. It also put about 160 cubic kilometres of dust and ash, and about 150 million tons of sulphuric acid mist, into the sky, which started a volcanic winter throughout the northern hemisphere. The next year was the year without a summer. No spring, no summer – it stayed dark and cold all the year round. This had its upside. In due course, all that ash and mist in the upper atmosphere made for some lovely sunsets, and Turner was inspired to paint this. The Lakeland poets took a holiday at Lake Geneva, and the weather was so horrible that Lord Byron was inspired to write this.
                  <image src ="Sumbawa.jpg" caption="Subawa, after the volcanic eruption">
            </paragraph>
          <paragraph>
              <poem>
                    <stanza>The bright sun was extinguish'd, and the stars Did wander darkling in the eternal space,</stanza>
                    <stanza>Rayless, and pathless, and the icy earth Swung blind and blackening in the moonless air;</stanza>
                    <stanza>Morn came and went – and came, and brought no day.</stanza>
              </poem>
          </paragraph>
          <paragraph>
                    Mary Shelley was inspired to write Frankenstein. The downside was that there were famines throughout Europe, India, China and North America, and perhaps 200 000 people died of starvation in Europe alone. 
                <image src = "Mary.jpg" caption="Mary Shelly: author of Frankenstein">
          </paragraph>
        </paragraphs>


Wednesday, 30 November 2011

Week 6 - XML Namespaces and Questions

Introduction
This week namespaces in XML. In XML you create your own element names and might happen that there would be clashes between names meaninig you use the same element name for different purposes. For example say that you are declaring if its a Ms. Or a Mr. In this case you can use element as <title> but when declaring the book name you may also use the element name <title>. As XML documents continue to grow they become more complex and might originate this problem. To limit this kind of clashes namespaces where created, these are a collection of nams which belong together. URI's are usefull so that your elememt names are different from anyones else. Namespaces consist of a prefix and the local part.(Middlesex lecture notes, lecture 6) Ex:

book:title
name:title

Quick questions
Question 1
What exactly does a DTD do in XML?
DTD's are made out of markup language, and stands for Document Type Definition.DTD's define a well structure of XML. To define which elements and attributes are and where they appear DTD's are used, these use formal syntax. DTD explains statements like every school element must have a course_name attribute. XML documents have to be validate in order to meet the rules defined in the DTD

Question 2
You've written an XML document, with the XML declaration <?xml version = "1.0"?> at the start. You realise that the text contains some arabic characters. Which of the following should you do: 
a) change the XML declaration to <?xml version = "1.0" encoding = " ISO 8859-6"?>
b) change the XML declaration to <?xml version = "1.0" encoding = " UTF-8"?>
c) do nothing: the declaration is fine as it is.

Answer:
change the XML declaration to <?xml version = "1.0" encoding = " ISO 8859-6"?>

Question 3 
Can you use a binary graphics file in an XML document?
Binary graphics cannot be used however if you specify that entity with the keyword "NDATA" this can be used, by assigning the path. Below is an example:

<!NOTATION JPG SYSTEM "myfile/jpg">
    <!ENTITY employee SYSTEM "employee.jpg" NDATA JPG>
Long Questions
Question 1. Answer
Refer to the previous blog (week 5) question 3.
Question 2
I decided to produce a book called "Toba: the worst volcanic eruption of all". I ask a colleague to write" Chapter: The mystery of Lake Toba's origins".
I ask another colleague to write "Chapter 2: Volcanic Winter".
I ask another colleage to write "Chapter 3: What Toba did to the human race".
I thank them, and put all three text files into a folder c:\bookproject\chapters on the hard drive on my computer. I insert <text> at the start of each file, and </text> at the end. I name the three files chap1.xml, chap2.xml, and chap3.xml respectivley. I draw up the title page, title page verso and contents page of the book like this:
Toba: the worst volcanic eruption of all
John 
Jack 
Jill
Joe 
STC Press
Malta
Copyright © 2010 STC Press
Published by STC Press Ltd., Malta
ISBN: 978-0-596-52722-0
Contents
Chapter 1: The mystery of Lake Toba’s origins
Chapter 2: Volcanic winter
Chapter 3: What Toba did to the human race

Then I construct an XML document that encompasses the whole book.
a) Provide this XML document
b) Provide the accompanying .dtd file


Answer 2a
<?xml version ="1.0" encoding ="UTF-8"?>
<!DOCTYPE book SYSTEM "book.dtd">
<!--This is the root element-->
<book> 
       <titlePage>
                 <title> Toba: the worst volcanic eruption of all </title>
                     <authors>
                       <author>
                                 <name>John</name>
                                 <surname>Johns</surname>
                       </author>
                       <author>
                                 <name>Jack</name>
                                 <surname>Jacks</surname>
                       </author>
                       <author>
                                 <name>Jill</name>
                                 <surname>Jills</surname>
                       </author>
                       <author>
                                 <name>Joe</name>
                                 <surname>Joes</surname>
                       <author>
                     </authors>
                       <published>STC Press</published>
                       <publishedCountry> Malta </publishedCountry>
      </titlePage>
      <titlePageVerso>
                            <disclamer> &copyright; </disclamer>
                            <address>Published by STC Press Ltd., Malta </address>
                            <isbnNumber>978-0-596-52722-0</isbnNumber>
                   
      </titlePageVerso>
      <contentsPage>
                                <cp:chapter chapterId="c1"
                                <cp:title> Chapter1: The mystery of Lake Toba's origins</title>
                                </chapter>

                                <cp:chapter chapterId="c2"
                                <cp:title> Chapter2: Volcanic Winter</title>
                                </chapter>

                                <cp:chapter chapterId="c3"
                                <cp:title> Chapter3: What Toba did to the human race</title>
                                </chapter>


      </contentsPage>
</book>


Answer 2b


<?xml version = "1.0" encoding ="UTF-8"?>
<!ELEMENT book (titlePage,titlePageVerson,contentsPage)>
<!ELEMENT titlePage(title, authors,published,publishedCountry)
<!ELEMENT title (#PCDATA)>
<!ELEMENT authors(author+)>
<!ELEMENT author (name, surname)
<!ELEMENT name(#PCDATA)>
<!ELEMENT surname(#PCDATA)>
<!ELEMENT published (#PCDATA)>
<!ELEMENT publishedCountry (#PCDATA)>
<!ELEMENT titlePageVerso(disclamer, address, isbnNumber)>
<!ELEMENT disclamer (#PCDATA)>
<!ELEMENT address (#PCDATA)>
<!ELEMENT isbnNumber (#PCDATA)>
<!ELEMENT contentsPage (chapter+)>
<!ELEMENT cp:chapter (title)>
<!ATTLIST cp:chapter chapterId #REQUIRED>
<!ELEMENT cp:title (#PCDATA)
<!ENTITY ch1 SYSTEM "c:\bookproject\chapters\champ1.xml">
<!ENTITY ch2 SYSTEM "c:\bookproject\chapters\champ2.xml">
<!ENTITY ch3 SYSTEM "c:\bookproject\chapters\champ3.xml">


References:

Wednesday, 23 November 2011

Week 5 - Character Encoding and Questions

Introduction
Character Encoding
In XML there are different types of encoding this is used for text which is any other language other than english like German or Arabic, usually these are not supported by ASCII. 
What is ASCII?
This stands for American Standard Code for Information Interchange. ASCII consists of 128 characters from 0 to 127, each one known as byte.  This represents text and makes it easier to transfer data from one computer to another.
What is Unicode?
Unicode is the same thing as ASCII however used for a larger range of character spectrum. There are two types of standards UTF-8 and UTF-16 which used to be able to convert ASCII into Unicode

Quick Questions
Question1
This is a smiley <:-/>. Is it also a well-formed XML document? Say why?
Answer
The above syntax is well formed XML. However XML syntax ideally do not start with colons but this is not banned or known as bad code. Colons  can be considered to be as a reserved word used for namespaces. Also these should start with either an underscore or a letter as according to W3C elements can start with anything which is not a number or punctuation and cannot start with the word XML. This is also closed with the use of "/>" meaning it is a well formed XML, but not highly considered. 

Question 2 
What is the difference between well-formed and valid XML? 
Answer
A well formed XML document is one which follows the syntax rules including having proper nesting and element names, anything which is defined within XML 1.0 Fifth Edition. 


A valid XML document has to validate against the DTD but can contain errors with the XML document.

Question 3 
Is it a good idea to start an XML document with a comment, explaining what the document is and what it's from? Say why.
Answer
Comments don't inter fear with any part of the code. It is good to put comments along the document this will put explanations. If you are passing on this document to someone else they will be able to understand what's going on through the code. They should have comments however they shouldn't be placed before the declaration as these might be completely ignored by an XML parser, hence it might not be a good idea of placing them exactly at the top of the document.

Longer Questions 
Question 1 
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.

Answer
<?xml version=”1.0” encoding =”utf-8”?>
<!DOCTYPE college_textbooks
[

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

<!ELEMENT collage_textbook (title_page, page_verso,chapter+)>
<!ELEMENT title_page (title, author, publisher, aphorism?)>
<!ELEMENT page_verso (pub_add, copyright,ISBN, dedication*)>
<!ELEMENT chapter (section+)>
<!ELEMENT section (bodytext +)>
<!ATTLIST chapter chapter_no CDATA #REQUIRED chapter_title CDATA #REQUIRED>
<!ATTLIST section section_no CDATA #REQUIRED section_title CDATA #REQUIRED>

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

<!ELEMENT pub_add (#PCDATA)>
<!ELEMENT copyright (#PCDATA)>
<!ELEMENT isbn (#PCDATA)>
<!ELEMENT dedication (#PCDATA)>

Question 2
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.
 Answer
<?xml version=”1.0”?><attractions>   <attraction type = “Gallery Muesum” set=”indoor”>London Arts </attraction>   <districtName> Oxford </districtName>   <yearBuilt>1752</yearBuilt></attractions>
Question  3a
The following is the document element (root element) of an XML document.
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> ?
Answer
This file is concerned with English to Russion translations, however it would be more usefull if you can translate into other languages without having the need of chaning element names and all you need to change is the attribute within the element <phrasebook>
Question 3b
Write a suitable prolog for this document.
Answer
<?xml version = “1.0” encoding = “utf-8”?>
<!DOCTYPE phraseBook SYSTEM “phraseBook.dtd”>
Question 3c
Write a .dtd file to act as the documet type description for this document
Answer
<?xml version=”1.0” encoding =”utf-8”?>
<!ELEMENT phraseBook (section+)>
<!ATTLIST pharseBook targLang CDATA #REQUIRED>
<!ELEMENT section(sectionTitle, pharseGroup+)>
<!ELEMENT sectionTitle (#PCDATA)>
<!ELEMENT pharseGroup (engPharse, translitePharse, trangLangPhrase)>
<!ELEMENT engPharse (#PCDATA | gloss)*)>
<!ELEMENT translitPharse (#PCDATA)>
<!ELEMENT  trangLangPhrase (#PCDATA)>

Question 3d
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?
Answer
If the encoding is set to “UTF-8” then there would be no compatability problem as this contains all the characters found in K018-R character set which is a native character encoding and is fully compatible with 7-bit ASCII.

References:
http://www.fileformat.info/info/unicode/utf8.htm
http://www.w3schools.com/dtd/dtd_intro.asp
http://www.webopedia.com/TERM/A/ASCII.html

Week 4 - XML and CSS

Introduction
This week XML entities were covered during the lecture. Entities can be used not only in XML but also in other languages like HTML. In XML an entity is formed using an ampersand followed by the name of the symbol and ending it with a semicolon.  Example: &example;

Some examples of entities are &cope; &alt; and &amp;

There are 3 different types of entities; internal, external and parameter entities. Internal works as a type of shortcuts like macros, external entities work by merging content from other files while parameter entities can be both external and internal.

Coursework
Quick Questions 
Question 1 
What does XML stand for? And CSS?
XML evolved from markup language which stands for Extensible Markup Language which was developed by the world wide consortium. XML is know as Extensible as it allows the creation of tags. 
CSS stands for Cascading Style Sheets which allows you to add styles to websites makes sites more presentable to the users. CSS is a markup language. In HTML styling can be added in-line within HMTL but to make things more understandable styling can be separated into different files and then linked in within the HTML. With CSS instead of chaining that format from each HTML page one has to edit only the CSS page once in order to make the change. 


Question 2 
Is this XML line well-formed? Say why? <b><i> This text is bold and italic </b> </i>
Answer
The above line is not properly coded this is because it does not go with the W3C standards, having an HTML document with proper nesting. An open tag must be closed before the next closing tag. Therefore this line is not well formed since the <b> tag, has the closing tag before the <i>. In order for this line of code to be well formed it has to be: 
<b><i> This text is bold and italic </i></b>

Question 3 
IS this XML document well-formed? Say why?
<?xml version "1.0"?>
          <greeting>Hello World! </greeting/>
          <greeting> Hello Mars too! </greeting>
Answer
This XML document is not well formed, as XML documents can only contain one root element. There cannot be an XML with duplicate root elements hence this is not well-formed. For this document to be well formed it must be as following: 

<salutations>
             <greeting> Hello World!</greeting>
             <greeting> Hello Mars too</greeting>
</salutations>

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. 

<?xml version = "1.0"?>
<course>
<coName> Internet Application and Development</coName>
   <module>
     <moduleName> CMT3315 </moduleName>
     <buildingName> STC </buildingName>
     <roomNumber> Room 4 </roomNumber>
     <moduleDate start="20/09/11" end="20/04/2012"/>
     <moduleTime start = "18:00" end = "21:00"/>
  </module>
</course>
Question 2 
Have a look at the XML document below. Identify all the syntax errors. 
Answer
Below are the syntax errors: 
  • The first line of syntax which is the declaration is not pointing to the correct root tag. The root should be called "bookStock" as it is specified in the DOCTYPE declaration and then there should be a closing tag. 
  • The next error which was found is the element names starting with numerics are invalid.  There are two elements called <1stEdition> and <2ndEdition> both tags are incorrect. 
  • Another error was placed within an element, the attribute "currency" was placed in the closing tag, attributes should be placed in the opening tag.
  • On line 11 the element <book category = "Children'> is not correct as attributes are to be enclosed within double quotes
  • There are a lot of mismatching start and ending tags at several different lines. These are found on line 16, 23, 24, 30 and also line 31
  • Another error is that XML is case sensitive, on line 16 there is an element the opening is lower case while the closing tag is upper case
  • The comment on line 13 is not types properly. Comments are to use "--" instead of "_"
  • On line 31 there is a "price" opening tag and a "discount" closing tag any opening tag must be closed before any other tag is opened.
  • On line 28 comments cannot start inside an element and as already stated above comments start by "<!--"
  • Attribute on line 27 must be in double quotes
  • The root element <bookstore> was not closed. 
Question 3 
You are asked to produce a DTD 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)>
<!ELEMENTbody (#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 wrtie "Secret" at the top). And a memo has a serial number-I think thats what you'd call an attribute isn't it?" How would you amend this .dtd file so that it did what the client wanted?
Answer 

<!DOCTYPE memo
[
<!ELEMENT memo (to, from, heading, body, classification)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
<!ELEMENT date (#PCDATA)>
<!ELEMENT classification (#PCDATA)>
<!ATTLIST memo classification PCDATA "Secret">
<!ATTLIST memo serialNum ID #REQUIRED>
]>

References:


Thursday, 10 November 2011

Week 3 - Worksheet 2

This weeks blog is about another worksheet which was handed out for us to complete. Below are two tasks which we had to do. 


Question 1 
Write an XML document that contains of the following information: your name, your e-mail address, your student number, your home town, your date of birth. Choose appropriate tags. Use attributes for the date of birth. 
Answer
<?xml version="1.0"?>
<personalProfile>
      <id dob="18/01/1986> 012345</id>
     <name> Twinky </name>
     <email> abc@xyz.com</email>
     <studentNumber>00123</studentNumber> 
     <homeTown> </homeTown>
</personalProfile>


Question 2 
Have a look at the XML document and identify all 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</borderingBodyOfWater>
<BorderingCountry CountryCode =”52”> Mexico</borderingBodyOfWater>
</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>


Answer:
Syntax Errors: 
No closing tag of the root element. </countryList>
All tags should follow case sensitive, there are a lot of tags like so:

  • <OfficialName> U.S </officialName>. This should be fixed to be as following <OfficialName> U.S </OfficialName>
  • <Label>Common Names: </label>.This should be fixed to be as following <Label> Common Names</Label>
  • <CommonName> U.S </commonName>. This should be fixed to be as following <CommonName> U.S </CommonName>

Also some tags are not properly nested and not properly closed. For example this tag is not properly nested <Label>Capital:</capital>. and so is this <Capital cityNum="1"> Washington, D.C </label>. While the following is not properly closed <Label> Capital: </capital> apart from having capslock differences it also isn't the correct label. 
Another tag which is a syntax error is <2ndCity cityNum ="2"> Mombosa </2ndCity> this tag is not correct as XML tags can contain numbers but cannot start with a number. 


There can't be two same attributes in one tag. <MajorCity cityNum=’6’ cityNum=’7’>Kisumu-Kericho</majorCity> Therefor this is not allowed.

Week 2 - Worksheet

This week's blog is about a work sheet that we had to work out. Since this subject is Advanced Web technology all questions are Web based. Following are the questions and answers.


Question 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 
Document 1 is  an HTML file document however it is not correctly structured. There are certain tags which don't have a closing tag. Open table tags are not properly closed. If it was arranged with proper HTML tags than it could be an HTML but only after amendments have been made.
The document starts with a tag called <head> and is followed with a <body> tag, hence it gives the look of an HTML document. There is also the use of metdata which is used by search engines


No closing tag
Document 2 
Document 2 is an XML document as it is not showing any layouts.  The reason for this is that it has a <DOCTYPE> which is declaration that it is XML pointing to a DTD. It has a root node, which is <advertisment> and other child and subchild elements which give detail about advertising information.  This also contains an XSL document which means that data might contain some formatting.
Document 3 
This document is an HTML document where it is outputting a form, containing a drop down selection menu and a button.  This document also contains some script which is declared as Javascript.

Showing a basic forn in HMTL
Document 4 
Document four is another XML document with its root element being story. This means that the XML will desribe what a story is made out of. Several child elements like <title><author><section> and others. The first line of code is a declaration pointing to a DTD file. Difference between this and the 2nd document is that this will show raw data with no formatting as it does not contain any XSL. 
Document 5 
The fifth document consists of both HTML and XML, however there are some errors which conclude into being neither an HTML document nor an XML document.
Document 6 
This is another XML document <countrylist> is the root element <country> is a child and contains a lot of subchilds like <officename>, <label>, <commoname> and others. This document looks like a valid XML  document. 
Document 7 
The last document is an HTML document containing Javascript. 


Question 2 
Make a list of the distinctive characteristics of an XML document, in terms of things that you can spot when looking at the code.
Answer
  • Each XML document would have an XML decleration 
  • An XML document would contain only one root element
  • It also contains  number of user specified tags
  • All opening tags should be closed
  • XML attributes must be within quotes


Question3
Assume that (with suitable changes) all these documents could become XML documents. Imagine, and describe, applications that could use these documents. 
Answer 
All the above documents can be used for several different things. HTML documents are used to display information.  XML docments are used to exchange information a good example of this is document two. Document three, which consists of an uploading form can be used for several different reasons in this case there is a list of countries and players being uploaded which can be used to state which country that player comes from. Document four is about a book or a story, this may allow users to be shown any information regarding that book. Document 6 is one which can be used by travel agents for example since it gives out a lot of country information.