XML Schema – simple types, keys and references

References for subject 3

Recommendations:

Tutorials and hints:

Simple types

Current examples are in XML03.zip.

Look at examples in types.xsd. Try to validate the example document. Check that the constraints are really being checked.

Task 1.

Start with students12.xsd.

  1. Define a simple type for PESEL.
  2. Add optional address information to Person type (students and teachers). Define appropriate simple types for address fields (postal code, list of known countries...)

Keys and references

Example definitions can be found in students12.xsd.

Task 2.

Continue working with your version of students12.xsd.

Elements /school/teachers/teacher and /school/students/student contains data of all teachers and students in the school. In a lecture, elements teacher and registered-students/student should refer to those records.

  1. Add attributes teacher-id and student-id to the records. (Find TODOs in the schema source.)
  2. Add the same attributes to the referring elements (which are now empty). (Find TODOs in the schema source.)
  3. Define appropriate keys and references to make a document consistent.

Target namespace

Task 3.

  1. Add a target namespace to your schema (you may work on a separate copy of it).
  2. Make the schema consistent (fix broken references to global elements or types).
  3. Change the information about schema location in the example document. (Generate a sample document to get a hint from Eclipse).
  4. Change the document and validate it.
  5. Fix keys a references, unless you've already done it.

Task 4.

Currently all lectures take place in one building, so it is enough to identify rooms by their numbers.

We want to extend our model to allow more than one building.

  1. Add building name to room information.
  2. Change key and keyref definitions, so that rooms are identified by pairs: (building, number). Adjust meeting definition accordingly.

Valid XHTML 1.1Valid CSS