XML Sample Generator XML Sample Generator

Home > Products > Liquid Studio > XML Sample Builder

The XML Sample Generator is a tool which creates an XML document from an XML Schema (XSD).

The user selects the element that will become the root node in the XML document, and the generator does the rest, creating all the child elements and attributes, populating them with valid placeholder values.

Options allow you to control the size of the generated document by forcing or restricting the creation of optional elements to a given depth in the XML document. This allows you to create minimal sample instances or comprehensive fully populated documents.

Prototyping

While designing XML Schemas it is often useful to be able to see what the resulting XML documents will look like. The XSD Schema diagrams make it clear what the structure is, but it is sometimes easier to see an example of an actual document in order to get a clear picture. The XML Sample generator takes an XSD and generates random sample XML documents based on your XSD. This allows you to quickly see any unexpected artefacts in the XML document.

Development

When tasked with reading an XML document into an application, it is useful to have a good set of valid test cases to work from. In the early stages of a development project such examples can be thin on the ground, so being able to generate them can save hours of manual typing. Furthermore when writing XML from an application, it is useful to have a clear idea of what the XML should look like, samples make it much easier to see where the applications output differ from the test cases.

For reading and writing XML from an application see XML Data Binding.

Testing

Testing an application is all about having good test cases, and good test cases need good test data. Being able to generate sample XML documents can save huge amounts of time when creating your test data, as it provides the skeletal message, making easy for meaningful test values to be inserted into the document.

Example

This following XML document was generated by the XML Sample Generator from the Bookstore.xsd. The generator created default values based on the rules defined in the XSD in order to create an XML document that conforms to the source XML Schema.

Source XML Schema (Bookstore.xsd)

<?xml version="1.0" encoding="utf-8" ?>
<!--Created with Liquid Studio -->
<xsd:schema elementFormDefault="qualified"
                xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xsd:element name="bookstore" type="bookstoreType" />
    <xsd:complexType name="bookstoreType">
        <xsd:sequence minOccurs="0" maxOccurs="unbounded">
            <xsd:element name="book" type="bookType" />
        </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="bookType">
        <xsd:sequence>
            <xsd:element name="title" type="xsd:string" />
            <xsd:element name="author" type="authorName" />
            <xsd:element name="genre" type="xsd:string" minOccurs="0" />
        </xsd:sequence>
        <xsd:attribute name="price" type="xsd:decimal" use="required" />
        <xsd:attribute name="publicationdate" type="xsd:date" />
        <xsd:attribute name="ISBN" type="xsd:string" />
    </xsd:complexType>
    <xsd:complexType name="authorName">
        <xsd:sequence>
            <xsd:element name="first-name" type="xsd:string" />
            <xsd:element name="last-name" type="xsd:string" />
        </xsd:sequence>
    </xsd:complexType>
</xsd:schema>

Generated XML Sample

<?xml version="1.0" encoding="utf-8"?>
<!-- Created with Liquid Studio -->
<bookstore xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xsi:noNamespaceSchemaLocation="BookStore.xsd">
    <book price="730.54" ISBN="string" publicationdate="2016-02-27">
        <title>string</title>
        <author>
            <first-name>string</first-name>
            <last-name>string</last-name>
        </author>
        <genre>string</genre>
    </book>
    <book price="6738.774" ISBN="string">
        <title>string</title>
        <author>
            <first-name>string</first-name>
            <last-name>string</last-name>
        </author>
    </book>
</bookstore>

Video Tutorials

VIEW TUTORIAL XML Schema Editor Overview

XML Schema Editor Overview

This video overview shows how to work in the graphical, text and split views, adding items, changing properties and updating documentation annotations.

VIEW TUTORIAL Generate a Sample XML Document

Generate a Sample XML Document

This video tutorial shows you how to create a sample XML document from an industry standard schema (Google Site Map).

VIEW TUTORIAL Generate HTML Documentation

Generate HTML Documentation

This video tutorial shows how to create HTML documentation for an XML Schema.

VIEW TUTORIAL XML Data Binder

XML Data Binding

This video tutorial shows you how to generate strongly typed API source code from your XSD using the Liquid XML Data Binder.

VIEW TUTORIAL XML Data Mapper

XML Data Mapper

This video tutorial shows how to create a mapping transform, using the graphical drag and drop interface, to convert XML data of different XML Schema.

Like what you see? Try Liquid XML Free Free Trial

More Editors and Tools

FEATURE DETAILS Graphical XSD Editor

Graphical XML Schema Editor(XSD)

FEATURE DETAILS Graphical WSDL Editor

Graphical WSDL Editor

FEATURE DETAILS XSLT Editor and Debugger

XSLT Editor and Debugger

FEATURE DETAILS XQuery Editor and Debugger

XQuery Editor and Debugger