A useful BizTalk tool
In BizTalk programming, it is often useful to generate schemas over examples of well-formed XML. You can, of course, generate schemas by opening XML files in Visual Studio and then right-clicking the editor screen and selecting 'Generate Schema'. However, this approach does not always work. The built-in schema generation facility in Visual Studio was designed only to support the requirements of ADO.NET. It will only generate schemas over XML that can, potentially, be loaded directly into a DataSet (strictly, the restrictions are associated with what can be displayed graphically in Visual Studio's default schema editor). Because DataSets must map the XML structure to a relational set of DataTables, there are a number of restrictions on the XML. Of course, these restrictions have nothing to do with BizTalk, and therefore the built in generator may be unsuitable for schema generation.
Another, fairly minor, issue is that the built-in schema generator emits additional attributes and annotations for use by ADO.NET. These are not generally required for BizTalk schemas, and so should be removed manually. Whilst this is easy to do, it is a bit messy.
The BizTalk 2004 SDK provides an alternative schema generator for well-formed XML which is, as far as I am currently aware, unrestricted. I have thrown some fairly sophisticated, non ADO.NET compliant, XML at it and it has coped admirably. It is not installed by default, so the first step is to run the following .vbs file:
C:\Program Files\Microsoft Biztalk Server 2004\SDK\Utilities\Schema Generator\installwfx.vbs
You can then utilise the schema generator from within a Visual Studio BizTalk project by right-clicking the project entry in the Solution Explorer tree and selecting Add\Add Generated Items... Select the 'Generate Schemas' icon and click 'Open'. As you will see, the wizard that opens up supports creation of XSD over well-formed XML, DTDs and XDRs. There is an additional .vbs file at the same location as 'installwfx.vbs' called 'installdtd.vbs' which you have to run before you can create XSD over DTDs. The XDR support appears to be built in, so I guess this code was based on Microsoft's existing code for migrating XDR to XSD.