AnsweredAssumed Answered

XML Schema Validation against multiple candidates

Question asked by stephan.burkard on Mar 14, 2017
Latest reply on Mar 14, 2017 by stephan.burkard

Let's assume

  • there is a message format that exists in multiple versions (1.0, 1.1, 2.0 etc)
  • each version has a dedicated schema definition
  • all message versions are sent to the same channel (mixed versions)


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?