Escolar Documentos
Profissional Documentos
Cultura Documentos
CS/JAN 2012/CSC570/ITC570
COURSE
XML PROGRAMMING
COURSE CODE
CSC570/ITC570
EXAMINATION
JANUARY 2012
TIME
3 HOURS
INSTRUCTIONS TO CANDIDATES
1.
2.
Answer ALL questions in the Answer Booklet. Start each answer on a new page.
3.
Do not bring any material into the examination room unless permission is given by the
invigilator.
4.
Please check to make sure that this examination pack consists of:
i)
ii)
PART A (6 Questions)
PART B (3 Questions)
CONFIDENTIAL
CONFIDENTIAL
CS/JAN 2012/CSC570/ITC570
QUESTION 1
Extensible Markup Language (XML) is a set of rules for encoding documents in machinereadable form. It is defined in the XML 1.0 Specification produced by the W3C, and several
other related specifications. Technically, an XML document is made up from three parts
which are prolog, document element (usually containing nested elements) and optional
comments.
a) Describe THREE (3) benefits of XML language.
(6 marks)
b) List THREE (3) items that can be contained in prolog Give an appropriate example for
each of the item.
(6 marks)
QUESTION 2
DTD defines the legal building blocks of an XML document.
a) Write a DTD for the following description:
The root element SATU must contain precisely one element DUA followed by one
element TIGA. Elements DUA and TIGA can contain some text but no other elements.
(2 marks)
b) Assume that a) is saved in a file called final.dtd. Explain, why the following XML
documents are consider invalid.
i)
ii)
iii)
iv)
CONFIDENTIAL
CONFIDENTIAL
CS/JAN 2012/CSC570/ITC570
QUESTION 3
Given below is XML document (named warna.xml) that contains information about color.
href="warna.xsl"?>
perak</ton_warnal>
etnas</ton warna2>
n i l a < / t o n warna3>
v i o l e t < / t o n warna4>
ungu</ton_warna3 >
z a i t u n < / t o n warna4>
CONFIDENTIAL
CONFIDENTIAL
CS/JAN 2012/CSC570/ITC570
Write the output extracted from the XSL file (warna. x s l ) below.
<?xml version="l.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="warna">
<pre>
Warna Tambahan putih.
<xsl:apply-templates select="sewarna"/>
Warna Tambahan hitam.
<xsl:apply-templates select="warna_kroma"/>
Warna Tambahan merah.
<xsl:apply-templates select="warna_neutral"/>
Warna Tambahan biru.
</pre>
</xsl:template>
<xsl:template match="sewarna">
Warna Tambahan jingga.
<xsl:apply-templates select "ton_warnal"/>
Warna Tambahan perang.
<xsl:apply-templates select "ton warna2"/>
Warna Tambahan kelabu.
</xsl:template>
<xsl:template match="warna_kroma">
Warna Tambahan hijau.
</xsl:template>
</xsl:stylesheet>
(10 marks;
QUESTION 4
Consider the following segment of the XML document, where <menu> is the root element.
1
<menu>
<chinese>
3
4
5
6
7
</chinese>
</menu>
What element(s) does each of the XPath expression select from the XML document? Use
the number of line for the answer.
a)
b)
c)
d)
Chinese
/Chinese
/ c h i n e s e / d i s h [price>25 . 00]
//chinese/dish
(8 marks)
Hak Cipta Universiti Teknologi MARA
CONFIDENTIAL
CONFIDENTIAL
CS/JAN 2012/CSC570/ITC570
QUESTION 5
The XML DOM presents an XML document as a tree-structure. It defines a standard way for
accessing and manipulating XML documents. We can access, change, add and delete
nodes in XML documents.
a)
b)
Below is the XML document that contains data regarding courses offered by a faculty.
<?xml version="l.0"?>
<FSKM>
<course>
<program> CS23 0 </program>
<code> BEL492 </code>
<prerequisite> none </prerequisite>
<name> PRESENTATION SKILLS </name>
<credit hours> 2 </credit hours>
</course>
<course>
<program> CS23 0 </program>
<code> CSC415 </code>
<prerequisite> CSC101 </prerequisite>
<name> Fundamental of Computer Problem Solving </name>
<credit_hours> 4 </credit hours>
</course>
<course>
<program> CS23 0 </program>
<code> CSC428 </code>
<prerequisite> none </prerequisite>
<name> Computer Organization </name>
<credit_hours> 4 </credit hours>
</course>
</FSKM>
Organization" to
of
Computer
(6 marks)
CONFIDENTIAL
CONFIDENTIAL
CS/JAN 2012/CSC570/ITC570
QUESTION 6
Below are the statements about XML Schemas. State whether each of the statement is
TRUE or FALSE.
a)
Unlike DTDs, XML Schemas must always be external to the XML file.
b)
c)
d)
A content model defines the type of content that can be contained in an attribute.
e)
f)
Attributes may have three attribute values associated with them, which determine
their initial value. They are required, fixed and use.
g)
Complex type elements are divided into two groups: those with simple content and
those with complex content.
h)
Complex content is used when you want your element to have child elements and
attributes.
(12 marks)
CONFIDENTIAL
CONFIDENTIAL
CS/JAN 2012/CSC570/ITC570
QUESTION 1
The following code named p e r s o n a l . d t d contains the document type declaration of
personal XML document named p e r s o n e l .xml.
<!ELEMENT personel (person)+>
<!ELEMENT person
(name,email*,url*,sub_relation?)>
(#PCDATA|family)*>
Write an XSLT Stylesheet that sorts the p e r s o n e l . x m l file based on the family name
according to alphabetical order. For each name, it also displays the family name, person's
i d , e m a i l , u r l and s u b _ r e l a t i o n of the personnel records as an HTML file.
Sample output using browser:
FAMILY NAME: Boon-Siew
ID: father
EMAIL: admin@boonsiew.com.my
URL: http://www.boonsiewmotor.com.my
SUB-RELATION: childA
FAMILY NAME: Fa-Kor
ID: childA
EMAIL: contact@morfakor.tv
URL: http://www.morfakor.tv
SUB-RELATION: father
(12 marks)
CONFIDENTIAL
CONFIDENTIAL
CS/JAN 2012/CSC570/ITC570
QUESTION 2
Assume that we want to define part of an XML document that contains elements
C u r r e n t A d d r e s s and Home_Address. Both elements contain the same information
represented using elements in the following sequence: houseNo, s t r e e t , an optional
s e c t i o n or v i l l a g e , town and postcode. Without repeating the content model
definition for c u r r e n t _ A d d r e s s and Home_Address, give the necessary declarations as
part of
a)
b)
a DTD and
an XML schema.
(14 marks)
QUESTION 3
The following is a list of description of UiTM Academic Calendar ( u i t m c a l e n d a r . xml).
Write the definition for the structure of XML document described above by using
a)
b)
a DTD and
an XML schema.
(14 marks)
CONFIDENTIAL