Refactored function handling and added XSpec tests for tocgen module

Refactored function handling to work with both XSLT 1.0 and XSLT 2.0 invocations, and added XSpec tests for tocgen module