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.
Note: This task depends on two external libraries not included in the Ant distribution: one called xbean.jar, one called jsr173_1.0_api.jar. Both can be found in the XMLBeans developer kit at http://xmlbeans.apache.org/. The build script will need to include a taskdef for xmlbean, which could look like this:
<taskdef name="xmlbean"
classname="org.apache.xmlbeans.impl.tool.XMLBean"
classpath="path/to/xbean.jar:path/to/jsr173_1.0_api.jar" />
It is possible to refine the set of files that are being processed. This can be done with the includes, includesfile, excludes, excludesfile and defaultexcludes attributes. With the includes or includesfile attribute you specify the files you want to have included by using patterns. The exclude or excludesfile attributes are used to specify the files you want to have excluded. This is also done with patterns. And finally with the defaultexcludes attribute, you can specify whether you want to use default exclusions or not. See the section on directory based tasks in the Ant documentation, on how the inclusion/exclusion of files works, and how to write patterns.
This task forms an implicit FileSet
and supports all attributes of <fileset>
(dir
becomes basedir
) as well as the nested <include>
,
<exclude>
and <patternset>
elements.
Attribute | Description | Required |
schema | A file that points to either an individual schema file or a directory of files. Not a path reference. If multiple schema files need to be built together, use a nested fileset instead of setting schema. | Yes, unless a fileset element is nested. |
destfile | Define the name of the jar file created. For instance, "myXMLBean.jar" will output the results of this task into a jar with the same name. | No, default is "xmltypes.jar". |
download | Set to true to permit the compiler to download URLs for
imports and includes. Defaults to false, meaning all imports and
includes must be copied locally. |
No, default is false. |
classgendir |
Set a location to generate CLASS files into. |
No |
srconly |
A value of true means that only source will be generated. |
No, default is false. |
srcgendir |
Set a location to generate JAVA files into. |
No |
javasource |
Generate java source compatible with the given
version. Currently only "1.4" and "1.5" are supported. |
No, Default is "1.4" |
classpath | 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. | No |
classpathref | Adds a classpath, given as reference to a path defined elsewhere. | No |
includes | Comma- or space-separated list of patterns of files that must be included. All files are included when omitted. | No |
includesfile | The name of a file. Each line of this file is taken to be an include pattern. | No |
excludes | Comma- or space-separated list of patterns of files that must be excluded. No files (except default excludes) are excluded when omitted. | No |
excludesfile | The name of a file. Each line of this file is taken to be an exclude pattern. | No |
defaultexcludes | Indicates whether default excludes should be used or not ("yes"/"no"). Default excludes are used when omitted. | No |
debug | Indicates whether source should be compiled with debug
information; defaults to off . If set to off ,
-g:none 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 true , the value of the debuglevel
attribute determines the command line argument. |
No |
debuglevel | Keyword list to be appended to the -g command-line
switch. This will be ignored by all implementations except modern
and classic(ver >= 1.2) . Legal values are none
or a comma-separated list of the following keywords: lines ,
vars , and source . If debuglevel
is not specified, by default, nothing will be appended to -g .
If debug is not turned on, this attribute will be ignored.
|
No |
optimize | Indicates whether source should be compiled with optimization;
defaults to off . |
No |
includeAntRuntime | Whether to include the Ant run-time libraries in the
classpath; defaults to yes . |
No |
includeJavaRuntime | Whether to include the default run-time libraries from
the executing VM in the classpath; defaults to no . |
No |
fork | Whether to execute javac using the JDK compiler
externally; defaults to yes . |
No, default is true |
executable | Complete path to the javac executable to
use in case of fork="yes" . Defaults to the compiler
of the Java version that is currently running Ant. Ignored if fork="no" |
No |
memoryInitialSize | The initial size of the memory for the underlying VM,
if javac is run externally; ignored otherwise. Defaults
to the standard VM memory setting. (Examples: 83886080 ,
81920k , or 80m ) |
No |
memoryMaximumSize | The maximum size of the memory for the underlying VM,
if javac is run externally; ignored otherwise. Defaults
to the standard VM memory setting. (Examples: 83886080 ,
81920k , or 80m ) |
No |
compiler | The compiler implementation to use. If this attribute
is not set, the value of the build.compiler property, if
set, will be used. Otherwise, the default compiler for the current VM
will be used.
| No |
failonerror | Determines whether or not the ant target will continue
if the XMLBean creation encounters a build error. |
No, default is true. |
verbose |
Controls the amount of build message output. |
No, default is true. |
quiet |
Controls the amount of build message output. |
No, default is false. |
typesystemname |
The name of the package that the TypeSystemHolder class
should be generated in. 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. |
No |
noupa | Do not enforce the unique particle attribution rule. |
No, default is false. | nopvr | Do not enforce the particle valid (restriction) rule. |
No, default is false. |
noann | Skip over schema <annotation> elements |
No, default is false. |
nopvr | Do not validate the contents of schema <documentation> elements. |
No, default is false. |
ignoreDuplicatesInNamespaces | Comma separated list of one or more namespaces in which duplicate definitions are to be ignored. | No |
<taskdef name="xmlbean"
classname="org.apache.xmlbeans.impl.tool.XMLBean"
classpath="path/to/xbean.jar:path/to/jsr173_1.0_api.jar" />
The following builds all the schemas in the schemas directory and creates a jar called "Schemas.jar". (Note: both xbean.jar and jsr173_1.0_api.jar must be on the classpath when the task executes).
<xmlbean schema="schemas" destfile="Schemas.jar" classpath="path/to/xbean.jar:path/to/jsr173_1.0_api.jar" />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.
<xmlbean schema="schemas/ourSchema.xsd" download="true"
classpath="path/to/xbean.jar:path/to/jsr173_1.0_api.jar" />
<xmlbean classgendir="${build.dir}" classpath="${class.path}"
failonerror="true">
<fileset basedir="src" excludes="**/*.xsd"/>
<fileset basedir="schemas" includes="**/*.*"/>
</xmlbean>
None.