Vous êtes sur la page 1sur 8

CONFIDENTIAL

CS/APR 2011/CSC570/ITC570

UNIVERSITI TEKNOLOGI MARA FINAL EXAMINATION

COURSE COURSE CODE EXAMINATION TIME

XML PROGRAMMING CSC570/ITC570 APRIL 2011 3 HOURS

INSTRUCTIONS TO CANDIDATES 1. This question paper consists of two (2) parts : PART A (6 Questions) PART B (3 Questions) 2. 3. 4. Answer ALL questions in the Answer Booklet. Start each answer on a new page. Do not bring any material into the examination room unless permission is given by the invigilator. Please check to make sure that this examination pack consists of: i) ii) the Question Paper an Answer Booklet - provided by the Faculty

DO NOT TURN THIS PAGE UNTIL YOU ARE TOLD TO DO SO


This examination paper consists of 7 printed pages
Hak Cipta Universiti Teknologi MARA CONFIDENTIAL

CONFIDENTIAL PART A (60 MARKS)

CS/APR 2011/CSC570/ITC570

QUESTION 1 XML can be designed and used in various kinds of applications. Supposed an XML application uses an XML document named s t o c k s . x m i ; a stylesheet file named s t o c k s . x s l ; and an external DTD named s t o c k s . d t d . Write the first THREE (3) instructions in the XML document to show how these files are linked to one another. The root element is named <stocks>. (6 marks)

QUESTION 2 The XML document must have a consistent and well-defined structure. There are a numbers of rules that need to be considered to make sure that the XML document conforms with the well-formedness constraints. State whether the element below is legal, illegal and depending on the XML parser you use for the XML names.

a) <discounted.price />
(1 mark)

b) <DISCOUNTED-price />
(1 mark)

c) <-price />
(1 mark)

d) <.price />
(1 mark)

e) <xsl .-apply-templates />


(1 mark)

f) <discounted:price />
(1 mark)

g) <xml:price />
(1 mark)

Hak Cipta Universiti Teknologi MARA

CONFIDENTIAL

CONFIDENTIAL QUESTION 3

CS/APR2011/CSC570/ITC570

Attributes are used to associate name-value pairs with elements. Describe the value of an attribute for: a) ID type (2 marks) b) NMTOKENtype (2 marks) c) NMTOKENS type (2 marks) d) IDREF type (2 marks) e) IDREFStype (2 marks)

QUESTION 4 Given below is the following XML document. Write a DTD that describe the XML below where the attributes i d and mark uniquely determine their element and the attributes r e f refer to these elements. <!DOCTYPE SATU SYSTEM 'final dtd"> <SATU> <DUA mark= "al"/> <DUA mark= "a2"/> <DUA mark= "a3"/> <TIGA id=" b001"/> <EMPAT ref ="a3"/> <LIMA ref= "al bOOl a2 '/> </SATU> (12 marks)

Hak Cipta Universiti Teknologi MARA

CONFIDENTIAL

CONFIDENTIAL QUESTION 5

CS/APR 2011/CSC570/ITC570

An XML Schema is a road map for the XML document that similar to a Document Type Definition (DTD) and created by the World Wide Web Consortium (W3C). DTD and XML Schema are use for an XML page and accomplish some of the same goals. a) Describe ONE (1) reason of why we are using XML Schema. (2 marks) b) State ONE (1) advantage using XML Schema as compared to DTD. (2 marks) c) Define a complex type in XML Schema. Give ONE (1) example to justify the answer. (4 marks) d) Define a simple type in XML Schema. Give TWO (2) examples to justify the answer. (6 marks) e) Write a corresponding Schema definition based on a snippet of XML coding given below. <mesej lang= "MY"> Apa khabar, saudara? </mesej>

(3 marks) QUESTION 6
Consider the following DTD fragment: <!ELEMENT b o o k s (book)+> <!ELEMENT book ( a u t h o r * , t i t l e , i s b n ? , p r i c e ) > <!ELEMENT a u t h o r ( f i r s t - n a m e ? , l a s t - n a m e ) > Write down absolute XPath expressions for the following queries on a document valid with respect to the above DTD fragment and with books as its root element: a) Find book(s) which have more than 2 author(s). (4 marks) b) Find book(s) which have an i s b n and all a u t h o r elements have a f i r s t - n a m e specified. (4 marks)

Hak Cipta Universiti Teknologi MARA

CONFIDENTIAL

CONFIDENTIAL QUESTION 5

CS/APR 2011/CSC570/ITC570

