When I implement a service to consume these messages, what is the best practice to validate the XML schema of the individual messages?
The most simple approach would be to just validate the message against ALL schema versions in an "at least one".
This works fine, but has the downside that if I get an invalid message with version 2.0 the resulting validation message is not very helpful since it would be the message(s) from the validation against version 2.1.
So the question finally is: How can I validate only against the matching schema version?
Do I have to extract the document namespace and, based on that, build a "switch-statement" to select the correct schema validation? Or is there are simpler way?
Your idea of using a "switch-statement" seems like the right way to go here. You can extract the document namespace and put that into a Context Variable to be used for comparison. The use a Compare Variable assertion within 'All assertions must evaluate to true' assertions to determine which schema you want to validate against. The last assertion within the VALIDATE SCHEMA (At least one...) assertion will handle your error condition where no matching schema version is found. Something like this:
Just one small addition: The last "case" in the VALIDATE SCHEMA (At least one...) "switch" statement is not only an unknown version, but also error handling in general.
When the version is identified, but the validation was not successful, the last "case" must also handle it. It would probably check for validation errors. If present, a validation happened, but with errors. If not present no validation happened, so the version is unknown.
With this strategy we just don't know what version was identified. To solve this, every version would have to set a version variable before validating the message.
By the way: this is quite a bit of policy logic to build for such a simple case. It would be nice to have an assertion that takes a collection of schemas (with different namespaces) and uses the one with the matching namespace for validation.