XML Sample Generator XML Sample Generator

Home > Products > Liquid Studio > XML Sample Generator

The XML Sample Generator creates an XML document from an XML Schema (XSD).

  • Simple intuitive wizard converts XSD to XML
  • Configurable output
  • Creates valid data values, even for regex xs:patterns
  • Generate samples directly from and XSD diagram
  • Sample XML from schemas in the Standards Library

The XML generator takes an element defined within an XML Schema (XSD) and creates the attributes and elements required to make the XML data valid. Primitive data values are generated that conform to the facets in the schema (length, min, max etc), this includes generating values that validate against the regex pattern facet.

XML Generator Typical Uses

Prototyping

While designing XML Schemas (XSD) it is often useful to be able to see what the resulting XML documents will look like. The XML 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 XML Schema 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 it easy for meaningful test values to be inserted into the document.

Example of generating XML from XSD

The following XML Schema will be used to generate an XML Sample document.

Bookstore XSD Example
<?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>

This following XML document was generated by the XML Sample Generator from the Bookstore.xsd (above). 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.

<?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>

Try Liquid Studio and see how we can help you today Free Trial

More Editors and Tools

FEATURE DETAILS Graphical XML Editor

Graphical XML Editor

FEATURE DETAILS Infer XSD

Infer XML Schema

FEATURE DETAILS XSLT Editor and Debugger

XSLT Editor and Debugger

FEATURE DETAILS Graphical XSD Editor

Graphical XML Schema Editor(XSD)