An XML Schema is a road map for the XML document that similar to a Document Type Definition (DTD) and created by the World Wide Web Consortium (W3C). DTD and XML Schema are use for an XML page and accomplish some of the same goals. a) Describe ONE (1) reason of why we are using XML Schema. (2 marks) b) State ONE (1) advantage using XML Schema as compared to DTD. (2 marks) c) Define a complex type in XML Schema. Give ONE (1) example to justify the answer. (4 marks) d) Define a simple type in XML Schema. Give TWO (2) examples to justify the answer. (6 marks) e) Write a corresponding Schema definition based on a snippet of XML coding given below. <mesej lang= "MY"> Apa khabar, saudara? </mesej>

(3 marks) QUESTION 6
Consider the following DTD fragment: <!ELEMENT b o o k s (book)+> <!ELEMENT book ( a u t h o r * , t i t l e , i s b n ? , p r i c e ) > <!ELEMENT a u t h o r ( f i r s t - n a m e ? , l a s t - n a m e ) > Write down absolute XPath expressions for the following queries on a document valid with respect to the above DTD fragment and with books as its root element: a) Find book(s) which have more than 2 author(s). (4 marks) b) Find book(s) which have an i s b n and all a u t h o r elements have a f i r s t - n a m e specified. (4 marks)

Hak Cipta Universiti Teknologi MARA

CONFIDENTIAL

CONFIDENTIAL PART B (40 MARKS)

CS/APR 2011/CSC570/ITC570

QUESTION 1 Many companies are in the position of being aware of Business-to-Business (B2B) eCommerce, but have questions about some of the basic concepts, and more importantly, the benefits of becoming involved in B2B processes with their trading partners, those being most commonly customers and suppliers. In the long run, XML may become a common thread uniting a wide variety of applications. Describe FOUR (4) points on how XML will benefit B2B environment. (8 marks) QUESTION 2 Consider using an XML document to represent a person's b a t i k collection. The collection consists of one or more b a t i k . Each b a t i k contains a name, a p r i c e and an optional c l o t h m a t e r i a l (i.e., Kelantan's silk). Each b a t i k is a t y p e of " t u l i s " or "cop" and this additional information must be provided for each b a t i k . A b a t i k also comprises zero or more c o l o r , each with an optional c o u n t associated with it (having zero count is interpreted as not knowing the number of c o l o r used). The p r i c e is described by q u a n t i t y which is either per p i e c e or per b u n d l e and the default being per p i e c e . a) Write a Document Type Definition (DTD) which satisfies the requirements described above. (7 marks) b) Write an XSL Stylesheet to transform the XML document to an HTML form that will display a table on a browser with the following information: BATIK COLLECTION Name

Price

Quantity (Piece/Bundle)

Sort the table by name in ascending order. (10 marks)

Hak Cipta Universiti Teknologi MARA

CONFIDENTIAL

CONFIDENTIAL QUESTION 3

CS/APR 2011/CSC570/ITC570

Given below is XML document that contains information about collection. Write an XML Schema that will conform to the XML document plus with additional requirements mentioned below. <?xml version = "1.0"?> <Collection version = "2"> <Book> <Title>Hikayat Merong Mahawangsa</Title> <Author> <Name sex="male"> <First>Yusry</First> <Last>Abdul Halim</Last> </Name > </Author> <Published publisher = "KRU Production"> 2011 </Published> <Rating> 5 stars </Rating> <Notes> Covers the year 1900 through 1960. No solo info. Great appendices with chart info, live performance</Notes> </Book> <CD> <Title> Band on the Run </Title> <Artist> Wings </Artist> <Label> Capitol </Label> <Label country='UK"> EMI</Label> <AlbumReleased> 2009 </AlbumReleased> <Remastered format="gold CD">2011</Remastered> <Remastered format="2 disc box set with booklet"> 2 013 </Remastered> </CD> <Book> <Title> Many Years from Now </Title> <Author> <Name sex="male"> <First> Paul </First> <Last> McCartney </Last> </Name > </Author> <Published publisher = "Pustaka Publisher"> 1997 </Published> </Book> </Collection>

Hak Cipta Universiti Teknologi MARA

CONFIDENTIAL

CONFIDENTIAL

CS/APR 2011/CSC570/ITC570

In the XML document, a c o l l e c t i o n consists of an arbitrary number of Book and CD elements in any order. Below are the details of the requirements: A Book has children elements called T i t l e , Author, Type, P u b l i s h e d , and optionally R a t i n g and/or Notes. A CD has a T i t l e , A r t i s t , one or more Label elements and AlbumReieased date, and one or more Remastered dates. The element Name (and its children, F i r s t and Last) is used both for a book Author. T i t l e element applies to both Book and CD. All attributes except Remastered have default values specified. Declare an attribute named v e r s i o n of string type with a fixed value of "2". A sex attribute constrained to be an x s d : NMTOKEN with only two possible values which
are "male" and " f e m a l e " .

(15 marks)

END OF QUESTION PAPER

Hak Cipta Universiti Teknologi MARA

CONFIDENTIAL

Vous aimerez peut-être aussi