BizTalk Server Tips and Tricks: Automatically Generate Schemas from a DTD instance

Published on : Oct 30, 2018

Category : BizTalk Server

Sandro

Author

I recently published a new BizTalk Server Tips and Tricks article: “Automatically Generate Schemas from a Well-Formed XML instance” on my blog post series about “BizTalk Server Tips and Tricks” for developers, administrators or business users and I couldn’t resist on asking what about DTD?

Definition of DTD schemas

For who doesn’t know what DTD is, a DTD is a Document Type Definition that defines the structure and the legal elements and attributes of an XML document… So basically, it is the equivalent of what BizTalk Server uses to define how an XML document can be structured: XSD Schema. Nevertheless, there are many differences between DTD (Document Type Definition) and XSD (XML Schema Definition). In short, DTD provides less control on XML structure whereas XSD (XML schema) provides more control.

Some of you may wonder, who cares? No one uses DTD anymore, so why bother?

Yes, indeed DTD is not used very regularly nowadays, and it is very probable that you will never use it… unless… for example, you are working with RosettaNet or in the future, you will have the need to work with RosettaNet. Why? Because most of the RosettaNet Standards – PIP messages – are defined in the format of DTD format!

As I mentioned in my previous blog, there are several ways we can create an XML Schemas in BizTalk Server:

  • Manually from the scratch
  • From XDR Schema instance
  • From a DTD instance
  • From a well-formed XML instance
  • Import them from a WCF Service or Web Service
  • Or automatically generated them from LOB systems (from the adapters)

Generating schemas based on a DTD instance

Today we will be talking about automatically generating XML Schemas from a DTD instance.

To accomplish this we need to:

  • In Solution Explorer, right-click a BizTalk project, point to Add, and then click Add Generated Items…

01-BizTalk-Server-Generate-Schemas-from-DTD

  • In the Add Generated Items – <BizTalk ProjectName> dialog box, in the Templates section, click Generate Schemas, and then click Add

02-BizTalk-Server-Generate-Schemas-from-DTD

  • In the Generate Schemas dialog box, in the Document type drop-down list, select DTD

03-BizTalk-Server-Generate-Schemas-from-DTD

  • One of the problems, especially in brand new installations, is that sometimes this feature was not installed, and you will see DTD (Not Loaded) in the drop-down list. To install and use this feature you need to:
    • Navigate to the “SDK\Utilities\Schema Generator” folder present in the BizTalk Server installation folder. Normally this will be “C:\Program Files (x86)\Microsoft BizTalk Server <version>\SDK\Utilities\Schema Generator”
    • And execute the InstallDTD.vbs script by double-clicking. This will install the “Microsoft.BizTalk.DTDToXSDGenerator.dll” DLL on the correct place. This basically means that it will copy this DLL to the “Developer Tools\Schema Editor Extensions” folder present in the BizTalk Server installation folder
    • Or manually “Microsoft.BizTalk.DTDToXSDGenerator.dll” DLL to the “Developer Tools\Schema Editor Extensions” folder present in the BizTalk Server installation folder. Normally this will be “C:\Program Files (x86)\Microsoft BizTalk Server <version>\Developer Tools\Schema Editor Extensions
  • Close the Generate Schemas dialog box and do the previous steps again. Now you will be able to see that you can use the option DTD in the drop-down list

04-BizTalk-Server-Generate-Schemas-from-DTD

  • In the Generate Schemas dialog box, click Browse, locate the file you want to import, click Open and then click OK
  • A new schema, or sometimes at least two schemas are generated from the specified file, using the same name as that file with the .xsd extension, and opened in BizTalk Editor

Quick, simple and practical.

Stay tuned for new Tips and Tricks!