Generating sample XML from XSD or DTD in Eclipse

- Image by carol shergold via Flickr
Feature is useful if you are writing your XSD schema files or you have XSD schema files and want to create sample XML files for schema elements. Process is the same for generating sample XML files from DTD files.
How to do it. Simple.
- Create a project and add, import or somehow see created, generated XSD files in Project Explorer.
- Select your desired XSD file.
- Right-click and choose Generate->XML File
- New XML File wizard will pop-up where you define where generated file should be saved and what should be it’s name. When desired information is input-ed press Next.
- In Select Root Element window choose root element of your sample XML file. Root element can be any element defined in XSD file you choose to use for generation of the sample XML.
- Set content options and pay special attention to optional attributes & optional elements. Check those if you would like a complete XML sample.
- Name-space information is populated with name-spaces defined in chosen XSD file. You can manipulate the existing name-space information by changing prefix, adding additional name-space or create new name-space.
- Once you are satisfied click Finish.
And presto you have your blank sample XML. Edit it with the information you wish to present and your sample XML is ready. No XMLSpy or any other commercial tools required.


![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=166876e5-abe3-4b02-8b0a-33ca217af0d2)
![Reblog this post [with Zemanta]](http://img.zemanta.com/reblog_e.png?x-id=1cb3076a-dc52-4181-89e3-282fa14a461a)