ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jonathan Locke <>
Subject question and idea.
Date Sat, 16 Feb 2002 18:53:05 GMT

is the SAX part of ant's XML parsing 100% pluggable?
is there a mechanism for doing this?

anyway, i have had an idea for some years now that i'm finally
ready to act on, especially if anyone would be interested in 
helping out.  the basic idea is to create a SAX parser that
accepts a simplified non-markup-style data format that is useful
for representing configuration files and other such strictly-tree 
data in a more readable format.  ant makefiles would be one such
data source.  although it would mean you couldn't work with 
makefiles using tools with hardcoded SAX parsers, it does play
within the larger XML story, as XML is touted as being format/
source independent.  i'm sure some people will see this as crazy,
but i'm hoping that others will see some value.  ;-)

as an example (would love some useful feedback), here is the first 
example from the ant documentation:

<project name="MyProject" default="dist" basedir=".">

  <!-- set global properties for this build -->
  <property name="src" value="."/>
  <property name="build" value="build"/>
  <property name="dist"  value="dist"/>

  <target name="init">
    <!-- Create the time stamp -->
    <!-- Create the build directory structure used by compile -->
    <mkdir dir="${build}"/>

  <target name="compile" depends="init">
    <!-- Compile the java code from ${src} into ${build} -->
    <javac srcdir="${src}" destdir="${build}"/>

  <target name="dist" depends="compile">
    <!-- Create the distribution directory -->
    <mkdir dir="${dist}/lib"/>

    <!-- Put everything in ${build} into the MyProject-${DSTAMP}.jar file -->
    <jar jarfile="${dist}/lib/MyProject-${DSTAMP}.jar" basedir="${build}"/>

  <target name="clean">
    <!-- Delete the ${build} and ${dist} directory trees -->
    <delete dir="${build}"/>
    <delete dir="${dist}"/>

and here it is in my proposed simplified XML format:

    name    = "MyProject"
    default = "dist"
    basedir = "."

    // Set global properties for this build
    property(name = "src"   value = ".")
    property(name = "build" value = "build")
    property(name = "dist"  value = "dist")

    target(name = "init")
        // Create the time stamp

        // Create the build directory structure used by compile

    target(name = "compile")
        depends = "init"

        // Compile the java code from ${src} into ${build}
        javac(srcdir = "${src}" destdir = "${build}")

    target(name = "dist")
        depends = "compile"
        // Create the distribution directory

        // Put everything in ${build} into the MyProject-${DSTAMP}.jar file
            jarfile = "${dist}/lib/MyProject-${DSTAMP}.jar" 
            basedir = "${build}"

    target(name = "clean")
        // Delete the ${build} and ${dist} directory trees

i personally find this substantially easier to create, read and maintain.
the parser is pretty simple.  the rules might be this (roughly):

1. each tag name must be followed either by ( or {
2. for (, an XML attribute list follows.  
   (as added syntactic sugar, if the dtd/schema only defines one 
    attribute, the "token = " part can be omitted).  
3. after any attribute list, the body of the tag is (optionally)
   defined in { }.  
4. a set of attributes belonging to the tag can immediately 
   follow the open { (but cannot appear elsewhere in the body.  
5. tags can be nested.

constructive comments and feedback are welcome.

thanks for listening!


Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message