QUICK QUESTIONS
What does XML stand for? And CSS?
XML stands for eXtensible Markup Language while CSS stands for Cascading Style Sheets. XML is a markup language designed to carry data and not to present data, while CSS is used to style and HTML (HyperText Markup Language) document.Is this XML line well-formed? Say why.
The above XML document is not well-formed because </i> should be placed before </b>. Therefore it should look like:
<b><i>This text is bold and italic</b></i>
<b><i>This text is bold and italic</i></b>Is this XML document well-formed? Say why.
The above XML document is not well-formed because it should have a root element. Therefore it should look like:
<?xml version= "1.0" ?>
<greeting> Hello, world! </greeting>
<greeting> Hello Mars too! </greeting>
1: <?xml version= "1.0" ?> 2: <greetings> 3: <greeting>Hello, world!</greeting> 4: <greeting>Hello Mars too!</greeting> 5: </greetings>
LONGER QUESTIONS
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.
1: <?xml version="1.0" ?> 2: <course> 3: <cname>Internet Application Development</cname> 4: <modules> 5: <module code="CMT 3315" start="18:00" end="21:00"> 6: <mname>Advanced Web Technologies</mname> 7: <building>STC Training</building> 8: <room>Room 5</room> 9: </module> 10: </modules> 11: </course>Have a look at the XML document below. Identify all the syntax errors.
- The root element of the DOCTYPE declaration "bookStock" is not the same as the root element of the XML document "bookstore";
- No closing tag for the root element <bookstore>;
- Tags should not start with a number <1stEdition> and <2ndEdition>;
- The attribute currency="pounds sterling" in <price>19.99</price currency="pounds sterling>, should be inside the opened tag not the close tag;
- Inside the comment, there should not be a -- between 'year' and '2009';
- Attributes should be enclosed in quotation marks <title lang="en">;
- Comments should not be written inside a tag <author <!--other authors not listed-->>;
- <book category="Children’> should be <book category=“Children”>;
- <price>29.99</Price> should be <price>29.99</price>;
- <price>9.95</discount><discount>15%</price> should be <price>9.95</price><discount>15%</discount>.
1: <?xml version= "1.0" ?> 2: <!DOCTYPE bookStock SYSTEM "bookstock.dtd"> 3: <bookStock> 4: <book category="Cooking"> 5: <title lang="en">Everyday Italian</title> 6: <author>Giada De Laurentiis</author> 7: <firstEdition>2005</firstEdition > 8: <secondEdition>2007</secondEdition > 9: <price currency="pounds sterling">19.99</price > 10: </book> 11: <book category="Children"> 12: <title lang="en">Harry Potter and the enormous pile of money</title> 13: <!--best selling children’s book of the year 2009 --> 14: <author>J K. Rowling</author> 15: <firstEdition>2005</firstEdition> 16: <price>29.99</price> 17: </book> 18: <book category="Web"> 19: <title lang="en">Learning XML</title> 20: <author>Erik T. Ray</author> 21: <firstEdition>2003</firstEdition> 22: <secondEdition >2008</secondEdition > 23: <price>29.95</price> 24: <discount>15%</discount> 25: </book> 26: <book category="Computing"> 27: <title lang="en">Insanely great – the life and times of Macintosh, the computer that changed everything </title> 28: <author><!--other authors not listed -->Steven Levy</author> 29: <firstEdition>1994</firstEdition> 30: <price>9.95</price> 31: <discount>15%</discount> 32: </book> 33: </bookStock>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?1: <!DOCTYPE memo 2: [ 3: <!ELEMENT memo (to,from,heading,body)> 4: <!ELEMENT to (#PCDATA)> 5: <!ELEMENT from (#PCDATA)> 6: <!ELEMENT heading (#PCDATA)> 7: <!ELEMENT body (#PCDATA)> 8: <!ATTLIST memo date CDATA #REQUIRED> 9: <!ATTLIST memo classification CDATA #IMPLIED> 10: <!ATTLIST memo serialNo ID #REQUIRED> 11: ]>