Sure I looked at your code. It's calling sum(Time) when the context node is an IRD element, which is clearly wrong, as the IRD only has one child called Time, and summing over a single element will get you nowhere.
Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference