XML and XSL Transformations

Difficulty: ***

There is somewhat less hand-holding in this test than previous tests, particularly in Part III (the hard part), which offers no hints as to how to break the problem down.  A common problem in Parts I and II was using inappropriate functions for decomposing strings, e.g. takeWhile and dropWhile, rather than break/span, resulting in multiple passes over the source string.

Part III takes quite a while to get your head round and the best attempts at Part III were from students who had finished Parts I and II within the first hour. One student completed Part III right on the three-hour deadline, passing all the test cases that we used for marking. Several others came very close. The highest mark was 29/30, which was achieved by two students. The class average was around 70%.

This is quite a tricky test, although it’s not that hard to get Part III to work in the time available. I’ve rated the difficulty *** largely because of the time constraints involved.

The original specification made use of a Null value in the XML data type, but I have removed this here in favour of Text "". Other than this the specification is precisely the one used in the test. An earlier draft of the exercise built in some basic syntax checking in the form of a small library of parsing utility functions. In the end, I opted to assume that all XML input is well formed in order to simplify the problem. This means that you can apply several shortcuts to the parser, e.g. skipping over ‘=‘ symbols in attributes because they will always be there. This isn’t entirely satisfactory, so if you’re going to try this out I would suggest putting the checks back, e.g. by defining utility functions for reading/skipping over specified terminal symbols, throwing an error if the symbols aren’t found. Your test cases should then include some syntactically broken XML strings.

Specification

Template File

filmTable.html

composerList.html


More Information

Full details of XML and XSLT can be found on the World-Wide Web Consortium’s (W3C) web pages.  In particular, details of XSL, including XSL transformations and XPaths can be found here.  The W3Schools web pages provide an excellent test-bed for experimenting with XML syntax and XSL semantics and proved incredibly useful when preparing the exercise.