xml2ddl Ant Wrapper - Generate DDL from Ant


Return to main dbmstools documentation page.


xml2ddl-ant is a wrapper script to enable xml2ddl to be executed as a task in Apache Ant (a Java build tool - if that means nothing to you, you can safely skip this section). It works in tandem with the Jython Ant task provided with dbmstools, which provides much more functionality than the standard Ant script task.

See the xml2ddl page for further details. You should also check the Use of DTD section on the XML schema page.


As with all the ant wrappers, this script uses Jython. See the installation page for details of the requirements to get any of the Ant tasks working.

You must also taskdef the jython task somewhere in your build script (or in something it includes).

Build Script

xml2ddl-ant.py should be executed using the jython task mentioned above. It requires that the script attribute be set to dbmstoolsjar/filterdml-ant.py

<jython script="dbmstoolsjar/xml2ddl-ant.py">

The script supports the following arguments:

Argument Example Details
xmlSchema ${db.scripts.dir}/ps.xml The path to the XML schema file. Mandatory
outputDir ${output.dir}/${ddl.scripts.dir} Directory where DDL scripts should be created. Mandatory
dbmsList postgres8, oracle CSV list of DBMS's for which to generate scripts. Mandatory, must contain at least one entry
writeHeaders Y Should we write headers in the DDL files? Optional, allowed values are 'Y' or 'N', defaults to 'Y'
commandTerminator \r\ngo The DDL command terminator to use (overrides the standard for the DBMS). The strings '\r' and '\n' will be replaced with CR and LF respectively. Optional, defaults to ';'
maxNameLength 100 The maximum length for names of schema objects. Optional, defaults to the value specified in the XML schema
baseName sampledb The base name to be used in generated file names. Optional, defaults to the database name in the XML schema
wikiMarkup Y Should [[BR]] (Wiki markup) in descriptions be interpreted as line breaks? Optional, defaults to 'N'.
utf8 Y If set, XML schema is output as UTF-8 unicode. Optional, defaults to 'N' (which outputs as ISO-8859-1, aka Latin 1)
verbose Y If set, outputs extra output. Optional, defaults to 'N'

The script also supports a single mapargument called variables. The contents of this element are arguments whose names and values are the values you wish to pass to xml2ddl (for condition evaluation or token replacement). See the example below.


<jython script="dbmstoolsjar/xml2ddl-ant.py">
    <argument name="xmlSchema" value="test/data/testSchema.xml"/>
    <argument name="outputDir" value="${output-dir}"/>
    <argument name="dbmsList" value="oracle, postgres8, mssql"/>
    <mapargument name="variables">
        <argument name="aVariableName" value="aValue"/>
        <argument name="anotherVariableName" value="anotherValue"/>