Generate a schema (XSD) from an XML model.

[ 25 Jan 2004 ]

[Perl]


[ Updated to V1.3 27 Jun 2005 ]


Description:

This script generates a loose schema based from an XML model

Features:

1. Creation of element references where duplicated elements exist and all common sub-elements will be added to the element declaration later in the schema. (Optional)

2. Guessing of data element types.(Optional)

3. Take multiple input XML models in a directory (which form a common package) and generate the individual schema, with any common elements generated to a seperate schema which is referenced by the originals. This is designed to work with Castor, which will generate Java objects from the schema. The common schema prevents package clashes of objects which have the same name but different types.


Required modules:

XML::DOM, XML::Writer, and GetOpt::Long


Command line options

Standard:
    -i=FILE   --input=FILE      Input XML model to process.
    -o=FILE   --output=FILE     Outputted XSD filename
    -h        --help            Display this help.
    -v        --version         Display the version of GenerateXSD

Style:
    -r        --refs            Move any commonly used element types
                                into an xs:element ref="TAGNAME"> node.
    -g        --guess           Attempt to guess the data type of elements and
                                attributes.

Multiple file generation:
    -l=DIR    --location=DIR    Generate all files in DIR. (Assumes -r)
                                any commonly used elements will be generated
                                to a file called "commonTypes.xsd" by default.
    -f        --folder=DIR      Generate files from specified location to DIR.
    -c=FILE   --common=FILE     Specify the filename for the commonly used
                                elements.
Logging:
    -d        --debug           Print debugging output.

Bugfixes since V1.0

Schema are now created with the maximum information available from the XML model, an oversight previously meant that as the elements in the model were traversed you could reach a node with optional sub-elements not present, though the sub-elements could be present in another element of the same type. Now all information available from nodes of the same type is cached.

Bugfixes since V1.1

A bug was present preventing full collated attribute information from an element to be added to the schema.

Bugfixes since V1.2

Another bug was present preventing full collated attribute information from an element to be added to the schema. :(

Download [21Kb].

Return to projects page