<?xml version="1.0" encoding="ISO-8859-1"?>
<document url="http://castor.codehaus.org/schemaGen-anttask.xml">

  <properties>
    <title>The Ant Task for the Castor schema generator</title>
    <author email="wguttmn AT codehaus DOT org">Werner Guttmann</author>
    <abstract>
       Describes how to use the Ant task for the Castor XML schema gnerator and
       what is currently supported.
    </abstract>
    <status>Final</status>
  </properties>

  <body>

    <title>Using the Ant task for the Castor XML schema generator</title>

    <section title="Castor XML schema generator Ant task">

      <p>
        An alternative to using the command line as shown in the previous section,
        the Castor XML schema generator Ant task can be used to call the XML schema
        generator for XML schema generation. The only requirement is that the
        castor-&lt;version&gt;-anttasks.jar must be on the CLASSPATH.
      </p>

      <section title="Configuration">

        <p>
          Please find below the complete list of parameters that can be set on the Castor
          XML schema generator.
        </p>

        <ctable>
          <cheader>
            <th>Attribute</th>
            <th>Description</th>
            <th>Required</th>
          </cheader>
          <crow>
            <td><b>file</b></td>
            <td>The name of the XML file to use as input for XML schema generation.</td>
            <td>Yes</td>
          </crow>
          <crow>
            <td><b>schemaFileName</b></td>
            <td>The name of the XML schema file to be generated; if not specified, a suffix '.xsd' 
                will be appended to the input file name.</td>
            <td>No</td>
          </crow>
          <crow>
            <td><b>defaultGroupingAsAll</b></td>
            <td>To indicate that &lt;xsd:all/&gt; should be used as default grouping.</td>
            <td>No</td>
          </crow>
        </ctable>
        
        <p>
          Alternatively to specifying the <tt>file</tt> property, it is possible to work 
          with a nested &lt;FileSet&gt; element or with the <tt>dir</tt>
          property.
        </p>

      </section>

      <section title="Example">

        <p>
          Below is an example of how to use this task from within an Ant target
          definition named 'castor:schema:gen':
        </p>

        <code-panel><![CDATA[
  <target name="castor:schema:gen" depends="init"
             description="Generate an XML schema from an XML document instance.">

    <taskdef name="schema-gen"
             classname="org.castor.anttask.XMLInstance2SchemaTask"
             classpathref="castor.class.path" />
    <mkdir dir="generated" />
    <schema-gen file="src/main/resources/input.xml"
                schemaFileName="target/generated/schema/input.xsd" />
  </target>]]>
        </code-panel>

      </section>

    </section>

  </body>

</document>
