Friday, January 14, 2011

Week10 (3)

CMT3315  –  Laboratory 12 
Quick questions:

  1. The following passage is to be found in the middle of a particular XML document:
The heavily-used<service xlink:type = "simple" xlink:href ="http://www.thetrams.co.uk/croydon"
> Croydon Tramlink </service> provides a cross link to nearby <location>Wimbledon</location>, <location>Addington</location> and <location>Beckenham</location>.
What can you say about how the text Croydon Tramlink will be treated by a browser such  as Mozilla Firefox?

The text Croydon Tramlink will become a hyperlink to http://www.thetrams.co.uk/croydon


  1. It’s possible to provide validation for a class of XML document using a Document Type Definition (.dtd) file, or using an XML schema. The DTD approach is easier. Why might you want to use the XML schema approach?

The XSD approach has better type validation and more control on output like sorting etc.
·         XSD is extensible. You can derive new elements from the existing elements. DTD is not.
·         XSD is defined in XML. It does not require intermediate processing by a parser. DTD is not defined in XML. You need separate parsers for DTD and XML.
·         XSD supports data types. You can restrict the content of an element. DTD does not support data types. Therefore, you cannot restrict the content of an element.
·         XSD supports default values. You can specify default values of the elements. You cannot specify the default values of elements in DTD.
·         XSD supports references to external XML schemas. You can include or import more than one XML schema within an XML schema. You cannot include other DTDs within a DTD.
  • Key mechanism that is directly analogous to relational database foreign keys
  • XML schemas provide better support for modularity and reuse with include and import elements.
  • XML schemas support inheritance for element, attribute, and data type definitions.

Longer question:
Notes on schema of XML doc shown:
 

1)      Book has numeric “isbn” attribute
2)      Every book has 1 title, 1 author and 1 or more character sections
3)      Every character section has;
A name element (string type)
An Optional friend-of element (string type)
A “since” element (date type)
A “qualification” element (string type)




No comments:

Post a Comment