Add new optionals hook.

Mulgara seems to break when running with multiple OPTIONAL
statements... Crazy UNIONs to workaround.
Avoid outputting OPTIONAL bit when we have none.
Merge pull request #104 from adam-vessey/7.x-ISLANDORA-945

7.x islandora 945