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

前端 未结 19 1549
梦毁少年i
梦毁少年i 2020-11-22 10:11

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 li

相关标签:
19条回答
  • 2020-11-22 10:48

    In recent versions of the free and open source Eclipse IDE you can generate XML documents from DTD and XSD files. Right-click on a given *.dtd or *.xsd file and select "Generate -> XML File...". You can choose which root element to generate and whether optional attributes and elements should be generated.

    Of course you can use Eclipse to create and edit your DTD and XSD schema files, too. And you don't need to install any plugins. It is included in the standard distribution.

    0 讨论(0)
  • 2020-11-22 10:49

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

    1. Open your XSD document
    2. Switch to XML Schema Explorer
    3. Right click the root node and choose "Generate Sample Xml"

    Screenshot of the XML Schema Explorer

    0 讨论(0)
  • 2020-11-22 10:51

    The open source Version of SoapUI can generate SOAP requests from WSDL (which contains XSD type definitions), so it looks like there IS an open source implementation of this functionality. Unfortunately, I haven't figured out which library is used to to this.

    0 讨论(0)
  • 2020-11-22 10:52

    You can also use XMLPad (free to use) found here http://www.wmhelp.com to generate your xml samples. From the menu : XSD -> generate sample XML file.

    0 讨论(0)
  • 2020-11-22 10:53

    You can use the XML Instance Generator which is part of the Sun/Oracle 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

    The tool appears to be released under a BSD license; the source code is accessible from here

    0 讨论(0)
  • 2020-11-22 10:53

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

    0 讨论(0)
提交回复
热议问题