XML Generator CLI
Overview
The XML Generator CLI is a command-line tool that generates XML files based on an XSD schema. It can be used to generate sample XML files for testing purposes.
The tool take into account the constraint attributes defined in the XSD schema and generates XML files that are compliant with the schema.
Installation
Software prerequisites
Java
In order to run TDK you need to install Java 17+ first.
Various Java 17+ builds from a number of vendors are available, some free options include Eclipse Temurin and Liberica JDK, but you can use any Java 17+ build available in your organization. |
Check the version of Java on your machine with the following command:
java --version
If Java is installed correctly, this command should run successfully, and the major Java version shown in the output should be 17 or higher.
License key
A license key is needed to use XML Generator CLI. |
Please contact us for more information about obtaining the key.
Download
XML Generator CLI can be downloaded here.
The executable JAR file is named xml-generator-<version>.jar
.
Usage
Basic usage of the XML Generator CLI is as follows:
java -jar xml-generator.jar --xsd <path-to-xsd> --xml <path-to-output-xml>
Help
For more information about the available options, you can run the following command:
java -jar xml-generator.jar
The output will be similar to the following:
Usage: generate [-fhV] -i=<input> [-n=<numberOfDocuments>] -o=<output>
[-s=<seed>] [-t=<xslt>] [COMMAND]
Generate XML files for the given XSD
-f, --force Force overwrite existing files. Default is false.
-h, --help Show this help message and exit.
-i, --xsd, --input=<input>
Path to the XSD file or directory with XSF files
-n, --number=<numberOfDocuments>
Number of generated documents. Default is 1.
-o, --xml, --output=<output>
Path to the directory with generated XML files
-s, --seed=<seed> Seed for random generation. Default is 0.
-t, --xslt=<xslt> Path to the directory containing XSLT files or a single
file for transforming XML files after generation.
-V, --version Print version information and exit.
Setting seed for random generation
The seed is used to generate deterministic random values for the XML file. If you want to generate different XML files, you can change the seed value.
The seed value can be set using the --seed
option.
java -jar xml-generator.jar --xsd <path-to-xsd> --xml <path-to-output-xml> --seed <seed>
Generation of multiple XML files
You can generate multiple XML files by specifying the --number
option.
java -jar xml-generator.jar --xsd <path-to-xsd> --xml <path-to-output-xml> --number <number-of-documents>
Applying XSL transformation
XSL transformation is a powerful tool for transforming XML files.
You can apply XSL transformation to the generated XML file. The XSL file can be a single file or a directory containing multiple XSL files.
The XSL file can be specified using the --xslt
option.
java -jar xml-generator.jar --xsd <path-to-xsd> --xml <path-to-output-xml> --xslt <path-to-xslt>