commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject cvs commit: jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly TestAll.java TestXMLTags.java example.jelly
Date Mon, 11 Feb 2002 00:27:41 GMT
jstrachan    02/02/10 16:27:41

  Added:       jelly    .cvsignore PROPOSAL.html STATUS.html TODO.txt
                        build.properties.sample build.xml
               jelly/src/conf MANIFEST.MF
               jelly/src/java/org/apache/commons/jelly Context.java
                        Script.java Tag.java TagLibrary.java package.html
               jelly/src/java/org/apache/commons/jelly/expression
                        ConstantExpression.java Expression.java
                        package.html
               jelly/src/java/org/apache/commons/jelly/impl
                        ScriptBlock.java TagScript.java TextScript.java
                        package.html
               jelly/src/java/org/apache/commons/jelly/parser
                        XMLParser.java package.html
               jelly/src/java/org/apache/commons/jelly/tags/xml
                        ExprTag.java ForEachTag.java ParseTag.java
                        SetTag.java XMLTagLibrary.java XPathExpression.java
                        package.html
               jelly/src/test/org/apache/commons/jelly TestAll.java
                        TestXMLTags.java example.jelly
  Log:
  First alpha-cut of a little research project called Jelly. Its a simple XML tag based scripting language. It borrows ideas from JSP taglibs, Velocity and XDoclet. For those that like Velocity-style syntax we should be able to layer a non-XML parser on top of the standard XML representation. Its still work in progress but any comments would be welcome
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/jelly/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  build.properties
  dist
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/PROPOSAL.html
  
  Index: PROPOSAL.html
  ===================================================================
  <html>
  <head>
  <title>Proposal for Jelly Package</title>
  </head>
  <body bgcolor="white">
  
  <div align="center">
  <h1>Proposal for <em>Jelly</em> Package</h1>
  </div>
  
  <h3>(0) Rationale</h3>
  
  <p>The <em>Jelly</em> package implements a simple XML tag based scripting 
  engine. It borrows many ideas from both JSP custom tags, Velocity and the 
  scripting engine inside XDoclet. Jelly can be used from the command line, inside 
  Ant or inside a Servlet. It allows the engine to be extended using custom tags 
  in a similar way to JSP. Though Jelly is really simple and has no dependencies 
  on JSP.</p>
  
  <p>As an experiment some of the JSTL tags are implemented.</p>
  
  <h3>(1) Scope of the Package</h3>
  <p>
     The package will create and maintain a number of classes for
     implementing a simple scripting engine and to be distributed under the ASF license.
  </p>
  
  <h3>(1.5) Interaction With Other Packages</h3>
  
  <p><em>Jelly</em> relies only on standard JDK 1.2 (or later) APIs for 
  production deployment.
  
  <p><i>Jelly</i> also currently uses the following packages from Jakarta 
  Commons<ul>
    <li>Collections (1.1 or greater)</li>
    <li>Logging (1.0 or greater)</li>
    <li>BeanUtils (1.1 or greater)</li>
    </ul>
  
  <p>The XML tags uses</p>
  <ul>
    <li>dom4j (1.1 or greater)</li>
  </ul>
  
  <p><i>Jelly</i> utilizes the JUnit unit testing framework for developing and 
  executing unit tests, but this is of interest only to developers of the 
  component.
  
  <p> No external configuration files are utilized. </p>
  
  <h3>(2) Initial Source of the Package</h3>
  
  <p>
     The code base is new and uses ideas from JSP taglibs, Velocity and XDoclet.
  </p>
  
  <p>The proposed package name for the new component is
  <code>org.apache.commons.jelly</code>.</p>
  
  
  <h3>(3)  Required Jakarta-Commons Resources</h3>
  
  <ul>
  <li>CVS Repository - New directory <code>jelly</code> in the
      <code>jakarta-commons</code> CVS repository.  All initial committers
      are already committers on <code>jakarta-commons</code>, so no
      additional user setups are required.</li>
  <li>Mailing List - Discussions will take place on the general
      <em>jakarta-commons@jakarta.apache.org</em> mailing list.  To help
      list subscribers identify messages of interest, it is suggested that
      the message subject of messages about this component be prefixed with
      [Jelly].</li>
  <li>Bugzilla - New component "Jelly" under the "Commons" product
      category, with appropriate version identifiers as needed.</li>
  <li>Jyve FAQ - New category "commons-jelly" (when available).
  </ul>
  
  
  <h3>(4) Initial Committers</h3>
  <ul>
     <li>James Strachan</li>
  </ul>
  </body>
  </html>
  
  
  1.1                  jakarta-commons-sandbox/jelly/STATUS.html
  
  Index: STATUS.html
  ===================================================================
  <html>
  <head>
  <title>Status File for Jakarta Commons "Jelly" Package</title>
  <head>
  <body bgcolor="white">
  
  
  <div align="center">
  <h1>The Jakarta Commons <em>Jelly</em> Package</h1>
  $Id: STATUS.html,v 1.1 2002/02/11 00:27:40 jstrachan Exp $<br>
  <a href="#Introduction">[Introduction]</a>
  <a href="#Dependencies">[Dependencies]</a>
  <a href="#Release Info">[Release Info]</a>
  <a href="#Committers">[Committers]</a>
  <a href="#Action Items">[Action Items]</a>
  <br><br>
  </div>
  
  
  <a name="Introduction"></a>
  <h3>1.  INTRODUCTION</h3>
  
  <p>The <em>Jelly</em> package implements a simple XML tag based scripting 
  engine. It borrows many ideas from both JSP custom tags, Velocity and the 
  scripting engine inside XDoclet. Jelly can be used from the command line, inside 
  Ant or inside a Servlet. It allows the engine to be extended using custom tags 
  in a similar way to JSP. Though Jelly is really simple and has no dependencies 
  on JSP.</p>
  
  <p>As an experiment some of the JSTL tags are implemented.</p>
  
  <a name="Dependencies"></a>
  <h3>2.  DEPENDENCIES</h3>
  
  <p>The <em>Jelly</em> package is dependent upon the following external
  components for development and use:</p>
  <ul>
  <li><a href="http://java.sun.com/j2se">Java Development Kit</a>
      (Version 1.2 or later)</li>
  <li><a href="http://jakarta.apache.org/commons/collections.html">Jakarta Commons Collections</a>
      (Version 1.1 or later)</li>
  <li><a href="http://jakarta.apache.org/commons/beanutils.html">Jakarta Commons BeanUtils</a> (Version 1.1 or later)</li>
  <li><a href="http://jakarta.apache.org/commons/logger.html">Jakarta Commons Logger</a>
      (Version 1.0 or later)</li>
  <li><a href="http://www.junit.org">JUnit Testing Framework</a>
      (Version 3.7 or later) - for unit tests only, not required
      for deployment</li>
  </ul>
  
  
  <p>The XML tags currently depend on</p>
  <ul>
    <li><a href="http://dom4j.org/">dom4j</a> (Version 1.1 or later)</li>
  </ul>
  
  
  <a name="Release Info"></a>
  <h3>3.  RELEASE INFO</h3>
  
  <p>Current Release:
  <!--
  <a href="http://jakarta.apache.org/builds/jakarta-commons/release/commons-jelly/v1.0">Version 1.0</a>
  -->
  
  <p>Planned Next Release:  TBD</p>
  
  <a name="Committers"></a>
  <h3>4.  COMMITTERS</h3>
  
  <p>The following individuals are the primary developers and maintainers of this
  component.  Developers who plan to use <em>Jelly</em> in their own
  projects are encouraged to collaborate on the future development of this
  component to ensure that it continues to meet a variety of needs.</p>
  <ul>
     <li><a href="mailto:jstrachan@apache.org">James Strachan</a></li>
  </ul>
  
  &nbsp;<a name="Action Items"></a><h3>5.  ACTION ITEMS</h3>
  
  <p>Want to help?  Here's some "to do" items the team has identified.</p>
  
  <table border="1">
    <tr>
      <th width="80%">Action Item</th>
      <th width="20%">Volunteer</th>
    </tr>
  
    <tr>
      <td>Please read the TODO.txt document in CVS</td>
      <td align="center">&nbsp;</td>
    </tr>
  
    </table>
  
  </body>
  </html>
  
  
  1.1                  jakarta-commons-sandbox/jelly/TODO.txt
  
  Index: TODO.txt
  ===================================================================
  TO DO LIST
  ==========
  
  * add core tags with pluggable expression engines like Velocity, beanshell, Rhino etc.
  
  * make Ant task to run Jelly
  
  * document much more!
  
  * provide an alternative non-XML parser such that Jelly scripts do not
    need to be XML. This could allow Velocity-style concise notation 
    for common Jelly tags.
  
  * provide easy compile time tag transformations. Here are some possible use cases
  
    <magic:form>
        <form>
            <input name="foo">
            <input name="bar">
        </form>
    </magic:form>
  
    Then at 'parse/compile' time the <magic:form> could transform its fragment
    of real HTML into
  
        <form>
            <input name="foo" <j:expr value="${foo}">
            <input name="bar" <j:expr value="${bar}">
        </form>
  
    i.e. tags can just be a simple transformation mechansim that can add some
    common programatical guff to scripts. 
  
  
    Or we could do SOAP scripting...
  
    <babelfish:translate from="EN" to="FR">
        hello Geir
    </babelfish:translate>
  
    The <babelfish:translate> tag could really just be a small 'macro'
    autogenerated from a SOAP WSDL file that expands in place to the full SOAP
    equivalent of
  
    <io:soap
        url=http://babelfish.altavista.com/soap
        SOAPAction="urn:babelfish">
     <io:body>
      <SOAP-ENV:Envelope
        xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
        SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
        <SOAP-ENV:Body>
            <babelfish:translate xmlns:babelfish="bablefish.altavista.com"
    from="EN" to="FR">
                hello Geir
            </babelfish:translate>
        </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>
     </io:body>
    </io:soap>
  
    So its more of a traditional macro - though could be implemented using XML
    technology for the transformation (e.g .it could use SAX, XSLT, XPath or
    DVSL to transform itself and its body).
  
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/build.properties.sample
  
  Index: build.properties.sample
  ===================================================================
  # junit.jar - JUnit 3.2+ Classpath
  junit.jar=/java/junit/junit.jar
  
  # jakarta-commons-collections.jar
  collections.jar=../../jakarta-commons/collections/dist/commons-collections.jar
  
  # jakarta-commons-logging.jar
  logging.jar=../../jakarta-commons/logging/dist/commons-logging.jar
  
  # dom4j.jar - go to http://dom4j.org to download
  dom4j.jar=/java/dom4j/dom4j.jar
  
  # you can change this property to point at a local copy of the java 2 platform api
  jdk-doc-url=http://java.sun.com/products/jdk/1.3/docs/api
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/build.xml
  
  Index: build.xml
  ===================================================================
  <project name="Digester" default="compile" basedir=".">
  
  
  <!--
          "Digester" component of the Jakarta Commons Subproject
          $Id: build.xml,v 1.1 2002/02/11 00:27:40 jstrachan Exp $
  -->
  
  
  <!-- ========== Initialize Properties ===================================== -->
  
  
    <property file="build.properties"/>                <!-- Component local   -->
    <property file="../build.properties"/>             <!-- Commons local     -->
    <property file="${user.home}/build.properties"/>   <!-- User local        -->
  
  
  <!-- ========== External Dependencies ===================================== -->
  
  
    <!-- The directories corresponding to your necessary dependencies -->
    <property name="jaxp.home"               value="/usr/local/jaxp1.1"/>
    <property name="jdk.home"                value="/usr/local/jdk1.3"/>
    <property name="junit.home"              value="/usr/local/junit3.7"/>
    <property name="commons.home"            value="../../jakarta-commons"/>
    <property name="beanutils.home"          value="${commons.home}/beanutils"/>
    <property name="collections.home"        value="${commons.home}/collections"/>
    <property name="logging.home"            value="${commons.home}/logging"/>
    <property name="digester.home"           value="${commons.home}/digester"/>
  
  
  <!-- ========== Derived Values ============================================ -->
  
  
    <!-- The locations of necessary jar files -->
    <property name="jdk.api"                 value="${jdk.home}/docs/api"/>
    <property name="jaxp.jaxp.jar"           value="${jaxp.home}/jaxp.jar"/>
    <property name="jaxp.parser.jar"         value="${jaxp.home}/crimson.jar"/>
    <property name="jaxp.api"                value="${jaxp.home}/docs/api"/>
    <property name="junit.jar"               value="${junit.home}/junit.jar"/>
    <property name="commons-beanutils.api"   value="${beanutils.home}/dist/docs/api"/>
    <property name="commons-beanutils.jar"   value="${beanutils.home}/dist/commons-beanutils.jar"/>
    <property name="commons-collections.api" value="${collections.home}/dist/docs/api"/>
    <property name="commons-collections.jar" value="${collections.home}/dist/commons-collections.jar"/>
    <property name="commons-logging.api"     value="${logging.home}/dist/docs/api"/>
    <property name="commons-logging.jar"     value="${logging.home}/dist/commons-logging.jar"/>
    <property name="commons-digester.api"    value="${digester.home}/dist/docs/api"/>
    <property name="commons-digester.jar"    value="${digester.home}/dist/commons-digester.jar"/>
    
  
  <!-- ========== Component Declarations ==================================== -->
  
  
    <!-- The name of this component -->
    <property name="component.name"          value="jelly"/>
  
    <!-- The primary package name of this component -->
    <property name="component.package"       value="org.apache.commons.jelly"/>
  
    <!-- The title of this component -->
    <property name="component.title"         value="Jelly - simple tag based Java and XML scripting engine"/>
  
    <!-- The current version number of this component -->
    <property name="component.version"       value="1.0-dev"/>
  
    <!-- The base directory for compilation targets -->
    <property name="build.home"              value="target"/>
  
    <!-- The base directory for component configuration files -->
    <property name="conf.home"               value="src/conf"/>
  
    <!-- The base directory for distribution targets -->
    <property name="dist.home"               value="dist"/>
  
    <!-- The base directory for component sources -->
    <property name="source.home"             value="src/java"/>
  
    <!-- The base directory for unit test sources -->
    <property name="test.home"               value="src/test"/>
  
  
  <!-- ========== Compiler Defaults ========================================= -->
  
  
    <!-- Should Java compilations set the 'debug' compiler option? -->
    <property name="compile.debug"           value="true"/>
  
    <!-- Should Java compilations set the 'deprecation' compiler option? -->
    <property name="compile.deprecation"     value="false"/>
  
    <!-- Should Java compilations set the 'optimize' compiler option? -->
    <property name="compile.optimize"        value="true"/>
  
    <!-- Construct compile classpath -->
    <path id="compile.classpath">
      <pathelement location="${build.home}/classes"/>
      <pathelement location="${jaxp.jaxp.jar}"/>
      <pathelement location="${jaxp.parser.jar}"/>
      <pathelement location="${dom4j.jar}"/>
      <pathelement location="${commons-beanutils.jar}"/>
      <pathelement location="${commons-collections.jar}"/>
      <pathelement location="${commons-logging.jar}"/>
      <pathelement location="${commons-digester.jar}"/>
      <pathelement location="${junit.jar}"/>
    </path>
  
  
  <!-- ========== Test Execution Defaults =================================== -->
  
  
    <!-- Construct unit test classpath -->
    <path id="test.classpath">
      <pathelement location="${build.home}/classes"/>
      <pathelement location="${build.home}/tests"/>
      <pathelement location="${junit.jar}"/>
      <pathelement location="${jaxp.jaxp.jar}"/>
      <pathelement location="${jaxp.parser.jar}"/>
      <pathelement location="${dom4j.jar}"/>
      <pathelement location="${commons-beanutils.jar}"/>
      <pathelement location="${commons-collections.jar}"/>
      <pathelement location="${commons-logging.jar}"/>
      <pathelement location="${commons-digester.jar}"/>
    </path>
  
    <!-- Should all tests fail if one does? -->
    <property name="test.failonerror"        value="true"/>
  
    <!-- The test runner to execute -->
    <property name="test.runner"             value="junit.textui.TestRunner"/>
  
  
  <!-- ========== Executable Targets ======================================== -->
  
  
    <target name="init"
     description="Initialize and evaluate conditionals">
      <echo message="-------- ${component.name} ${component.version} --------"/>
      <filter  token="name"                  value="${component.package}"/>
      <filter  token="version"               value="${component.version}"/>
    </target>
  
  
    <target name="prepare" depends="init"
     description="Prepare build directory">
      <mkdir dir="${build.home}"/>
      <mkdir dir="${build.home}/classes"/>
      <mkdir dir="${build.home}/conf"/>
      <mkdir dir="${build.home}/tests"/>
    </target>
  
  
    <target name="static" depends="prepare"
     description="Copy static files to build directory">
      <tstamp/>
      <copy  todir="${build.home}/conf" filtering="on">
        <fileset dir="${conf.home}" includes="*.MF"/>
      </copy>
    </target>
  
  
    <target name="compile" depends="static"
     description="Compile shareable components">
      <javac  srcdir="${source.home}"
             destdir="${build.home}/classes"
               debug="${compile.debug}"
         deprecation="${compile.deprecation}"
            optimize="${compile.optimize}">
        <classpath refid="compile.classpath"/>
      </javac>
      <copy    todir="${build.home}/classes" filtering="on">
        <fileset dir="${source.home}" excludes="**/*.java"/>
      </copy>
    </target>
  
  
    <target name="compile.tests" depends="compile"
     description="Compile unit test cases">
      <javac  srcdir="${test.home}"
             destdir="${build.home}/tests"
               debug="${compile.debug}"
         deprecation="${compile.deprecation}"
            optimize="${compile.optimize}">
        <classpath refid="test.classpath"/>
      </javac>
      <copy    todir="${build.home}/tests" filtering="on">
        <fileset dir="${test.home}" excludes="**/*.java"/>
      </copy>
    </target>
  
  
    <target name="clean"
     description="Clean build and distribution directories">
      <delete    dir="${build.home}"/>
      <delete    dir="${dist.home}"/>
    </target>
  
  
    <target name="all" depends="clean,compile"
     description="Clean and compile all components"/>
  
  
    <target name="javadoc" depends="compile"
     description="Create component Javadoc documentation">
      <mkdir      dir="${dist.home}"/>
      <mkdir      dir="${dist.home}/docs"/>
      <mkdir      dir="${dist.home}/docs/api"/>
      <javadoc sourcepath="${source.home}"
                  destdir="${dist.home}/docs/api"
             packagenames="org.apache.commons.*"
                   author="true"
                  private="true"
                  version="true"
                 doctitle="&lt;h1&gt;${component.title}&lt;/h1&gt;"
              windowtitle="${component.title} (Version ${component.version})"
                   bottom="Copyright (c) 2002 - Apache Software Foundation">
        <link     offline="true" packagelistLoc="${commons-beanutils.api}"
                     href="http://jakarta.apache.org/commons/beanutils/api/"/>
        <link     offline="true" packagelistLoc="${commons-collections.api}"
                     href="http://jakarta.apache.org/commons/collections/api/"/>
        <link     offline="true" packagelistLoc="${commons-logging.api}"
                     href="http://jakarta.apache.org/commons/logging/api/"/>
        <link     offline="true"  packagelistLoc="${jdk.api}"
                     href="http://java.sun.com/products/jdk/1.3/docs/api"/>
        <link     offline="true"  packagelistLoc="${jaxp.api}"
                     href="http://java.sun.com/xml/jaxp-docs-1.1/docs/api"/>
        <classpath  refid="compile.classpath"/>
      </javadoc>
    </target>
  
  
    <target name="dist" depends="compile,javadoc"
     description="Create binary distribution">
      <mkdir      dir="${dist.home}"/>
      <copy      file="../LICENSE"
                todir="${dist.home}"/>
      <mkdir      dir="${build.home}/classes/META-INF"/>
      <copy      file="../LICENSE"
               tofile="${build.home}/classes/META-INF/LICENSE.txt"/>
      <jar    jarfile="${dist.home}/commons-${component.name}.jar"
              basedir="${build.home}/classes"
             manifest="${build.home}/conf/MANIFEST.MF"/>
    </target>
  
  
  <!-- ========== Unit Test Targets ========================================= -->
  
  
    <target name="test" depends="compile.tests"
     description="Run all unit test cases">
      <java classname="org.apache.commons.jelly.TestAll" fork="yes" failonerror="${test.failonerror}">
        <classpath refid="test.classpath"/>
      </java>
    </target>
  
  
     <target name="test.xml" depends="compile.tests" 
        description="Runs sample XML tags">
      <java classname="org.apache.commons.jelly.TestXMLTags" fork="yes">
        <classpath refid="test.classpath"/>
        <sysproperty key="org.apache.commons.logging.log" value="org.apache.commons.logging.SimpleLog"/>
        <sysproperty key="org.apache.commons.logging.simplelog.defaultlog" value="debug"/>
      </java>
     </target>
  
  <!-- ========== Sample Program Targets ==================================== -->
  
  
  </project>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/conf/MANIFEST.MF
  
  Index: MANIFEST.MF
  ===================================================================
  Extension-Name: org.apache.commons.jelly
  Specification-Vendor: Apache Software Foundation
  Specification-Version: 1.0
  Implementation-Vendor: Apache Software Foundation
  Implementation-Version: 1.0-dev
  
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Context.java
  
  Index: Context.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Context.java,v 1.1 2002/02/11 00:27:40 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2002/02/11 00:27:40 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: Context.java,v 1.1 2002/02/11 00:27:40 jstrachan Exp $
   */
  package org.apache.commons.jelly;
  
  import java.io.Writer;
  import java.util.Hashtable;
  import java.util.Map;
  
  /** <p><code>Context</code> represents the Jelly context.</p>
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public class Context {
  
      /** synchronized access to the variables in scope */
      private Map variables = new Hashtable();
      
      /** @return the value of the given variable name */
      public Object getVariable( String name ) {
          return variables.get( name );
      }
      
      /** Sets the value of the given variable name */
      public void setVariable( String name, Object value ) {
          if ( value == null ) {
              variables.remove( name );
          }
          else {
              variables.put( name, value );
          }
      }    
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Script.java
  
  Index: Script.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Script.java,v 1.1 2002/02/11 00:27:40 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2002/02/11 00:27:40 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: Script.java,v 1.1 2002/02/11 00:27:40 jstrachan Exp $
   */
  package org.apache.commons.jelly;
  
  import java.io.Writer;
  
  /** <p><code>Script</code> represents a Jelly script.</p>
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public interface Script {
  
      /** Called by the parser to allow a more efficient
       * representation of the script to be used.
       */
      public Script compile() throws Exception;
      
      /** Evaluates the body of a tag */
      public void run(Context context, Writer writer) throws Exception;
      
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Tag.java
  
  Index: Tag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Tag.java,v 1.1 2002/02/11 00:27:40 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2002/02/11 00:27:40 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: Tag.java,v 1.1 2002/02/11 00:27:40 jstrachan Exp $
   */
  package org.apache.commons.jelly;
  
  import java.io.Writer;
  
  /** <p><code>Tag</code> represents a Jelly custom tag.</p>
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public interface Tag {
  
      /** Evaluates this tag after all the tags properties have been initialized.
       */
      public void run(Context context, Writer writer, Script body) throws Exception;
      
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/TagLibrary.java
  
  Index: TagLibrary.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/TagLibrary.java,v 1.1 2002/02/11 00:27:40 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2002/02/11 00:27:40 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: TagLibrary.java,v 1.1 2002/02/11 00:27:40 jstrachan Exp $
   */
  package org.apache.commons.jelly;
  
  import java.io.Writer;
  import java.util.HashMap;
  import java.util.Map;
  
  import org.apache.commons.jelly.expression.Expression;
  import org.apache.commons.jelly.impl.TagScript;
  
  import org.xml.sax.Attributes;
  
  /** <p><code>Taglib</code> represents the metadata for a Jelly custom tag library.</p>
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public abstract class TagLibrary {
  
      private Map tags = new HashMap();
      
      public TagLibrary() {
      }
      
      /** Creates a new script to execute the given tag name and attributes */
      public TagScript createTagScript(String name, Attributes attributes) throws Exception {
          Class type = (Class) tags.get( name );
          Tag tag = (Tag) type.newInstance();        
          return new TagScript( tag );
      }
      
      /** Allows taglibs to use their own expression evaluation mechanism */
      public Expression createExpression(String tagName, String attributeName, String attributeValue) {
          // will use the default expression instead
          return null;
      }
      
      // Implementation methods
      //-------------------------------------------------------------------------     
      
      /** Registers a tag class for a given tag name */
      protected void registerTag( String name, Class type ) {
          tags.put( name, type );
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/package.html
  
  Index: package.html
  ===================================================================
  <html>
  <head>
  </head>
  <body>
  
    <p>This package contains the main jelly API classes. Developers writing tags should use this package.
    </p>
  </body>
  </html>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/expression/ConstantExpression.java
  
  Index: ConstantExpression.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/expression/ConstantExpression.java,v 1.1 2002/02/11 00:27:41 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2002/02/11 00:27:41 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: ConstantExpression.java,v 1.1 2002/02/11 00:27:41 jstrachan Exp $
   */
  package org.apache.commons.jelly.expression;
  
  import org.apache.commons.jelly.Context;
  
  /** <p><code>ConstantExpression</code> represents a constant expression.</p>
    *
    * <p> In other words, {@link #evaluate} returns a value independent of the context. </p>
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public class ConstantExpression implements Expression {
  
      /** The value of this expression */
      private Object value;
      
      /** Base constructor
       */
      public ConstantExpression() {
      }
      
      /** Convenience constructor sets <code>value</code> property.
       */
      public ConstantExpression(Object value) {
          this.value = value;
      }
      
      public String toString() {
          return super.toString() + "[value=" + value +"]";
      }
      
      /** 
        * Evaluate expression against given context.
        *
        * @param context evaluate expression against this context
        * @return current value of <code>value</code> property  
        */
      public Object evaluate(Context context) {
          return value;
      }
      
      /** Gets the constant value of this expression */
      public Object getValue() {
          return value;
      }
      
      /** Sets the constant value of this expression */
      public void setValue(Object value) {
          this.value = value;
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/expression/Expression.java
  
  Index: Expression.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/expression/Expression.java,v 1.1 2002/02/11 00:27:41 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2002/02/11 00:27:41 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: Expression.java,v 1.1 2002/02/11 00:27:41 jstrachan Exp $
   */
  package org.apache.commons.jelly.expression;
  
  import org.apache.commons.jelly.Context;
  
  /** <p><code>Expression</code> represents an arbitrary expression using some pluggable
    * expression language.</p>
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public interface Expression {
  
      /** Evaluates the expression with the given context
       * and returns the result 
       */
      public Object evaluate(Context context);        
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/expression/package.html
  
  Index: package.html
  ===================================================================
  <html>
  <head>
  </head>
  <body>
  
    <p>Expressions used to turn the tag attribute values into compiled
    expression objects for languages such as Velocity, XPath, beanshell, Rhino 
    etc.
    </p>
  
  </body>
  </html>
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/ScriptBlock.java
  
  Index: ScriptBlock.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/ScriptBlock.java,v 1.1 2002/02/11 00:27:41 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2002/02/11 00:27:41 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: ScriptBlock.java,v 1.1 2002/02/11 00:27:41 jstrachan Exp $
   */
  package org.apache.commons.jelly.impl;
  
  import java.io.Writer;
  import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.List;
  
  import org.apache.commons.jelly.Context;
  import org.apache.commons.jelly.Script;
  
  /** <p><code>ScriptBlock</code> a block of scripts.</p>
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public class ScriptBlock implements Script {
      
      private static final Script[] EMPTY_ARRAY = {};
      
      /** The list of scripts */
      private List list = new ArrayList();
      
      /** Compiled form uses arrays for speed 
       * - no Iterator, object allocation or typecast */
      private Script[] scripts = EMPTY_ARRAY;
  
      public ScriptBlock() {
      }
      
      public String toString() {
          return super.toString() + "[scripts=" + list + "]";
      }
      
      
      /** Add a new script to the end of this block */
      public void addScript(Script script) {
          list.add( script );
      }
      
      /** Removes a script from this block */
      public void removeScript(Script script) {
          list.remove( script );
      }
  
      /** Gets the child scripts that make up this block */
      public Script[] getScripts() {
          return scripts;
      }
      
      // Script interface
      //-------------------------------------------------------------------------                    
      public Script compile() throws Exception {        
          int size = list.size();
          if ( size == 1 ) {
              return (Script) list.get(0);
          }
          scripts = new Script[ size ];
          list.toArray( scripts );
  
          // now compile children
          for ( int i = 0; i < size; i++ ) {
              Script script = scripts[i];
              script.compile();
          }
          return this;
      }
      
      /** Evaluates the body of a tag */
      public void run(Context context, Writer writer) throws Exception {
          for ( int i = 0, size = scripts.length; i < size; i++ ) {
              Script script = scripts[i];
              script.run( context, writer );
          }
      }    
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/TagScript.java
  
  Index: TagScript.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/TagScript.java,v 1.1 2002/02/11 00:27:41 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2002/02/11 00:27:41 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * $Id: TagScript.java,v 1.1 2002/02/11 00:27:41 jstrachan Exp $
   */
  package org.apache.commons.jelly.impl;
  
  import java.beans.BeanInfo;
  import java.beans.Introspector;
  import java.beans.PropertyDescriptor;
  import java.lang.reflect.Method;
  import java.io.Writer;
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.List;
  import java.util.Map;
  
  import org.apache.commons.beanutils.ConvertUtils;
  
  import org.apache.commons.jelly.Context;
  import org.apache.commons.jelly.Script;
  import org.apache.commons.jelly.Tag;
  import org.apache.commons.jelly.expression.Expression;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogSource;
  
  /** <p><code>TagScript</code> evaluates a custom tag.</p>
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public class TagScript implements Script {
      
      /** The Log to which logging calls will be made. */
      private static final Log log = LogSource.getInstance( TagScript.class );
      
      /** the tag to be evaluated */
      private Tag tag;
  
      /** the body of the tag */
      private Script body;
  
      /** The attribute expressions that are created */
      private Map attributes = new HashMap();
      
      /** Expressions for each attribute */
      private Expression[] expressions = {};
      
      /** Write Methods for each attribute */
      private Method[] methods = {};
      
      /** Types of each attribute */
      private Class[] types = {};
      
      public TagScript() {
      }
      
      public TagScript(Tag tag) {
          this.tag = tag; 
      }
  
      public String toString() {
          return super.toString() + "[tag=" + tag + ", body=" + body + "]";
      }
      
      /** Add an initialization attribute for the tag.
       * This method must be called after the setTag() method 
       */
      public void addAttribute(String name, Expression expression) {
          if ( log.isDebugEnabled() ) {
              log.debug( "adding attribute name: " + name + " expression: " + expression );
          }
          attributes.put( name, expression );
      }
      
      // Script interface
      //-------------------------------------------------------------------------                
      
      /** Compiles the script to a more efficient form. 
        * Will only be called once by the parser 
        */
      public Script compile() throws Exception {
          this.body = body.compile();
          
          List typeList = new ArrayList();
          List methodList = new ArrayList();
          List expressionList = new ArrayList();
          
          BeanInfo info = Introspector.getBeanInfo( tag.getClass() );
          PropertyDescriptor[] descriptors = info.getPropertyDescriptors();
          
          if ( descriptors != null ) {
              for ( int i = 0, size = descriptors.length; i < size; i++ ) {
                  PropertyDescriptor descriptor = descriptors[i];
                  String name = descriptor.getName();
                  Expression expression = (Expression) attributes.get( name );                
                  if ( expression != null ) {
                      Method writeMethod = descriptor.getWriteMethod();                    
                      if ( writeMethod != null) {
                          Class type = descriptor.getPropertyType();
                          expressionList.add( expression );
                          methodList.add( writeMethod );
                          typeList.add( type );
                          
                          if ( log.isDebugEnabled() ) {
                              log.debug( "Adding tag property name: " + name + " type: " + type.getName() + " expression: " + expression );
                          }
                      }
                  }
              }
          }
          
          // now create the arrays to avoid object allocation & casting when
          // running the script
          int size = expressionList.size();
          expressions = new Expression[ size ];
          methods = new Method[ size ];
          types = new Class[ size ];
          expressionList.toArray( expressions );
          methodList.toArray( methods );
          typeList.toArray( types );
          return this;
      }
      
      /** Evaluates the body of a tag */
      public void run(Context context, Writer writer) throws Exception {
          // initialize all the properties of the tag before its used
          // if there is a problem abort this tag
          for ( int i = 0, size = expressions.length; i < size; i++ ) {
              Expression expression = expressions[i];
              Method method =  methods[i];
              
              Object value = expression.evaluate( context );
              
              // convert value to correct type
              if ( value != null ) {
                  value = convertType( value, types[i] );
              }
              
              Object[] arguments = { value };
              method.invoke( tag, arguments );
          }        
          tag.run( context, writer, body );
      }
      
      // Properties
      //-------------------------------------------------------------------------                
      
      /** @return the tag to be evaluated */
      public Tag getTag() {
          return tag;
      }
      
      /** Sets the tag to be evaluated */
      public void setTag(Tag tag) {
          this.tag = tag; 
      }
      
      /** @return the body of the tag */
      public Script getBody() {
          return body;
      }
      
      /** Sets the body of the tag */
      public void setBody(Script body) {
          this.body = body; 
      }
      
      // Implementation methods
      //-------------------------------------------------------------------------      
      /** Converts the given value to the required type. 
       *
       * @param value is the value to be converted. This will not be null
       * @param requiredType the type that the value should be converted to
       */
      protected Object convertType(Object value, Class requiredType ) throws Exception {
          if ( requiredType.isInstance( value ) ) {
              return value;
          }
          if ( value instanceof String ) {
              return ConvertUtils.convert( (String) value, requiredType );
          }
          return value;
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/TextScript.java
  
  Index: TextScript.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/TextScript.java,v 1.1 2002/02/11 00:27:41 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2002/02/11 00:27:41 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: TextScript.java,v 1.1 2002/02/11 00:27:41 jstrachan Exp $
   */
  package org.apache.commons.jelly.impl;
  
  import java.io.Writer;
  
  import org.apache.commons.jelly.Context;
  import org.apache.commons.jelly.Script;
  
  /** <p><code>TextScript</code> outputs some static text.</p>
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public class TextScript implements Script {
      
      /** the text output by this script */
      private String text;
  
      public TextScript() {
      }
      
      public TextScript(String text) {
          this.text = text; 
      }
  
      public String toString() {
          return super.toString() + "[text=" + text + "]";
      }
      
      /** @return the text output by this script */
      public String getText() {
          return text;
      }
      
      /** Sets the text output by this script */
      public void setText(String text) {
          this.text = text; 
      }
      
      
      // Script interface
      //-------------------------------------------------------------------------                
      
      public Script compile() {        
          return this;
      }
      
      /** Evaluates the body of a tag */
      public void run(Context context, Writer writer) throws Exception {
          writer.write( text );
      }    
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/package.html
  
  Index: package.html
  ===================================================================
  <html>
  <head>
  </head>
  <body>
  
    <p>Core implementation classes for Jelly.
    </p>
  
  </body>
  </html>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/parser/XMLParser.java
  
  Index: XMLParser.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/parser/XMLParser.java,v 1.1 2002/02/11 00:27:41 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2002/02/11 00:27:41 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   * $Id: XMLParser.java,v 1.1 2002/02/11 00:27:41 jstrachan Exp $
   */
  package org.apache.commons.jelly.parser;
  
  import java.io.File;
  import java.io.FileReader;
  import java.io.InputStream;
  import java.io.IOException;
  import java.io.PrintWriter;
  import java.io.Reader;
  import java.net.URL;
  import java.net.URLConnection;
  import java.util.ArrayList;
  import java.util.EmptyStackException;
  import java.util.HashMap;
  import java.util.Iterator;
  import java.util.List;
  import java.util.Map;
  
  import javax.xml.parsers.SAXParser;
  import javax.xml.parsers.SAXParserFactory;
  
  
  import org.apache.commons.collections.ArrayStack;
  
  import org.apache.commons.jelly.Context;
  import org.apache.commons.jelly.Script;
  import org.apache.commons.jelly.Tag;
  import org.apache.commons.jelly.TagLibrary;
  import org.apache.commons.jelly.impl.ScriptBlock;
  import org.apache.commons.jelly.impl.TagScript;
  import org.apache.commons.jelly.impl.TextScript;
  import org.apache.commons.jelly.expression.ConstantExpression;
  import org.apache.commons.jelly.expression.Expression;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogSource;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.ContentHandler;
  import org.xml.sax.EntityResolver;
  import org.xml.sax.ErrorHandler;
  import org.xml.sax.helpers.DefaultHandler;
  import org.xml.sax.InputSource;
  import org.xml.sax.Locator;
  import org.xml.sax.SAXException;
  import org.xml.sax.SAXParseException;
  import org.xml.sax.XMLReader;
  
  
  /** <p><code>XMLParser</code> parses the XML Jelly format.
   * The SAXParser and XMLReader portions of this code come from Digester.</p>
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.1 $
   */
  public class XMLParser extends DefaultHandler {
      
      /** The current script block */
      private ScriptBlock script;
      
      /** The current tag */
      private TagScript tag;
      
      /** The stack of body scripts. */
      private ArrayStack scriptStack = new ArrayStack();
      
      /** The stack of tags - use ArrayList as it allows null. */
      private ArrayList tagStack = new ArrayList();
      
      /** The current text buffer where non-custom tags get written */
      private StringBuffer textBuffer;
      
      /** Tag libraries found so far */
      private Map taglibs = new HashMap();
      
      /** whether we are inside the root element or not */
      private boolean insideRoot = false;
      
      /**
       * The class loader to use for instantiating application objects.
       * If not specified, the context class loader, or the class loader
       * used to load XMLParser itself, is used, based on the value of the
       * <code>useContextClassLoader</code> variable.
       */
      protected ClassLoader classLoader = null;
      
      
      
      /**
       * The application-supplied error handler that is notified when parsing
       * warnings, errors, or fatal errors occur.
       */
      protected ErrorHandler errorHandler = null;
      
      
      /**
       * The SAXParserFactory that is created the first time we need it.
       */
      protected static SAXParserFactory factory = null;
      
      /**
       * The SAXParser we will use to parse the input stream.
       */
      protected SAXParser parser = null;
      
      /**
       * The XMLReader used to parse digester rules.
       */
      protected XMLReader reader = null;
      
      
      /**
       * The Locator associated with our parser.
       */
      protected Locator locator = null;
      
      
      /**
       * Registered namespaces we are currently processing.  The key is the
       * namespace prefix that was declared in the document.  The value is an
       * ArrayStack of the namespace URIs this prefix has been mapped to --
       * the top Stack element is the most current one.  (This architecture
       * is required because documents can declare nested uses of the same
       * prefix for different Namespace URIs).
       */
      protected HashMap namespaces = new HashMap();
      
      
      
      /**
       * Do we want to use the Context ClassLoader when loading classes
       * for instantiating new objects?  Default is <code>false</code>.
       */
      protected boolean useContextClassLoader = false;
      
      
      /**
       * Do we want to use a validating parser?
       */
      protected boolean validating = false;
      
      
      /**
       * The Log to which most logging calls will be made.
       */
      private Log log = LogSource.getInstance("org.apache.commons.digester.XMLParser");
      
      
      /**
       * Construct a new XMLParser with default properties.
       */
      public XMLParser() {
      }
      
      /**
       * Construct a new XMLParser, allowing a SAXParser to be passed in.  This
       * allows XMLParser to be used in environments which are unfriendly to
       * JAXP1.1 (such as WebLogic 6.0).  Thanks for the request to change go to
       * James House (james@interobjective.com).  This may help in places where
       * you are able to load JAXP 1.1 classes yourself.
       */
      public XMLParser(SAXParser parser) {
          this.parser = parser;
      }
      
      /**
       * Construct a new XMLParser, allowing an XMLReader to be passed in.  This
       * allows XMLParser to be used in environments which are unfriendly to
       * JAXP1.1 (such as WebLogic 6.0).  Note that if you use this option you
       * have to configure namespace and validation support yourself, as these
       * properties only affect the SAXParser and emtpy constructor.
       */
      public XMLParser(XMLReader reader) {
          this.reader = reader;
      }
      
      
      /**
       * Parse the content of the specified file using this XMLParser.  Returns
       * the root element from the object stack (if any).
       *
       * @param file File containing the XML data to be parsed
       *
       * @exception IOException if an input/output error occurs
       * @exception SAXException if a parsing exception occurs
       */
      public Script parse(File file) throws IOException, SAXException {
          getXMLReader().parse(new InputSource(new FileReader(file)));
          return script;
      }
      
      
      /**
       * Parse the content of the specified input source using this XMLParser.
       * Returns the root element from the object stack (if any).
       *
       * @param input Input source containing the XML data to be parsed
       *
       * @exception IOException if an input/output error occurs
       * @exception SAXException if a parsing exception occurs
       */
      public Script parse(InputSource input) throws IOException, SAXException {
          getXMLReader().parse(input);
          return script;
          
      }
      
      
      /**
       * Parse the content of the specified input stream using this XMLParser.
       * Returns the root element from the object stack (if any).
       *
       * @param input Input stream containing the XML data to be parsed
       *
       * @exception IOException if an input/output error occurs
       * @exception SAXException if a parsing exception occurs
       */
      public Script parse(InputStream input) throws IOException, SAXException {
          getXMLReader().parse(new InputSource(input));
          return script;
          
      }
      
      
      /**
       * Parse the content of the specified reader using this XMLParser.
       * Returns the root element from the object stack (if any).
       *
       * @param reader Reader containing the XML data to be parsed
       *
       * @exception IOException if an input/output error occurs
       * @exception SAXException if a parsing exception occurs
       */
      public Script parse(Reader reader) throws IOException, SAXException {
          getXMLReader().parse(new InputSource(reader));
          return script;
          
      }
      
      
      /**
       * Parse the content of the specified URI using this XMLParser.
       * Returns the root element from the object stack (if any).
       *
       * @param uri URI containing the XML data to be parsed
       *
       * @exception IOException if an input/output error occurs
       * @exception SAXException if a parsing exception occurs
       */
      public Script parse(String uri) throws IOException, SAXException {
          getXMLReader().parse(uri);
          return script;
          
      }
      
      
      
      /**
       * Return the currently mapped namespace URI for the specified prefix,
       * if any; otherwise return <code>null</code>.  These mappings come and
       * go dynamically as the document is parsed.
       *
       * @param prefix Prefix to look up
       */
      public String findNamespaceURI(String prefix) {
          ArrayStack stack = (ArrayStack) namespaces.get(prefix);
          if (stack == null) {
              return (null);
          }
          try {
              return ((String) stack.peek());
          }
          catch (EmptyStackException e) {
              return (null);
          }
      }
      
      
      /**
       * Return the class loader to be used for instantiating application objects
       * when required.  This is determined based upon the following rules:
       * <ul>
       * <li>The class loader set by <code>setClassLoader()</code>, if any</li>
       * <li>The thread context class loader, if it exists and the
       *     <code>useContextClassLoader</code> property is set to true</li>
       * <li>The class loader used to load the XMLParser class itself.
       * </ul>
       */
      public ClassLoader getClassLoader() {
          if (this.classLoader != null) {
              return (this.classLoader);
          }
          if (this.useContextClassLoader) {
              ClassLoader classLoader =
              Thread.currentThread().getContextClassLoader();
              if (classLoader != null) {
                  return (classLoader);
              }
          }
          return (this.getClass().getClassLoader());
      }
      
      
      /**
       * Set the class loader to be used for instantiating application objects
       * when required.
       *
       * @param classLoader The new class loader to use, or <code>null</code>
       *  to revert to the standard rules
       */
      public void setClassLoader(ClassLoader classLoader) {
          this.classLoader = classLoader;
      }
      
      
      
      /**
       * Return the error handler for this XMLParser.
       */
      public ErrorHandler getErrorHandler() {
          return (this.errorHandler);
      }
      
      
      /**
       * Set the error handler for this XMLParser.
       *
       * @param errorHandler The new error handler
       */
      public void setErrorHandler(ErrorHandler errorHandler) {
          this.errorHandler = errorHandler;
      }
      
      
      /**
       * Return the current Logger associated with this instance of the XMLParser
       */
      public Log getLogger() {
          return log;
      }
      
      
      /**
       * Set the current logger for this XMLParser.
       */
      public void setLogger(Log log) {
          this.log = log;
      }
      
      /**
       * Return the SAXParser we will use to parse the input stream.  If there
       * is a problem creating the parser, return <code>null</code>.
       */
      public SAXParser getParser() {
          // Return the parser we already created (if any)
          if (parser != null) {
              return (parser);
          }
          
          // Create and return a new parser
          synchronized (this) {
              try {
                  if (factory == null) {
                      factory = SAXParserFactory.newInstance();
                  }
                  factory.setNamespaceAware(true);
                  factory.setValidating(validating);
                  parser = factory.newSAXParser();
                  return (parser);
              }
              catch (Exception e) {
                  log.error("XMLParser.getParser: ", e);
                  return (null);
              }
          }
      }
      
      
      /**
       * By setting the reader in the constructor, you can bypass JAXP and
       * be able to use digester in Weblogic 6.0.
       *
       * @deprecated Use getXMLReader() instead, which can throw a
       *  SAXException if the reader cannot be instantiated
       */
      public XMLReader getReader() {
          try {
              return (getXMLReader());
          }
          catch (SAXException e) {
              log.error("Cannot get XMLReader", e);
              return (null);
          }
      }
      
      
      /**
       * Return the XMLReader to be used for parsing the input document.
       *
       * @exception SAXException if no XMLReader can be instantiated
       */
      public synchronized XMLReader getXMLReader() throws SAXException {
          if (reader == null) {
              reader = getParser().getXMLReader();
          }
          
          //set up the parse
          reader.setContentHandler(this);
          reader.setDTDHandler(this);
          //reader.setEntityResolver(this);
          reader.setErrorHandler(this);
          return reader;
      }
      
      
      
      /**
       * Return the validating parser flag.
       */
      public boolean getValidating() {
          return (this.validating);
      }
      
      
      /**
       * Set the validating parser flag.  This must be called before
       * <code>parse()</code> is called the first time.
       *
       * @param validating The new validating parser flag.
       */
      public void setValidating(boolean validating) {
          this.validating = validating;
      }
      
      
      /**
       * Return the boolean as to whether the context classloader should be used.
       */
      public boolean getUseContextClassLoader() {
          return useContextClassLoader;
      }
      
      
      /**
       * Determine whether to use the Context ClassLoader (the one found by
       * calling <code>Thread.currentThread().getContextClassLoader()</code>)
       * to resolve/load classes that are defined in various rules.  If not
       * using Context ClassLoader, then the class-loading defaults to
       * using the calling-class' ClassLoader.
       *
       * @param boolean determines whether to use Context ClassLoader.
       */
      public void setUseContextClassLoader(boolean use) {
          useContextClassLoader = use;
      }
      
      
      // ContentHandler interface
      //-------------------------------------------------------------------------
      
      /**
       * Process notification of the beginning of the document being reached.
       *
       * @exception SAXException if a parsing error is to be reported
       */
      public void startDocument() throws SAXException {
          script = new ScriptBlock();
          textBuffer = new StringBuffer();
          insideRoot = false;
      }
      
      
      /**
       * Process notification of the end of the document being reached.
       *
       * @exception SAXException if a parsing error is to be reported
       */
      public void endDocument() throws SAXException {
          textBuffer = null;
      }
      
      /**
       * Process notification of the start of an XML element being reached.
       *
       * @param uri The Namespace URI, or the empty string if the element
       *   has no Namespace URI or if Namespace processing is not being performed.
       * @param localName The local name (without prefix), or the empty
       *   string if Namespace processing is not being performed.
       * @param qName The qualified name (with prefix), or the empty
       *   string if qualified names are not available.\
       * @param list The attributes attached to the element. If there are
       *   no attributes, it shall be an empty Attributes object.
       * @exception SAXException if a parsing error is to be reported
       */
      public void startElement(
      String namespaceURI, String localName, String qName, Attributes list
      ) throws SAXException {
          
          // ignore the first element
          if ( ! insideRoot ) {
              insideRoot = true;
              tagStack.add( null );
              return;
          }
          
          // if this is a tag then create a script to run it
          // otherwise pass the text to the current body
          tag = createTag( namespaceURI, localName, list );
          tagStack.add( tag );
          
          if ( tag != null ) {
              if ( textBuffer.length() > 0 ) {
                  script.addScript( new TextScript( textBuffer.toString() ) );
                  textBuffer.setLength(0);
              }
              
              script.addScript( tag );
              
              // start a new body
              scriptStack.push( script );
              script = new ScriptBlock();
              tag.setBody( script );
          }
          else {
              // XXXX: might wanna handle empty elements later...
              
              textBuffer.append( "<" );
              textBuffer.append( qName );
              int size = list.getLength();
              for ( int i = 0; i < size; i++ ) {
                  textBuffer.append( " " );
                  textBuffer.append( list.getQName(i) );
                  textBuffer.append( "=" );
                  textBuffer.append( "\"" );
                  textBuffer.append( list.getValue(i) );
                  textBuffer.append( "\"" );
              }
              textBuffer.append( ">" );
          }
      }
      
      /**
       * Process notification of character data received from the body of
       * an XML element.
       *
       * @param buffer The characters from the XML document
       * @param start Starting offset into the buffer
       * @param length Number of characters from the buffer
       *
       * @exception SAXException if a parsing error is to be reported
       */
      public void characters(char buffer[], int start, int length) throws SAXException {
          textBuffer.append(buffer, start, length);
      }
      
      
      
      /**
       * Process notification of the end of an XML element being reached.
       *
       * @param uri - The Namespace URI, or the empty string if the
       *   element has no Namespace URI or if Namespace processing is not
       *   being performed.
       * @param localName - The local name (without prefix), or the empty
       *   string if Namespace processing is not being performed.
       * @param qName - The qualified XML 1.0 name (with prefix), or the
       *   empty string if qualified names are not available.
       * @exception SAXException if a parsing error is to be reported
       */
      public void endElement(
          String namespaceURI, String localName, String qName
      ) throws SAXException {        
          
          tag = (TagScript) tagStack.remove( tagStack.size() - 1 );
          if ( tag != null ) {
              if ( textBuffer.length() > 0 ) {
                  script.addScript( new TextScript( textBuffer.toString() ) );
                  textBuffer.setLength(0);
              }
              if ( scriptStack.isEmpty() ) {
                  script = (ScriptBlock) scriptStack.peek();
              }
              else {
                  script = (ScriptBlock) scriptStack.pop();
              }
          }
          else {
              textBuffer.append( "</" );
              textBuffer.append( qName );
              textBuffer.append( ">" );
          }
      }
      
      
      /**
       * Process notification that a namespace prefix is going out of scope.
       *
       * @param prefix Prefix that is going out of scope
       *
       * @exception SAXException if a parsing error is to be reported
       */
      public void endPrefixMapping(String prefix) throws SAXException {
          
          // Deregister this prefix mapping
          ArrayStack stack = (ArrayStack) namespaces.get(prefix);
          if (stack == null) {
              return;
          }
          try {
              stack.pop();
              if (stack.empty()) {
                  namespaces.remove(prefix);
              }
          }
          catch (EmptyStackException e) {
              throw createSAXException("endPrefixMapping popped too many times");
          }
          
      }
      
      
      /**
       * Process notification of ignorable whitespace received from the body of
       * an XML element.
       *
       * @param buffer The characters from the XML document
       * @param start Starting offset into the buffer
       * @param length Number of characters from the buffer
       *
       * @exception SAXException if a parsing error is to be reported
       */
      public void ignorableWhitespace(char buffer[], int start, int len)
      throws SAXException {
          ;	// No processing required
          
      }
      
      
      /**
       * Process notification of a processing instruction that was encountered.
       *
       * @param target The processing instruction target
       * @param data The processing instruction data (if any)
       *
       * @exception SAXException if a parsing error is to be reported
       */
      public void processingInstruction(String target, String data)
      throws SAXException {
          ;	// No processing is required
      }
      
      
      /**
       * Set the document locator associated with our parser.
       *
       * @param locator The new locator
       */
      public void setDocumentLocator(Locator locator) {
          this.locator = locator;
      }
      
      
      /**
       * Process notification of a skipped entity.
       *
       * @param name Name of the skipped entity
       *
       * @exception SAXException if a parsing error is to be reported
       */
      public void skippedEntity(String name) throws SAXException {
          ; // No processing required
      }
      
      
      /**
       * Process notification that a namespace prefix is coming in to scope.
       *
       * @param prefix Prefix that is being declared
       * @param namespaceURI Corresponding namespace URI being mapped to
       *
       * @exception SAXException if a parsing error is to be reported
       */
      public void startPrefixMapping(String prefix, String namespaceURI)
      throws SAXException {
          
          // Register this prefix mapping
          ArrayStack stack = (ArrayStack) namespaces.get(prefix);
          if (stack == null) {
              stack = new ArrayStack();
              namespaces.put(prefix, stack);
          }
          stack.push(namespaceURI);
      }
      
      
      // DTDHandler interface
      //-------------------------------------------------------------------------
      
      
      /**
       * Receive notification of a notation declaration event.
       *
       * @param name The notation name
       * @param publicId The public identifier (if any)
       * @param systemId The system identifier (if any)
       */
      public void notationDecl(String name, String publicId, String systemId) {
      }
      
      
      /**
       * Receive notification of an unparsed entity declaration event.
       *
       * @param name The unparsed entity name
       * @param publicId The public identifier (if any)
       * @param systemId The system identifier (if any)
       * @param notation The name of the associated notation
       */
      public void unparsedEntityDecl(String name, String publicId,
      String systemId, String notation) {
      }
      
      // ErrorHandler interface
      //-------------------------------------------------------------------------
      
      
      /**
       * Forward notification of a parsing error to the application supplied
       * error handler (if any).
       *
       * @param exception The error information
       *
       * @exception SAXException if a parsing exception occurs
       */
      public void error(SAXParseException exception) throws SAXException {
          
          log.error("Parse Error at line " + exception.getLineNumber() +
          " column " + exception.getColumnNumber() + ": " +
          exception.getMessage(), exception);
          if (errorHandler != null) {
              errorHandler.error(exception);
          }
          
      }
      
      
      /**
       * Forward notification of a fatal parsing error to the application
       * supplied error handler (if any).
       *
       * @param exception The fatal error information
       *
       * @exception SAXException if a parsing exception occurs
       */
      public void fatalError(SAXParseException exception) throws SAXException {
          
          log.error("Parse Fatal Error at line " + exception.getLineNumber() +
          " column " + exception.getColumnNumber() + ": " +
          exception.getMessage(), exception);
          if (errorHandler != null) {
              errorHandler.fatalError(exception);
          }
          
      }
      
      
      /**
       * Forward notification of a parse warning to the application supplied
       * error handler (if any).
       *
       * @param exception The warning information
       *
       * @exception SAXException if a parsing exception occurs
       */
      public void warning(SAXParseException exception) throws SAXException {
          
          log.error("Parse Warning at line " + exception.getLineNumber() +
          " column " + exception.getColumnNumber() + ": " +
          exception.getMessage(), exception);
          if (errorHandler != null) {
              errorHandler.warning(exception);
          }
          
      }
      
      
      
      
      
      
      
      // Implementation methods
      //-------------------------------------------------------------------------
      
      
      /**
       * Factory method to create new Tag script for the given namespaceURI and name or
       * return null if this is not a custom Tag.
       */
      protected TagScript createTag( String namespaceURI, String localName, Attributes list ) throws SAXException {
          try {
              // use the URI to load a taglib
              TagLibrary taglib = (TagLibrary) taglibs.get( namespaceURI );
              if ( taglib == null ) {
                  if ( namespaceURI.startsWith( "jelly:" ) ) {
                      String uri = namespaceURI.substring(6);
                      // try to find the class on the claspath
                      try {
                          Class taglibClass = getClassLoader().loadClass( uri );
                          taglib = (TagLibrary) taglibClass.newInstance();
                      }
                      catch (ClassNotFoundException e) {
                          log.warn( "Could not load class: " + uri + " so disabling the taglib" );
                      }
                  }
              }
              if ( taglib != null ) {
                  TagScript script = taglib.createTagScript( localName, list );
                  
                  // now iterate through through the expressions
                  int size = list.getLength();
                  for ( int i = 0; i < size; i++ ) {
                      String attributeName = list.getLocalName(i);
                      String attributeValue = list.getValue(i);
                      Expression expression = taglib.createExpression( localName, attributeName, attributeValue );
                      if ( expression == null ) {
                          expression = createExpression( localName, attributeName, attributeValue );
                      }
                      script.addAttribute( attributeName, expression );
                  }
                  return script;
                  
              }
              return null;
          }
          catch (Exception e) {
              log.warn( "Could not create taglib or URI: " + namespaceURI + " tag name: " + localName, e );
              throw createSAXException(e);
          }
      }
      
      protected Expression createExpression( String tagName, String attributeName, String attributeValue ) {
          // should use the default Expression library in context
          return new ConstantExpression( attributeValue );
      }
      
      
      
      /**
       * Create a SAX exception which also understands about the location in
       * the file where the exception occurs
       *
       * @return the new exception
       */
      protected SAXException createSAXException(String message, Exception e) {
          if (locator != null) {
              String error = "Error at (" + locator.getLineNumber() + ", "
              + locator.getColumnNumber() + ": " + message;
              if (e != null) {
                  return new SAXParseException(error, locator, e);
              } else {
                  return new SAXParseException(error, locator);
              }
          }
          log.error("No Locator!");
          if (e != null) {
              return new SAXException(message, e);
          } else {
              return new SAXException(message);
          }
      }
      
      /**
       * Create a SAX exception which also understands about the location in
       * the digester file where the exception occurs
       *
       * @return the new exception
       */
      protected SAXException createSAXException(Exception e) {
          return createSAXException(e.getMessage(), e);
      }
      
      /**
       * Create a SAX exception which also understands about the location in
       * the digester file where the exception occurs
       *
       * @return the new exception
       */
      protected SAXException createSAXException(String message) {
          return createSAXException(message, null);
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/parser/package.html
  
  Index: package.html
  ===================================================================
  <html>
  <head>
  </head>
  <body>
  
    <p>Jelly parsers both XML syntax and non-XML syntaxes are supported.
    </p>
  
  </body>
  </html>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/ExprTag.java
  
  Index: ExprTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/ExprTag.java,v 1.1 2002/02/11 00:27:41 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2002/02/11 00:27:41 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: ExprTag.java,v 1.1 2002/02/11 00:27:41 jstrachan Exp $
   */
  package org.apache.commons.jelly.tags.xml;
  
  import java.io.IOException;
  import java.io.Writer;
  
  import org.apache.commons.jelly.Context;
  import org.apache.commons.jelly.Script;
  import org.apache.commons.jelly.Tag;
  
  import org.dom4j.XPath;
  
  /** A tag which performs a string XPath expression; similar to &lt;xsl:value-of&gt;
    * in XLST
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public class ExprTag implements Tag {
  
      /** The XPath expression to evaluate. */
      private XPath select;        
  
      public ExprTag() {
      }
  
      // Tag interface
      //------------------------------------------------------------------------- 
      public void run(Context context, Writer writer, Script body) throws IOException {
          if ( select != null ) {
              String text = select.valueOf( null );
              writer.write( text );
          }
      }
  
      // Properties
      //-------------------------------------------------------------------------                
      
      /** Sets the XPath expression to evaluate. */
      public void setSelect(XPath select) {
          this.select = select;
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/ForEachTag.java
  
  Index: ForEachTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/ForEachTag.java,v 1.1 2002/02/11 00:27:41 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2002/02/11 00:27:41 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: ForEachTag.java,v 1.1 2002/02/11 00:27:41 jstrachan Exp $
   */
  package org.apache.commons.jelly.tags.xml;
  
  import java.io.IOException;
  import java.io.Writer;
  import java.util.Iterator;
  import java.util.List;
  
  import org.apache.commons.jelly.Context;
  import org.apache.commons.jelly.Script;
  import org.apache.commons.jelly.Tag;
  
  import org.dom4j.XPath;
  
  
  /** A tag which performs an iteration over the results of an XPath expression
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public class ForEachTag implements Tag {
  
      /** Holds the XPath selector. */
      private XPath select;
      /** If specified then the current item iterated through will be defined
        * as the given variable name. */
      private String var;
      
      public ForEachTag() {
      }
  
      // Tag interface
      //------------------------------------------------------------------------- 
      public void run(Context context, Writer writer, Script body) throws Exception {
          if ( select != null ) { 
              Iterator iter = select.selectNodes(null).iterator();
              while ( iter.hasNext() ) {
                  Object value = iter.next();
                  if (var != null) {
                      context.setVariable( var, value );
                  }
                  body.run( context, writer );
              }
          }
      }
      
      // Properties
      //-------------------------------------------------------------------------                    
      
      /** Sets the XPath selection expression
        */
      public void setSelect(XPath select) {
          this.select = select;
      }
      
      /** Sets the variable name to export for the item being iterated over
       */
      public void setVar(String var) {
          this.var = var;
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/ParseTag.java
  
  Index: ParseTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/ParseTag.java,v 1.1 2002/02/11 00:27:41 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2002/02/11 00:27:41 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: ParseTag.java,v 1.1 2002/02/11 00:27:41 jstrachan Exp $
   */
  package org.apache.commons.jelly.tags.xml;
  
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.Reader;
  import java.io.StringReader;
  import java.io.StringWriter;
  import java.io.Writer;
  import java.net.MalformedURLException;
  import java.net.URL;
  
  import org.apache.commons.jelly.Context;
  import org.apache.commons.jelly.Script;
  import org.apache.commons.jelly.Tag;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogSource;
  
  import org.dom4j.Document;
  import org.dom4j.DocumentException;
  import org.dom4j.io.SAXReader;
  
  import org.xml.sax.SAXException;
  
  /** A tag which parses some XML and defines a variable with the parsed Document.
    * The XML can either be specified as its body or can be passed in via the
    * source property which can be a Reader, InputStream, URL or String URI.
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public class ParseTag implements Tag {
  
      /** The Log to which logging calls will be made. */
      private static final Log log = LogSource.getInstance( ParseTag.class );
  
      /** The variable that will be generated for the document */
      private String var;
      /** The source to parse, either a String URI, a Reader or InputStream */
      private Object source;
      
      // Optional properties not defined in JSTL
      
      /** whether XML validation is enabled or disabled */
      private boolean validate;
      /** The SAXReader used to parser the document */
      private SAXReader saxReader;
      
      public ParseTag() {
      }
  
      // Tag interface
      //------------------------------------------------------------------------- 
      public void run(Context context, Writer writer, Script body) throws Exception {
          if ( var == null ) {
              throw new IllegalArgumentException( "The var attribute cannot be null" );
          }
          Document document = null;
          if ( source == null ) {
              // parse body
              StringWriter buffer = new StringWriter();
              body.run( context, buffer );
              
              if ( log.isDebugEnabled() ) {
                  log.debug( "Evaluated body: " + body );
                  log.debug( "About to parse: " + buffer.toString() );
              }
              document = getSAXReader().read( new StringReader( buffer.toString() ) );
          }
          else {
              if ( source instanceof String ) {
                  document = getSAXReader().read( (String) source );
              }
              else if ( source instanceof Reader ) {
                  document = getSAXReader().read( (Reader) source );
              }
              else if ( source instanceof InputStream ) {
                  document = getSAXReader().read( (InputStream) source );
              }
              else if ( source instanceof URL ) {
                  document = getSAXReader().read( (URL) source );
              }
              else {
                  throw new IllegalArgumentException( 
                      "Invalid source argument. Must be a String, Reader, InputStream or URL."
                      + " Was type; " + source.getClass().getName() 
                      + " with value: " + source 
                  );
              }
          }
          context.setVariable( var, document );
      }
  
      // Properties
      //-------------------------------------------------------------------------                
      
      /** The variable name that will be used for the Document variable created
       */
      public String getVar() {
          return var;
      }
      
      /** Sets the variable name that will be used for the Document variable created
       */
      public void setVar(String var) {
          this.var = var;
      }
      
      /** @return whether XML validation is enabled or disabled */
      public boolean getValidate() {
          return validate;
      }
      
      /** Sets whether XML validation is enabled or disabled */
      public void setValidate(boolean validate) {
          this.validate = validate;
      }
      
      /** @return the SAXReader used for parsing, creating one lazily if need be  */
      public SAXReader getSAXReader() throws SAXException {
          if ( saxReader == null ) {
              saxReader = new SAXReader(validate);
          }
          return saxReader;
      }
      
      /** Sets the SAXReader used for parsing */
      public void setSAXReader(SAXReader saxReader) {
          this.saxReader = saxReader;
      }    
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/SetTag.java
  
  Index: SetTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/SetTag.java,v 1.1 2002/02/11 00:27:41 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2002/02/11 00:27:41 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: SetTag.java,v 1.1 2002/02/11 00:27:41 jstrachan Exp $
   */
  package org.apache.commons.jelly.tags.xml;
  
  import java.io.Writer;
  
  import org.apache.commons.jelly.Context;
  import org.apache.commons.jelly.Script;
  import org.apache.commons.jelly.Tag;
  
  import org.dom4j.XPath;
  
  /** A tag which defines a variable from an XPath expression 
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public class SetTag implements Tag {
  
      /** The variable name to export. */
      private String var;
      /** The XPath expression to evaluate. */
      private XPath select;        
  
      public SetTag() {
      }
  
      // Tag interface
      //------------------------------------------------------------------------- 
      public void run(Context context, Writer writer, Script body) {
          if ( var == null ) {
              throw new IllegalArgumentException( "The var attribute cannot be null" );
          }
          if ( select != null ) {
              Object value = select.evaluate( null );
              context.setVariable( var, value );
          }
      }
  
      // Properties
      //-------------------------------------------------------------------------                
      
      /** Sets the variable name to define for this expression
       */
      public void setVar(String var) {
          this.var = var;
      }
      
      /** Sets the XPath expression to evaluate. */
      public void setSelect(XPath select) {
          this.select = select;
      }
      
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/XMLTagLibrary.java
  
  Index: XMLTagLibrary.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/XMLTagLibrary.java,v 1.1 2002/02/11 00:27:41 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2002/02/11 00:27:41 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: XMLTagLibrary.java,v 1.1 2002/02/11 00:27:41 jstrachan Exp $
   */
  package org.apache.commons.jelly.tags.xml;
  
  import java.io.IOException;
  import java.io.Writer;
  import java.util.Iterator;
  import java.util.List;
  
  import org.apache.commons.jelly.Context;
  import org.apache.commons.jelly.Script;
  import org.apache.commons.jelly.TagLibrary;
  import org.apache.commons.jelly.expression.Expression;
  
  import org.dom4j.XPath;
  
  
  /** Describes the Taglib. This class could be generated by XDoclet
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public class XMLTagLibrary extends TagLibrary {
  
      public XMLTagLibrary() {
          registerTag( "expr", ExprTag.class );
          registerTag( "forEach", ForEachTag.class );
          registerTag( "parse", ParseTag.class );
          registerTag( "set", SetTag.class );
      }
      
      public Expression createExpression(String tagName, String attributeName, String attributeValue) {
          if (attributeName.equals( "select" ) ) {
              return new XPathExpression( attributeValue );
          }
          // will use the default expression instead
          return null;
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/XPathExpression.java
  
  Index: XPathExpression.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/XPathExpression.java,v 1.1 2002/02/11 00:27:41 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2002/02/11 00:27:41 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: XPathExpression.java,v 1.1 2002/02/11 00:27:41 jstrachan Exp $
   */
  package org.apache.commons.jelly.tags.xml;
  
  import java.io.IOException;
  import java.io.Writer;
  
  import org.apache.commons.jelly.Context;
  import org.apache.commons.jelly.Script;
  import org.apache.commons.jelly.Tag;
  import org.apache.commons.jelly.expression.Expression;
  
  import org.dom4j.DocumentFactory;
  import org.dom4j.XPath;
  import org.jaxen.VariableContext;
  
  /** An expression which returns an XPath object.
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public class XPathExpression implements Expression, VariableContext {
  
      private XPath xpath;        
      private Context context;
      
      public XPathExpression() {
      }
  
      public XPathExpression(XPath xpath) {
          this.xpath = xpath;
      }
  
      public XPathExpression(String text) {
          this.xpath = DocumentFactory.getInstance().createXPath( text ); 
      }
  
      // Expression interface
      //------------------------------------------------------------------------- 
      public Object evaluate(Context context) {
          this.context = context;
          xpath.setVariableContext( this );
          return xpath;
      }
      
      // VariableContext interface
      //------------------------------------------------------------------------- 
      public Object getVariableValue( 
          String namespaceURI, String prefix, String localName 
      ) {
          return context.getVariable( localName );
      }
      
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/package.html
  
  Index: package.html
  ===================================================================
  <html>
  <head>
  </head>
  <body>
  
    <p>The XML Tags from the JSTL
    </p>
  </body>
  </html>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/TestAll.java
  
  Index: TestAll.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/TestAll.java,v 1.1 2002/02/11 00:27:41 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2002/02/11 00:27:41 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: TestAll.java,v 1.1 2002/02/11 00:27:41 jstrachan Exp $
   */
  package org.apache.commons.jelly;
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  import junit.textui.TestRunner;
  
  /** Entry point for all JUnit tests.
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
   */
  public class TestAll extends TestCase {
      
      public static void main( String[] args ) {
          TestRunner.run( suite() );
      }
      
      public static Test suite() {
          TestSuite suite = new TestSuite();
          suite.addTest(TestXMLTags.suite());
          return suite;
      }
      
      public TestAll(String testName) {
          super(testName);
      }
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/TestXMLTags.java
  
  Index: TestXMLTags.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/TestXMLTags.java,v 1.1 2002/02/11 00:27:41 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2002/02/11 00:27:41 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: TestXMLTags.java,v 1.1 2002/02/11 00:27:41 jstrachan Exp $
   */
  package org.apache.commons.jelly;
  
  import java.io.InputStream;
  import java.io.IOException;
  import java.io.StringWriter;
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  import junit.textui.TestRunner;
  
  import org.apache.commons.jelly.Context;
  import org.apache.commons.jelly.Script;
  import org.apache.commons.jelly.impl.ScriptBlock;
  import org.apache.commons.jelly.parser.XMLParser;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogSource;
  
  
  /** Tests the parser, the engine and the XML tags
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public class TestXMLTags extends TestCase {
      
      /** The Log to which logging calls will be made. */
      private static final Log log = LogSource.getInstance( TestXMLTags.class );
  
      public static void main( String[] args ) {
          TestRunner.run( suite() );
      }
      
      public static Test suite() {
          return new TestSuite(TestXMLTags.class);
      }
      
      public TestXMLTags(String testName) {
          super(testName);
      }
      
      public void testParse() throws Exception {
          InputStream in = getClass().getResourceAsStream( "example.jelly" );
          XMLParser parser = new XMLParser();
          Script script = parser.parse( in );
          script = script.compile();
  
          assertTrue( "Script is a ScriptBlock", script instanceof ScriptBlock );
          
          ScriptBlock block = (ScriptBlock) script;
          Script[] scripts = block.getScripts();
          
          assertTrue( "block contains child scripts", scripts.length != 0 );
  
          if ( log.isDebugEnabled() ) {
              for ( int i = 0, size = scripts.length; i < size; i++ ) {
                  Script s = scripts[i];
                  log.debug( "Found script: " + i + " = " + s );
              }
          }
          
          Context context = new Context();        
          StringWriter buffer = new StringWriter();
          
          script.run( context, buffer );
          
          String text = buffer.toString().trim();
          
          if ( log.isDebugEnabled() ) {
              log.debug( "Evaluated script as..." );
              log.debug( text );
          }
          
          assertEquals( "Produces the correct output", "It works!", text );        
      }    
  }
  
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/example.jelly
  
  Index: example.jelly
  ===================================================================
  <?xml version="1.0"?>
  
  <j:jelly 
    xmlns:j="http://jakarta.apache.org/commons/jelly/1.0"
    xmlns:x="jelly:org.apache.commons.jelly.tags.xml.XMLTagLibrary"
  >
    <x:parse var="doc">
      <html>
        <title>It works!</title>
        <body>
        </body>
      </html>
    </x:parse>
    <x:expr select="$doc/html/title"/>
  </j:jelly>
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message