Make sure the generated XML are valid according to NRML and fix the problem in scenario

See https://bugs.launchpad.net/oq-engine/+bug/1167324