DTD to Schema

Assignment 6 — XML Foundations (INFOSYS 242; Fall 2006)

Assigned: 2006-10-05 / Due: 2006-10-12

Authors: Bob Glushko & Erik Wilde / TA: Katrina Rhoads Lindholm

Introduction: Convert your résumé DTD to an XML Schema. In addition to the simple way of moving from DTD syntax to XML Schema syntax, we also require you to improve the schema, so that is a better schema than the DTD (because it is more selective in what it validates).
Resource: w3schools.com XML Schema Reference
Instructions:

Take your résumé DTD from the last assignment (A5) and convert it to an XML Schema. You can either perform the translation manually (which would be very instructional and is an experience that every XML expert should have had once in a lifetime) or you can cheat and use your XML editor to do the work (slightly less instructional). Either way, you will need to modify the Schema in a few ways to highlight the robustness of Schemas over DTDs:

The following things are required for this assignment:
  • If you choose to automatically convert your DTD to an XML Schema, you will first need to clean up the XML Schema a bit because the editor tends to make things more complicated than they need to be. Try to spot pointless complications in the schema. Depending on the XML Schema generator you are using, these may be more or less easy to spot.
  • Schemas support data types which is a major advantage over DTDs. For any date in your résumé XML, make sure that your XML Schema checks for a valid date value. Try to avoid xs:string as much as possible, or if you think that something really is a string, use your own string type which for example could take care of checking for a maximum length and some character set (a xs:pattern could be used to achieve the latter).
  • Make sure that at least one of your types is used by more than one element (because reuse is good). In real-life applications, you would start to design a type library, and then start using it when constructing your schema from the ground up.
  • Use minOccurs and maxOccurs to restrict the cardinality of some elements.
The following are recommended (but optional) for this assignment:
  • Depending on how similar or different your employer and education entries are, try to think of a way how you could find some structural similarity between these entries and then represent this similarity using complex type derivation.
  • Try to add a targetNamespace to your schema, so that your résumé schema now is a full-grown schema with its own namespace. Don't forget that you have to change the instance (by using the namespace there) to match the schema when you do that.
  • Try using an <any> element or <anyAttribute> element in your XML Schema to help make it extensible. (We have not covered these wildcards in the course so this part is completely optional.)
  • Identity constraints could be used to check various aspects of the résumé, depending on what you think should be unique, a key, or a reference to an existing key. A typical example would be to have a key for institutions (educational or companies), and then have each of your skills reference this key so that you can represent where you have acquired each skill.

If you are editing your schema by hand, make sure to check it using some tool after every change. It may be hard to fix the XML Schema when you started with a correct schema, and then made several changes which might have introduced several interacting problems. If you use some tool for editing (such as XML Spy's graphical schema editor), switch to the text view occasionally so that you actually see what you are doing.

When you are done, make sure that your document still validates against the XML Schema. The XML Schema Primer describes how to do that be using the schemaLocation or noNamespaceSchemaLocation attribute in the instance (depending on whether your Schema defines a targetNamespace or not).

Submission Instructions: Please submit your original DTD file and your new XML Schema file with the naming convention a6_firstname_lastname.


please send comments to dret@sims.berkeley.edu
last modification on Sunday, 10-Dec-2006 01:24:15 MET
valid CSS! valid XHTML 1.0!