1. What exactly does a DTD do in XML?
A Document Type Definition (DTD) specifies the schematic rules (structure) that must be followed, after the XML has been validated successfully to be syntactically correct, the XML document is validated against the rules defined in the DTD document.
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.
change the XML declaration to <?xml version= "1.0" encoding="ISO 8859-6"?>
3. Can you use a binary graphics file in an XML document?
Binary files such as images cannot be embedded directly inside the XML document, but path references may be used.
Longer Questions
1. The following is the document element (root element) of an XML document.
a) 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> ?
b) Write a suitable prolog for this document.
c) Write a .dtd file to act as the Document Type Description for this document.
d) 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?
Ref: answer in previous post http://cmt3315-danielvella.blogspot.com/2011/12/cmt3315-lab-05-well-formed-xml.html
Ref: answer in previous post http://cmt3315-danielvella.blogspot.com/2011/12/cmt3315-lab-05-well-formed-xml.html
2. I decide to produce a book called “Toba: the worst volcanic eruption of all”. I ask 3 colleagues to write three text files entitled:
“Chapter 1: The mystery of Lake Toba’s origins”.
“Chapter 2: Volcanic winter”.
“Chapter 3: What Toba did to the human race”.
All three text files are placed 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 respectively. I draw up the title page, title page verso and contents page of the book like this:
Toba: the worst volcanic eruption of all
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
<?xml version="1.0" ?>
<Book>
<TitlePage>
<Title>Toba: the worst volcanic eruption of all</Title>
<Authors>
<Author>John</Author>
<Author>Jack</Author>
<Author>Jill</Author>
<Author>Joe</Author>
<Authors>
<Publisher>STC Press Malta</Publisher>
</TitlePage>
<TitlePageVersio>
<Copyright>Copyright (c) 2010 STC Press</Copyright>
<Address>Published by STC Press Ltd. Malta</Address>
<Isbn>978-0-596-52722-0</Isbn>
</TitlePageVersio>
<Contents>
<Chapter ChapterNumber="1" ChapterTitle="The mystery of Lake Toba's Origins">
<Title>Chapter 1: The mystery of Lake Toba's Origins</Title>
</Chapter>
<Chapter ChapterNumber="2" ChapterTitle="Volcanic winter">
<Title>Chapter 2: Volcanic winter</Title>
</Chapter>
<Chapter ChapterNumber="3" ChapterTitle="What Toba did to the human race">
<Title>Chapter 3: What Toba did to the human race</Title>
</Chapter>
</Contents>
</Book>
<?xml version="1.0" ?>
<Book>
<TitlePage>
<Title>Toba: the worst volcanic eruption of all</Title>
<Authors>
<Author>John</Author>
<Author>Jack</Author>
<Author>Jill</Author>
<Author>Joe</Author>
<Authors>
<Publisher>STC Press Malta</Publisher>
</TitlePage>
<TitlePageVersio>
<Copyright>Copyright (c) 2010 STC Press</Copyright>
<Address>Published by STC Press Ltd. Malta</Address>
<Isbn>978-0-596-52722-0</Isbn>
</TitlePageVersio>
<Contents>
<Chapter ChapterNumber="1" ChapterTitle="The mystery of Lake Toba's Origins">
<Title>Chapter 1: The mystery of Lake Toba's Origins</Title>
</Chapter>
<Chapter ChapterNumber="2" ChapterTitle="Volcanic winter">
<Title>Chapter 2: Volcanic winter</Title>
</Chapter>
<Chapter ChapterNumber="3" ChapterTitle="What Toba did to the human race">
<Title>Chapter 3: What Toba did to the human race</Title>
</Chapter>
</Contents>
</Book>
(b) Provide the accompanying .dtd file
<?xml version = "1.0" encoding="UTF-8"?>
<!ENTITY chap1 SYSTEM "c:\bookproject\chapters\chap1.xml">
<!ENTITY chap2 SYSTEM "c:\bookproject\chapters\chap2.xml">
<!ENTITY chap3 SYSTEM "c:\bookproject\chapters\chap3.xml">
<!ELEMENT Book (TitlePage,TitlePageVerson,Contents)>
<!ELEMENT TitlePage(Title, Authors,Publisher)
<!ELEMENT Title (#PCDATA)>
<!ELEMENT Authors(Author+)>
<!ELEMENT Author(#PCDATA)>
<!ELEMENT Publisher (#PCDATA)>
<!ELEMENT TitlePageVerso(Copyright, Address, Isbn)>
<!ELEMENT Copyright (#PCDATA)>
<!ELEMENT Address (#PCDATA)>
<!ELEMENT Isbn (#PCDATA)>
<!ELEMENT Contents (chapter+)>
<!ELEMENT chapter (title)>
<!ATTLIST chapter ChapterNumber #REQUIRED ChapterTitle>
<?xml version = "1.0" encoding="UTF-8"?>
<!ENTITY chap1 SYSTEM "c:\bookproject\chapters\chap1.xml">
<!ENTITY chap2 SYSTEM "c:\bookproject\chapters\chap2.xml">
<!ENTITY chap3 SYSTEM "c:\bookproject\chapters\chap3.xml">
<!ELEMENT Book (TitlePage,TitlePageVerson,Contents)>
<!ELEMENT TitlePage(Title, Authors,Publisher)
<!ELEMENT Title (#PCDATA)>
<!ELEMENT Authors(Author+)>
<!ELEMENT Author(#PCDATA)>
<!ELEMENT Publisher (#PCDATA)>
<!ELEMENT TitlePageVerso(Copyright, Address, Isbn)>
<!ELEMENT Copyright (#PCDATA)>
<!ELEMENT Address (#PCDATA)>
<!ELEMENT Isbn (#PCDATA)>
<!ELEMENT Contents (chapter+)>
<!ELEMENT chapter (title)>
<!ATTLIST chapter ChapterNumber #REQUIRED ChapterTitle>
No comments:
Post a Comment