org.enhydra.xml.xmlc.taskdef
Class Xmlc

java.lang.Object
  |
  +--org.apache.tools.ant.taskdefs.MatchingTask
        |
        +--org.enhydra.xml.xmlc.taskdef.Xmlc

public class Xmlc
extends org.apache.tools.ant.taskdefs.MatchingTask

ANT task to invoke the XMLC compiler to generate Java code.

Implements an Ant taskdef to perform XMLC compilations. Please refer to the Ant website for more information. XMLCTask extends MatchingTask which means that it has the ability to include or exclude files based on pattern matching. The supported tags are as follows:

tag required default value description
srcdir yes   The source directory root
destdir no   The destination directory root. Only really useful if you want XMLC to do the compilation, so we can check dependencies.
packagedir no blank package Package prefix for generated classes, expressed as a directory path. If not specified, the relative path from srcdir becomes the package.
markup no HTML The kind of markup language being processed. Choices currently include HTML, WML, XHTML, CHTML and VoiceXML. The generated class is suffixed with this value
verbose no no Displays the XMLC command and all of the arguments
compile no no Have XMLC compile the resulting java files? Note: The default is to not invoke the Java compiler through XMLC, since this is really slow. Any java files created are better handled by the ANT rule.
keep no yes Keep the Java files generated by XMLC? To not keep them, you must allow XMLC to compile them first. However, since this is slower, the default is to keep them and let ANT compile the files using a seperate task.
performExec no no XMLC is invoked by performing a Runtime.exec()
(kept for historical reasons by the author)
options no   File name of XMLC options or a glob style pattern.
arg no   Nested element representing additional command line arguments to be passed to XMLC. See the XMLC documentation for all the possible commands. Note: these are applied after the other XMLC arguments derived from the options listed above.

For example, to specify an URL mapping to XMLC:

            <xmlc source="." includes="*.html">
              <arg value="-urlmapping" />
              <arg value="Edit.html" />
              <arg value="To.po" />
            </xmlc>
            
Caution: Do not be tempted to surround the URL's with single-quotes, as is common when calling XMLC from a shell command line, for example
            <xmlc source="." includes="*.html">
              <arg line="-urlmapping 'Edit.html' 'To.po'" />
            </xmlc>
            
The single-quotes will be taken as part of the URL to replace, and this is probably not what you intend

Since:
1.0
Version:
%I%, %G%
Author:
simon.tuffs@lutris.com, christos@dynamic.net.au, kevin@bluedog.com.au, ericb@interactiveportal.com, Christian Cryder , Stephen Peterson , Jacob Kjome , David Li , Stefan Armbruster
See Also:
Serialized Form

Nested Class Summary
static class Xmlc.BooleanAttribute
           
 
Field Summary
protected  String classPath
           
protected  Commandline cmdl
           
protected  boolean compile
           
protected  File destDir
           
protected  boolean forceBuild
           
protected  boolean keep
           
protected static String logHdr
           
protected  int logLevel
           
protected  String ML
           
protected  String options
           
protected  String packageDir
           
protected  String packageName
           
protected  String performExec
           
protected  File srcDir
           
protected  String srcDirName
           
protected  File srcOutDir
           
protected  String srcOutDirName
           
protected  int upToDate
           
protected  boolean verbose
           
protected  String xmlcArgs
           
 
Constructor Summary
Xmlc()
           
 
Method Summary
 Commandline.Argument createArg()
          Set nested arguments to the XMLC command to be executed.
 void execute()
          Required by ant framework - implements execute() in Task.
 void setArgs(String args)
          Deprecated. Use <arg> tags for now, this will eventually be removed.
 void setClasspath(String classpath)
          Deprecated. Use nested elements or "args" option instead.
 void setCompile(Xmlc.BooleanAttribute _compile)
          Set whether or not to have XMLC compile the generated Java file.
 void setDestdir(String destDirName)
          Set the destination directory into which the generated classes are written.
 void setForce(String force)
          Force XMLC to always re-process the ML code (or not)
 void setKeep(Xmlc.BooleanAttribute _keep)
          Set whether or not to keep the generated Java file.
 void setMarkup(String markup)
          The kind of markup language being processed.
 void setOptions(String _options)
          Set to a specific options file to add parameters to the XMLC command.
 void setPackagedir(String packagedir)
          Set the Package prefix for generated classes.
 void setPackagename(String packagename)
          Set the package prefix for generated classes, while preserving any source file directory paths.
 void setPerformexec(String _performExec)
          Set whether or not to invoke XMLC by using Runtime.exec() to create a seperate JVM.
 void setSourceout(String sourceout)
          Set the destination directory into which the generated source .java files are written, if -keep is used.
 void setSrcdir(String srcdirname)
          Set the source directory containing the HTML files.
 void setVerbose(Xmlc.BooleanAttribute _verbose)
          Run XMLC in verbose mode (-verbose flag)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logHdr

