<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!DOCTYPE document PUBLIC "-//APACHE//DTD Documentation V2.0//EN" "http://forrest.apache.org/dtd/document-v20.dtd">
<document>
    <header>
        <title>XMLBeans Ant Task</title>
    </header>
    <body>
        <section>
            <title>XMLBeans Ant Task</title>

            <p>Compiles a set of XSD and/or WSDL files into XMLBeans. This is useful for
                building an XMLBean JAR from XSD and WSDL files. If desired, the task can
                also generate the source code that makes up the XMLBean type system specified
                by the schema files.
            </p>
            <note>
                <strong>Note:</strong>
                This task depends on an external libraries not
                included in the Ant distribution - called xmlbeans.jar (or xbean.jar in older versions).
                Older versions of xmlbeans may also need jsr173_1.0_api.jar.
                xmlbeans.jar can be found in the XMLBeans developer kit at <a
                    href="http://xmlbeans.apache.org/">http://xmlbeans.apache.org/</a>.
                The build script will need to include a taskdef for xmlbean, which could look
                like this:
            </note>
            <source><![CDATA[
                <taskdef name="xmlbean"
                    classname="org.apache.xmlbeans.impl.tool.XMLBean"
                    classpath="path/to/xmlbeans.jar" />
            ]]></source>

            <p>It is possible to refine the set of files that are being processed. This
                can be done with the <strong>includes</strong>, <strong>includesfile</strong>,
                <strong>excludes</strong>,
                <strong>excludesfile</strong>
                and <strong>defaultexcludes</strong> attributes. With the
                <strong>includes</strong>
                or <strong>includesfile</strong> attribute you specify the
                files you want to have included by using patterns. The
                <strong>exclude</strong>
                or <strong>excludesfile</strong> attributes are used to specify
                the files you want to have excluded. This is also done with patterns. And
                finally with the <strong>defaultexcludes</strong> attribute,
                you can specify whether you want to use default exclusions or not. See the
                section on <a href="http://ant.apache.org/manual/dirtasks.html#directorybasedtasks">directory
                    based tasks
                </a> in the <a href="http://ant.apache.org/manual/">Ant
                    documentation</a>, on how the inclusion/exclusion of files works, and how
                to write patterns.
            </p>

            <p>This task forms an implicit
                <a
                        href="http://ant.apache.org/manual/CoreTypes/fileset.html">FileSet
                </a>
                and supports all attributes of <code>&lt;fileset></code> (
                <code>dir</code>
                becomes <code>basedir</code>) as well as the nested <code>&lt;include></code>,
                <code>&lt;exclude></code>
                and <code>&lt;patternset></code> elements.
            </p>

        </section>

        <section>
            <title>Parameters</title>

            <table>
                <tr>
                    <th>Attribute</th>
                    <th>Description</th>
                    <th>Required</th>
                </tr>
                <tr>
                    <td>schema</td>
                    <td>A file that points to either an individual schema file
                        or a directory of files. &nbsp;Not a path reference. &nbsp;If multiple
                        schema files need to be built together, use a nested fileset instead
                        of setting schema.
                    </td>
                    <td>Yes, unless a fileset element is nested.</td>
                </tr>
                <tr>
                    <td>destfile</td>
                    <td>Define the name of the jar file created.&nbsp; For instance,
                        "myXMLBean.jar" will output the results of this task into a jar with
                        the same name.
                    </td>
                    <td>No, default is "xmltypes.jar".</td>
                </tr>
                <tr>
                    <td>download</td>
                    <td>Set to true to permit the compiler to download URLs for
                        imports and includes.&nbsp; Defaults to false, meaning all imports and
                        includes must be copied locally.
                    </td>
                    <td>No, default is false.</td>
                </tr>
                <tr>
                    <td>classgendir</td>
                    <td>Set a location to generate CLASS files into.</td>
                    <td>No</td>
                </tr>
                <tr>
                    <td>srconly</td>
                    <td>A value of true means that only source will be generated.
                    </td>
                    <td>No, default is false.</td>
                </tr>
                <tr>
                    <td>srcgendir</td>
                    <td>Set a location to generate JAVA files into.</td>
                    <td>No</td>
                </tr>
                <tr>
                    <td>javasource</td>
                    <td>Generate java source compatible with the given
                        version. Currently only "1.4" and "1.5" are supported.
                    </td>
                    <td>No, Default is "1.4"</td>
                </tr>
                <tr>
                    <td>classpath</td>
                    <td>The classpath to use if schemas in the fileset import
                        definitions that are supplied by other compiled XMLBeans JAR files,
                        or if JAVA files are in the schema fileset. Also supports a nested classpath.
                    </td>
                    <td>No</td>
                </tr>
                <tr>
                    <td>classpathref</td>
                    <td>Adds a classpath, given as
                        <a
                                href="http://ant.apache.org/manual/using.html#references">reference
                        </a>
                        to a path defined elsewhere.
                    </td>
                    <td>No</td>
                </tr>
                <tr>
                    <td>includes</td>
                    <td>Comma- or space-separated list of patterns of files that
                        must be included. All files are included when omitted.
                    </td>
                    <td>No</td>
                </tr>
                <tr>
                    <td>includesfile</td>
                    <td>The name of a file. Each line of this file is taken to
                        be an include pattern.
                    </td>
                    <td>No</td>
                </tr>
                <tr>
                    <td>excludes</td>
                    <td>Comma- or space-separated list of patterns of files that
                        must be excluded. No files (except default excludes) are excluded when
                        omitted.
                    </td>
                    <td>No</td>
                </tr>
                <tr>
                    <td>excludesfile</td>
                    <td>The name of a file. Each line of this file is taken to
                        be an exclude pattern.
                    </td>
                    <td>No</td>
                </tr>
                <tr>
                    <td>defaultexcludes</td>
                    <td>Indicates whether default excludes should be used or
                        not ("yes"/"no"). Default excludes are used when omitted.
                    </td>
                    <td>No</td>
                </tr>
                <tr>
                    <td>debug</td>
                    <td>Indicates whether source should be compiled with debug
                        information; defaults to <code>off</code>. If set to <code>off</code>,
                        <code>-g:none</code>
                        will be passed on the command line for compilers
                        that support it (for other compilers, no command line argument will
                        be used). If set to <code>true</code>, the value of the
                        <code>debuglevel</code>
                        attribute determines the command line argument.
                    </td>
                    <td>No</td>
                </tr>
                <tr>
                    <td>debuglevel</td>
                    <td>Keyword list to be appended to the <code>-g</code> command-line
                        switch. This will be ignored by all implementations except
                        <code>modern</code>
                        and <code>classic(ver >= 1.2)</code>. Legal values are
                        <code>none</code>
                        or a comma-separated list of the following keywords: <code>lines</code>,
                        <code>vars</code>, and <code>source</code>. If
                        <code>debuglevel</code>
                        is not specified, by default, nothing will be appended to <code>-g</code>.
                        If <code>debug</code> is not turned on, this attribute will be ignored.
                    </td>
                    <td>No</td>
                </tr>
                <tr>
                    <td>optimize</td>
                    <td>Indicates whether source should be compiled with optimization;
                        defaults to <code>off</code>.
                    </td>
                    <td>No</td>
                </tr>
                <tr>
                    <td>includeAntRuntime</td>
                    <td>Whether to include the Ant run-time libraries in the
                        classpath; defaults to <code>yes</code>.
                    </td>
                    <td>No</td>
                </tr>
                <tr>
                    <td>includeJavaRuntime</td>
                    <td>Whether to include the default run-time libraries from
                        the executing VM in the classpath; defaults to <code>no</code>.
                    </td>
                    <td>No</td>
                </tr>
                <tr>
                    <td>nowarn</td>
                    <td>Whether the <code>-nowarn</code> switch should be passed to
                        the JDK compiler; defaults to <code>no</code>.
                    </td>
                    <td>No</td>
                </tr>
                <tr>
                    <td>fork</td>
                    <td>Whether to execute <code>javac</code> using the JDK compiler
                        externally; defaults to <code>yes</code>.
                    </td>
                    <td>No, default is true</td>
                </tr>
                <tr>
                    <td>executable</td>
                    <td>Complete path to the <code>javac</code> executable to
                        use in case of <code>fork="yes"</code>. Defaults to the compiler
                        of the Java version that is currently running Ant. Ignored if
                        <code>fork="no"</code>
                    </td>
                    <td>No</td>
                </tr>
                <tr>
                    <td>memoryInitialSize</td>
                    <td>The initial size of the memory for the underlying VM,
                        if <code>javac</code> is run externally; ignored otherwise. Defaults
                        to the standard VM memory setting. (Examples: <code>83886080</code>,
                        <code>81920k</code>, or <code>80m</code>)
                    </td>
                    <td>No</td>
                </tr>
                <tr>
                    <td>memoryMaximumSize</td>
                    <td>The maximum size of the memory for the underlying VM,
                        if <code>javac</code> is run externally; ignored otherwise. Defaults
                        to the standard VM memory setting. (Examples: <code>83886080</code>,
                        <code>81920k</code>, or <code>80m</code>)
                    </td>
                    <td>No</td>
                </tr>
                <tr>
                    <td>compiler</td>
                    <td>The compiler implementation to use. If this attribute
                        is not set, the value of the <code>build.compiler</code> property, if
                        set, will be used. Otherwise, the default compiler for the current VM
                        will be used.
                    </td>
                    <td>No</td>
                </tr>
                <tr>
                    <td>failonerror</td>
                    <td>Determines whether or not the ant target will continue
                        if the XMLBean creation encounters a build error.
                    </td>
                    <td>No, default is true.</td>
                </tr>
                <tr>
                    <td>verbose</td>
                    <td>Controls the amount of build message output.</td>
                    <td>No, default is true.</td>
                </tr>
                <tr>
                    <td>quiet</td>
                    <td>Controls the amount of build message output.</td>
                    <td>No, default is false.</td>
                </tr>
                <tr>
                    <td>typesystemname</td>
                    <td>The name of the package that the TypeSystemHolder class
                        should be generated in.&nbsp; Normally this should be left unspecified.
                        None of the XMLBeans are generated in this package. Use .xsdconfig files
                        to modify XMLBean package or class names.
                    </td>
                    <td>No</td>
                </tr>
                <tr>
                    <td>noupa</td>
                    <td>Do not enforce the unique particle attribution rule.</td>
                    <td>No, default is false.</td>
                </tr>
                <tr>
                    <td>nopvr</td>
                    <td>Do not enforce the particle valid (restriction) rule.</td>
                    <td>No, default is false.</td>
                </tr>
                <tr>
                    <td>noann</td>
                    <td>Skip over schema &lt;annotation> elements</td>
                    <td>No, default is false.</td>
                </tr>
                <tr>
                    <td>nopvr</td>
                    <td>Do not validate the contents of schema &lt;documentation> elements.</td>
                    <td>No, default is false.</td>
                </tr>
                <tr>
                    <td>ignoreDuplicatesInNamespaces</td>
                    <td>Comma separated list of one or more namespaces
                        in which duplicate definitions are to be ignored.
                    </td>
                    <td>No</td>
                </tr>
            </table>
        </section>

        <section>
            <title>Example</title>

            <p>Be sure to define the task in your script, like this:</p>

            <source><![CDATA[
                <taskdef name="xmlbean"
                     classname="org.apache.xmlbeans.impl.tool.XMLBean"
                     classpath="path/to/xmlbeans.jar" />
            ]]></source>

            <p>The following builds all the schemas in the schemas directory and creates
                a jar called "Schemas.jar". (Note: xmlbeans.jar must be on the classpath when the task executes).
            </p>

            <source><![CDATA[
                <xmlbean schema="schemas" destfile="Schemas.jar"
                    classpath="path/to/xmlbeans.jar" />
            ]]></source>

            <p>The following compiles the schema "ourSchema.xsd" into the default
                jar "xmltypes.jar". If any imports and includes are defined
                by remote URLs, they are downloaded during the build.
            </p>

            <source><![CDATA[
                <xmlbean schema="schemas/ourSchema.xsd" download="true"
                      classpath="path/to/xmlbeans.jar" />
            ]]></source>

        </section>

        <section>
            <title>Using a fileset</title>

            <source><![CDATA[
                <xmlbean classgendir="${build.dir}" classpath="${class.path}" failonerror="true">
                    <fileset basedir="src" excludes="**/*.xsd"/>
                    <fileset basedir="schemas" includes="**/*.*"/>
                </xmlbean>
            ]]></source>

            <p>Gathers all the files in the src directory except XSD files, along with
                every file in the schemas directory, and compiles them. The fileset can include
                schema files that refer to previously compiled schema components.&nbsp; The
                fileset can also contain JAVA files.&nbsp; The classpath parameter defines
                the classpath necessary to resolve compiled schema and java references (and must include xbean.jar and
                jsr173_1.0_api.jar).
                <br/>
                The built classes will go into ${build.dir}.
            </p>

        </section>

        <section id="relatedtopics">
            <title>Related Topics</title>
            <p>None.</p>
        </section>
    </body>
</document>