4

Possible Duplicate:
How to generate sample XML documents from their DTD or XSD?

Given an XSD schema, is there a means to generate a collection of XML files from this XSD schema (all of which successfully validate against that XSD schema) to be used for testing purposes?

We are creating a series of Java 6 applications which pass inputs/output using XML files. All XML files should successfully validate against one of our XSD schemas. The XSD schemas are quite complex, so creating XML files by hand for testing is prohibitive. We want a collection of testing XML files that will exercise the limits of the input data (so having a single XML data file will not be sufficient). Ideally, it would be nice to have a tool which allows a tester to pick a few values for each XML tag (the max value, the min value, a zero value, a negative value, etc) and then the tool will generate collections of XML files using combinations of those tester-chosen values.

The system is being tested upon a Microsoft Windows XP environment, but we could certainly generate the XML testing files upon a different environment (if a particular tool could help automate this). We would like this XML-generation-from-XSD capability for testing purposes and we do not need it within the application itself, so a stand-alone XML-generation tool could be used (if one exists).

related question: It seems that the only existing tool I found that even attempts this task is jCAM (main project site is at http://sourceforge.net/projects/camprocessor/; list of jCAM capabilities and tutorial available at https://www.oasis-open.org/committees/download.php/29661/XSD%20and%20jCAM%20tutorial.pdf). Other than the tutorial, I have not investigated this tool yet. Does anyone have experience with this tool?

Community
  • 1
  • 1
navySV
  • 223
  • 4
  • 12
  • This is not a valid approach. You need to generate XML files, independent of the schema, which you believe are valid (positive test cases), based on the requirements of your project, as well as XML files which you believe are invalid (negative test cases) and verify that your schema validates or invalidates them accurately. Even if you could find a tool that would generate XML files for you from the schema, those files would not be good test cases because they would be based on the unproven characteristics of the schema, rather than the requirements of your project. It's flawed logic. – David Jan 11 '13 at 21:20
  • The auto-generation of XML input files for testing would not be used to verify the inner behavior/logic of the application (as you have explained)...that would require the deeper knowledge that a subject matter expert must provide. We are not looking for an automated tool to replace people or their intelligence. – navySV Jan 11 '13 at 21:55
  • However, an automated tool should be able to generate XML files for the more common testing gotchas (as an example, an XML file containing an integer value could have simple generated test cases which include the minimum value value and the maximum allowed value and a zero (if that is an allowed value). This simple collection of testing cases would be far more useful than the existing development tool's generating of only one single semi-random-data-filled XML file. – navySV Jan 11 '13 at 21:56
  • I still don't buy it. Let me give you an example. Let's say that your project includes some characteristic, defined as an integer, whose range is 0 - 100, but the author of the schema codes the restriction as 0 - 1000. Now your "tool" generates XML test cases, faithfully using the schema as a guide, that include values 0 - 1000, which, of course, all pass. Unfortunately, your schema now violates the requirements of your project, even though it passed your test cases. It's a circular argument, because you're trying to use the thing that you're testing (schema) as a template for your tests. – David Jan 11 '13 at 22:30
  • @David, I could also argue that you're putting up a `circular argument`. You assume that the XSDs in question are NOT the requirements; you postulate that there is something else, which you're referring to as "the requirements of your project" that is better suited. Someone else could say that those requirements in fact are a translation of **something else**, hence whatever got lost in translation is ultimately going to make the effort of building test cases on top of that artifact called "requirements of your projects" flawed. Reality is, for practical reasons, people put a stake in the ... – Petru Gardea Jan 11 '13 at 23:22
  • (cont'd) ground and do what they can in a **frame of reference**. It may be the responsibility of a different team to overlay a different view of the same requirements, or new others, to find bugs in **the components** that make the end product (XSD being one of those components). – Petru Gardea Jan 11 '13 at 23:28
  • @David, thinking of real-time environment, XML validation will be done on the inbound XMLs (ie, XML from other system are incoming to our system). Before updating database or process it etc, we would prefer to validate the quality of data! **SO** .. being a developer if I am creating an XSD file for validating such a transaction, it would be better idea to test it with sample XMLs before pushing to testing environments! And it wouldn't be smart technic to create such a sample **XML manually** rather one would seek help of such sample XML generators! – Rookie Programmer Aravind Jan 12 '13 at 16:08
  • It would be step 1, before pushing to testing-environments and test against genuine XML data. And your example of wrong coding `0 - 100` as `0 - 1000` will never be caught while testing with Real-time XML files as well. Please justify if you think otherwise.. – Rookie Programmer Aravind Jan 12 '13 at 16:18
  • 3
    @MarkOConnor, @JesusRamos, @Stony, @M42, @mpapis - I think you're missing the point here. This question is different, if only because it is **more** specific in what it is desired to generate the sample XML: `a tool which allows a tester to pick a few values for each XML tag`, and `using **combinations** of those tester-chosen values.` The devil is in the details of the question! If anything, please pay attention next time you close a question! Oh, and Oxygen doesn't do what's requested here. – Petru Gardea Jan 14 '13 at 15:29
  • 1
    This question is NOT a duplicate of the generate-a-single-sample-XML-file questions. Please note that we are wanting to create multiple XML files in order to test. Many tools create a single XML file from an XSD schema using semi-random choices of data values...but this does not help us. – navySV Jan 16 '13 at 15:32
  • 1
    Example: If we have a weather subcomponent, the input schema may contain air temperature and relative humidity (each with an appropriate range of valid values). However, some combinations of temperature and humidity are not valid together...this interdependency could be caught using some of the more complex schema technologies (such as schematron); the subcomponent itself should watch for such possibilities. However, the testing team does not want to manually generate a ridiculous number of XML testing files for the hundreds of input values (and several sample values for each input value). – navySV Jan 16 '13 at 15:33
  • @PetruGardea is correct: this question should not have been closed as it's not really a duplicate. – C. M. Sperberg-McQueen Jun 10 '16 at 03:11

1 Answers1

0

I have not used it in a while, but I know that Altova XmlSpy used to do this. You can get a free download or trial version of it (with 30 days of trial period) and give it a shot.

http://www.altova.com/xml-editor/

Rookie Programmer Aravind
  • 11,952
  • 23
  • 81
  • 114
ShawnW.
  • 1,771
  • 1
  • 12
  • 12
  • Thanks for the suggestion. Unfortunately, Altova's XMLSpy only generates a single XML "sample" file, just like other tools. It does not appear to generate a collection of XML files. quote from http://manual.altova.com/xmlspy/spystandard/index.html?generatesamplexmlfile.htm: "The DTD/Schema | Generate Sample XML File command generates an XML file based on the currently active schema (DTD or XML Schema) in the main window. " – navySV Jan 16 '13 at 15:22