protected static String logHdr

srcDir

protected File srcDir

destDir

protected File destDir

srcOutDir

protected File srcOutDir

classPath

protected String classPath

packageDir

protected String packageDir

packageName

protected String packageName

srcDirName

protected String srcDirName

srcOutDirName

protected String srcOutDirName

options

protected String options

xmlcArgs

protected String xmlcArgs

verbose

protected boolean verbose

forceBuild

protected boolean forceBuild

logLevel

protected int logLevel

upToDate

protected int upToDate

performExec

protected String performExec

ML

protected String ML

keep

protected boolean keep

compile

protected boolean compile

cmdl

protected Commandline cmdl
Constructor Detail

Xmlc

public Xmlc()
Method Detail

setSrcdir

public void setSrcdir(String srcdirname)
Set the source directory containing the HTML files.


setDestdir

public void setDestdir(String destDirName)
Set the destination directory into which the generated classes are written.

Parameters:
destDirName - The destination directory into which the generated classes are written.

setForce

public void setForce(String force)
Force XMLC to always re-process the ML code (or not)


setArgs

public void setArgs(String args)
Deprecated. Use <arg> tags for now, this will eventually be removed.

Allow general XMLC options to be passed through unchanged. Appended to the options lists.

Parameters:
args - The XMLC options to be passed through.

setClasspath

public void setClasspath(String classpath)
Deprecated. Use nested elements or "args" option instead.

Set the classpath for the XMLC compiler.

Parameters:
classpath - The classpath for XMLC to use.

setSourceout

public void setSourceout(String sourceout)
Set the destination directory into which the generated source .java files are written, if -keep is used.

Parameters:
sourceout - The destination directory into which the generated sources are written. Note: Currently -keep is used by devault since the .java files are best compiled by the built-in Ant javac command as a separate rule.

setVerbose

public void setVerbose(Xmlc.BooleanAttribute _verbose)
Run XMLC in verbose mode (-verbose flag)

Parameters:
_verbose - Set "true" for -verbose, anything else (e.g. "false") for quiet mode.

setPackagedir

public void setPackagedir(String packagedir)
Set the Package prefix for generated classes. Expressed as a directory path.

Note: packagedir is used to set the package name of the generated class, and to specify the directory where the file will be generated (relative to sourceout). As such, any directory prefix on a source file is stripped before the packagedir is applied. This means that all files from the source tree will end up in the same directory, which may not be what you intend, if you are using Xmlc to process files in a directory hierarchy.

Parameters:
packagedir - Expressed as a directory path, either '/' or '\' are accepted.
See Also:
setPackagename(String)

setPackagename

public void setPackagename(String packagename)
Set the package prefix for generated classes, while preserving any source file directory paths. This is useful if you want to take source (markup language) files from one tree, but generate the Java code into another tree, preserving relative paths.

For example, suppose that you have .html files under a directory called "foo/resources", and you want to generate Java code under "foo/source", but have the package name be "a.b". The following Xmlc taskdef will achieve this:

A markup file located at "foo/resources/c/d/Foo.ml" will be generated to "foo/source/a/b/c/d/FooML.java" and will start with a "package a.b.c.d" statement.


setMarkup

public void setMarkup(String markup)
The kind of markup language being processed. Choices currently include HTML, WML, XHTML, CHTML and VoiceXML. The generated class is suffixed with this value.

Parameters:
markup - The type of markup language (controls only the file-name suffix, the actual markup is controlled through the XMLC -dom option which is accessible through the "args" option or <arg> tag.

setPerformexec

public void setPerformexec(String _performExec)
Set whether or not to invoke XMLC by using Runtime.exec() to create a seperate JVM. This capability was originally written to get around a problem with name-space clashes between packages. Set this to the command to execute.


execute

public void execute()
             throws org.apache.tools.ant.BuildException
Required by ant framework - implements execute() in Task. Called by the project to let the task do its work.

Throws:
BuildException - All exceptions are thrown as BuildException. Note: most of the logic here was cloned from the Javac command. Unfortunately this was the only way to 'reuse' it.

setKeep

public void setKeep(Xmlc.BooleanAttribute _keep)
Set whether or not to keep the generated Java file.


setCompile

public void setCompile(Xmlc.BooleanAttribute _compile)
Set whether or not to have XMLC compile the generated Java file.


setOptions

public void setOptions(String _options)
Set to a specific options file to add parameters to the XMLC command. Or, use a glob style pattern to base the options file name off the name of each source file to be processed (e.g. *.xmlc).


createArg

public Commandline.Argument createArg()
Set nested arguments to the XMLC command to be executed.



Copyright © 1999-2002 David Li, enhydra.org. All Rights reserved.