In recent BizTalk implementations, BizTalk was supposed to receive a common client envelope schema which can internally contain data for different message types. The incoming message looked similar to below image. Body can optionally contain any one of the message types.
A common approach followed in these type of cases is to implement a custom pipeline component with custom disassembler that will contain envelope schema and corresponding document schemas.
An alternative and simple way to implement this message processing scenario is by creating a choice group in the xsd file. The choice node can contain other nodes (or entire subtrees of nodes), only one of which can appear in an instance message. A given instance message, if valid, will have only one of the choices present. This solution hence avoids creation of a custom pipeline component to extract document xml from envelope xml message. Note that there may be specific cases where custom pipeline component cannot be avoided but in common scenario like above, choice group is sufficient to address the issue.
If a schema file contains multiple root elements, you can generate xml instance for any specific root element in visual studio by changing root reference property to the root element name for which you require to generate xml instance.
The default functionality of Logical Existence functoid is to return the value "true" if the input record or field exists in the source message. There are cases where we do not want the target element to appear in the output xml file as empty tags if the element is missing in the source xml message. This can be achieved using logical existence functoid.
In the background, BizTalk mapper generated xslt adds condition to not allow empty xml nodes being created in output xml file.
Without Logical Existence functoid, mapper would have generated above xslt code as: