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 TestCoreTags.java TestXMLTags.java
Date Wed, 24 Apr 2002 11:59:14 GMT
jstrachan    02/04/24 04:59:13

  Modified:    jelly    OVERVIEW.html PROPOSAL.html STATUS.html
                        build.properties.sample build.xml
               jelly/src/java/org/apache/commons/jelly CompilableTag.java
                        Context.java Jelly.java Script.java Tag.java
                        TagLibrary.java TagSupport.java
               jelly/src/java/org/apache/commons/jelly/impl
                        ScriptBlock.java TagScript.java TextScript.java
               jelly/src/java/org/apache/commons/jelly/parser
                        XMLParser.java
               jelly/src/java/org/apache/commons/jelly/tags/core
                        ChooseTag.java ExprTag.java ForEachTag.java
                        IfTag.java JellyTag.java OtherwiseTag.java
                        SetTag.java WhenTag.java
               jelly/src/java/org/apache/commons/jelly/tags/xml
                        ExprTag.java ForEachTag.java ParseTag.java
                        SetTag.java
               jelly/src/test/org/apache/commons/jelly TestCoreTags.java
                        TestXMLTags.java
  Added:       jelly/src/java/org/apache/commons/jelly DynaTag.java
                        MapTagSupport.java XMLOutput.java
               jelly/src/java/org/apache/commons/jelly/impl StaticTag.java
  Log:
  Refactored the Jelly engine to be XML native. Jelly now uses a class called XMLOutput which is-a SAX ContentHandler. This means that each custom tag is essentially a tap in the SAX pipestream. Indeed a custom tag can easily filter its body in a typical SAX pipeline like that used in Cocoon. Updated the documentation to reflect the new core dependencies
  
  Revision  Changes    Path
  1.4       +12 -8     jakarta-commons-sandbox/jelly/OVERVIEW.html
  
  Index: OVERVIEW.html
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/OVERVIEW.html,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- OVERVIEW.html	10 Mar 2002 00:56:33 -0000	1.3
  +++ OVERVIEW.html	24 Apr 2002 11:59:12 -0000	1.4
  @@ -21,10 +21,10 @@
       public void setCount(int count) {
           this.count = count;
       }
  -    public void run(Context context, Writer writer) throws Exception {
  +    public void run(Context context, XMLOutput output) throws Exception {
           for ( int i = 0; i < count; i++ ) {
               // evaluate body
  -            getBody().run( context, writer );
  +            getBody().run( context, output );
           }
       }
   }</pre>
  @@ -34,7 +34,7 @@
   &lt;/f:foo&gt;</pre>
   <p>Jelly is totally extendable 
   via custom actions (in a similar way to JSP custom tags) as well as cleanly integrating with  scripting 
  -languages such as Velocity, pnuts, beanshell and via BSF (Bean Scripting Framework) 
  +languages such as Jexl, Velocity, pnuts, beanshell and via BSF (Bean Scripting Framework) 
   languages like JavaScript &amp; JPython</p>
   
   <h2>Background</h2>
  @@ -87,6 +87,9 @@
     with a fairly complex set of event-based methods that are called by the page 
     container. Jelly tags are very easy - just derive from TagSupport and 
     implement the run() method. Really simple!</li>
  +  <li>Jelly is XML native both as the format of the scripts and the output 
  +  format, so its ideal for work with XML and XML based applications and web 
  +  services</li>
     <li>Jelly tags can parse and compile their bodies for more optimal performance 
     and easier validation. So a tag can ignore whitespace, iterate over its body, 
     transform its body at compile time etc. So a Jelly tag can be a simple macro, preprocessing 
  @@ -122,13 +125,14 @@
   
   <p>Jelly has various possible uses. Here's a few to think about</p>
   <ul>
  -  <li>SOAP, HTTP and/or JMS based scripting framework</li>
  -  <li>A unit testing framework similar to Latka and AntEater</li>
  +  <li>SOAP scripting engine</li>
  +  <li>HTTP and/or JMS based scripting and unit testing framework similar to Latka and AntEater</li>
  +  <li>XML or page templating system</li>
  +  <li>Ant scripting</li>
  +  <li>Alternative (very lightweight) implementation of JSTL that can be run from 
  +  Ant to generate static content</li>
     <li>A workflow, EAI or integration, maybe integrated into commons-workflow</li>
  -  <li>Page templating system</li>
     <li>Code generation system, maybe an enhanced scripting engine for XDoclet</li>
  -  <li>Ant scripting</li>
  -  <li>Alternative implementation of JSTL</li>
   </ul>
   
   </body>
  
  
  
  1.4       +13 -6     jakarta-commons-sandbox/jelly/PROPOSAL.html
  
  Index: PROPOSAL.html
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/PROPOSAL.html,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PROPOSAL.html	4 Mar 2002 03:32:25 -0000	1.3
  +++ PROPOSAL.html	24 Apr 2002 11:59:12 -0000	1.4
  @@ -10,8 +10,8 @@
   
   <h3>(0) Rationale</h3>
   
  -<p>The <em>Jelly</em> package implements a simple XML tag based scripting 
  -engine. Jelly borrows many ideas from both JSP custom tags, Velocity and the 
  +<p>The <em>Jelly</em> is an XML based scripting and processing engine. Jelly borrows many 
  +good ideas from both JSP custom tags, Velocity, Cocoon, XMLC and the 
   scripting engine inside XDoclet. Jelly can be used from the command line, inside 
   Ant or inside a Servlet. 
   </p>
  @@ -21,6 +21,10 @@
   Though Jelly is really simple and has no dependencies either Servlets or JSP.
   </p>
   
  +<p>We hope Jelly can be both an XML processing and transformation engine, a HTTP 
  +/ JMS / SOAP scripting engine as well as an XML based unit testing framework for 
  +testing XML based applications and web services.</p>
  +
   <p>As an experiment some of the JSTL tags are implemented.</p>
   
   <h3>(1) Scope of the Package</h3>
  @@ -39,12 +43,13 @@
     <li>Collections (1.1 or greater)</li>
     <li>Logging (1.0 or greater)</li>
     <li>BeanUtils (1.1 or greater)</li>
  +  <li>Jexl (1.0 or greater)</li>
     </ul>
   
  -<p>The XML tags uses</p>
  +<p><i>Jelly</i> also uses these other libraries</p>
   <ul>
  -  <li>dom4j (1.1 or greater)</li>
  -</ul>
  +  <li>dom4j (1.3 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 
  @@ -55,7 +60,9 @@
   <h3>(2) Initial Source of the Package</h3>
   
   <p>
  -   The code base is new and uses ideas from JSP taglibs, Velocity and XDoclet.
  +   The code base is new and uses ideas from JSP taglibs, Velocity and XDoclet as 
  +   well as incorporating pipelining ideas from Cocoon and XML processing ideas 
  +   from XMLC.
   </p>
   
   <p>The proposed package name for the new component is
  
  
  
  1.3       +16 -15    jakarta-commons-sandbox/jelly/STATUS.html
  
  Index: STATUS.html
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/STATUS.html,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- STATUS.html	11 Feb 2002 18:14:17 -0000	1.2
  +++ STATUS.html	24 Apr 2002 11:59:12 -0000	1.3
  @@ -7,7 +7,7 @@
   
   <div align="center">
   <h1>The Jakarta Commons <em>Jelly</em> Package</h1>
  -$Id: STATUS.html,v 1.2 2002/02/11 18:14:17 jstrachan Exp $<br>
  +$Id: STATUS.html,v 1.3 2002/04/24 11:59:12 jstrachan Exp $<br>
   <a href="#Introduction">[Introduction]</a>
   <a href="#Dependencies">[Dependencies]</a>
   <a href="#Release Info">[Release Info]</a>
  @@ -20,37 +20,38 @@
   <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 
  +<p>The <em>Jelly</em> is an XML based scripting and processing engine. Jelly borrows many 
  +good ideas from both JSP custom tags, Velocity, Cocoon, XMLC 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>
  +Ant or inside a Servlet. 
  +</p>
   
  -<p>As an experiment some of the JSTL tags are implemented.</p>
  +<p>
  +Jelly is completely extendable via custom tags in a similar way to JSP. 
  +Though Jelly is really simple and has no dependencies either Servlets or JSP.
  +</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>
  +<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/jexl.html">Jakarta Commons Jexl</a> (Version 1.0 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>
  +<li><a href="http://dom4j.org/">dom4j</a> (Version 1.3 or later)</li>
   </ul>
   
   
  -<p>The XML tags currently depend on</p>
  +<p>The <em>Jelly</em> is also dependent upon the following external
  +components for unit testing, not required for deployment:</p>
   <ul>
  -  <li><a href="http://dom4j.org/">dom4j</a> (Version 1.1 or later)</li>
  +<li><a href="http://www.junit.org">JUnit Testing Framework</a> (Version 3.7 or 
  +later)</li>
   </ul>
   
   
  
  
  
  1.6       +3 -0      jakarta-commons-sandbox/jelly/build.properties.sample
  
  Index: build.properties.sample
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/build.properties.sample,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- build.properties.sample	7 Mar 2002 03:57:12 -0000	1.5
  +++ build.properties.sample	24 Apr 2002 11:59:12 -0000	1.6
  @@ -10,6 +10,9 @@
   # jakarta-commons-httpclient.jar
   httpclient.jar=../../jakarta-commons/httpclient/dist/commons-httpclient.jar
   
  +# jakarta-commons-jexl.jar
  +jexl.jar=../jexl/dist/commons-jexl.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.10      +4 -3      jakarta-commons-sandbox/jelly/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/build.xml,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- build.xml	7 Mar 2002 03:57:12 -0000	1.9
  +++ build.xml	24 Apr 2002 11:59:12 -0000	1.10
  @@ -3,7 +3,7 @@
   
   <!--
           "Jelly" component of the Jakarta Commons Subproject
  -        $Id: build.xml,v 1.9 2002/03/07 03:57:12 jstrachan Exp $
  +        $Id: build.xml,v 1.10 2002/04/24 11:59:12 jstrachan Exp $
   -->
   
   
  @@ -322,7 +322,7 @@
         description="Runs the test of the 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.log" value="org.apache.commons.logging.impl.SimpleLog"/>
         <sysproperty key="org.apache.commons.logging.simplelog.defaultlog" value="debug"/>
       </java>
      </target>
  @@ -331,7 +331,7 @@
         description="Runs the BeanShell EL tests">
       <java classname="org.apache.commons.jelly.beanshell.TestBeanShellEL" 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.log" value="org.apache.commons.logging.impl.SimpleLog"/>
         <sysproperty key="org.apache.commons.logging.simplelog.defaultlog" value="debug"/>
       </java>
      </target>
  @@ -343,6 +343,7 @@
       <java classname="org.apache.commons.jelly.Jelly" fork="yes">
         <classpath refid="test.classpath"/>
         <arg value="src/test/org/apache/commons/jelly/hello_world.jelly"/> 
  +      <sysproperty key="org.apache.commons.logging.simplelog.defaultlog" value="debug"/>
       </java>
      </target>
   
  
  
  
  1.2       +5 -7      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/CompilableTag.java
  
  Index: CompilableTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/CompilableTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CompilableTag.java	15 Feb 2002 18:25:06 -0000	1.1
  +++ CompilableTag.java	24 Apr 2002 11:59:12 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/CompilableTag.java,v 1.1 2002/02/15 18:25:06 jstrachan Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/02/15 18:25:06 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/CompilableTag.java,v 1.2 2002/04/24 11:59:12 jstrachan Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/24 11:59:12 $
    *
    * ====================================================================
    *
  @@ -57,16 +57,14 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: CompilableTag.java,v 1.1 2002/02/15 18:25:06 jstrachan Exp $
  + * $Id: CompilableTag.java,v 1.2 2002/04/24 11:59:12 jstrachan Exp $
    */
   package org.apache.commons.jelly;
   
  -import java.io.Writer;
  -
   /** <p><code>Compilable</code> represents a Tag that is compilable.</p>
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.1 $
  +  * @version $Revision: 1.2 $
     */
   public interface CompilableTag {
   
  
  
  
  1.5       +5 -6      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Context.java
  
  Index: Context.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Context.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Context.java	7 Mar 2002 02:46:03 -0000	1.4
  +++ Context.java	24 Apr 2002 11:59:12 -0000	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Context.java,v 1.4 2002/03/07 02:46:03 jstrachan Exp $
  - * $Revision: 1.4 $
  - * $Date: 2002/03/07 02:46:03 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Context.java,v 1.5 2002/04/24 11:59:12 jstrachan Exp $
  + * $Revision: 1.5 $
  + * $Date: 2002/04/24 11:59:12 $
    *
    * ====================================================================
    *
  @@ -57,11 +57,10 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: Context.java,v 1.4 2002/03/07 02:46:03 jstrachan Exp $
  + * $Id: Context.java,v 1.5 2002/04/24 11:59:12 jstrachan Exp $
    */
   package org.apache.commons.jelly;
   
  -import java.io.Writer;
   import java.util.Hashtable;
   import java.util.Iterator;
   import java.util.Map;
  @@ -69,7 +68,7 @@
   /** <p><code>Context</code> represents the Jelly context.</p>
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.4 $
  +  * @version $Revision: 1.5 $
     */
   public class Context {
   
  
  
  
  1.4       +10 -7     jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Jelly.java
  
  Index: Jelly.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Jelly.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Jelly.java	19 Feb 2002 15:40:58 -0000	1.3
  +++ Jelly.java	24 Apr 2002 11:59:12 -0000	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Jelly.java,v 1.3 2002/02/19 15:40:58 jstrachan Exp $
  - * $Revision: 1.3 $
  - * $Date: 2002/02/19 15:40:58 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Jelly.java,v 1.4 2002/04/24 11:59:12 jstrachan Exp $
  + * $Revision: 1.4 $
  + * $Date: 2002/04/24 11:59:12 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: Jelly.java,v 1.3 2002/02/19 15:40:58 jstrachan Exp $
  + * $Id: Jelly.java,v 1.4 2002/04/24 11:59:12 jstrachan Exp $
    */
   package org.apache.commons.jelly;
   
  @@ -74,7 +74,7 @@
   /** <p><code>Jelly</code> an application which runs a Jelly script.</p>
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.3 $
  +  * @version $Revision: 1.4 $
     */
   public class Jelly {
   
  @@ -99,7 +99,7 @@
               : new OutputStreamWriter( System.out );
           BufferedWriter output = new BufferedWriter( writer );
   */      
  -        Writer output = new BufferedWriter( 
  +        Writer writer = new BufferedWriter( 
               new OutputStreamWriter( System.out )
           );
           
  @@ -117,7 +117,10 @@
           Context context = new Context();
           context.setVariable( "args", args );
           
  +        XMLOutput output= XMLOutput.createXMLOutput( writer );
  +        
           script.run( context, output );
  -        output.close();
  +        
  +        writer.close();
       }    
   }
  
  
  
  1.2       +6 -8      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Script.java
  
  Index: Script.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Script.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Script.java	11 Feb 2002 00:27:40 -0000	1.1
  +++ Script.java	24 Apr 2002 11:59:12 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $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 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Script.java,v 1.2 2002/04/24 11:59:12 jstrachan Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/24 11:59:12 $
    *
    * ====================================================================
    *
  @@ -57,16 +57,14 @@
    * 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 $
  + * $Id: Script.java,v 1.2 2002/04/24 11:59:12 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 $
  +  * @version $Revision: 1.2 $
     */
   public interface Script {
   
  @@ -76,6 +74,6 @@
       public Script compile() throws Exception;
       
       /** Evaluates the body of a tag */
  -    public void run(Context context, Writer writer) throws Exception;
  +    public void run(Context context, XMLOutput output) throws Exception;
       
   }
  
  
  
  1.3       +6 -8      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Tag.java
  
  Index: Tag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Tag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Tag.java	12 Feb 2002 21:34:33 -0000	1.2
  +++ Tag.java	24 Apr 2002 11:59:12 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Tag.java,v 1.2 2002/02/12 21:34:33 jstrachan Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/02/12 21:34:33 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/Tag.java,v 1.3 2002/04/24 11:59:12 jstrachan Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/04/24 11:59:12 $
    *
    * ====================================================================
    *
  @@ -57,16 +57,14 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: Tag.java,v 1.2 2002/02/12 21:34:33 jstrachan Exp $
  + * $Id: Tag.java,v 1.3 2002/04/24 11:59:12 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.2 $
  +  * @version $Revision: 1.3 $
     */
   public interface Tag {
   
  @@ -84,6 +82,6 @@
       
       /** Evaluates this tag after all the tags properties have been initialized.
        */
  -    public void run(Context context, Writer writer) throws Exception;
  +    public void run(Context context, XMLOutput output) throws Exception;
       
   }
  
  
  
  1.3       +5 -6      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/TagLibrary.java
  
  Index: TagLibrary.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/TagLibrary.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TagLibrary.java	13 Feb 2002 17:03:09 -0000	1.2
  +++ TagLibrary.java	24 Apr 2002 11:59:12 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/TagLibrary.java,v 1.2 2002/02/13 17:03:09 jstrachan Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/02/13 17:03:09 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/TagLibrary.java,v 1.3 2002/04/24 11:59:12 jstrachan Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/04/24 11:59:12 $
    *
    * ====================================================================
    *
  @@ -57,11 +57,10 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: TagLibrary.java,v 1.2 2002/02/13 17:03:09 jstrachan Exp $
  + * $Id: TagLibrary.java,v 1.3 2002/04/24 11:59:12 jstrachan Exp $
    */
   package org.apache.commons.jelly;
   
  -import java.io.Writer;
   import java.util.HashMap;
   import java.util.Map;
   
  @@ -74,7 +73,7 @@
   /** <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.2 $
  +  * @version $Revision: 1.3 $
     */
   public abstract class TagLibrary {
   
  
  
  
  1.2       +4 -4      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/TagSupport.java
  
  Index: TagSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/TagSupport.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TagSupport.java	12 Feb 2002 21:34:33 -0000	1.1
  +++ TagSupport.java	24 Apr 2002 11:59:12 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/TagSupport.java,v 1.1 2002/02/12 21:34:33 jstrachan Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/02/12 21:34:33 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/TagSupport.java,v 1.2 2002/04/24 11:59:12 jstrachan Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/24 11:59:12 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: TagSupport.java,v 1.1 2002/02/12 21:34:33 jstrachan Exp $
  + * $Id: TagSupport.java,v 1.2 2002/04/24 11:59:12 jstrachan Exp $
    */
   package org.apache.commons.jelly;
   
  @@ -68,7 +68,7 @@
     * inherit from if developing your own tag.</p>
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.1 $
  +  * @version $Revision: 1.2 $
     */
   public abstract class TagSupport implements Tag {
   
  @@ -136,7 +136,7 @@
       protected String getBodyText( Context context ) throws Exception {
           // XXX: could maybe optimise this later on by having a pool of buffers
           StringWriter writer = new StringWriter();
  -        body.run( context, writer );
  +        body.run( context, XMLOutput.createXMLOutput( writer ) );
           return writer.toString();
       }
       
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/DynaTag.java
  
  Index: DynaTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/DynaTag.java,v 1.1 2002/04/24 11:59:12 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2002/04/24 11:59:12 $
   *
   * ====================================================================
   *
   * 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: DynaTag.java,v 1.1 2002/04/24 11:59:12 jstrachan Exp $
   */
  package org.apache.commons.jelly;
  
  /** 
   * <p><code>DynaTag</code> represents a Jelly custom tag which
   * can take its attributes dynamically and store them in some data structure.
   * Typically a DynaTag may use either a Map or a DynaBean to implement itself
   * which avoids writing explicit getter and setter methods for each possible attribute.
   * </p>
   * <p>
   * This kind of tag can be extremely useful when making HTML-like tags which
   * generally output all the attributes which are used in the markup, except
   * one or two special attributes are used, all others pass through.</p>
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.1 $
   */
  public interface DynaTag extends Tag {
  
      /** Sets an attribute value of this tag before the tag is invoked
       */
      public void setAttribute(String name, Object value);    
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/MapTagSupport.java
  
  Index: MapTagSupport.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/MapTagSupport.java,v 1.1 2002/04/24 11:59:12 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2002/04/24 11:59:12 $
   *
   * ====================================================================
   *
   * 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: MapTagSupport.java,v 1.1 2002/04/24 11:59:12 jstrachan Exp $
   */
  package org.apache.commons.jelly;
  
  import java.util.HashMap;
  import java.util.Map;
  
  /** 
   * <p><code>MapTag</code> is a DynaTag implementation which uses a Map
   * to store its attribute values in. Derived tags can then process this
   * Map, change values, add or remove attributes or perform some other form
   * of processsing pretty easily.
   * </p>
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.1 $
   */
  public abstract class MapTagSupport extends TagSupport implements DynaTag {
  
      private Map map;
      
      /** Sets an attribute value of this tag before the tag is invoked
       */
      public void setAttribute(String name, Object value) {
          getAttributes().put(name, value);
      }
      
      
      /** 
       * Helper method which allows derived tags to access the attributes
       * associated with this tag
       */
      protected Map getAttributes() {
          if ( map == null ) {
              map = createAttributes();
          }
          return map;
      }
      
      /**
       * A Factory Method which allows derived tags to overload the Map
       * implementation used by this tag
       */
      protected Map createAttributes() {
          return new HashMap();
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/XMLOutput.java
  
  Index: XMLOutput.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/XMLOutput.java,v 1.1 2002/04/24 11:59:12 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2002/04/24 11:59:12 $
   *
   * ====================================================================
   *
   * 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: XMLOutput.java,v 1.1 2002/04/24 11:59:12 jstrachan Exp $
   */
  package org.apache.commons.jelly;
  
  import java.io.Writer;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  import org.dom4j.io.XMLWriter;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.ContentHandler;
  import org.xml.sax.Locator;
  import org.xml.sax.SAXException;
  import org.xml.sax.XMLReader;
  import org.xml.sax.ext.LexicalHandler;
  
  /** <p><code>XMLOutput</code> is used to output XML events 
    * in a SAX-like manner. This also allows pipelining to be done
    * such as in the <a href="http://xml.apache.org/cocoon/">Cocoon</a> project.</p>
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.1 $
    */
  public class XMLOutput implements ContentHandler, LexicalHandler {
  
      protected static final String[] LEXICAL_HANDLER_NAMES = {
          "http://xml.org/sax/properties/lexical-handler",
          "http://xml.org/sax/handlers/LexicalHandler"
      };
      
      /** The Log to which logging calls will be made. */
      private static final Log log = LogFactory.getLog( XMLOutput.class );
      
      /** The SAX ContentHandler that output goes to */
      private ContentHandler contentHandler;
      /** The SAX LexicalHandler that output goes to */
      private LexicalHandler lexicalHandler;
      
      
      public XMLOutput() {
      }
      
      public XMLOutput(ContentHandler contentHandler) {
          this.contentHandler = contentHandler;
          
          // often classes will implement LexicalHandler as well 
          if ( contentHandler instanceof LexicalHandler ) {
              this.lexicalHandler = (LexicalHandler) contentHandler;
          }
      }
      
      public XMLOutput(ContentHandler contentHandler, LexicalHandler lexicalHandler) {
          this.contentHandler = contentHandler;
          this.lexicalHandler = lexicalHandler;
      }
  
  
      public String toString() {
          return super.toString() + "[contentHandler=" + contentHandler + ";lexicalHandler=" + lexicalHandler + "]";
      }
      
      // Static helper methods
      //-------------------------------------------------------------------------                    
      
      /** 
       * Creates an XMLOutput from an existing SAX XMLReader
       */
      public static XMLOutput createXMLOutput(XMLReader xmlReader) {
          XMLOutput output = new XMLOutput( xmlReader.getContentHandler() );
  
          // isn't it lovely what we've got to do to find the LexicalHandler... ;-)
          for (int i = 0; i < LEXICAL_HANDLER_NAMES.length; i++) {
              try {
                  Object value = xmlReader.getProperty( LEXICAL_HANDLER_NAMES[i] );
                  if ( value instanceof LexicalHandler ) {
                      output.setLexicalHandler((LexicalHandler) value);
                      break;
                  }
              }
              catch (Exception e) {
                  // ignore any unsupported-operation exceptions
              }
          }
          return output;
      }
      
      
      /** 
       * Creates a text based XMLOutput which converts all XML events into
       * text and writes to the underlying Writer.
       */
      public static XMLOutput createXMLOutput(Writer writer) {
          XMLWriter xmlWriter = new XMLWriter( writer );
          return new XMLOutput( xmlWriter );
      }
      
      // Extra helper methods provided for tag authors
      //-------------------------------------------------------------------------                    
      
      /** 
       * Outputs the given String as a piece of valid text in the 
       * XML event stream.
       * Any special XML characters should be properly escaped.
       */
      public void write(String text) throws SAXException {
          char[] ch = text.toCharArray();
          characters( ch, 0, ch.length );
      }
  
      /** 
       * Outputs the given String as a piece of CDATA in the 
       * XML event stream.
       */
      public void writeCDATA(String text) throws SAXException {
          startCDATA();
          char[] ch = text.toCharArray();
          characters( ch, 0, ch.length );
          endCDATA();
      }
  
      /** 
       * Outputs a comment to the XML stream
       */
      public void writeComment(String text) throws SAXException {
          char[] ch = text.toCharArray();
          comment( ch, 0, ch.length );
      }
  
      
      // ContentHandler interface
      //-------------------------------------------------------------------------                    
      
  
      /**
       * Receive an object for locating the origin of SAX document events.
       *
       * <p>SAX parsers are strongly encouraged (though not absolutely
       * required) to supply a locator: if it does so, it must supply
       * the locator to the application by invoking this method before
       * invoking any of the other methods in the ContentHandler
       * interface.</p>
       *
       * <p>The locator allows the application to determine the end
       * position of any document-related event, even if the parser is
       * not reporting an error.  Typically, the application will
       * use this information for reporting its own errors (such as
       * character content that does not match an application's
       * business rules).  The information returned by the locator
       * is probably not sufficient for use with a search engine.</p>
       *
       * <p>Note that the locator will return correct information only
       * during the invocation of the events in this interface.  The
       * application should not attempt to use it at any other time.</p>
       *
       * @param locator An object that can return the location of
       *                any SAX document event.
       * @see org.xml.sax.Locator
       */
      public void setDocumentLocator(Locator locator) {
          contentHandler.setDocumentLocator(locator);
      }
  
  
      /**
       * Receive notification of the beginning of a document.
       *
       * <p>The SAX parser will invoke this method only once, before any
       * other event callbacks (except for {@link #setDocumentLocator 
       * setDocumentLocator}).</p>
       *
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see #endDocument
       */
      public void startDocument() throws SAXException {
          contentHandler.startDocument();
      }
  
      /**
       * Receive notification of the end of a document.
       *
       * <p>The SAX parser will invoke this method only once, and it will
       * be the last method invoked during the parse.  The parser shall
       * not invoke this method until it has either abandoned parsing
       * (because of an unrecoverable error) or reached the end of
       * input.</p>
       *
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see #startDocument
       */
      public void endDocument() throws SAXException {
          contentHandler.endDocument();
      }
  
      /**
       * Begin the scope of a prefix-URI Namespace mapping.
       *
       * <p>The information from this event is not necessary for
       * normal Namespace processing: the SAX XML reader will 
       * automatically replace prefixes for element and attribute
       * names when the <code>http://xml.org/sax/features/namespaces</code>
       * feature is <var>true</var> (the default).</p>
       *
       * <p>There are cases, however, when applications need to
       * use prefixes in character data or in attribute values,
       * where they cannot safely be expanded automatically; the
       * start/endPrefixMapping event supplies the information
       * to the application to expand prefixes in those contexts
       * itself, if necessary.</p>
       *
       * <p>Note that start/endPrefixMapping events are not
       * guaranteed to be properly nested relative to each other:
       * all startPrefixMapping events will occur immediately before the
       * corresponding {@link #startElement startElement} event, 
       * and all {@link #endPrefixMapping endPrefixMapping}
       * events will occur immediately after the corresponding
       * {@link #endElement endElement} event,
       * but their order is not otherwise 
       * guaranteed.</p>
       *
       * <p>There should never be start/endPrefixMapping events for the
       * "xml" prefix, since it is predeclared and immutable.</p>
       *
       * @param prefix The Namespace prefix being declared.
       *	An empty string is used for the default element namespace,
       *	which has no prefix.
       * @param uri The Namespace URI the prefix is mapped to.
       * @exception org.xml.sax.SAXException The client may throw
       *            an exception during processing.
       * @see #endPrefixMapping
       * @see #startElement
       */
      public void startPrefixMapping(String prefix, String uri) throws SAXException {
          contentHandler.startPrefixMapping(prefix, uri);
      }
  
      /**
       * End the scope of a prefix-URI mapping.
       *
       * <p>See {@link #startPrefixMapping startPrefixMapping} for 
       * details.  These events will always occur immediately after the
       * corresponding {@link #endElement endElement} event, but the order of 
       * {@link #endPrefixMapping endPrefixMapping} events is not otherwise
       * guaranteed.</p>
       *
       * @param prefix The prefix that was being mapped.
       *	This is the empty string when a default mapping scope ends.
       * @exception org.xml.sax.SAXException The client may throw
       *            an exception during processing.
       * @see #startPrefixMapping
       * @see #endElement
       */
      public void endPrefixMapping (String prefix) throws SAXException {
          contentHandler.endPrefixMapping(prefix);
      }
  
  
      /**
       * Receive notification of the beginning of an element.
       *
       * <p>The Parser will invoke this method at the beginning of every
       * element in the XML document; there will be a corresponding
       * {@link #endElement endElement} event for every startElement event
       * (even when the element is empty). All of the element's content will be
       * reported, in order, before the corresponding endElement
       * event.</p>
       *
       * <p>This event allows up to three name components for each
       * element:</p>
       *
       * <ol>
       * <li>the Namespace URI;</li>
       * <li>the local name; and</li>
       * <li>the qualified (prefixed) name.</li>
       * </ol>
       *
       * <p>Any or all of these may be provided, depending on the
       * values of the <var>http://xml.org/sax/features/namespaces</var>
       * and the <var>http://xml.org/sax/features/namespace-prefixes</var>
       * properties:</p>
       *
       * <ul>
       * <li>the Namespace URI and local name are required when 
       * the namespaces property is <var>true</var> (the default), and are
       * optional when the namespaces property is <var>false</var> (if one is
       * specified, both must be);</li>
       * <li>the qualified name is required when the namespace-prefixes property
       * is <var>true</var>, and is optional when the namespace-prefixes property
       * is <var>false</var> (the default).</li>
       * </ul>
       *
       * <p>Note that the attribute list provided will contain only
       * attributes with explicit values (specified or defaulted):
       * #IMPLIED attributes will be omitted.  The attribute list
       * will contain attributes used for Namespace declarations
       * (xmlns* attributes) only if the
       * <code>http://xml.org/sax/features/namespace-prefixes</code>
       * property is true (it is false by default, and support for a 
       * true value is optional).</p>
       *
       * <p>Like {@link #characters characters()}, attribute values may have
       * characters that need more than one <code>char</code> value.  </p>
       *
       * @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 atts The attributes attached to the element.  If
       *        there are no attributes, it shall be an empty
       *        Attributes object.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see #endElement
       * @see org.xml.sax.Attributes
       */
      public void startElement(
          String uri, String localName, String qName, Attributes atts 
      ) throws SAXException {
          contentHandler.startElement(uri, localName, qName, atts);
      }
  
  
      /**
       * Receive notification of the end of an element.
       *
       * <p>The SAX parser will invoke this method at the end of every
       * element in the XML document; there will be a corresponding
       * {@link #startElement startElement} event for every endElement 
       * event (even when the element is empty).</p>
       *
       * <p>For information on the names, see startElement.</p>
       *
       * @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 org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       */
      public void endElement(
          String uri, String localName,
  	String qName
      ) throws SAXException {
          contentHandler.endElement(uri, localName, qName);
      }
  
  
      /**
       * Receive notification of character data.
       *
       * <p>The Parser will call this method to report each chunk of
       * character data.  SAX parsers may return all contiguous character
       * data in a single chunk, or they may split it into several
       * chunks; however, all of the characters in any single event
       * must come from the same external entity so that the Locator
       * provides useful information.</p>
       *
       * <p>The application must not attempt to read from the array
       * outside of the specified range.</p>
       *
       * <p>Individual characters may consist of more than one Java
       * <code>char</code> value.  There are two important cases where this
       * happens, because characters can't be represented in just sixteen bits.
       * In one case, characters are represented in a <em>Surrogate Pair</em>,
       * using two special Unicode values. Such characters are in the so-called
       * "Astral Planes", with a code point above U+FFFF.  A second case involves
       * composite characters, such as a base character combining with one or
       * more accent characters. </p>
       *
       * <p> Your code should not assume that algorithms using
       * <code>char</code>-at-a-time idioms will be working in character
       * units; in some cases they will split characters.  This is relevant
       * wherever XML permits arbitrary characters, such as attribute values,
       * processing instruction data, and comments as well as in data reported
       * from this method.  It's also generally relevant whenever Java code
       * manipulates internationalized text; the issue isn't unique to XML.</p>
       *
       * <p>Note that some parsers will report whitespace in element
       * content using the {@link #ignorableWhitespace ignorableWhitespace}
       * method rather than this one (validating parsers <em>must</em> 
       * do so).</p>
       *
       * @param ch The characters from the XML document.
       * @param start The start position in the array.
       * @param length The number of characters to read from the array.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see #ignorableWhitespace 
       * @see org.xml.sax.Locator
       */
      public void characters (char ch[], int start, int length) throws SAXException {
          contentHandler.characters(ch, start, length);
      }
  
  
      /**
       * Receive notification of ignorable whitespace in element content.
       *
       * <p>Validating Parsers must use this method to report each chunk
       * of whitespace in element content (see the W3C XML 1.0 recommendation,
       * section 2.10): non-validating parsers may also use this method
       * if they are capable of parsing and using content models.</p>
       *
       * <p>SAX parsers may return all contiguous whitespace in a single
       * chunk, or they may split it into several chunks; however, all of
       * the characters in any single event must come from the same
       * external entity, so that the Locator provides useful
       * information.</p>
       *
       * <p>The application must not attempt to read from the array
       * outside of the specified range.</p>
       *
       * @param ch The characters from the XML document.
       * @param start The start position in the array.
       * @param length The number of characters to read from the array.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       * @see #characters
       */
      public void ignorableWhitespace(char ch[], int start, int length) throws SAXException {
          contentHandler.ignorableWhitespace(ch, start, length);
      }
  
      /**
       * Receive notification of a processing instruction.
       *
       * <p>The Parser will invoke this method once for each processing
       * instruction found: note that processing instructions may occur
       * before or after the main document element.</p>
       *
       * <p>A SAX parser must never report an XML declaration (XML 1.0,
       * section 2.8) or a text declaration (XML 1.0, section 4.3.1)
       * using this method.</p>
       *
       * <p>Like {@link #characters characters()}, processing instruction
       * data may have characters that need more than one <code>char</code>
       * value. </p>
       *
       * @param target The processing instruction target.
       * @param data The processing instruction data, or null if
       *        none was supplied.  The data does not include any
       *        whitespace separating it from the target.
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       */
      public void processingInstruction(String target, String data) throws SAXException{        
          contentHandler.processingInstruction(target, data);
      }
  
      /**
       * Receive notification of a skipped entity.
       * This is not called for entity references within markup constructs
       * such as element start tags or markup declarations.  (The XML
       * recommendation requires reporting skipped external entities.
       * SAX also reports internal entity expansion/non-expansion, except
       * within markup constructs.)
       *
       * <p>The Parser will invoke this method each time the entity is
       * skipped.  Non-validating processors may skip entities if they
       * have not seen the declarations (because, for example, the
       * entity was declared in an external DTD subset).  All processors
       * may skip external entities, depending on the values of the
       * <code>http://xml.org/sax/features/external-general-entities</code>
       * and the
       * <code>http://xml.org/sax/features/external-parameter-entities</code>
       * properties.</p>
       *
       * @param name The name of the skipped entity.  If it is a 
       *        parameter entity, the name will begin with '%', and if
       *        it is the external DTD subset, it will be the string
       *        "[dtd]".
       * @exception org.xml.sax.SAXException Any SAX exception, possibly
       *            wrapping another exception.
       */
      public void skippedEntity(String name) throws SAXException {
          contentHandler.skippedEntity(name);
      }
      
  
      // Lexical Handler interface
      //-------------------------------------------------------------------------                    
      
      /**
       * Report the start of DTD declarations, if any.
       *
       * <p>This method is intended to report the beginning of the
       * DOCTYPE declaration; if the document has no DOCTYPE declaration,
       * this method will not be invoked.</p>
       *
       * <p>All declarations reported through 
       * {@link org.xml.sax.DTDHandler DTDHandler} or
       * {@link org.xml.sax.ext.DeclHandler DeclHandler} events must appear
       * between the startDTD and {@link #endDTD endDTD} events.
       * Declarations are assumed to belong to the internal DTD subset
       * unless they appear between {@link #startEntity startEntity}
       * and {@link #endEntity endEntity} events.  Comments and
       * processing instructions from the DTD should also be reported
       * between the startDTD and endDTD events, in their original 
       * order of (logical) occurrence; they are not required to
       * appear in their correct locations relative to DTDHandler
       * or DeclHandler events, however.</p>
       *
       * <p>Note that the start/endDTD events will appear within
       * the start/endDocument events from ContentHandler and
       * before the first 
       * {@link org.xml.sax.ContentHandler#startElement startElement}
       * event.</p>
       *
       * @param name The document type name.
       * @param publicId The declared public identifier for the
       *        external DTD subset, or null if none was declared.
       * @param systemId The declared system identifier for the
       *        external DTD subset, or null if none was declared.
       *        (Note that this is not resolved against the document
       *        base URI.)
       * @exception SAXException The application may raise an
       *            exception.
       * @see #endDTD
       * @see #startEntity
       */
      public void startDTD(
          String name, String publicId, String systemId
      ) throws SAXException {
          if ( lexicalHandler != null ) {
              lexicalHandler.startDTD(name, publicId, systemId);
          }
      }
  
  
      /**
       * Report the end of DTD declarations.
       *
       * <p>This method is intended to report the end of the
       * DOCTYPE declaration; if the document has no DOCTYPE declaration,
       * this method will not be invoked.</p>
       *
       * @exception SAXException The application may raise an exception.
       * @see #startDTD
       */
      public void endDTD() throws SAXException {
          if ( lexicalHandler != null ) {
              lexicalHandler.endDTD();
          }
      }
  
  
      /**
       * Report the beginning of some internal and external XML entities.
       *
       * <p>The reporting of parameter entities (including
       * the external DTD subset) is optional, and SAX2 drivers that
       * report LexicalHandler events may not implement it; you can use the
       * <code
       * >http://xml.org/sax/features/lexical-handler/parameter-entities</code>
       * feature to query or control the reporting of parameter entities.</p>
       *
       * <p>General entities are reported with their regular names,
       * parameter entities have '%' prepended to their names, and 
       * the external DTD subset has the pseudo-entity name "[dtd]".</p>
       *
       * <p>When a SAX2 driver is providing these events, all other 
       * events must be properly nested within start/end entity 
       * events.  There is no additional requirement that events from 
       * {@link org.xml.sax.ext.DeclHandler DeclHandler} or
       * {@link org.xml.sax.DTDHandler DTDHandler} be properly ordered.</p>
       *
       * <p>Note that skipped entities will be reported through the
       * {@link org.xml.sax.ContentHandler#skippedEntity skippedEntity}
       * event, which is part of the ContentHandler interface.</p>
       *
       * <p>Because of the streaming event model that SAX uses, some
       * entity boundaries cannot be reported under any 
       * circumstances:</p>
       *
       * <ul>
       * <li>general entities within attribute values</li>
       * <li>parameter entities within declarations</li>
       * </ul>
       *
       * <p>These will be silently expanded, with no indication of where
       * the original entity boundaries were.</p>
       *
       * <p>Note also that the boundaries of character references (which
       * are not really entities anyway) are not reported.</p>
       *
       * <p>All start/endEntity events must be properly nested.
       *
       * @param name The name of the entity.  If it is a parameter
       *        entity, the name will begin with '%', and if it is the
       *        external DTD subset, it will be "[dtd]".
       * @exception SAXException The application may raise an exception.
       * @see #endEntity
       * @see org.xml.sax.ext.DeclHandler#internalEntityDecl
       * @see org.xml.sax.ext.DeclHandler#externalEntityDecl 
       */
      public void startEntity(String name) throws SAXException {
          if ( lexicalHandler != null ) {
              lexicalHandler.startEntity(name);
          }
      }
  
  
      /**
       * Report the end of an entity.
       *
       * @param name The name of the entity that is ending.
       * @exception SAXException The application may raise an exception.
       * @see #startEntity
       */
      public void endEntity(String name) throws SAXException {
          if ( lexicalHandler != null ) {
              lexicalHandler.endEntity(name);
          }
      }
  
  
      /**
       * Report the start of a CDATA section.
       *
       * <p>The contents of the CDATA section will be reported through
       * the regular {@link org.xml.sax.ContentHandler#characters
       * characters} event; this event is intended only to report
       * the boundary.</p>
       *
       * @exception SAXException The application may raise an exception.
       * @see #endCDATA
       */
      public void startCDATA() throws SAXException {
          if ( lexicalHandler != null ) {
              lexicalHandler.startCDATA();
          }
      }
  
  
      /**
       * Report the end of a CDATA section.
       *
       * @exception SAXException The application may raise an exception.
       * @see #startCDATA
       */
      public void endCDATA() throws SAXException {
          if ( lexicalHandler != null ) {
              lexicalHandler.endCDATA();
          }
      }
  
  
      /**
       * Report an XML comment anywhere in the document.
       *
       * <p>This callback will be used for comments inside or outside the
       * document element, including comments in the external DTD
       * subset (if read).  Comments in the DTD must be properly
       * nested inside start/endDTD and start/endEntity events (if
       * used).</p>
       *
       * @param ch An array holding the characters in the comment.
       * @param start The starting position in the array.
       * @param length The number of characters to use from the array.
       * @exception SAXException The application may raise an exception.
       */
      public void comment(char ch[], int start, int length)  throws SAXException {
          if ( lexicalHandler != null ) {
              lexicalHandler.comment(ch, start, length);
          }
      }
  
      
      // Properties
      //-------------------------------------------------------------------------                    
      
      /**
       * @return the SAX ContentHandler to use to pipe SAX events into
       */
      public ContentHandler getContentHandler() {
          return contentHandler;
      }
  
      /**
       * Sets the SAX ContentHandler to pipe SAX events into
       *
       * @param contentHandler is the new ContentHandler to use. 
       *      This value cannot be null.
       */
      public void setContentHandler(ContentHandler contentHandler) {
          if (contentHandler == null ) {
              throw new NullPointerException( "ContentHandler cannot be null!" );
          }
          this.contentHandler = contentHandler;
      }
  
      /**
       * @return the SAX LexicalHandler to use to pipe SAX events into
       */
      public LexicalHandler getLexicalHandler() {
          return lexicalHandler;
      }
  
      /**
       * Sets the SAX LexicalHandler to pipe SAX events into
       *
       * @param lexicalHandler is the new LexicalHandler to use. 
       *      This value can be null.
       */
      public void setLexicalHandler(LexicalHandler lexicalHandler) {
          this.lexicalHandler = lexicalHandler;
      }
  }
  
  
  
  1.3       +8 -7      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/ScriptBlock.java
  
  Index: ScriptBlock.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/ScriptBlock.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ScriptBlock.java	12 Feb 2002 21:34:34 -0000	1.2
  +++ ScriptBlock.java	24 Apr 2002 11:59:12 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/ScriptBlock.java,v 1.2 2002/02/12 21:34:34 jstrachan Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/02/12 21:34:34 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/ScriptBlock.java,v 1.3 2002/04/24 11:59:12 jstrachan Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/04/24 11:59:12 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: ScriptBlock.java,v 1.2 2002/02/12 21:34:34 jstrachan Exp $
  + * $Id: ScriptBlock.java,v 1.3 2002/04/24 11:59:12 jstrachan Exp $
    */
   package org.apache.commons.jelly.impl;
   
  @@ -68,11 +68,12 @@
   
   import org.apache.commons.jelly.Context;
   import org.apache.commons.jelly.Script;
  +import org.apache.commons.jelly.XMLOutput;
   
   /** <p><code>ScriptBlock</code> a block of scripts.</p>
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.2 $
  +  * @version $Revision: 1.3 $
     */
   public class ScriptBlock implements Script {
       
  @@ -133,10 +134,10 @@
       }
       
       /** Evaluates the body of a tag */
  -    public void run(Context context, Writer writer) throws Exception {
  +    public void run(Context context, XMLOutput output) throws Exception {
           for ( int i = 0, size = scripts.length; i < size; i++ ) {
               Script script = scripts[i];
  -            script.run( context, writer );
  +            script.run( context, output );
           }
       }    
   }
  
  
  
  1.6       +8 -7      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/TagScript.java
  
  Index: TagScript.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/TagScript.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TagScript.java	19 Feb 2002 15:40:58 -0000	1.5
  +++ TagScript.java	24 Apr 2002 11:59:12 -0000	1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/TagScript.java,v 1.5 2002/02/19 15:40:58 jstrachan Exp $
  - * $Revision: 1.5 $
  - * $Date: 2002/02/19 15:40:58 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/TagScript.java,v 1.6 2002/04/24 11:59:12 jstrachan Exp $
  + * $Revision: 1.6 $
  + * $Date: 2002/04/24 11:59:12 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    *
  - * $Id: TagScript.java,v 1.5 2002/02/19 15:40:58 jstrachan Exp $
  + * $Id: TagScript.java,v 1.6 2002/04/24 11:59:12 jstrachan Exp $
    */
   package org.apache.commons.jelly.impl;
   
  @@ -78,6 +78,7 @@
   import org.apache.commons.jelly.Context;
   import org.apache.commons.jelly.Script;
   import org.apache.commons.jelly.Tag;
  +import org.apache.commons.jelly.XMLOutput;
   import org.apache.commons.jelly.expression.Expression;
   
   import org.apache.commons.logging.Log;
  @@ -86,7 +87,7 @@
   /** <p><code>TagScript</code> evaluates a custom tag.</p>
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.5 $
  +  * @version $Revision: 1.6 $
     */
   public class TagScript implements Script {
       
  @@ -183,7 +184,7 @@
       }
       
       /** Evaluates the body of a tag */
  -    public void run(Context context, Writer writer) throws Exception {
  +    public void run(Context context, XMLOutput output) 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++ ) {
  @@ -209,7 +210,7 @@
               Object[] arguments = { value };
               method.invoke( tag, arguments );
           }        
  -        tag.run( context, writer );
  +        tag.run( context, output );
       }
       
       // Properties
  
  
  
  1.2       +8 -7      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/TextScript.java
  
  Index: TextScript.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/TextScript.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TextScript.java	11 Feb 2002 00:27:41 -0000	1.1
  +++ TextScript.java	24 Apr 2002 11:59:12 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $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 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/TextScript.java,v 1.2 2002/04/24 11:59:12 jstrachan Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/24 11:59:12 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * 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 $
  + * $Id: TextScript.java,v 1.2 2002/04/24 11:59:12 jstrachan Exp $
    */
   package org.apache.commons.jelly.impl;
   
  @@ -65,11 +65,12 @@
   
   import org.apache.commons.jelly.Context;
   import org.apache.commons.jelly.Script;
  +import org.apache.commons.jelly.XMLOutput;
   
   /** <p><code>TextScript</code> outputs some static text.</p>
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.1 $
  +  * @version $Revision: 1.2 $
     */
   public class TextScript implements Script {
       
  @@ -106,7 +107,7 @@
       }
       
       /** Evaluates the body of a tag */
  -    public void run(Context context, Writer writer) throws Exception {
  -        writer.write( text );
  +    public void run(Context context, XMLOutput output) throws Exception {
  +        output.write( text );
       }    
   }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/StaticTag.java
  
  Index: StaticTag.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/StaticTag.java,v 1.1 2002/04/24 11:59:12 jstrachan Exp $
   * $Revision: 1.1 $
   * $Date: 2002/04/24 11:59:12 $
   *
   * ====================================================================
   *
   * 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: StaticTag.java,v 1.1 2002/04/24 11:59:12 jstrachan Exp $
   */
  package org.apache.commons.jelly.impl;
  
  import org.apache.commons.jelly.Context;
  import org.apache.commons.jelly.DynaTag;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  
  import org.xml.sax.Attributes;
  import org.xml.sax.helpers.AttributesImpl;
  
  /** 
   * <p><code>StaticTag</code> represents a static XML element
   * which echos itself to XMLOutput when it is invoked.</p>
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.1 $
   */
  public class StaticTag extends TagSupport implements DynaTag {
      
      /** The namespace URI */
      private String uri;
      /** The qualified name */
      private String qname;
      /** The local name */
      private String localName;
      /** The XML Attributes */
      private AttributesImpl attributes = new AttributesImpl();
      
      public StaticTag() {
      }
      
      public StaticTag(String uri, String localName) {
          this.uri = uri;
          this.localName = localName;
          this.qname = localName;
      }
      
      public String toString() {
          return super.toString() + "[qname=" + qname + ";attributes=" + attributes+ "]";
      }
  
      // Tag interface
      //-------------------------------------------------------------------------                    
      public void run(Context context, XMLOutput output) throws Exception {
          output.startElement( uri, localName, qname, attributes );
          
          getBody().run(context, output);
          
          output.endElement( uri, localName, qname );
      }    
      
      // DynaTag interface
      //-------------------------------------------------------------------------                    
      public void setAttribute(String name, Object value) {
          // ### we'll assume that all attributes are in no namespace!
          // ### this is severely limiting!
          // ### - Tag attributes should allow for namespace aware 
          int index = attributes.getIndex( "", name );
          if ( index > 0 ) {
              attributes.removeAttribute( index );
          }
          
          // treat null values as no attribute 
          if ( value != null ) {
              attributes.addAttribute( "", name, name, "CDATA", value.toString() );
          }
      }
      
      // Properties
      //-------------------------------------------------------------------------                    
      public String getURI() {
          return uri;
      }
      
      public void setURI(String uri) {
          this.uri = uri;
      }
  
      public String getQName() {
          return qname;
      }
      
      public void setQName(String qname) {
          this.qname = qname;
          
          int idx = qname.indexOf(':');
          if ( idx >= 0 ) {
              this.localName = qname.substring(idx+1);
          }
          else {
              this.localName = qname;
          }
      }
      
      public String getLocalName() {
          return localName;
      }
      
      public void setLocalName(String localName) {
          this.localName = localName;
          if ( qname == null || ! qname.endsWith( localName ) ) {
              localName = qname;
          }
      }
  }
  
  
  
  1.8       +37 -5     jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/parser/XMLParser.java
  
  Index: XMLParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/parser/XMLParser.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- XMLParser.java	7 Mar 2002 02:46:04 -0000	1.7
  +++ XMLParser.java	24 Apr 2002 11:59:12 -0000	1.8
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/parser/XMLParser.java,v 1.7 2002/03/07 02:46:04 jstrachan Exp $
  - * $Revision: 1.7 $
  - * $Date: 2002/03/07 02:46:04 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/parser/XMLParser.java,v 1.8 2002/04/24 11:59:12 jstrachan Exp $
  + * $Revision: 1.8 $
  + * $Date: 2002/04/24 11:59:12 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    *
  - * $Id: XMLParser.java,v 1.7 2002/03/07 02:46:04 jstrachan Exp $
  + * $Id: XMLParser.java,v 1.8 2002/04/24 11:59:12 jstrachan Exp $
    */
   package org.apache.commons.jelly.parser;
   
  @@ -88,6 +88,7 @@
   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.StaticTag;
   import org.apache.commons.jelly.impl.TagScript;
   import org.apache.commons.jelly.impl.TextScript;
   import org.apache.commons.jelly.expression.ConstantExpression;
  @@ -116,7 +117,7 @@
    * 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.7 $
  + * @version $Revision: 1.8 $
    */
   public class XMLParser extends DefaultHandler {
       
  @@ -622,6 +623,9 @@
           // if this is a tag then create a script to run it
           // otherwise pass the text to the current body
           tagScript = createTag( namespaceURI, localName, list );
  +        if ( tagScript == null ) {
  +            tagScript = createStaticTag( namespaceURI, localName, list );
  +        }
           tagScriptStack.add( tagScript );
   
           if ( tagScript != null ) {            
  @@ -1005,6 +1009,34 @@
           catch (Throwable e) {
               log.warn( "Could not create taglib or URI: " + namespaceURI + " tag name: " + localName, e );
               return null;
  +        }
  +    }
  +    
  +    /**
  +     * Factory method to create a static Tag that represents some static content.
  +     */
  +    protected TagScript createStaticTag( String namespaceURI, String localName, Attributes list ) throws SAXException {
  +        try {
  +            Tag tag = new StaticTag( namespaceURI, localName );
  +            
  +            TagScript script = new TagScript( tag );
  +                
  +            // 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 = getExpressionFactory().createExpression( attributeValue );
  +                if ( expression == null ) {
  +                    expression = createExpression( localName, attributeName, attributeValue );
  +                }
  +                script.addAttribute( attributeName, expression );
  +            }
  +            return script;
  +        }
  +        catch (Exception e) {
  +            log.warn( "Could not create static tag for URI: " + namespaceURI + " tag name: " + localName, e );
  +            throw createSAXException(e);
           }
       }
       
  
  
  
  1.2       +9 -8      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ChooseTag.java
  
  Index: ChooseTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ChooseTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ChooseTag.java	15 Feb 2002 18:25:06 -0000	1.1
  +++ ChooseTag.java	24 Apr 2002 11:59:13 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ChooseTag.java,v 1.1 2002/02/15 18:25:06 jstrachan Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/02/15 18:25:06 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ChooseTag.java,v 1.2 2002/04/24 11:59:13 jstrachan Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/24 11:59:13 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: ChooseTag.java,v 1.1 2002/02/15 18:25:06 jstrachan Exp $
  + * $Id: ChooseTag.java,v 1.2 2002/04/24 11:59:13 jstrachan Exp $
    */
   package org.apache.commons.jelly.tags.core;
   
  @@ -72,6 +72,7 @@
   import org.apache.commons.jelly.Script;
   import org.apache.commons.jelly.Tag;
   import org.apache.commons.jelly.TagSupport;
  +import org.apache.commons.jelly.XMLOutput;
   import org.apache.commons.jelly.impl.ScriptBlock;
   import org.apache.commons.jelly.impl.TagScript;
   import org.apache.commons.jelly.expression.Expression;
  @@ -79,7 +80,7 @@
   /** A tag which conditionally evaluates its body based on some condition
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.1 $
  +  * @version $Revision: 1.2 $
     */
   public class ChooseTag extends TagSupport implements CompilableTag {
       
  @@ -133,17 +134,17 @@
   
       // Tag interface
       //------------------------------------------------------------------------- 
  -    public void run(Context context, Writer writer) throws Exception {
  +    public void run(Context context, XMLOutput output) throws Exception {
           for ( int i = 0, size = whenTags.length; i < size; i++ ) {
               TagScript script = whenTags[i];
  -            script.run( context, writer );
  +            script.run( context, output );
               WhenTag tag = (WhenTag) script.getTag();
               if ( tag.getValue() ) {
                   return;
               }
           }
           if ( otherwiseTag != null ) {
  -            otherwiseTag.run( context, writer );
  +            otherwiseTag.run( context, output );
           }
       }
   }
  
  
  
  1.4       +8 -10     jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ExprTag.java
  
  Index: ExprTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ExprTag.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ExprTag.java	19 Feb 2002 15:40:58 -0000	1.3
  +++ ExprTag.java	24 Apr 2002 11:59:13 -0000	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ExprTag.java,v 1.3 2002/02/19 15:40:58 jstrachan Exp $
  - * $Revision: 1.3 $
  - * $Date: 2002/02/19 15:40:58 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ExprTag.java,v 1.4 2002/04/24 11:59:13 jstrachan Exp $
  + * $Revision: 1.4 $
  + * $Date: 2002/04/24 11:59:13 $
    *
    * ====================================================================
    *
  @@ -57,16 +57,14 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: ExprTag.java,v 1.3 2002/02/19 15:40:58 jstrachan Exp $
  + * $Id: ExprTag.java,v 1.4 2002/04/24 11:59:13 jstrachan Exp $
    */
   package org.apache.commons.jelly.tags.core;
   
  -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.TagSupport;
  +import org.apache.commons.jelly.XMLOutput;
   import org.apache.commons.jelly.expression.Expression;
   
   import org.apache.commons.logging.Log;
  @@ -75,7 +73,7 @@
   /** A tag which evaluates an expression
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.3 $
  +  * @version $Revision: 1.4 $
     */
   public class ExprTag extends TagSupport {
   
  @@ -90,11 +88,11 @@
   
       // Tag interface
       //------------------------------------------------------------------------- 
  -    public void run(Context context, Writer writer) throws IOException {
  +    public void run(Context context, XMLOutput output) throws Exception {
           if ( value != null ) {
               String text = value.evaluateAsString( context );            
               if ( text != null ) {
  -                writer.write( text );
  +                output.write( text );
               }
           }
       }
  
  
  
  1.4       +8 -7      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ForEachTag.java
  
  Index: ForEachTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ForEachTag.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ForEachTag.java	19 Feb 2002 15:40:58 -0000	1.3
  +++ ForEachTag.java	24 Apr 2002 11:59:13 -0000	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ForEachTag.java,v 1.3 2002/02/19 15:40:58 jstrachan Exp $
  - * $Revision: 1.3 $
  - * $Date: 2002/02/19 15:40:58 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ForEachTag.java,v 1.4 2002/04/24 11:59:13 jstrachan Exp $
  + * $Revision: 1.4 $
  + * $Date: 2002/04/24 11:59:13 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: ForEachTag.java,v 1.3 2002/02/19 15:40:58 jstrachan Exp $
  + * $Id: ForEachTag.java,v 1.4 2002/04/24 11:59:13 jstrachan Exp $
    */
   package org.apache.commons.jelly.tags.core;
   
  @@ -69,6 +69,7 @@
   import org.apache.commons.jelly.Context;
   import org.apache.commons.jelly.Script;
   import org.apache.commons.jelly.TagSupport;
  +import org.apache.commons.jelly.XMLOutput;
   import org.apache.commons.jelly.expression.Expression;
   
   import org.apache.commons.logging.Log;
  @@ -78,7 +79,7 @@
   /** 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.3 $
  +  * @version $Revision: 1.4 $
     */
   public class ForEachTag extends TagSupport {
   
  @@ -111,7 +112,7 @@
   
       // Tag interface
       //------------------------------------------------------------------------- 
  -    public void run(Context context, Writer writer) throws Exception {
  +    public void run(Context context, XMLOutput output) throws Exception {
           if ( log.isDebugEnabled() ) {
               log.debug( "running with items: " + items );
           }
  @@ -131,7 +132,7 @@
                   if ( indexVar != null ) {
                       context.setVariable( indexVar, new Integer(index) );
                   }
  -                getBody().run( context, writer );
  +                getBody().run( context, output );
               }
           }
       }
  
  
  
  1.2       +8 -7      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/IfTag.java
  
  Index: IfTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/IfTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IfTag.java	15 Feb 2002 18:25:06 -0000	1.1
  +++ IfTag.java	24 Apr 2002 11:59:13 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/IfTag.java,v 1.1 2002/02/15 18:25:06 jstrachan Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/02/15 18:25:06 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/IfTag.java,v 1.2 2002/04/24 11:59:13 jstrachan Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/24 11:59:13 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: IfTag.java,v 1.1 2002/02/15 18:25:06 jstrachan Exp $
  + * $Id: IfTag.java,v 1.2 2002/04/24 11:59:13 jstrachan Exp $
    */
   package org.apache.commons.jelly.tags.core;
   
  @@ -67,12 +67,13 @@
   import org.apache.commons.jelly.Context;
   import org.apache.commons.jelly.Script;
   import org.apache.commons.jelly.TagSupport;
  +import org.apache.commons.jelly.XMLOutput;
   import org.apache.commons.jelly.expression.Expression;
   
   /** A tag which conditionally evaluates its body based on some condition
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.1 $
  +  * @version $Revision: 1.2 $
     */
   public class IfTag extends TagSupport {
   
  @@ -84,10 +85,10 @@
   
       // Tag interface
       //------------------------------------------------------------------------- 
  -    public void run(Context context, Writer writer) throws Exception {
  +    public void run(Context context, XMLOutput output) throws Exception {
           if ( test != null ) {
               if ( test.evaluateAsBoolean( context ) ) {
  -                getBody().run( context, writer );
  +                getBody().run( context, output );
               }
           }
       }
  
  
  
  1.3       +8 -7      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/JellyTag.java
  
  Index: JellyTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/JellyTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- JellyTag.java	19 Feb 2002 15:40:58 -0000	1.2
  +++ JellyTag.java	24 Apr 2002 11:59:13 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/JellyTag.java,v 1.2 2002/02/19 15:40:58 jstrachan Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/02/19 15:40:58 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/JellyTag.java,v 1.3 2002/04/24 11:59:13 jstrachan Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/04/24 11:59:13 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: JellyTag.java,v 1.2 2002/02/19 15:40:58 jstrachan Exp $
  + * $Id: JellyTag.java,v 1.3 2002/04/24 11:59:13 jstrachan Exp $
    */
   package org.apache.commons.jelly.tags.core;
   
  @@ -68,6 +68,7 @@
   import org.apache.commons.jelly.Context;
   import org.apache.commons.jelly.Script;
   import org.apache.commons.jelly.TagSupport;
  +import org.apache.commons.jelly.XMLOutput;
   import org.apache.commons.jelly.expression.Expression;
   import org.apache.commons.jelly.impl.ScriptBlock;
   import org.apache.commons.jelly.impl.TextScript;
  @@ -79,7 +80,7 @@
   /** The root Jelly tag which should be evaluated first
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.2 $
  +  * @version $Revision: 1.3 $
     */
   public class JellyTag extends TagSupport {
   
  @@ -97,7 +98,7 @@
   
       // Tag interface
       //------------------------------------------------------------------------- 
  -    public void run(Context context, Writer writer) throws Exception {
  +    public void run(Context context, XMLOutput output) throws Exception {
           if ( trim && ! hasTrimmed ) {
               trimBody();
               hasTrimmed = true;
  @@ -105,7 +106,7 @@
           if ( log.isDebugEnabled() ) {
               log.debug( "Running body: " + getBody() );
           }
  -        getBody().run( context, writer );
  +        getBody().run( context, output );
       }
   
       // Properties
  
  
  
  1.2       +8 -7      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/OtherwiseTag.java
  
  Index: OtherwiseTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/OtherwiseTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- OtherwiseTag.java	15 Feb 2002 18:25:06 -0000	1.1
  +++ OtherwiseTag.java	24 Apr 2002 11:59:13 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/OtherwiseTag.java,v 1.1 2002/02/15 18:25:06 jstrachan Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/02/15 18:25:06 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/OtherwiseTag.java,v 1.2 2002/04/24 11:59:13 jstrachan Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/24 11:59:13 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: OtherwiseTag.java,v 1.1 2002/02/15 18:25:06 jstrachan Exp $
  + * $Id: OtherwiseTag.java,v 1.2 2002/04/24 11:59:13 jstrachan Exp $
    */
   package org.apache.commons.jelly.tags.core;
   
  @@ -67,12 +67,13 @@
   import org.apache.commons.jelly.Context;
   import org.apache.commons.jelly.Script;
   import org.apache.commons.jelly.TagSupport;
  +import org.apache.commons.jelly.XMLOutput;
   import org.apache.commons.jelly.expression.Expression;
   
   /** The otherwise block of a choose/when/otherwise group of tags
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.1 $
  +  * @version $Revision: 1.2 $
     */
   public class OtherwiseTag extends TagSupport {
   
  @@ -81,7 +82,7 @@
   
       // Tag interface
       //------------------------------------------------------------------------- 
  -    public void run(Context context, Writer writer) throws Exception {
  -        getBody().run( context, writer );
  +    public void run(Context context, XMLOutput output) throws Exception {
  +        getBody().run( context, output );
       }
   }
  
  
  
  1.2       +5 -4      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/SetTag.java
  
  Index: SetTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/SetTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SetTag.java	12 Feb 2002 21:34:34 -0000	1.1
  +++ SetTag.java	24 Apr 2002 11:59:13 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/SetTag.java,v 1.1 2002/02/12 21:34:34 jstrachan Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/02/12 21:34:34 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/SetTag.java,v 1.2 2002/04/24 11:59:13 jstrachan Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/24 11:59:13 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: SetTag.java,v 1.1 2002/02/12 21:34:34 jstrachan Exp $
  + * $Id: SetTag.java,v 1.2 2002/04/24 11:59:13 jstrachan Exp $
    */
   package org.apache.commons.jelly.tags.core;
   
  @@ -66,12 +66,13 @@
   import org.apache.commons.jelly.Context;
   import org.apache.commons.jelly.Script;
   import org.apache.commons.jelly.TagSupport;
  +import org.apache.commons.jelly.XMLOutput;
   import org.apache.commons.jelly.expression.Expression;
   
   /** A tag which sets a variable from the result of an expression 
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.1 $
  +  * @version $Revision: 1.2 $
     */
   public class SetTag extends TagSupport {
   
  @@ -85,7 +86,7 @@
   
       // Tag interface
       //------------------------------------------------------------------------- 
  -    public void run(Context context, Writer writer) throws Exception {
  +    public void run(Context context, XMLOutput output) throws Exception {
           if ( var == null ) {
               throw new IllegalArgumentException( "The var attribute cannot be null" );
           }
  
  
  
  1.2       +8 -7      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/WhenTag.java
  
  Index: WhenTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/WhenTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- WhenTag.java	15 Feb 2002 18:25:06 -0000	1.1
  +++ WhenTag.java	24 Apr 2002 11:59:13 -0000	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/WhenTag.java,v 1.1 2002/02/15 18:25:06 jstrachan Exp $
  - * $Revision: 1.1 $
  - * $Date: 2002/02/15 18:25:06 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/WhenTag.java,v 1.2 2002/04/24 11:59:13 jstrachan Exp $
  + * $Revision: 1.2 $
  + * $Date: 2002/04/24 11:59:13 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: WhenTag.java,v 1.1 2002/02/15 18:25:06 jstrachan Exp $
  + * $Id: WhenTag.java,v 1.2 2002/04/24 11:59:13 jstrachan Exp $
    */
   package org.apache.commons.jelly.tags.core;
   
  @@ -67,12 +67,13 @@
   import org.apache.commons.jelly.Context;
   import org.apache.commons.jelly.Script;
   import org.apache.commons.jelly.TagSupport;
  +import org.apache.commons.jelly.XMLOutput;
   import org.apache.commons.jelly.expression.Expression;
   
   /** A tag which conditionally evaluates its body based on some condition
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.1 $
  +  * @version $Revision: 1.2 $
     */
   public class WhenTag extends TagSupport {
   
  @@ -87,12 +88,12 @@
   
       // Tag interface
       //------------------------------------------------------------------------- 
  -    public void run(Context context, Writer writer) throws Exception {
  +    public void run(Context context, XMLOutput output) throws Exception {
           value = false;
           if ( test != null ) {            
               if ( test.evaluateAsBoolean( context ) ) {
                   value = true;
  -                getBody().run( context, writer );
  +                getBody().run( context, output );
               }
           }
       }
  
  
  
  1.3       +8 -10     jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/ExprTag.java
  
  Index: ExprTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/ExprTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ExprTag.java	12 Feb 2002 21:34:34 -0000	1.2
  +++ ExprTag.java	24 Apr 2002 11:59:13 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/ExprTag.java,v 1.2 2002/02/12 21:34:34 jstrachan Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/02/12 21:34:34 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/ExprTag.java,v 1.3 2002/04/24 11:59:13 jstrachan Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/04/24 11:59:13 $
    *
    * ====================================================================
    *
  @@ -57,16 +57,14 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: ExprTag.java,v 1.2 2002/02/12 21:34:34 jstrachan Exp $
  + * $Id: ExprTag.java,v 1.3 2002/04/24 11:59:13 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.TagSupport;
  +import org.apache.commons.jelly.XMLOutput;
   
   import org.dom4j.XPath;
   
  @@ -74,7 +72,7 @@
     * in XSLT
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.2 $
  +  * @version $Revision: 1.3 $
     */
   public class ExprTag extends TagSupport {
   
  @@ -86,10 +84,10 @@
   
       // Tag interface
       //------------------------------------------------------------------------- 
  -    public void run(Context context, Writer writer) throws IOException {
  +    public void run(Context context, XMLOutput output) throws Exception {
           if ( select != null ) {
               String text = select.valueOf( null );
  -            writer.write( text );
  +            output.write( text );
           }
       }
   
  
  
  
  1.3       +8 -9      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/ForEachTag.java
  
  Index: ForEachTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/ForEachTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ForEachTag.java	12 Feb 2002 21:34:34 -0000	1.2
  +++ ForEachTag.java	24 Apr 2002 11:59:13 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/ForEachTag.java,v 1.2 2002/02/12 21:34:34 jstrachan Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/02/12 21:34:34 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/ForEachTag.java,v 1.3 2002/04/24 11:59:13 jstrachan Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/04/24 11:59:13 $
    *
    * ====================================================================
    *
  @@ -57,18 +57,17 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: ForEachTag.java,v 1.2 2002/02/12 21:34:34 jstrachan Exp $
  + * $Id: ForEachTag.java,v 1.3 2002/04/24 11:59:13 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.TagSupport;
  +import org.apache.commons.jelly.XMLOutput;
   
   import org.dom4j.XPath;
   
  @@ -76,7 +75,7 @@
   /** 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.2 $
  +  * @version $Revision: 1.3 $
     */
   public class ForEachTag extends TagSupport {
   
  @@ -91,7 +90,7 @@
   
       // Tag interface
       //------------------------------------------------------------------------- 
  -    public void run(Context context, Writer writer) throws Exception {
  +    public void run(Context context, XMLOutput output) throws Exception {
           if ( select != null ) { 
               Iterator iter = select.selectNodes(null).iterator();
               while ( iter.hasNext() ) {
  @@ -99,7 +98,7 @@
                   if (var != null) {
                       context.setVariable( var, value );
                   }
  -                getBody().run( context, writer );
  +                getBody().run( context, output );
               }
           }
       }
  
  
  
  1.4       +24 -7     jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/ParseTag.java
  
  Index: ParseTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/ParseTag.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ParseTag.java	19 Feb 2002 15:40:58 -0000	1.3
  +++ ParseTag.java	24 Apr 2002 11:59:13 -0000	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/ParseTag.java,v 1.3 2002/02/19 15:40:58 jstrachan Exp $
  - * $Revision: 1.3 $
  - * $Date: 2002/02/19 15:40:58 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/ParseTag.java,v 1.4 2002/04/24 11:59:13 jstrachan Exp $
  + * $Revision: 1.4 $
  + * $Date: 2002/04/24 11:59:13 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: ParseTag.java,v 1.3 2002/02/19 15:40:58 jstrachan Exp $
  + * $Id: ParseTag.java,v 1.4 2002/04/24 11:59:13 jstrachan Exp $
    */
   package org.apache.commons.jelly.tags.xml;
   
  @@ -73,12 +73,14 @@
   import org.apache.commons.jelly.Context;
   import org.apache.commons.jelly.Script;
   import org.apache.commons.jelly.TagSupport;
  +import org.apache.commons.jelly.XMLOutput;
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
   
   import org.dom4j.Document;
   import org.dom4j.DocumentException;
  +import org.dom4j.io.SAXContentHandler;
   import org.dom4j.io.SAXReader;
   
   import org.xml.sax.SAXException;
  @@ -88,7 +90,7 @@
     * 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.3 $
  +  * @version $Revision: 1.4 $
     */
   public class ParseTag extends TagSupport {
   
  @@ -112,19 +114,34 @@
   
       // Tag interface
       //------------------------------------------------------------------------- 
  -    public void run(Context context, Writer writer) throws Exception {
  +    public void run(Context context, XMLOutput output) throws Exception {
           if ( var == null ) {
               throw new IllegalArgumentException( "The var attribute cannot be null" );
           }
           Document document = null;
           if ( source == null ) {
  -            // parse body
  +            SAXContentHandler handler = new SAXContentHandler();
  +            
  +            XMLOutput newOutput = new XMLOutput( handler );
  +            
  +            handler.startDocument();
  +            
  +            getBody().run( context, newOutput );
  +            
  +            handler.endDocument();
  +            
  +            document = handler.getDocument();
  +/*
  +            // the following is inefficient as it requires a parse of the text
  +            // but is left here in the code to see how it could be done.
  +
               String text = getBodyText( context );
               
               if ( log.isDebugEnabled() ) {
                   log.debug( "About to parse: " + text );
               }
               document = getSAXReader().read( new StringReader( text ) );
  +*/
           }
           else {
               if ( source instanceof String ) {
  
  
  
  1.3       +7 -6      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/SetTag.java
  
  Index: SetTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/SetTag.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SetTag.java	12 Feb 2002 21:34:34 -0000	1.2
  +++ SetTag.java	24 Apr 2002 11:59:13 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/SetTag.java,v 1.2 2002/02/12 21:34:34 jstrachan Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/02/12 21:34:34 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/SetTag.java,v 1.3 2002/04/24 11:59:13 jstrachan Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/04/24 11:59:13 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: SetTag.java,v 1.2 2002/02/12 21:34:34 jstrachan Exp $
  + * $Id: SetTag.java,v 1.3 2002/04/24 11:59:13 jstrachan Exp $
    */
   package org.apache.commons.jelly.tags.xml;
   
  @@ -66,13 +66,14 @@
   import org.apache.commons.jelly.Context;
   import org.apache.commons.jelly.Script;
   import org.apache.commons.jelly.TagSupport;
  +import org.apache.commons.jelly.XMLOutput;
   
   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.2 $
  +  * @version $Revision: 1.3 $
     */
   public class SetTag extends TagSupport {
   
  @@ -86,7 +87,7 @@
   
       // Tag interface
       //------------------------------------------------------------------------- 
  -    public void run(Context context, Writer writer) {
  +    public void run(Context context, XMLOutput output) {
           if ( var == null ) {
               throw new IllegalArgumentException( "The var attribute cannot be null" );
           }
  
  
  
  1.3       +7 -6      jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/TestCoreTags.java
  
  Index: TestCoreTags.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/TestCoreTags.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestCoreTags.java	19 Feb 2002 15:40:58 -0000	1.2
  +++ TestCoreTags.java	24 Apr 2002 11:59:13 -0000	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/TestCoreTags.java,v 1.2 2002/02/19 15:40:58 jstrachan Exp $
  - * $Revision: 1.2 $
  - * $Date: 2002/02/19 15:40:58 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/TestCoreTags.java,v 1.3 2002/04/24 11:59:13 jstrachan Exp $
  + * $Revision: 1.3 $
  + * $Date: 2002/04/24 11:59:13 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: TestCoreTags.java,v 1.2 2002/02/19 15:40:58 jstrachan Exp $
  + * $Id: TestCoreTags.java,v 1.3 2002/04/24 11:59:13 jstrachan Exp $
    */
   package org.apache.commons.jelly;
   
  @@ -72,6 +72,7 @@
   
   import org.apache.commons.jelly.Context;
   import org.apache.commons.jelly.Script;
  +import org.apache.commons.jelly.XMLOutput;
   import org.apache.commons.jelly.impl.TagScript;
   import org.apache.commons.jelly.parser.XMLParser;
   
  @@ -82,7 +83,7 @@
   /** Tests the core tags
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.2 $
  +  * @version $Revision: 1.3 $
     */
   public class TestCoreTags extends TestCase {
       
  @@ -116,7 +117,7 @@
           context.setVariable( "args", args );
           StringWriter buffer = new StringWriter();
           
  -        script.run( context, buffer );
  +        script.run( context, XMLOutput.createXMLOutput( buffer ) );
           
           String text = buffer.toString().trim();
           
  
  
  
  1.4       +7 -6      jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/TestXMLTags.java
  
  Index: TestXMLTags.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/TestXMLTags.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestXMLTags.java	19 Feb 2002 15:40:58 -0000	1.3
  +++ TestXMLTags.java	24 Apr 2002 11:59:13 -0000	1.4
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/TestXMLTags.java,v 1.3 2002/02/19 15:40:58 jstrachan Exp $
  - * $Revision: 1.3 $
  - * $Date: 2002/02/19 15:40:58 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/TestXMLTags.java,v 1.4 2002/04/24 11:59:13 jstrachan Exp $
  + * $Revision: 1.4 $
  + * $Date: 2002/04/24 11:59:13 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: TestXMLTags.java,v 1.3 2002/02/19 15:40:58 jstrachan Exp $
  + * $Id: TestXMLTags.java,v 1.4 2002/04/24 11:59:13 jstrachan Exp $
    */
   package org.apache.commons.jelly;
   
  @@ -72,6 +72,7 @@
   
   import org.apache.commons.jelly.Context;
   import org.apache.commons.jelly.Script;
  +import org.apache.commons.jelly.XMLOutput;
   import org.apache.commons.jelly.impl.TagScript;
   import org.apache.commons.jelly.parser.XMLParser;
   
  @@ -82,7 +83,7 @@
   /** Tests the parser, the engine and the XML tags
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.3 $
  +  * @version $Revision: 1.4 $
     */
   public class TestXMLTags extends TestCase {
       
  @@ -114,7 +115,7 @@
           Context context = new Context();        
           StringWriter buffer = new StringWriter();
           
  -        script.run( context, buffer );
  +        script.run( context, XMLOutput.createXMLOutput( buffer ) );
           
           String text = buffer.toString().trim();
           
  
  
  

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