ANT Java2Schema Task  Locate

Overview  Locate

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]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.

Task NameTask Class
Java2Schemacom.idoox.wasp.tools.ant.Java2SchemaTask

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>

Attributes of the Java2Schema Task  Locate

Attribute NameDescriptionRequiredCommand-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
dirThe 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
generateWsdlGenerates 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
noJavaMappingExtensionIf set to true, disables the generation of extensibility elements into XML Schema.No--no-java-mapping-extension
outputFileNameNames 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
processingSets the name of the processing node (block) in the deployment descriptorNo--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
singledimArraysDisables 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 0No

--verbose

Sub-elements of the ANT Java2Schema Task  Locate

<addType>   Locate

Generates a schema type for a given class for output definition(s).

Attribute of addTypeDescriptionRequired
nameThe name of the class for which the schema type will be generated. No
<class>   Locate

A class to be processed.

Attribute of classDescription
nameThe comma-separated list of classes to be processed.
<classpath>   Locate

Sets the classpath that the task will use to find other classes.

Attribute of classpathDescription
refidReference to classpath described elsewhere in the script
<excludeClass>   Locate

Excludes all methods of a given class from the output definition.

Attributes of excludeClassDescriptionRequired
nameThe class that will be excluded from generation. Java notation can be used. For example: "java.lang.*" will exclude all classes. Yes
<includeClass>   Locate

Includes a given class in the output definition.

Attribute of includeClassDescriptionRequired
nameThe class that will be included in generation. No
<inheritance>   Locate

Specifies the inheritance path.

Attribute of inheritanceDescriptionRequired
nameThe name of the classYes
inheritsFromThe name of the superclass of the classYes
<package2TargetNamespace>   Locate

Maps a Java package to the WSDL target namespace. Comma separated package=targetNamespace pairs are expected.

Attribute of package2TargetNamespaceDescriptionRequired
packageThe name of the package that is to be mapped to the specified namespaceYes
namespaceThe namespace to which the package is mappedYes