The Java2Schema ANT Task is for launching the Java2Schema command-line tool in Apache ANT. Java2Schema maps Java classes and structures to their XML Schema representations. It is used by Java2WSDL and can be used to implement certain more advanced techniques as a standalone utility. More detailed information is given in Java2Schema.
![]() | Note |
---|---|
Examples You can find usage examples of ANT tasks in WASP_HOME/src/example/tools/ant and in the build.xml files in Demos. See also Example 217. |
Example 217. Java2Schema ANT Task Using Attributes
<?xml version="1.0" encoding="UTF-8"?> <project basedir="." default="main" name="test"> <taskdef classname="com.idoox.wasp.tools.ant.Java2SchemaTask" name="java2Schema"/> <path id="schemaClasspath"> <pathelement path="C:\work\build"/> </path> <target name="main"> <java2Schema addType="test.Structure,test.test.Structure" class="test.TestClass,test.test.TestClass" classpathRef="schemaClasspath" dir="../test_ouptut_3" excludeClass="test.TestClass" outputFileName="schemaOutput.xml" package2TargetNamespace="test=testNs,test.test=testTestNs"/> </target> </project>
Attribute Name | Description | Required | Command-line Option |
---|---|---|---|
addType | Generates a schema type for a given class for output definition(s). It contains one required attribute, name. The value of the attribute is the name of the class for which the schema type will be generated. The addType sub-element has the same function. | No | --add-type |
class | A comma separated list of classes to be processed. Equivalent to the class sub-element. | Yes | - |
classpathRef | Reference to the classpath element where the task will find the required classes. | No | --classpath |
deploymentDescriptor | Sets the filename of the deployment descriptor to be used. When you specify it, you must also set the processing attribute. | No | --deployment-descriptor |
dir | The directory where output schema(s) will be stored. The default is the current directory. | No | --output-directory |
excludeClass | Excludes all methods of a given class from the output definition. It contains the one required name attribute. The value of the attribute is the class that will be excluded from generation. Java notation can be used. For example: "java.lang.*" will exclude all classes. Equivalent to the excludeClass sub-element. | No | --exclude-class |
force | Overwrites existing file, when a file with same path as the file being generated exists already. This prevents "File already exists"-type errors. (=true/false) | No | --force |
generateWsdl | Generates a single WSDL file instead of multiple XML Schema files. (=true/false) | --generate-wsdl | |
includeClass | Includes the method of a given class in the output definition. The same as the includeMethod sub-element. | No | --include-class |
inheritance | Specifies the inheritance path. Comma separated class=superclass pairs are expected. It contains two required attributes: name and inheritsFrom. The value of the class attribute is the name of the class. The value of the inheritsFrom attribute is the name of the superclass of the class.Equivalent to the inheritance sub-element. | No | --inherit |
insert | A comma separated list of the given XML Schemas, or a WSDL file, from which previously defined types will be used as the base for compilation. | No | --insert |
noJavaMappingExtension | If set to true, disables the generation of extensibility elements into XML Schema. | No | --no-java-mapping-extension |
outputFileName | Names the main output file. The name is relative to the output directory. | No | --output-filename |
package2TargetNamespace | Maps the Java package to the WSDL target namespace. Comma separated package=targetNamespace pairs are expected. Equivalent to the package2TargetNamespace sub-element. | No | --package-mapping |
processing | Sets the name of the processing node (block) in the deployment descriptor | No | --processing |
reference | A comma separated list of the given XML Schemas, or a WSDL file, from which already defined types will be used as the base for compilation. | No | --reference |
singledimArrays | Disables SOAP Sec. 5 array generation. Two dimensional arrays will be generated as an [][] array (an array of arrays), not as an [,] array (Java multidimensional array). | No | --singledim-arrays |
soapEncodingStyle | Specifies the SOAP encoding style. The style can be either literal or encoded. The default style is literal. | No | --soap-encoding-style |
useNillable (true/false) | Sets which attribute should be generated for Java reference data types. If true, nillable="true" is generated. If false, minOccurs="0" is generated. Default value is true. This switch can be useful if you are experiencing trouble communicating with .NET, as C# prefers optional elements to be present rather than nillable. | No | --use-nillable |
verbose | Additional information during processing will be printed to stderr. Value is a level from 0-10. Default is 0 | No | --verbose |
Generates a schema type for a given class for output definition(s).
Attribute of addType | Description | Required |
---|---|---|
name | The name of the class for which the schema type will be generated. | No |
A class to be processed.
Attribute of class | Description |
---|---|
name | The comma-separated list of classes to be processed. |
Sets the classpath that the task will use to find other classes.
Attribute of classpath | Description |
---|---|
refid | Reference to classpath described elsewhere in the script |
Excludes all methods of a given class from the output definition.
Attributes of excludeClass | Description | Required |
---|---|---|
name | The class that will be excluded from generation. Java notation can be used. For example: "java.lang.*" will exclude all classes. | Yes |
Includes a given class in the output definition.
Attribute of includeClass | Description | Required |
---|---|---|
name | The class that will be included in generation. | No |
Specifies the inheritance path.
Attribute of inheritance | Description | Required |
---|---|---|
name | The name of the class | Yes |
inheritsFrom | The name of the superclass of the class | Yes |
Maps a Java package to the WSDL target namespace. Comma separated package=targetNamespace pairs are expected.
Attribute of package2TargetNamespace | Description | Required |
---|---|---|
package | The name of the package that is to be mapped to the specified namespace | Yes |
namespace | The namespace to which the package is mapped | Yes |