T-110.5140 Network Application Frameworks P (5 cr)

A1: Structured Information


This document has been updated for the course 2012. 

The XML schema specification defines a schema language for XML, i.e., a language for describing the syntax and structure of XML documents. A schema defines what elements, attributes, etc. are permitted in different places of an XML document.

The target of this assignment is to create an XML Schema for a catalog or a library, i.e., a collection of items. For bonus points, you will need to gain some practical experience in other XML-related technologies.

0. Introduction To The Assignment 

Requirements

Please follow the general guidelines for assignments (see on the left). In addition, the goals of this particular assignment are to

  • Familiarize yourself with XML schema
  • Understand how types are defined and extended in XML Schema
  • Create reusable XML schemas
  • Familiarize yourself with some of the programmatic aspects of XML processing

The schema that you turn in needs to demonstrate your understanding of the following features of XML schemas:

  • Elements and attributes
  • Extension of complex types
  • References
  • Cardinality constraints
  • Importing other schemas
  • Namespaces

Estimated Workload

An average student should reserve 10-15 hours for this exercise.

Evaluation and Point Distribution

There are three exercises in this assignment. Every exercise is worth 5 points.

Points

Grade
2 1
4 2
6 3
8 4
10

Deliverables

Please add a directory called assignment_1 into your directory in the SVN repository. Then put the following items (described in general guidelines) into assignment_1.

  • README
  • documentation
  • source code 

Development Environment

For this exercise, we accept only Java. You are free to choose your development environment, assuming your code remains compilable and runnable without third party software. We also accept Eclipse projects.

You may not replace those XML parsing functionalities that the Java standard library provides. However, using other tools is mostly allowed. For example, GUI utilities, lightweight database or custom data structures are completely fine. Please ask us first, though, to prevent any disputes. Also remember to mention them in your documentation, including the setup they need.

1. XML Schema Basics

Create a schema describing your bookshelf. Use the schema features listed in the requirements.

To help defining the problem set, here's how the course assistant describes his shelf. The description is just an example, so please don't hesitate to make your own justifications. Moreover, all the things in the description would not probably work in their literal form in the schema. Use your judgement, what and how to include.

 

I have two bookshelves and both of them are almost full of books. Some of them are in Finnish, while others are in English or in one of a few other languages. Also their thicknesses vary. A few books include a CD for additional material. The books on the only non-full shelf lean to each other, and the paperbacks haven't liked it so much. Unlike many of the scientific textbooks, the most of the fictional books have only one author. Some of the books amuse me more than the others. Some authors are so magnificient that I have bought complete series of their books. Three of the books are from the library. Mathematics books and physics books are next to each other. I can also remember one book that isn't in the shelf. In fact, I don't know where it is.

 

Include a documentation where you describe your design by

  • justifying its structure and key features,
  • telling about at least one delicate subtlety.

In addition, provide an example document that corresponds to the schema.

2. Programmatic Approach to XML

Write a simple program that allows you to list the books in your bookshelf, using an XML document based on your schema as its database (i.e. XML document). In addition, the program should validate the database against the schema. Use the features of Java.

The program should have two features that the user should be able to select from:

 

  • validation against the schema
  • listing the books (validation run automatically before this)

 

We suppose you to have a user interface, which allows the user to define an input file and select the operation. However, the main goals of this section are validating and editing XML documents. Therefore you don't need to pay much attention to the user interface, its purpose is merely a proof of concept. Command line parameters are just enough. You might want to try something like in the following clip:

	> java BookShelf shelf.xml validate
	shelf.xml is valid.
	
	> java BookShelf shelf.xml list
	Adams: Calculus
	Rochkind: Advanced UNIX Programming

Your short documentation should describe:

 

  • A really short overview of the underlying technology (What features does Java provide?)
  • Usage instructions of the program
  • Structure of your code (if simple, just a few words should be enough)
  • Known bugs
  • Learning experience (Briefly; how did you do with the exercise? What was easy? What was difficult?)
 

3. Bonus Features


This section is not mandatory. You have four alternatives: all of them are extensions to the bookshelf program. You may complete all the features, but only two will be graded. Correctly implemented, one feature equals 3 points, while two will bring 5 points.
 
Please include a reasonable amount of documentation. 

1. XPath

Implement search feature to your bookshelf by allowing the user to define an XPath step (or path). Alternatively, you can provide the user with a few reasonable alternatives, letting user decide only on the search string.

2. XSLT

Implement XHTML export with XSLT so that the contents of the book shelf are rendered into a table.

3. XML to JSON

Implement JSON export of the books with either XSLT or other library-based technique. You may fetch the references to their places, if you think it is a good idea. For this exercise, we accept also Python, PHP, Perl and Ruby. We will not debug your Perl code.

4. Addition And Deletion for Bookshelf

Implement addition and deletion features for your Bookshelf program. Some kind of simple user interface is needed, but it does not need to provide a way for adding new information. Instead, you might want to bring the new information in by using another XML file or other syntax.

Please note that the numbers in this clip are only for demonstrating the deletion functionality. If you want design a more elegant solution for identifying the target of deletion, you are free to do so.

> java BookShelf shelf.xml list
1 Adams: Calculus
2 Rochkind: Advanced UNIX Programming

> java BookShelf shelf.xml add network_architecture.xml
Day: Patterns in Network Architecture

> java BookShelf shelf.xml del 1
Adams: Calculus

> java BookShelf shelf.xml list
1 Rochkind: Advanced UNIX Programming
2 Day: Patterns in Network Architecture