Generating sample XML from XSD or DTD in Eclipse
Posted by RRunner on June 4th, 2010 in Programming | 5 comments

- 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.


This is awesome. Thanks for the tip!
which plugin do we need to install in eclipse?
No need to install any plugins.
Just add the XSD to your Eclipse project, then right click it and follow the steps mentioned above.
thanks mate
I’m using Eclipse Indigo and when I do a right click -> Generate on the xsd, I just see “JAXB Classes”. Do you know why this is happening?