views:

14074

answers:

10

We are developing an application that involves a substantial amount of XML transformations. We do not have any proper input test data per se, only DTD or XSD files. We'd like to generate our test data ourselves from these files. Is there an easy/free way to do that?

Edit

There are apparently no free tools for this, and I agree that OxygenXML is one of the best tools for this.

+3  A: 

XMLSpy does that for you, although that's not free...

I believe that this does it for you and is free, but I have not personally used it to create create test data.

SCdF
It generates something, but you don't have much control over it: you can choose the toplevel element and some general options, but you cannot use XMLSpy to generate set of testcases with many variants etc.
hstoerr
+5  A: 

I think Oxygen (http://www.oxygenxml.com/) does it as well, but that's another commerical product. It's a nice one, though... I'd strongly recommend it for anyone doing a lot of XML work. It comes in a nice Eclipse plugin, too.

I do believe there is a free, fully-featured 30 day trial.

levand
I have an bunch of XSDs which in turn inherits schema's from different XSD's and I need to generate an XML file for testing purpose from this XSD, am using oxygenXML to do this but when I try to do it, it is not working for me and it says please define root node but than it does not allow me to do so. So if anyone had worked with oxygenXML do suggest of what could be way around for this ?
Rachel
+8  A: 

In Visual Studio 2008 SP1 the XML Schema Explorer can create an XML document with some basic sample data.

Sam Warwick
yes, this is the easiest way. Open XSD, switch to XML Schema Explorer, select the root node, right click and choose "Generate Sample Xml".
balint
+5  A: 

The camprocessor available on Sourceforge.net will do xml test case generation for any XSD. There is a tutorial available to show you how to generate your own test examples - including using content hints to ensure realistic examples, not just random junk ones.

The tutorial is available here: http://www.oasis-open.org/committees/download.php/29661/XSD%20and%20jCAM%20tutorial.pdf

And more information on the tool - which is using the OASIS Content Assembly Mechanism (CAM) standard to refactor your XSD into a more XSLT friendly structure - can be found from the resource website - http://www.jcam.org.uk

Enjoy, DW

Direct link to Sourceforge.net download is: http://sourceforge.net/projects/camprocessor
+2  A: 

You can use the XML Instance Generator which is part of the Sun Multi-Schema Validator.

It's README.txt states:

Sun XML Generator is a Java tool to generate various XML instances from several kinds of schemas. It supports DTD, RELAX Namespace, RELAX Core, TREX, and a subset of W3C XML Schema Part 1. [...]

This is a command-line tool that can generate both valid and invalid instances from schemas. It can be used for generating test cases for XML applications that need to conform to a particular schema.

Download and unpack xmlgen.zip from the msv download page and run the following command to get detailed usage instructions:

java -jar xmlgen.jar -help

Unfortunately, the tool is not free software because it is released under Sun's Binary Code License Agreement.

falko
Very nice! A little bit limited though. I tried it on an XSD that imports other XSD and it failed. But on a DTD it works very well. Thanks!
lindelof
+1  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 run the sample 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).

Above link is to an article on MSDN called 'Generating XML Documents from XML Schemas'
Sam Warwick
A: 

Microsoft Office has 'InfoPath', which takes an XSD as an import and lets you quickly and easily define a form-based editor for creating XML files. It has two modes - one where you define the form, and another mode where you create the XML file by filling out the form. I believe it first came with Office 2003, and most people never install it. It shocks me at how much I like it.

Kieveli
+10  A: 
Florian
+1  A: 

XMLBlueprint 7.5 can do the following: - generate sample xml from dtd - generate sample xml from relax ng schema - generate sample xml from xml schema

Peter
A: 

Liquid XML Studio has an XML Sample Generator wizard which will build sample XML files from an XML Schema. The resulting data seems to comply with the schema (it just can't generate data for regex patterns).

alt text

Sprotty