Kirk Evans has an interesting read about
the wisdom
(or lack thereof) of relying on post schema validation infosets (PSVI`s) in web
service contracts.
Let me attempt to summarize Kirk`s article: XSD lets you define default values
for optional attributes in schema, much in the same way databases let you define default
values columns. When you validate an instance document against such a schema, these
defaults get magically inserted into the PSVI, which now contains additional information
(the defaults) that was not originally specified in the document. However, in order
to get a PSVI the consumer of the document needs to do schema validation, which
it may or may not actually be doing. Since there`s no for the other side to actually
do schema validation, relying on information contained only in the PSVI leads to interop
problems. As such, it`s better to be explicit and not rely on PSVI`s to provide default
values for optional things.
I think it`s pretty clear that relying on PSVI`s adds another layer of coupling to
the system. If you use them, it`s not enough for a client to recieve your document
-- they now have to explicitly validate that document against a schema you provide
in order to construct a PSVI both sides can agree on. However, this additional step
would be unnecessary if the both sides were explicit about the contents of the message.
If you can reduce coupling by being explicit, why wouldn`t you