Wednesday 1 October 2008

Schema (XSD) from XML or DTD file

In software development often the reverse engineering comes handy, creating the design document from the code, drawing a database diagram the existing database etc. Similarly I have often faced situation where I need to generate the schema files from the XML  or DTD file. Though we have various options to achieve the same, we were always using some utility outside the standard IDE's.

Visual studio (from 2005) has provided an option to generate the schema file from the XML or DTD file using the following ways:

  • Right click on the project name
  • Select "Add', choose "Add Generated Items.." option.
  • Choose "Generate Schemas" and click "Add" button.

For XML file:

Select the "Document type" as "Well-Formed XML" and browse for the input XML file

If this option is being used for the first time in your machine,you will see "Well-Formed XML (Not Loaded)" in the document type dropdown list, so you have to execute the "InstallWFX.vbs" script, from "InstallDir:\Program Files\Microsoft BizTalk Server 2006\sdk\Utilities\Schema Generator\" before you use the above method.

For DTD file:

Select the "Document type" as "DTD" and browse for the input XML file

If this option is been used for the first time in your machine "DTD(Not Loaded)" in the document type dropdown list, so you have execute the "InstallDTD.vbs" script, from "InstallDir:\Program Files\Microsoft BizTalk Server 2006\sdk\Utilities\Schema Generator\" before you use the above method.

Click "Finish" to get your schema file.

0 comments: