Quick questions:
CMT3315 – Lab Session 04
1. What does XML stand for? And CSS ?
XML – eXtensible Markup Language – ie it can be extended by the user
2. Is this XML line well-formed? Say why.
<b><i>This text is bold and italic</b></i>
NO – the tags at the end are swapped
3. Is this XML document well-formed? Say why.
<?xml version= “1.0” ?>
<greeting>
Hello, world!
</greeting>
<greeting>
Hello Mars too!
</greeting>
NO – there is no Root Element
- - - - - - - - - - - - - - - - -
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 start=”” end=””>
<name>CMT3315</name>
<building>Block C</building>
<room>402</room>
</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>
<bookstore>
Doctype bookStock while root is bookstore
<book category="Cooking">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<1stEdition>2005</1stEdition >
<2ndEdition>2007</2ndEdition >Cannot start tag with a number
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<1stEdition>2005</1stEdition >
<2ndEdition>2007</2ndEdition >Cannot start tag with a number
<price>19.99</price currency=”pounds sterling”>
cannot have an attribute in end tag
</book>
<book category="Children’>
</book>
<book category="Children’>
mismatch in qoutes
<title lang="en">Harry Potter and the enormous pile of money</title>
<title lang="en">Harry Potter and the enormous pile of money</title>
<!—best selling children’s book of the year --2009 -->
Invalid remark syntax
<author>J K. Rowling</author>
<1stEdition>2005</1stEdition>
<author>J K. Rowling</author>
<1stEdition>2005</1stEdition>
Cannot start tag with a number
<price>29.99</Price>
<price>29.99</Price>
Mismatch in case between tags
</book>
<book category="Web">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<1stEdition>2003</1stEdition>
<2ndEdition >2008</2ndEdition >
</book>
<book category="Web">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<1stEdition>2003</1stEdition>
<2ndEdition >2008</2ndEdition >
Cannot start tag with a number
<price>29.95</discount>
<price>29.95</discount>
<discount>15%</price>
Mismatch between tags
</book>
<book category="Computing">
<title lang=en>Insanely great – the life and times of Macintosh, the computer that changed everything </title>
</book>
<book category="Computing">
<title lang=en>Insanely great – the life and times of Macintosh, the computer that changed everything </title>
Value of attribute Should be in quotes
<author <!—other authors not listed -->>Steven Levy</author>
<author <!—other authors not listed -->>Steven Levy</author>
Invalid remark in opening tag
<1stEdition>1994</1stEdition>
<1stEdition>1994</1stEdition>
Cannot start tag with a number
<price>9.95</discount>
<price>9.95</discount>
<discount>15%</price>
Mismatch between tags
</book>No Closing Root tag
</book>No Closing Root tag
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:
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?
<!DOCTYPE memo
[
<!ELEMENT memo (security?,date,to,from,heading,body)>
[
<!ELEMENT memo (security?,date,to,from,heading,body)>
<!ELEMENT security (#PCDATA)>
<!ELEMENT date (#PCDATA)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
<!ATTLIST memo serial CDATA #REQUIRED>
]>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
<!ATTLIST memo serial CDATA #REQUIRED>
]>
No comments:
Post a Comment