views:

14544

answers:

10

I have an xsd file and have not done much xml manipulation, parsing, etc. I want/need test xml files for my code but don't have any samples. (I am using xerces to parse)

This is similar to: xml-instance-generation-from-xml-schema-xsd

but I don't really want to make it a two step process. (python or java)

I just want to feed xsd file to some tool and have it generate a sample xml file. How can I do that?

Also see: how-to-generate-sample-xml-documents-from-their-dtd-or-xsd

+1  A: 

I've used XMLSpy for this in the past with great success.

Kyle W. Cartmell
I'll try that as well
Tim
A: 

Have you taken a look at Microsoft's XML Schema Definition Tool (xsd.exe)?

kronoz
I think that tool goes from xml to xsd - I want to generate an xml from xsd.
Tim
+6  A: 

Eclipse has tools for doing this (and it's free.)

EDIT (yeah, I was a little too terse) : What you want are the XSD editing tools in Eclipse. I know it's bundled with Eclipse IDE for Java EE Developers, and I think also with the Eclipse Modeling Tools download. (It's also possible to add them into an existing Eclipse install, though I don't know exactly which plugin(s) you'll want to add.)

(I'd like to be more precise than that, but the eclipse.org web site models itself after Massachusetts roads: If you don't know where you are, you don't belong there.)

Anyway: Once you've got the right version of Eclipse, open the existing schema file for editing (or create a new one: select File -> New... Other ... XML / XML Schema ). When you're ready to generate a test XML file, locate the file in the Package Explorer (the navigator view, usually on the left side), right click on it, and select Generate/XML File.

(What was I saying about navigability... ?)

Dan Breslau
Can you elaborate? Is it in the basic/common install or is it a plugin? Link? Thanks
Tim
Updated the answer.
Dan Breslau
thanks. that helps. I'll try that as well.
Tim
+1 for the Mass. roads; at least they're better than Pittsburgh roads (motto: if you can see it, you can't get there in a straight line). Tweak for MyEclipse users: in the context menu, select "MyEclipse > Generate XML File..."
Lord Torgamus
+2  A: 

Oxygen's XML Schema Editor can generate sample XML instance documents from a given Schema.

Lyle
this looks promising - I'll give the free trial a whirl.
Tim
+2  A: 

Liquid XML will do XML sample generation, don't think there's a command line option but you can do it through the UI. Seems to do a pretty good job, gets all the data types/enums right, the only thing it seems to struggle on is patterns, but then understanding a regular expression well enough to produce a valid string is a bit tricky...

Colin
+5  A: 

Microsoft has published a "document generator" tool as a sample. This is an article that describes the architecture and operation of the sample app in some detail.

If you just want to use the doc generation tool, click here and install the MSI.

It's free. The source is available. Requires the .NET Framework to run. Works only with XSDs. (not Relax NG or DTD).

Cheeso
+2  A: 

Using Eclipse Ganymede or later you can generate xml from xsd. Just right click the xsd and navigate to generate > xml.

hari gorak
+2  A: 

I can do this very simply in VS2010, I don't know if this has been a new feature but this works pretty easy. Right click on the root element of an xsd in the 'xml schema explorer'. You will see an option to 'Generate Sample XML'. On clicking it VS creates a temp file

satyajit
A: 

Check out Benerator: www.databene.org

JamHan