2

I have a frequent use case of handling collections of XML documents that have a common structure but almost always utilize just a small subset of the allowed elements. For testing purposes I would prefer an example XML that would contain all the allowed elements. I can of course use some tools to infer XSD from the XML documents, and use the XSD to generate an example XML, but the resulting document would just contain filler data, using any of the XSD-to-XML tools I know. Instead, I would like to generate a document with real data, i.e. an "address" element would contain the text from the "address" element of one of the original XML documents.

Anton Kupias
  • 3,945
  • 3
  • 16
  • 20
  • Something like XBEGene? http://link.springer.com/chapter/10.1007%2F978-3-642-28807-4_63#page-1 Usually just have to get a large set of the real data and use a sub set of that for testing. You generate the subset by searching the real data looking for the edge cases that populate structures that aren't usually populated. So far as I know there is no tool commercially available that does what you are asking. Also asking for tools is off topic for this site, unless you are asking how to program one. :-) – Dijkgraaf Nov 17 '14 at 01:50
  • I am just looking for the simplest solution, whether that is an existing tool or a one-liner in any common programming language. I don't really need to generate a statistically representative example like XBEGene seems to do, but an example with values from a given data set. As I can already generate an example document with all allowed elements, an approach that just replaces the generated dummy values with values from a given set of documents would be fine. – Anton Kupias Nov 17 '14 at 07:03
  • possible duplicate of [Any tools to generate an XSD schema from an XML instance document?](http://stackoverflow.com/questions/74879/any-tools-to-generate-an-xsd-schema-from-an-xml-instance-document) – Dijkgraaf Nov 18 '14 at 22:00
  • No, this is not a duplicate. I have no problem generating an XSD with for example Trang. – Anton Kupias Nov 19 '14 at 00:41

1 Answers1

0

I have the same issue like you. I think this blog, describes in a nutshell your need: http://www.altova.com/newsletter/newsletter_2013_02.html but the solution they propose is unfortunately a commercial solution and you would have to pay for their tool in order to do that. I am sure if you research a bit more (and I am doing the same) there could be a free tool of this sort... Hope that helps...

Clyde
  • 83
  • 9