Backport updates to GetCapabilities generation

Backport of redoing GetCapabilities in terms of XMLBuilder and a fix for problems in WMTS get Capabilities when the Style filter has legalValues of null or empty list.  #248