cziegeler    2003/11/07 05:25:54

  Modified:    src/java/org/apache/cocoon/components/treeprocessor/sitemap
                        MountNode.java
               src/java/org/apache/cocoon/generation
                        JXTemplateGenerator.java
               src/webapp/WEB-INF web.xml
  Log:
  Adding bugfixes applied to 2.1 (totally forgot to commit these) 
  Thanks to Vadim for the reminder!
  
  Revision  Changes    Path
  1.10      +4 -2      
cocoon-2.2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java
  
  Index: MountNode.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/components/treeprocessor/sitemap/MountNode.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- MountNode.java    30 Oct 2003 11:30:12 -0000      1.9
  +++ MountNode.java    7 Nov 2003 13:25:54 -0000       1.10
  @@ -134,8 +134,10 @@
               // Restore context
                        env.setURI(oldPrefix, oldURI);
   
  +            // Turning recomposing as a test, according to:
  +            // http://marc.theaimsgroup.com/?t=106802211400005&r=1&w=2
               // Recompose pipelines which may have been recomposed by 
subsitemap
  -            context.recompose(this.manager);
  +            // context.recompose(this.manager);
           }
       }
   
  
  
  
  1.16      +474 -387  
cocoon-2.2/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java
  
  Index: JXTemplateGenerator.java
  ===================================================================
  RCS file: 
/home/cvs/cocoon-2.2/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- JXTemplateGenerator.java  27 Oct 2003 07:38:10 -0000      1.15
  +++ JXTemplateGenerator.java  7 Nov 2003 13:25:54 -0000       1.16
  @@ -1,4 +1,4 @@
  -/*
  +/* 
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -124,12 +124,12 @@
   import org.xml.sax.helpers.LocatorImpl;
   
   /**
  - * <p>(<em>JX</em> for <a 
href="http://jakarta.apache.org/commons/jxpath";>Apache <em>JX</em>Path</a>
  + * <p>(<em>JX</em> for <a 
href="http://jakarta.apache.org/commons/jxpath";>Apache <em>JX</em>Path</a> 
    * and <a href="http://jakarta.apache.org/commons/jexl";>Apache 
<em>J</em>e<em>x</em>l</a>).</p>
    * <p>Uses the namespace 
<code>http://apache.org/cocoon/templates/jx/1.0</code></p>
  - * <p>Provides a generic page template with embedded JSTL and XPath
  + * <p>Provides a generic page template with embedded JSTL and XPath 
    * expression substitution to access data sent by Cocoon Flowscripts.</p>
  - * The embedded expression language allows a page author to access an
  + * The embedded expression language allows a page author to access an 
    * object using a simplified syntax such as
    *
    *  <p><pre>
  @@ -138,10 +138,10 @@
    *
    * <p>Embedded JSTL expressions are contained in <code>${}</code>.</p>
    * <p>Embedded XPath expressions are contained in <code>#{}</code>.</p>
  - * <p>Note that since this generator uses
  - * <a href="http://jakarta.apache.org/commons/jxpath";>Apache JXPath</a>
  - * and <a href="http://jakarta.apache.org/commons/jexl";>Apache Jexl</a>, the
  - * referenced objects may be Java Beans, DOM, JDOM, or JavaScript objects 
from
  + * <p>Note that since this generator uses 
  + * <a href="http://jakarta.apache.org/commons/jxpath";>Apache JXPath</a> 
  + * and <a href="http://jakarta.apache.org/commons/jexl";>Apache Jexl</a>, the 
  + * referenced objects may be Java Beans, DOM, JDOM, or JavaScript objects 
from 
    * a Flowscript. In addition the following implicit objects are available as
    * both XPath and JSTL variables:</p>
    * <p>
  @@ -163,15 +163,15 @@
    * </dl>
    * </p>
    *
  - * The current Web Continuation from the Flowscript
  - * is also available as a variable named <code>continuation</code>. You would
  + * The current Web Continuation from the Flowscript 
  + * is also available as a variable named <code>continuation</code>. You 
would 
    * typically access its <code>id</code>:
    *
    * <p><pre>
    *    &lt;form action="${continuation.id}"&gt;
    * </pre></p>
    *
  - * <p>You can also reach previous continuations by using the
  + * <p>You can also reach previous continuations by using the 
    * <code>getContinuation()</code> function:</p>
    *
    * <p><pre>
  @@ -185,17 +185,17 @@
    *    &lt;/template&gt;
    * </pre></p>
    *
  - * <p>The <code>import</code> tag allows you to include another template
  - * within the current template. The content of the imported template is
  + * <p>The <code>import</code> tag allows you to include another template 
  + * within the current template. The content of the imported template is 
    * compiled and will be executed in place of the <code>import</code> 
tag:</p><pre>
    *    &lt;import uri="URI" [context="Expression"]/&gt;
  - * </pre></p><p>The Cocoon source resolver is used to resolve 
<code>uri</code>.
  - * If <code>context</code> is present, then its value is used as the context
  - * for evaluating the imported template, otherwise the current context is
  + * </pre></p><p>The Cocoon source resolver is used to resolve 
<code>uri</code>. 
  + * If <code>context</code> is present, then its value is used as the context 
  + * for evaluating the imported template, otherwise the current context is 
    * used.</p>
  - * <p>The <code>set</code> tag creates a local alias of an object. The
  - * <code>var</code> attribute specifies the name of a variable to assign the
  - * object to. The <code>value</code> attribute specifies the object (defaults
  + * <p>The <code>set</code> tag creates a local alias of an object. The 
  + * <code>var</code> attribute specifies the name of a variable to assign the 
  + * object to. The <code>value</code> attribute specifies the object 
(defaults 
    * to <code>body</code> if not present):</p>
    *
    * <pre>
  @@ -204,10 +204,10 @@
    *    &lt;/set&gt;
    * </pre></p>
    *
  - * <p>If used within a <code>macro</code> definition (see below)
  - * variables created by <code>set</code> are only visible within the body of
  + * <p>If used within a <code>macro</code> definition (see below) 
  + * variables created by <code>set</code> are only visible within the body of 
    * the <code>macro</code>.</p>
  - * <p>The <code>if</code> tag allows the conditional execution of its body
  + * <p>The <code>if</code> tag allows the conditional execution of its body 
    * according to value of a <code>test</code> attribute:</p>
    *
    * <p><pre>
  @@ -216,11 +216,11 @@
    *   &lt;/if&gt;
    * </pre></p>
    *
  - * <p>The <code>choose</code> tag performs conditional block execution by the
  - * embedded <code>when</code> sub tags. It renders the body of the first
  - * <code>when</code> tag whose <code>test</code> condition evaluates to true.
  + * <p>The <code>choose</code> tag performs conditional block execution by 
the 
  + * embedded <code>when</code> sub tags. It renders the body of the first 
  + * <code>when</code> tag whose <code>test</code> condition evaluates to 
true. 
    * If none of the <code>test</code> conditions of nested <code>when</code> 
tags
  - * evaluate to <code>true</code>, then the body of an <code>otherwise</code>
  + * evaluate to <code>true</code>, then the body of an <code>otherwise</code> 
    * tag is evaluated, if present:</p>
    *
    * <p><pre>
  @@ -234,40 +234,40 @@
    *  &lt;/choose&gt;
    * </pre></p>
    *
  - * <p>The <code>out</code> tag evaluates an expression and outputs
  + * <p>The <code>out</code> tag evaluates an expression and outputs 
    * the result of the evaluation:</p>
    *
    * <p><pre>
    * &lt;out value="Expression"/&gt;
    * </pre></p>
    *
  - * <p>The <code>forEach</code> tag allows you to iterate over a collection
  + * <p>The <code>forEach</code> tag allows you to iterate over a collection 
    * of objects:<p>
    *
    * <p><pre>
  - *   &lt;forEach [var="Name"] [items="Expression"]
  + *   &lt;forEach [var="Name"] [items="Expression"] 
                    [begin="Number"] [end="Number"] [step="Number"]&gt;
    *     body
    *  &lt;/forEach&gt;
    * </pre></p>
    *
  - * <p>The <code>items</code> attribute specifies the list of items to iterate
  - * over. The <code>var</code> attribute specifies the name of a variable to
  - * hold the current item. The <code>begin</code> attribute specifies the
  - * element to start with (<code>0</code> = first item,
  - * <code>1</code> = second item, ...).
  - * If unspecified it defaults to <code>0</code>. The <code>end</code>
  - * attribute specifies the item to end with (<code>0</code> = first item,
  - * <code>1</code> = second item, ...). If unspecified it defaults to the last
  + * <p>The <code>items</code> attribute specifies the list of items to 
iterate 
  + * over. The <code>var</code> attribute specifies the name of a variable to 
  + * hold the current item. The <code>begin</code> attribute specifies the 
  + * element to start with (<code>0</code> = first item, 
  + * <code>1</code> = second item, ...). 
  + * If unspecified it defaults to <code>0</code>. The <code>end</code> 
  + * attribute specifies the item to end with (<code>0</code> = first item, 
  + * <code>1</code> = second item, ...). If unspecified it defaults to the 
last 
    * item in the list. Every <code>step</code> items are
  - * processed (defaults to <code>1</code> if <code>step</code> is absent).
  - * Either <code>items</code> or both <code>begin</code> and <code>end</code>
  + * processed (defaults to <code>1</code> if <code>step</code> is absent). 
  + * Either <code>items</code> or both <code>begin</code> and <code>end</code> 
    * must be present.<p>
    *
    *
    *
    * <p>
  - * The <code>formatNumber</code> tag is used to display numeric data, 
including currencies and percentages, in a locale-specific manner. The 
<code>formatNumber</code>> action determines from the locale, for example, 
whether to use a period or a comma for delimiting the integer and decimal 
portions of a number. Here is its syntax:
  + * The <code>formatNumber</code> tag is used to display numeric data, 
including currencies and percentages, in a locale-specific manner. The 
<code>formatNumber</code>> action determines from the locale, for example, 
whether to use a period or a comma for delimiting the integer and decimal 
portions of a number. Here is its syntax: 
    * </p>
    * <p>
    * &lt;formatNumber value="Expression"
  @@ -279,10 +279,10 @@
    *     [var="Name"] [locale="Expression"]&gt;
    * </p>
    *
  - * <p>The <code>formatDate</code> tag provides facilities to format Date 
values:</p>
  + * <p>The <code>formatDate</code> tag provides facilities to format Date 
values:</p> 
    *<p>
  - * &lt;formatDate value="Expression" [dateStyle="Style"]
  - [timeStyle="Style"] [pattern="Expression"] [type="Type"] [var="Name"]
  + * &lt;formatDate value="Expression" [dateStyle="Style"] 
  + [timeStyle="Style"] [pattern="Expression"] [type="Type"] [var="Name"] 
    [locale="Expression"]&gt;
    * </p>
    *
  @@ -303,17 +303,17 @@
    * &lt;/c:macro&gt;
    * </pre></p>
    *
  - * <p>The tag being defined in this example is <code>&lt;d&gt;</code> and it
  + * <p>The tag being defined in this example is <code>&lt;d&gt;</code> and it 
    * can be used like any other tag:</p>
    *
    * <p><pre>
    *   &lt;d/&gt;
    * </pre></p>
    *
  - * <p>However, when this tag is used it will be replaced with a row 
containing
  + * <p>However, when this tag is used it will be replaced with a row 
containing 
    * a single empty data cell.</p>
  - * <p> When such a tag is used, the attributes and content of the tag become
  - * available as variables in the body of the <code>macro</code>'s definition,
  + * <p> When such a tag is used, the attributes and content of the tag become 
  + * available as variables in the body of the <code>macro</code>'s 
definition, 
    * for example:</p>
    *
    * <p><pre>
  @@ -326,10 +326,10 @@
    * &lt;/c:macro&gt;
    * </pre></p>
    *
  - * <p>The <code>parameter</code> tags in the macro definition define formal
  - * parameters, which are replaced with the actual attribute values of the
  - * tag when it is used. The content of the tag is also available as a special
  - * variable <code>${content}</code>.</p><p>Assuming you had this code in your
  + * <p>The <code>parameter</code> tags in the macro definition define formal 
  + * parameters, which are replaced with the actual attribute values of the 
  + * tag when it is used. The content of the tag is also available as a 
special 
  + * variable <code>${content}</code>.</p><p>Assuming you had this code in 
your 
    * flowscript:</p>
    * <code>var greatlakes = ["Superior", "Michigan", "Huron", "Erie", 
"Ontario"];</code>
    * </p><p><code> sendPage(uri, {greatlakes: greatlakes});</code>
  @@ -341,7 +341,7 @@
    * &lt;/table&gt;
    * </pre></p>
    *
  - * <p>When the <code>tablerows</code> tag is used in this situation the
  + * <p>When the <code>tablerows</code> tag is used in this situation the 
    * following output would be generated:
    * </p>
    *<p><pre>
  @@ -353,10 +353,12 @@
    *   &lt;tr&gt;&lt;td bgcolor="blue"&gt;Ontario&lt;/td&gt;&lt;/tr&gt;
    * &lt;/table&gt;
    * </pre></p>
  + * 
  + *  @version CVS $Id$
    */
   public class JXTemplateGenerator extends ServiceableGenerator {
   
  -    private static final JXPathContextFactory
  +    private static final JXPathContextFactory 
           jxpathContextFactory = JXPathContextFactory.newInstance();
   
       private static final char[] EMPTY_CHARS = "".toCharArray();
  @@ -384,30 +386,67 @@
               public void remove() {
               }
           };
  -
  +    
       private static final Locator NULL_LOCATOR = new LocatorImpl();
   
  +    private XMLConsumer getConsumer()
  +    {
  +        return this.xmlConsumer;
  +    }
  +
  +    /**
  +     * Facade to the Locator to be set on the consumer prior to
  +     * sending other events, location member changeable
  +     */
  +    public class LocatorFacade implements Locator {
  +        private Locator locator;
  +   
  +        public LocatorFacade(Locator intialLocator) {
  +            this.locator = intialLocator;
  +        }
  +        
  +        public void setDocumentLocator(Locator newLocator) {
  +            this.locator = newLocator;
  +        }
  +       
  +        public int getColumnNumber() {
  +            return this.locator.getColumnNumber();
  +        }
  +        
  +        public int getLineNumber() {
  +            return this.locator.getLineNumber();
  +        }
  +        
  +        public String getPublicId() {
  +            return this.locator.getPublicId();
  +        }
  +        
  +        public String getSystemId() {
  +            return this.locator.getSystemId();
  +        }
  +    }
  +   
       /**
        * Jexl Introspector that supports Rhino JavaScript objects
        * as well as Java Objects
        */
       static class JSIntrospector extends UberspectImpl {
  -
  +        
           static class JSMethod implements VelMethod {
  -
  +            
               Scriptable scope;
               String name;
  -
  +            
               public JSMethod(Scriptable scope, String name) {
                   this.scope = scope;
                   this.name = name;
               }
  -
  +            
               public Object invoke(Object thisArg, Object[] args)
                   throws Exception {
                   Context cx = Context.enter();
                   try {
  -                    Object result;
  +                    Object result; 
                       Scriptable thisObj;
                       if (!(thisArg instanceof Scriptable)) {
                           thisObj = Context.toObject(thisArg, scope);
  @@ -420,7 +459,7 @@
                           newArgs = new Object[args.length];
                           for (int i = 0; i < args.length; i++) {
                               newArgs[i] = args[i];
  -                            if (args[i] != null &&
  +                            if (args[i] != null && 
                                   !(args[i] instanceof Number) &&
                                   !(args[i] instanceof Boolean) &&
                                   !(args[i] instanceof String) &&
  @@ -429,12 +468,12 @@
                               }
                           }
                       }
  -                    result = ScriptRuntime.call(cx, result, thisObj,
  +                    result = ScriptRuntime.call(cx, result, thisObj, 
                                                   newArgs, scope);
                       if (result == Undefined.instance ||
                           result == Scriptable.NOT_FOUND) {
                           result = null;
  -
  +                        
                       } else {
                           if (!(result instanceof NativeJavaClass)) {
                               while (result instanceof Wrapper) {
  @@ -449,31 +488,31 @@
                       Context.exit();
                   }
               }
  -
  +            
               public boolean isCacheable() {
                   return false;
               }
  -
  +            
               public String getMethodName() {
                   return name;
               }
  -
  +            
               public Class getReturnType() {
                   return Object.class;
               }
  -
  +            
           }
  -
  +        
           static class JSPropertyGet implements VelPropertyGet {
  -
  +            
               Scriptable scope;
               String name;
  -
  +            
               public JSPropertyGet(Scriptable scope, String name) {
                   this.scope = scope;
                   this.name = name;
               }
  -
  +            
               public Object invoke(Object thisArg) throws Exception {
                   Context.enter();
                   try {
  @@ -484,10 +523,10 @@
                           thisObj = (Scriptable)thisArg;
                       }
                       Object result = ScriptableObject.getProperty(thisObj, 
name);
  -                    if (result == Undefined.instance ||
  +                    if (result == Undefined.instance || 
                           result == Scriptable.NOT_FOUND) {
                           result = null;
  -                    }
  +                    } 
                       if (result instanceof Wrapper) {
                           if (!(result instanceof NativeJavaClass)) {
                               result = ((Wrapper)result).unwrap();
  @@ -498,27 +537,27 @@
                       Context.exit();
                   }
               }
  -
  +            
               public boolean isCacheable() {
                   return false;
               }
  -
  +            
               public String getMethodName() {
                   return name;
               }
  -
  +            
           }
  -
  +        
           static class JSPropertySet implements VelPropertySet {
  -
  +            
               Scriptable scope;
               String name;
  -
  +            
               public JSPropertySet(Scriptable scope, String name) {
                   this.scope = scope;
                   this.name = name;
               }
  -
  +            
               public Object invoke(Object thisArg, Object rhs) throws 
Exception {
                   Context.enter();
                   try {
  @@ -529,7 +568,7 @@
                       } else {
                           thisObj = (Scriptable)thisArg;
                       }
  -                    if (arg != null &&
  +                    if (arg != null && 
                           !(arg instanceof Number) &&
                           !(arg instanceof Boolean) &&
                           !(arg instanceof String) &&
  @@ -542,30 +581,30 @@
                       Context.exit();
                   }
               }
  -
  +            
               public boolean isCacheable() {
                   return false;
               }
  -
  +            
               public String getMethodName() {
  -                return name;
  +                return name;        
               }
           }
  -
  +        
           static class NativeArrayIterator implements Iterator {
  -
  +            
               NativeArray arr;
               int index;
  -
  +            
               public NativeArrayIterator(NativeArray arr) {
                   this.arr = arr;
                   this.index = 0;
               }
  -
  +            
               public boolean hasNext() {
                   return index < (int)arr.jsGet_length();
               }
  -
  +            
               public Object next() {
                   Context.enter();
                   try {
  @@ -585,33 +624,33 @@
                       Context.exit();
                   }
               }
  -
  +            
               public void remove() {
                   arr.delete(index);
               }
           }
  -
  +        
           static class ScriptableIterator implements Iterator {
  -
  +            
               Scriptable scope;
               Object[] ids;
               int index;
  -
  +            
               public ScriptableIterator(Scriptable scope) {
                   this.scope = scope;
                   this.ids = scope.getIds();
                   this.index = 0;
               }
  -
  +            
               public boolean hasNext() {
                   return index < ids.length;
               }
  -
  +            
               public Object next() {
                   Context.enter();
                   try {
  -                    Object result =
  -                        ScriptableObject.getProperty(scope,
  +                    Object result = 
  +                        ScriptableObject.getProperty(scope, 
                                                        
ids[index++].toString());
                       if (result == Undefined.instance ||
                           result == Scriptable.NOT_FOUND) {
  @@ -628,7 +667,7 @@
                       Context.exit();
                   }
               }
  -
  +            
               public void remove() {
                   Context.enter();
                   try {
  @@ -638,7 +677,7 @@
                   }
               }
           }
  -
  +        
           public Iterator getIterator(Object obj, Info i)
               throws Exception {
               if (!(obj instanceof Scriptable)) {
  @@ -649,8 +688,8 @@
               }
               return new ScriptableIterator((Scriptable)obj);
           }
  -
  -        public VelMethod getMethod(Object obj, String methodName,
  +        
  +        public VelMethod getMethod(Object obj, String methodName, 
                                      Object[] args, Info i)
               throws Exception {
               if (!(obj instanceof Scriptable)) {
  @@ -658,8 +697,8 @@
               }
               return new JSMethod((Scriptable)obj, methodName);
           }
  -
  -        public VelPropertyGet getPropertyGet(Object obj, String identifier,
  +        
  +        public VelPropertyGet getPropertyGet(Object obj, String identifier, 
                                                Info i)
               throws Exception {
               if (!(obj instanceof Scriptable)) {
  @@ -667,8 +706,8 @@
               }
               return new JSPropertyGet((Scriptable)obj, identifier);
           }
  -
  -        public VelPropertySet getPropertySet(Object obj, String identifier,
  +        
  +        public VelPropertySet getPropertySet(Object obj, String identifier, 
                                                Object arg, Info i)
               throws Exception {
               if (!(obj instanceof Scriptable)) {
  @@ -678,7 +717,7 @@
           }
       }
   
  -    static class MyJexlContext
  +    static class MyJexlContext 
           extends HashMap implements JexlContext {
           public Map getVars() {
               return this;
  @@ -746,7 +785,7 @@
               }
               return localVariables.containsKey(varName);
           }
  -
  +        
           public Object getVariable(String varName) {
               if (varName.equals("continuation")) {
                   return kont;
  @@ -765,11 +804,11 @@
               }
               return localVariables.get(varName);
           }
  -
  +        
           public void declareVariable(String varName, Object value) {
               localVariables.put(varName, value);
           }
  -
  +        
           public void undeclareVariable(String varName) {
               localVariables.remove(varName);
           }
  @@ -778,7 +817,7 @@
       static {
           // Hack: there's no _nice_ way to add my introspector to Jexl right 
now
           try {
  -            Field field =
  +            Field field = 
                   
org.apache.commons.jexl.util.Introspector.class.getDeclaredField("uberSpect");
               field.setAccessible(true);
               field.set(null, new JSIntrospector());
  @@ -788,8 +827,8 @@
       }
   
   
  -    final static String NS =
  -        "http://apache.org/cocoon/templates/jx/1.0";;
  +    /** The namespace used by this generator */
  +    public final static String NS = 
"http://apache.org/cocoon/templates/jx/1.0";;
   
       final static String TEMPLATE = "template";
       final static String FOR_EACH = "forEach";
  @@ -808,11 +847,11 @@
   
       /**
        * Compile a single Jexl expr (contained in ${}) or XPath expression
  -     * (contained in #{})
  +     * (contained in #{}) 
        */
   
  -    private static Expression compileExpr(String expr, String errorPrefix,
  -                                          Locator location)
  +    private static Expression compileExpr(String expr, String errorPrefix, 
  +                                          Locator location) 
           throws SAXParseException {
           try {
               return compileExpr(expr);
  @@ -868,9 +907,12 @@
           }
           return new Expression(inStr, null);
       }
  -    // Compile an integer expression (returns either a Compiled Expression
  -    // or an Integer literal)
  -    private static Expression compileInt(String val, String msg, Locator 
location)
  +    
  +    /*
  +     * Compile an integer expression (returns either a Compiled Expression
  +     * or an Integer literal)
  +     */
  +    private static Expression compileInt(String val, String msg, Locator 
location) 
           throws SAXException {
           Expression res = compileExpr(val, msg, location);
           if (res == null) return null;
  @@ -880,7 +922,7 @@
           return res;
       }
   
  -    private static Expression compileBoolean(String val, String msg, Locator 
location)
  +    private static Expression compileBoolean(String val, String msg, Locator 
location) 
           throws SAXException {
           Expression res = compileExpr(val, msg, location);
           if (res == null) return null;
  @@ -890,7 +932,7 @@
           return res;
       }
   
  -    private static Expression compile(final String variable, boolean xpath)
  +    private static Expression compile(final String variable, boolean xpath) 
           throws Exception {
           Object compiled;
           if (xpath) {
  @@ -902,16 +944,24 @@
       }
   
       static private Object getValue(Expression expr, JexlContext jexlContext,
  -                            JXPathContext jxpathContext)
  +                            JXPathContext jxpathContext, Boolean lenient) 
           throws Exception {
           if (expr == null) return null;
           Object compiled = expr.compiledExpression;
           try {
               if (compiled instanceof CompiledExpression) {
                   CompiledExpression e = (CompiledExpression)compiled;
  -                return e.getValue(jxpathContext);
  +                boolean oldLenient = jxpathContext.isLenient();
  +                if (lenient != null) {
  +                    jxpathContext.setLenient(lenient.booleanValue());
  +                }
  +                try {
  +                    return e.getValue(jxpathContext);
  +                } finally {
  +                    jxpathContext.setLenient(oldLenient);
  +                }
               } else if (compiled instanceof 
org.apache.commons.jexl.Expression) {
  -                org.apache.commons.jexl.Expression e =
  +                org.apache.commons.jexl.Expression e = 
                       (org.apache.commons.jexl.Expression)compiled;
                   return e.evaluate(jexlContext);
               }
  @@ -924,9 +974,13 @@
               throw (Error)t;
           }
       }
  +    
  +    static private Object getValue(Expression expr, JexlContext jexlContext, 
JXPathContext jxpathContext) throws Exception {
  +        return getValue(expr, jexlContext, jxpathContext, null);
  +    }
   
       static private int getIntValue(Expression expr, JexlContext jexlContext,
  -                            JXPathContext jxpathContext)
  +                            JXPathContext jxpathContext) 
           throws Exception {
           Object res = getValue(expr, jexlContext, jxpathContext);
           if (res instanceof Number) {
  @@ -936,7 +990,7 @@
       }
   
       static private Number getNumberValue(Expression expr, JexlContext 
jexlContext,
  -                               JXPathContext jxpathContext)
  +                               JXPathContext jxpathContext) 
           throws Exception {
           Object res = getValue(expr, jexlContext, jxpathContext);
           if (res instanceof Number) {
  @@ -949,7 +1003,7 @@
       }
   
       static private String getStringValue(Expression expr, JexlContext 
jexlContext,
  -                                  JXPathContext jxpathContext)
  +                                  JXPathContext jxpathContext) 
           throws Exception {
           Object res = getValue(expr, jexlContext, jxpathContext);
           if (res != null) {
  @@ -962,7 +1016,7 @@
       }
   
       static private Boolean getBooleanValue(Expression expr, JexlContext 
jexlContext,
  -                                    JXPathContext jxpathContext)
  +                                    JXPathContext jxpathContext) 
           throws Exception {
           Object res = getValue(expr, jexlContext, jxpathContext);
           if (res instanceof Boolean) {
  @@ -973,15 +1027,21 @@
   
       // Hack: try to prevent JXPath from converting result to a String
       private Object getNode(Expression expr, JexlContext jexlContext,
  -                           JXPathContext jxpathContext)
  +                           JXPathContext jxpathContext, Boolean lenient) 
           throws Exception {
           try {
               Object compiled = expr.compiledExpression;
               if (compiled instanceof CompiledExpression) {
                   CompiledExpression e = (CompiledExpression)compiled;
  -                return e.getPointer(jxpathContext, expr.raw).getNode();
  +                boolean oldLenient = jxpathContext.isLenient();
  +                if (lenient != null) 
jxpathContext.setLenient(lenient.booleanValue());
  +                try {
  +                    return e.getPointer(jxpathContext, expr.raw).getNode();
  +                } finally {
  +                    jxpathContext.setLenient(oldLenient);
  +                }
               } else if (compiled instanceof 
org.apache.commons.jexl.Expression) {
  -                org.apache.commons.jexl.Expression e =
  +                org.apache.commons.jexl.Expression e = 
                       (org.apache.commons.jexl.Expression)compiled;
                   return e.evaluate(jexlContext);
               }
  @@ -994,12 +1054,16 @@
               throw (Error)t;
           }
       }
  +    
  +    private Object getNode(Expression expr, JexlContext jexlContext, 
JXPathContext jxpathContext) throws Exception {
  +        return getNode(expr, jexlContext, jxpathContext, null);
  +    }
   
       static class Event {
           final Locator location;
           Event next; // in document order
           Event(Locator locator) {
  -            this.location =
  +            this.location = 
                   locator == null ? NULL_LOCATOR : new LocatorImpl(locator);
           }
   
  @@ -1016,13 +1080,13 @@
               }
               return result;
           }
  -
  +        
       }
   
   
       static class TextEvent extends Event {
  -        TextEvent(Locator location,
  -                  char[] chars, int start, int length)
  +        TextEvent(Locator location, 
  +                  char[] chars, int start, int length) 
               throws SAXException {
               super(location);
               StringBuffer buf = new StringBuffer();
  @@ -1043,16 +1107,16 @@
                                       buf.append('\\');
                                   } else {
                                       buf.append((char)ch);
  -                                }
  +                                } 
                               } else if (c == '}') {
                                   String str = buf.toString();
                                   Object compiledExpression;
                                   try {
                                       if (xpath) {
  -                                        compiledExpression =
  +                                        compiledExpression = 
                                               JXPathContext.compile(str);
                                       } else {
  -                                        compiledExpression =
  +                                        compiledExpression = 
                                               
ExpressionFactory.createExpression(str);
                                       }
                                   } catch (Exception exc) {
  @@ -1081,9 +1145,9 @@
                                       xpath = c == '#';
                                       inExpr = true;
                                       if (buf.length() > 0) {
  -                                        char[] charArray =
  +                                        char[] charArray = 
                                               new char[buf.length()];
  -
  +                                        
                                           buf.getChars(0, buf.length(),
                                                        charArray, 0);
                                           substitutions.add(charArray);
  @@ -1109,7 +1173,7 @@
                   ignored.printStackTrace();
               }
               if (buf.length() > 0) {
  -                char[] charArray =
  +                char[] charArray = 
                       new char[buf.length()];
                   buf.getChars(0, buf.length(), charArray, 0);
                   substitutions.add(charArray);
  @@ -1122,8 +1186,8 @@
       }
   
       static class Characters extends TextEvent {
  -        Characters(Locator location,
  -                   char[] chars, int start, int length)
  +        Characters(Locator location, 
  +                   char[] chars, int start, int length) 
               throws SAXException {
               super(location, chars, start, length);
           }
  @@ -1145,7 +1209,7 @@
       }
   
       static class EndElement extends Event {
  -        EndElement(Locator location,
  +        EndElement(Locator location, 
                      StartElement startElement) {
               super(location);
               this.startElement = startElement;
  @@ -1160,10 +1224,10 @@
           }
           final String prefix;
       }
  -
  +    
       static class IgnorableWhitespace extends TextEvent {
  -        IgnorableWhitespace(Locator location,
  -                            char[] chars, int start, int length)
  +        IgnorableWhitespace(Locator location, 
  +                            char[] chars, int start, int length) 
               throws SAXException {
               super(location, chars, start, length);
           }
  @@ -1201,9 +1265,9 @@
           final String raw;
           final String type;
       }
  -
  +    
       static class CopyAttribute extends AttributeEvent {
  -        CopyAttribute(String namespaceURI,
  +        CopyAttribute(String namespaceURI, 
                         String localName,
                         String raw,
                         String type, String value) {
  @@ -1212,17 +1276,17 @@
           }
           final String value;
       }
  -
  +    
       static class Subst {
       }
  -
  +    
       static class Literal extends Subst {
           Literal(String val) {
               this.value = val;
           }
           final String value;
       }
  -
  +    
       static class Expression extends Subst {
           Expression(String raw, Object expr) {
               this.raw = raw;
  @@ -1246,7 +1310,7 @@
       static class StartElement extends Event {
           StartElement(Locator location, String namespaceURI,
                        String localName, String raw,
  -                     Attributes attrs)
  +                     Attributes attrs) 
               throws SAXException {
               super(location);
               this.namespaceURI = namespaceURI;
  @@ -1292,8 +1356,8 @@
                                           throw new 
SAXParseException(err.getMessage(),
                                                                       location,
                                                                       null);
  -
  -                                    }
  +                                        
  +                                    } 
                                       substEvents.add(compiledExpression);
                                       buf.setLength(0);
                                       inExpr = false;
  @@ -1330,7 +1394,7 @@
                                   }
                               }
                               break;
  -                        }
  +                        } 
                       }
                   } catch (IOException ignored) {
                       ignored.printStackTrace();
  @@ -1421,7 +1485,7 @@
       }
   
       static class StartDTD extends Event {
  -        StartDTD(Locator location, String name,
  +        StartDTD(Locator location, String name, 
                    String publicId, String systemId) {
               super(location);
               this.name = name;
  @@ -1432,7 +1496,7 @@
           final String publicId;
           final String systemId;
       }
  -
  +    
       static class StartEntity extends Event {
           public StartEntity(Locator location, String name) {
               super(location);
  @@ -1449,9 +1513,9 @@
           final StartElement startElement;
           EndInstruction endInstruction;
       }
  -
  +    
       static class EndInstruction extends Event {
  -        EndInstruction(Locator locator,
  +        EndInstruction(Locator locator, 
                          StartInstruction startInstruction) {
               super(locator);
               this.startInstruction = startInstruction;
  @@ -1463,21 +1527,23 @@
       static class StartForEach extends StartInstruction {
           StartForEach(StartElement raw,
                        Expression items, String var,
  -                     Expression begin, Expression end, Expression step) {
  +                     Expression begin, Expression end, Expression step, 
Boolean lenient) {
               super(raw);
               this.items = items;
               this.var = var;
               this.begin = begin;
               this.end = end;
               this.step = step;
  +            this.lenient = lenient;
           }
           final Expression items;
           final String var;
           final Expression begin;
           final Expression end;
           final Expression step;
  +        final Boolean lenient;
       }
  -
  +    
       static class StartIf extends StartInstruction {
           StartIf(StartElement raw, Expression test) {
               super(raw);
  @@ -1511,15 +1577,17 @@
       }
   
       static class StartOut extends StartInstruction {
  -        StartOut(StartElement raw, Expression expr) {
  +        StartOut(StartElement raw, Expression expr, Boolean lenient) {
               super(raw);
               this.compiledExpression = expr;
  +            this.lenient = lenient;
           }
           final Expression compiledExpression;
  +        final Boolean lenient;
       }
   
       static class StartImport extends StartInstruction {
  -        StartImport(StartElement raw, AttributeEvent uri,
  +        StartImport(StartElement raw, AttributeEvent uri, 
                       Expression select) {
               super(raw);
               this.uri = uri;
  @@ -1557,7 +1625,7 @@
                       if (!params) {
                           throw new SAXParseException("<parameter> not allowed 
here: \""+startParam.name +"\"", startParam.location, null);
                       }
  -                    Object prev =
  +                    Object prev = 
                           parameters.put(startParam.name, startParam);
                       if (prev != null) {
                           throw new SAXParseException("duplicate parameter: 
\""+startParam.name +"\"", location, null);
  @@ -1653,25 +1721,25 @@
           return ret;
       }
   
  -    private static final String NUMBER = "number";
  +    private static final String NUMBER = "number";    
       private static final String CURRENCY = "currency";
       private static final String PERCENT = "percent";
   
       static class StartFormatNumber extends StartInstruction {
   
  -        Expression value;
  -        Expression type;
  -        Expression pattern;
  -        Expression currencyCode;
  -        Expression currencySymbol;
  -        Expression isGroupingUsed;
  -        Expression maxIntegerDigits;
  -        Expression minIntegerDigits;
  -        Expression maxFractionDigits;
  -        Expression minFractionDigits;
  +        Expression value;                   
  +        Expression type;                    
  +        Expression pattern;                 
  +        Expression currencyCode;            
  +        Expression currencySymbol;          
  +        Expression isGroupingUsed;         
  +        Expression maxIntegerDigits;           
  +        Expression minIntegerDigits;           
  +        Expression maxFractionDigits;          
  +        Expression minFractionDigits;          
           Expression locale;
  -
  -        Expression var;
  +        
  +        Expression var;                        
   
           private static Class currencyClass;
   
  @@ -1685,33 +1753,33 @@
   
           public StartFormatNumber(StartElement raw,
                                    Expression var,
  -                                 Expression value,
  -                                 Expression type,
  -                                 Expression pattern,
  -                                 Expression currencyCode,
  -                                 Expression currencySymbol,
  -                                 Expression isGroupingUsed,
  -                                 Expression maxIntegerDigits,
  -                                 Expression minIntegerDigits,
  -                                 Expression maxFractionDigits,
  +                                 Expression value,                   
  +                                 Expression type,                   
  +                                 Expression pattern,                 
  +                                 Expression currencyCode,            
  +                                 Expression currencySymbol,          
  +                                 Expression isGroupingUsed,         
  +                                 Expression maxIntegerDigits,           
  +                                 Expression minIntegerDigits,           
  +                                 Expression maxFractionDigits,          
                                    Expression minFractionDigits,
                                    Expression locale) {
               super(raw);
  -            this.var = var;
  -            this.value = value;
  -            this.type = type;
  -            this.pattern = pattern;
  -            this.currencyCode = currencyCode;
  -            this.currencySymbol = currencySymbol;
  -            this.isGroupingUsed = isGroupingUsed;
  -            this.maxIntegerDigits = maxIntegerDigits;
  -            this.minIntegerDigits = minIntegerDigits;
  -            this.maxFractionDigits = maxFractionDigits;
  -            this.minFractionDigits = minFractionDigits;
  +            this.var = var;                   
  +            this.value = value;                   
  +            this.type = type;                    
  +            this.pattern = pattern;                 
  +            this.currencyCode = currencyCode;            
  +            this.currencySymbol = currencySymbol;          
  +            this.isGroupingUsed = isGroupingUsed;         
  +            this.maxIntegerDigits = maxIntegerDigits;           
  +            this.minIntegerDigits = minIntegerDigits;           
  +            this.maxFractionDigits = maxFractionDigits;          
  +            this.minFractionDigits = minFractionDigits;          
               this.locale = locale;
           }
   
  -        String format(JexlContext jexl, JXPathContext jxp)
  +        String format(JexlContext jexl, JXPathContext jxp) 
               throws Exception {
               // Determine formatting locale
               String var = getStringValue(this.var, jexl, jxp);
  @@ -1719,17 +1787,17 @@
               String type = getStringValue(this.type, jexl, jxp);
               String pattern = getStringValue(this.pattern, jexl, jxp);
               String currencyCode = getStringValue(this.currencyCode, jexl, 
jxp);
  -            String currencySymbol = getStringValue(this.currencySymbol,
  +            String currencySymbol = getStringValue(this.currencySymbol, 
                                                    jexl, jxp);
  -            Boolean isGroupingUsed = getBooleanValue(this.isGroupingUsed,
  +            Boolean isGroupingUsed = getBooleanValue(this.isGroupingUsed, 
                                                        jexl, jxp);
  -            Number maxIntegerDigits = getNumberValue(this.maxIntegerDigits,
  +            Number maxIntegerDigits = getNumberValue(this.maxIntegerDigits, 
                                                        jexl, jxp);
  -            Number minIntegerDigits = getNumberValue(this.minIntegerDigits,
  +            Number minIntegerDigits = getNumberValue(this.minIntegerDigits, 
                                                        jexl, jxp);
  -            Number maxFractionDigits = getNumberValue(this.maxFractionDigits,
  +            Number maxFractionDigits = 
getNumberValue(this.maxFractionDigits, 
                                                         jexl, jxp);
  -            Number minFractionDigits = getNumberValue(this.minFractionDigits,
  +            Number minFractionDigits = 
getNumberValue(this.minFractionDigits, 
                                                         jexl, jxp);
               String localeStr = getStringValue(this.locale,
                                                 jexl, jxp);
  @@ -1741,7 +1809,7 @@
               }
               String formatted;
               if (loc != null) {
  -                // Create formatter
  +                // Create formatter 
                   NumberFormat formatter = null;
                   if ((pattern != null) && !pattern.equals("")) {
                       // if 'pattern' is specified, 'type' is ignored
  @@ -1777,9 +1845,9 @@
               }
               return formatted;
           }
  -
  +        
           private NumberFormat createFormatter(Locale loc,
  -                                             String type)
  +                                             String type) 
               throws Exception {
               NumberFormat formatter = null;
               if ((type == null) || NUMBER.equalsIgnoreCase(type)) {
  @@ -1816,7 +1884,7 @@
               if (minFractionDigits != null)
                   
formatter.setMinimumFractionDigits(minFractionDigits.intValue());
           }
  -
  +        
           /*
            * Override the formatting locale's default currency symbol with the
            * specified currency code (specified via the "currencyCode" 
attribute) or
  @@ -1841,7 +1909,7 @@
            * >=1.4       EUR            ---         Locale's currency symbol 
for Euro
            *
            * all         ---           \u20AC       \u20AC
  -         *
  +         * 
            * <1.4        EUR           \u20AC       \u20AC
            * >=1.4       EUR           \u20AC       Locale's currency symbol 
for Euro
            */
  @@ -1850,11 +1918,11 @@
                                    String currencySymbol) throws Exception {
               String code = null;
               String symbol = null;
  -
  +            
               if ((currencyCode == null) && (currencySymbol == null)) {
                   return;
               }
  -
  +            
               if ((currencyCode != null) && (currencySymbol != null)) {
                   if (currencyClass != null)
                       code = currencyCode;
  @@ -1868,10 +1936,10 @@
                   else
                       symbol = currencyCode;
               }
  -
  +            
               if (code != null) {
                   Object[] methodArgs = new Object[1];
  -
  +                
                   /*
                    * java.util.Currency.getInstance()
                    */
  @@ -1880,7 +1948,7 @@
   
                   methodArgs[0] = code;
                   Object currency = m.invoke(null, methodArgs);
  -
  +                
                   /*
                    * java.text.NumberFormat.setCurrency()
                    */
  @@ -1940,11 +2008,11 @@
               this.locale = locale;
           }
   
  -        String format(JexlContext jexl, JXPathContext jxp)
  +        String format(JexlContext jexl, JXPathContext jxp) 
               throws Exception {
               String var = getStringValue(this.var, jexl, jxp);
               Object value = getValue(this.value, jexl, jxp);
  -            Object locVal = getValue(this.locale,
  +            Object locVal = getValue(this.locale, 
                                        jexl, jxp);
               String pattern = getStringValue(this.pattern,
                                               jexl, jxp);
  @@ -1993,7 +2061,7 @@
                   } else {
                       throw new IllegalArgumentException("Illegal timeZone 
value: \""+timeZone+"\"");
                   }
  -            }
  +            } 
               if (tz != null) {
                   formatter.setTimeZone(tz);
               }
  @@ -2010,7 +2078,7 @@
           private DateFormat createFormatter(Locale loc,
                                              String type,
                                              String dateStyle,
  -                                           String timeStyle)
  +                                           String timeStyle) 
               throws Exception {
               DateFormat formatter = null;
               if ((type == null) || DATE.equalsIgnoreCase(type)) {
  @@ -2070,7 +2138,7 @@
           }
   
           StartDocument getStartEvent() {
  -            return startEvent;
  +            return this.startEvent;
           }
   
           private void addEvent(Event ev) throws SAXException {
  @@ -2099,7 +2167,7 @@
               }
           }
   
  -        public void characters(char[] ch, int start, int length)
  +        public void characters(char[] ch, int start, int length) 
               throws SAXException {
               if (charBuf == null) {
                   charBuf = new StringBuffer();
  @@ -2121,14 +2189,14 @@
   
           public void endElement(String namespaceURI,
                                  String localName,
  -                               String raw)
  +                               String raw) 
               throws SAXException {
               Event start = (Event)stack.pop();
               Event newEvent = null;
               if (NS.equals(namespaceURI)) {
  -                StartInstruction startInstruction =
  +                StartInstruction startInstruction = 
                       (StartInstruction)start;
  -                EndInstruction endInstruction =
  +                EndInstruction endInstruction = 
                       new EndInstruction(locator, startInstruction);
                   newEvent = endInstruction;
                   if (start instanceof StartWhen) {
  @@ -2144,14 +2212,14 @@
                           startChoose.firstChoice = startWhen;
                       }
                   } else if (start instanceof StartOtherwise) {
  -                    StartOtherwise startOtherwise =
  +                    StartOtherwise startOtherwise = 
                           (StartOtherwise)start;
                       StartChoose startChoose = (StartChoose)stack.peek();
                       startChoose.otherwise = startOtherwise;
  -                }
  +                } 
               } else {
                   StartElement startElement = (StartElement)start;
  -                newEvent = startElement.endElement =
  +                newEvent = startElement.endElement = 
                       new EndElement(locator, startElement);
               }
               addEvent(newEvent);
  @@ -2161,20 +2229,20 @@
               }
           }
   
  -
  +        
           public void endPrefixMapping(String prefix) throws SAXException {
  -            EndPrefixMapping endPrefixMapping =
  +            EndPrefixMapping endPrefixMapping = 
                   new EndPrefixMapping(locator, prefix);
               addEvent(endPrefixMapping);
           }
   
  -        public void ignorableWhitespace(char[] ch, int start, int length)
  +        public void ignorableWhitespace(char[] ch, int start, int length) 
               throws SAXException {
               Event ev = new IgnorableWhitespace(locator, ch, start, length);
               addEvent(ev);
           }
   
  -        public void processingInstruction(String target, String data)
  +        public void processingInstruction(String target, String data) 
               throws SAXException {
               Event pi = new ProcessingInstruction(locator, target, data);
               addEvent(pi);
  @@ -2193,16 +2261,16 @@
               lastEvent = startEvent;
               stack.push(lastEvent);
           }
  -
  +        
   
   
           public void startElement(String namespaceURI,
                                    String localName,
                                    String qname,
  -                                 Attributes attrs)
  +                                 Attributes attrs) 
               throws SAXException {
               Event newEvent = null;
  -            StartElement startElement =
  +            StartElement startElement = 
                   new StartElement(locator, namespaceURI,
                                    localName, qname, attrs);
               if (NS.equals(namespaceURI)) {
  @@ -2227,48 +2295,50 @@
                       Expression expr;
                       expr = compileExpr(items == null ? select : items,
                                          null, locator);
  -                    StartForEach startForEach =
  -                        new StartForEach(startElement, expr,
  -                                         var, begin, end, step);
  +                    String lenientValue = attrs.getValue("lenient");
  +                    Boolean lenient = (lenientValue == null) ? null : 
Boolean.valueOf(lenientValue);
  +                    StartForEach startForEach = 
  +                        new StartForEach(startElement, expr, 
  +                                         var, begin, end, step,lenient);
                       newEvent = startForEach;
                   } else if (localName.equals(FORMAT_NUMBER)) {
  -                    Expression value =
  +                    Expression value = 
                           compileExpr(attrs.getValue("value"),
  -                                    null, locator);;
  -                    Expression type =
  +                                    null, locator);
  +                    Expression type = 
                           compileExpr(attrs.getValue("type"),
                                       null, locator);
  -                    Expression pattern =
  +                    Expression pattern = 
                           compileExpr(attrs.getValue("pattern"),
                                       null, locator);
  -                    Expression currencyCode =
  +                    Expression currencyCode = 
                           compileExpr(attrs.getValue("currencyCode"),
                                       null, locator);
  -                    Expression currencySymbol =
  +                    Expression currencySymbol = 
                           compileExpr(attrs.getValue("currencySymbol"),
  -                                    null, locator);
  -                    Expression isGroupingUsed =
  -                        compileBoolean(attrs.getValue("isGroupingUsed"),
  +                                    null, locator);       
  +                    Expression isGroupingUsed =  
  +                        compileBoolean(attrs.getValue("isGroupingUsed"), 
                                          null, locator);
  -                    Expression maxIntegerDigits =
  -                        compileInt(attrs.getValue("maxIntegerDigits"),
  -                                   null, locator);
  -                    Expression minIntegerDigits =
  -                        compileInt(attrs.getValue("minIntegerDigits"),
  -                                   null, locator);
  -                    Expression maxFractionDigits =
  -                        compileInt(attrs.getValue("maxFractionDigits"),
  -                                   null, locator);
  -                    Expression minFractionDigits =
  -                        compileInt(attrs.getValue("minFractionDigits"),
  -                                   null, locator);
  +                    Expression maxIntegerDigits = 
  +                        compileInt(attrs.getValue("maxIntegerDigits"), 
  +                                   null, locator);           
  +                    Expression minIntegerDigits =            
  +                        compileInt(attrs.getValue("minIntegerDigits"), 
  +                                   null, locator);           
  +                    Expression maxFractionDigits =          
  +                        compileInt(attrs.getValue("maxFractionDigits"), 
  +                                   null, locator);           
  +                    Expression minFractionDigits =           
  +                        compileInt(attrs.getValue("minFractionDigits"), 
  +                                   null, locator);           
                       Expression var =
  -                        compileExpr(attrs.getValue("var"),
  -                                    null, locator);
  +                        compileExpr(attrs.getValue("var"), 
  +                                    null, locator);           
                       Expression locale =
  -                        compileExpr(attrs.getValue("locale"),
  -                                    null, locator);
  -                    StartFormatNumber startFormatNumber =
  +                        compileExpr(attrs.getValue("locale"), 
  +                                    null, locator);           
  +                    StartFormatNumber startFormatNumber = 
                           new StartFormatNumber(startElement,
                                                 var,
                                                 value,
  @@ -2285,30 +2355,30 @@
                       newEvent = startFormatNumber;
                   } else if (localName.equals(FORMAT_DATE)) {
                       Expression var =
  -                        compileExpr(attrs.getValue("var"),
  -                                    null, locator);
  -                    Expression value =
  +                        compileExpr(attrs.getValue("var"), 
  +                                    null, locator);           
  +                    Expression value = 
                           compileExpr(attrs.getValue("value"),
                                       null, locator);
  -                    Expression type =
  +                    Expression type = 
                           compileExpr(attrs.getValue("type"),
                                       null, locator);
  -                    Expression pattern =
  +                    Expression pattern = 
                           compileExpr(attrs.getValue("pattern"),
                                       null, locator);
                       Expression timeZone =
  -                        compileExpr(attrs.getValue("timeZone"),
  -                                    null, locator);
  +                        compileExpr(attrs.getValue("timeZone"), 
  +                                    null, locator);           
                       Expression dateStyle =
  -                        compileExpr(attrs.getValue("dateStyle"),
  -                                    null, locator);
  +                        compileExpr(attrs.getValue("dateStyle"), 
  +                                    null, locator);           
                       Expression timeStyle =
  -                        compileExpr(attrs.getValue("timeStyle"),
  -                                    null, locator);
  +                        compileExpr(attrs.getValue("timeStyle"), 
  +                                    null, locator);           
                       Expression locale =
  -                        compileExpr(attrs.getValue("locale"),
  -                                    null, locator);
  -                    StartFormatDate startFormatDate =
  +                        compileExpr(attrs.getValue("locale"), 
  +                                    null, locator);           
  +                    StartFormatDate startFormatDate = 
                           new StartFormatDate(startElement,
                                               var,
                                               value,
  @@ -2340,16 +2410,18 @@
                       if (value == null) {
                           throw new SAXParseException("out: \"value\" is 
required", locator, null);
                       }
  -                    Expression expr = compileExpr(value,
  -                                              "out: \"value\": ",
  +                    Expression expr = compileExpr(value, 
  +                                              "out: \"value\": ", 
                                                 locator);
  -                    newEvent = new StartOut(startElement, expr);
  +                    String lenientValue = attrs.getValue("lenient");
  +                    Boolean lenient = lenientValue == null ? null: 
Boolean.valueOf(lenientValue);
  +                    newEvent = new StartOut(startElement, expr, lenient);
                   } else if (localName.equals(OTHERWISE)) {
                       if (stack.size() == 0 ||
                           !(stack.peek() instanceof StartChoose)) {
                           throw new SAXParseException("<otherwise> must be 
within <choose>", locator, null);
                       }
  -                    StartOtherwise startOtherwise =
  +                    StartOtherwise startOtherwise = 
                           new StartOtherwise(startElement);
                       newEvent = startOtherwise;
                   } else if (localName.equals(IF)) {
  @@ -2357,9 +2429,9 @@
                       if (test == null) {
                           throw new SAXParseException("if: \"test\" is 
required", locator, null);
                       }
  -                    Expression expr =
  +                    Expression expr = 
                           compileExpr(test, "if: \"test\": ", locator);
  -                    StartIf startIf =
  +                    StartIf startIf = 
                           new StartIf(startElement, expr);
                       newEvent = startIf;
                   } else if (localName.equals(MACRO)) {
  @@ -2375,8 +2447,8 @@
                       if (name == null) {
                           throw new SAXParseException("macro: \"name\" is 
required", locator, null);
                       }
  -                    StartDefine startDefine =
  -                        new StartDefine(startElement, namespace, name);
  +                    StartDefine startDefine = 
  +                        new StartDefine(startElement, namespace, name); 
                       newEvent = startDefine;
                   } else if (localName.equals(PARAMETER)) {
                       boolean syntaxErr = false;
  @@ -2390,8 +2462,8 @@
                           if (name == null) {
                               throw new SAXParseException("parameter: \"name\" 
is required", locator, null);
                           }
  -                        StartParameter startParameter =
  -                            new StartParameter(startElement,
  +                        StartParameter startParameter = 
  +                            new StartParameter(startElement, 
                                                  name, optional, default_);
                           newEvent = startParameter;
                       }
  @@ -2403,10 +2475,10 @@
                       String value = attrs.getValue("value");
                       Expression valueExpr = null;
                       if (value != null) {
  -                        valueExpr =
  +                        valueExpr = 
                               compileExpr(value, "set: \"value\":",
                                           locator);
  -                    }
  +                    } 
                       StartSet startSet = new StartSet(startElement, var, 
valueExpr);
                       newEvent = startSet;
                   } else if (localName.equals(IMPORT)) {
  @@ -2428,11 +2500,11 @@
                       String select = attrs.getValue("context");
                       Expression expr = null;
                       if (select != null) {
  -                        expr =
  +                        expr = 
                               compileExpr(select, "import: \"context\": ",
                                           locator);
                       }
  -                    StartImport startImport =
  +                    StartImport startImport = 
                           new StartImport(startElement, uri, expr);
                       newEvent = startImport;
                   } else if (localName.equals(TEMPLATE)) {
  @@ -2448,13 +2520,13 @@
               stack.push(newEvent);
               addEvent(newEvent);
           }
  -
  -        public void startPrefixMapping(String prefix, String uri)
  +        
  +        public void startPrefixMapping(String prefix, String uri) 
               throws SAXException {
               addEvent(new StartPrefixMapping(locator, prefix, uri));
           }
   
  -        public void comment(char ch[], int start, int length)
  +        public void comment(char ch[], int start, int length) 
               throws SAXException {
               addEvent(new Comment(locator, ch, start, length));
           }
  @@ -2475,11 +2547,11 @@
               addEvent(new StartCDATA(locator));
           }
   
  -        public void startDTD(String name, String publicId, String systemId)
  +        public void startDTD(String name, String publicId, String systemId) 
               throws SAXException {
               addEvent(new StartDTD(locator, name, publicId, systemId));
           }
  -
  +        
           public void startEntity(String name) throws SAXException {
               addEvent(new StartEntity(locator, name));
           }
  @@ -2487,7 +2559,7 @@
   
       /**
        * Adapter that makes this generator usable as a transformer
  -     * (Note there is a performance penalty for this however:
  +     * (Note there is a performance penalty for this however: 
        * you effectively recompile the template for every instance document)
        */
   
  @@ -2495,7 +2567,7 @@
           static class TemplateConsumer extends Parser implements XMLConsumer {
   
               public TemplateConsumer(SourceResolver resolver, Map objectModel,
  -                                    String src, Parameters parameters)
  +                                    String src, Parameters parameters) 
                   throws ProcessingException, SAXException, IOException {
                   this.gen = new JXTemplateGenerator();
                   this.gen.setup(resolver, objectModel, null, parameters);
  @@ -2503,7 +2575,7 @@
   
               public void endDocument() throws SAXException {
                   super.endDocument();
  -                gen.execute(gen.xmlConsumer,
  +                gen.execute(gen.getConsumer(),
                               gen.getJexlContext(),
                               gen.getJXPathContext(),
                               getStartEvent(), null);
  @@ -2518,8 +2590,8 @@
   
           TemplateConsumer templateConsumer;
   
  -        public void reset() {
  -            super.reset();
  +        public void recycle() {
  +            super.recycle();
               templateConsumer = null;
           }
   
  @@ -2552,21 +2624,27 @@
           return globalJexlContext;
       }
   
  -    public void reset() {
  +    /* (non-Javadoc)
  +     * @see org.apache.avalon.excalibur.pool.Recyclable#recycle()
  +     */
  +    public void recycle() {
           if ( this.resolver != null) {
  -            this.resolver.release(this.inputSource);
  +            this.resolver.release(this.inputSource);            
           }
           this.inputSource = null;
           this.jxpathContext = null;
           this.globalJexlContext = null;
           this.variables = null;
           this.definitions = null;
  -        super.reset();
  +        super.recycle();
       }
   
  +    /* (non-Javadoc)
  +     * @see 
org.apache.cocoon.sitemap.SitemapModelComponent#setup(org.apache.cocoon.environment.SourceResolver,
 java.util.Map, java.lang.String, 
org.apache.avalon.framework.parameters.Parameters)
  +     */
       public void setup(SourceResolver resolver, Map objectModel,
                         String src, Parameters parameters)
  -        throws ProcessingException, SAXException, IOException {
  +    throws ProcessingException, SAXException, IOException {
   
           super.setup(resolver, objectModel, src, parameters);
           if (src != null) {
  @@ -2575,7 +2653,7 @@
               } catch (SourceException se) {
                   throw SourceUtil.handle("Error during resolving of '" + src 
+ "'.", se);
               }
  -            String uri = inputSource.getURI();
  +            final String uri = inputSource.getURI();
               synchronized (cache) {
                   StartDocument startEvent = (StartDocument)cache.get(uri);
                   if (startEvent != null) {
  @@ -2597,12 +2675,12 @@
                       objectModel);
           this.definitions = new HashMap();
       }
  -
  +    
       private void fillContext(Object contextObject, Map map) {
           if (contextObject == null) return;
           // Hack: I use jxpath to populate the context object's properties
           // in the jexl context
  -        final JXPathBeanInfo bi =
  +        final JXPathBeanInfo bi = 
               JXPathIntrospector.getBeanInfo(contextObject.getClass());
           if (bi.isDynamic()) {
               Class cl = bi.getDynamicPropertyHandlerClass();
  @@ -2625,7 +2703,7 @@
                   try {
                       Method read = props[i].getReadMethod();
                       if (read != null) {
  -                        map.put(props[i].getName(),
  +                        map.put(props[i].getName(), 
                                   read.invoke(contextObject, null));
                       }
                   } catch (Exception ignored) {
  @@ -2643,7 +2721,7 @@
           final Response response = ObjectModelHelper.getResponse(objectModel);
           final org.apache.cocoon.environment.Context app =
                     ObjectModelHelper.getContext(objectModel);
  -
  +        
           this.variables = new MyVariables(contextObject,
                                           kont,
                                           request,
  @@ -2657,13 +2735,14 @@
               map = new HashMap();
               fillContext(contextObject, map);
           }
  -
  +        
           jxpathContext = jxpathContextFactory.newContext(null, contextObject);
           jxpathContext.setVariables(variables);
  +        
jxpathContext.setLenient(parameters.getParameterAsBoolean("lenient-xpath", 
false));
           globalJexlContext = new MyJexlContext();
           globalJexlContext.setVars(map);
           map = globalJexlContext.getVars();
  -
  +        
           if (contextObject != null) {
               map.put("flowContext", contextObject);
               // FIXME (VG): Is this required (what it's used for - examples)?
  @@ -2681,17 +2760,20 @@
           map.put("response", response);
           map.put("context", app);
           map.put("parameters", parameters);
  -
  +        
           final Object session = request.getSession(false);
           if (session != null) {
               map.put("session", session);
           }
       }
   
  -    public void generate()
  -        throws IOException, SAXException, ProcessingException {
  -        final String cacheKey = inputSource.getURI();
  -
  +    /* (non-Javadoc)
  +     * @see org.apache.cocoon.generation.Generator#generate()
  +     */
  +    public void generate() 
  +    throws IOException, SAXException, ProcessingException {
  +        final String cacheKey = this.inputSource.getURI();
  +        
           StartDocument startEvent;
           synchronized (cache) {
               startEvent = (StartDocument)cache.get(cacheKey);
  @@ -2700,13 +2782,13 @@
               Parser parser = new Parser();
               SourceUtil.parse(this.manager, this.inputSource, parser);
               startEvent = parser.getStartEvent();
  -            startEvent.compileTime = inputSource.getValidity();
  +            startEvent.compileTime = this.inputSource.getValidity();
               synchronized (cache) {
                   cache.put(cacheKey, startEvent);
               }
           }
           execute(this.xmlConsumer,
  -                globalJexlContext, jxpathContext,
  +                globalJexlContext, jxpathContext, 
                   startEvent, null);
       }
   
  @@ -2716,7 +2798,7 @@
       }
   
       private void characters(JexlContext jexlContext,
  -                            JXPathContext jxpathContext,
  +                            JXPathContext jxpathContext, 
                               TextEvent event,
                               CharHandler handler) throws SAXException {
           Iterator iter = event.substitutions.iterator();
  @@ -2749,18 +2831,20 @@
       }
   
       private void executeRaw(final XMLConsumer consumer,
  -                            Event startEvent, Event endEvent)
  -        throws SAXException {
  +                            Event startEvent, Event endEvent) 
  +    throws SAXException {
           Event ev = startEvent;
  +        LocatorFacade loc = new LocatorFacade(ev.location);
  +        consumer.setDocumentLocator(loc);
           while (ev != endEvent) {
  -            consumer.setDocumentLocator(ev.location);
  +            loc.setDocumentLocator(ev.location);
               if (ev instanceof Characters) {
                   TextEvent text = (TextEvent)ev;
                   consumer.characters(text.raw, 0, text.raw.length);
               } else if (ev instanceof EndDocument) {
                   consumer.endDocument();
               } else if (ev instanceof StartElement) {
  -                StartElement startElement =
  +                StartElement startElement = 
                       (StartElement)ev;
                   consumer.startElement(startElement.namespaceURI,
                                         startElement.localName,
  @@ -2773,7 +2857,7 @@
                                       startElement.localName,
                                       startElement.raw);
               } else if (ev instanceof EndPrefixMapping) {
  -                EndPrefixMapping endPrefixMapping =
  +                EndPrefixMapping endPrefixMapping = 
                       (EndPrefixMapping)ev;
                   consumer.endPrefixMapping(endPrefixMapping.prefix);
               } else if (ev instanceof IgnorableWhitespace) {
  @@ -2792,9 +2876,9 @@
                       consumer.startDocument();
                   }
               } else if (ev instanceof StartPrefixMapping) {
  -                StartPrefixMapping startPrefixMapping =
  +                StartPrefixMapping startPrefixMapping = 
                       (StartPrefixMapping)ev;
  -                consumer.startPrefixMapping(startPrefixMapping.prefix,
  +                consumer.startPrefixMapping(startPrefixMapping.prefix, 
                                               startPrefixMapping.uri);
               } else if (ev instanceof Comment) {
                   TextEvent text = (TextEvent)ev;
  @@ -2823,7 +2907,7 @@
                                         startElement.attributes);
               } else if (ev instanceof EndInstruction) {
                   EndInstruction endInstruction = (EndInstruction)ev;
  -                StartInstruction startInstruction =
  +                StartInstruction startInstruction = 
                       endInstruction.startInstruction;
                   StartElement startElement = startInstruction.startElement;
                   consumer.endElement(startElement.namespaceURI,
  @@ -2832,7 +2916,7 @@
               }
               ev = ev.next;
           }
  -    }
  +    } 
   
       private void executeDOM(final XMLConsumer consumer,
                               MyJexlContext jexlContext,
  @@ -2852,14 +2936,14 @@
                         final XMLConsumer consumer,
                         MyJexlContext jexlContext,
                         JXPathContext jxpathContext,
  -                      Event startEvent, Event endEvent)
  +                      Event startEvent, Event endEvent) 
           throws SAXException {
           try {
               execute(consumer, jexlContext,
                       jxpathContext, startEvent, endEvent);
           } catch (SAXParseException exc) {
               throw new SAXParseException(messagePrefix +": " 
+exc.getMessage(),
  -                                        location,
  +                                        location, 
                                           exc);
           }
       }
  @@ -2867,11 +2951,13 @@
       private void execute(final XMLConsumer consumer,
                            MyJexlContext jexlContext,
                            JXPathContext jxpathContext,
  -                         Event startEvent, Event endEvent)
  -        throws SAXException {
  +                         Event startEvent, Event endEvent) 
  +    throws SAXException {
           Event ev = startEvent;
  +        LocatorFacade loc = new LocatorFacade(ev.location);
  +        consumer.setDocumentLocator(loc);
           while (ev != endEvent) {
  -            consumer.setDocumentLocator(ev.location);
  +            loc.setDocumentLocator(ev.location);
               if (ev instanceof Characters) {
                   TextEvent text = (TextEvent)ev;
                   Iterator iter = text.substitutions.iterator();
  @@ -2883,7 +2969,7 @@
                       } else {
                           Expression expr = (Expression)subst;
                           try {
  -                            Object val =
  +                            Object val = 
                                   getNode(expr, jexlContext, jxpathContext);
                               if (val instanceof Node) {
                                   executeDOM(consumer,
  @@ -2936,17 +3022,17 @@
                                       startElement.localName,
                                       startElement.raw);
               } else if (ev instanceof EndPrefixMapping) {
  -                EndPrefixMapping endPrefixMapping =
  +                EndPrefixMapping endPrefixMapping = 
                       (EndPrefixMapping)ev;
                   consumer.endPrefixMapping(endPrefixMapping.prefix);
               } else if (ev instanceof IgnorableWhitespace) {
                   TextEvent text = (TextEvent)ev;
  -                characters(jexlContext,
  -                           jxpathContext,
  -                           text,
  +                characters(jexlContext, 
  +                           jxpathContext, 
  +                           text, 
                              new CharHandler() {
                                  public void characters(char[] ch, int offset,
  -                                                      int len)
  +                                                      int len) 
                                      throws SAXException {
                                      consumer.ignorableWhitespace(ch, offset, 
len);
                                  }
  @@ -2967,7 +3053,7 @@
                   StartIf startIf = (StartIf)ev;
                   Object val;
                   try {
  -                    val = getValue(startIf.test, jexlContext, jxpathContext);
  +                    val = getValue(startIf.test, jexlContext, jxpathContext, 
Boolean.TRUE);
                   } catch (Exception e) {
                       throw new SAXParseException(e.getMessage(),
                                                   ev.location,
  @@ -2998,9 +3084,9 @@
                       } else {
                           Expression expr = (Expression)items;
                           if (expr.compiledExpression instanceof 
CompiledExpression) {
  -                            CompiledExpression compiledExpression =
  +                            CompiledExpression compiledExpression = 
                                   (CompiledExpression)expr.compiledExpression;
  -                            Object val =
  +                            Object val = 
                                   compiledExpression.getPointer(jxpathContext,
                                                                 
expr.raw).getNode();
                               // FIXME: workaround for JXPath bug
  @@ -3010,7 +3096,7 @@
                                   iter = 
compiledExpression.iteratePointers(jxpathContext);
                               }
                           } else if (expr.compiledExpression instanceof 
org.apache.commons.jexl.Expression) {
  -                            org.apache.commons.jexl.Expression e =
  +                            org.apache.commons.jexl.Expression e = 
                                   
(org.apache.commons.jexl.Expression)expr.compiledExpression;
                               Object result = e.evaluate(jexlContext);
                               if (result != null) {
  @@ -3018,7 +3104,7 @@
                                       
org.apache.commons.jexl.util.Introspector.getUberspect().getIterator(result, 
new Info(ev.location.getSystemId(),
                                                                                
                                             ev.location.getLineNumber(),
                                                                                
                                             ev.location.getColumnNumber()));
  -
  +                                
                               }
                               if (iter == null) {
                                   iter = EMPTY_ITER;
  @@ -3026,19 +3112,19 @@
                           } else {
                               // literal value
                               iter = new Iterator() {
  -
  +                                    
                                   Object val = items;
  -
  +                                
                                   public boolean hasNext() {
                                       return val != null;
                                   }
  -
  +                                
                                   public Object next() {
                                       Object res = val;
                                       val = null;
                                       return res;
                                   }
  -
  +                                
                                   public void remove() {
                                   }
                               };
  @@ -3046,10 +3132,10 @@
                       }
                       begin = startForEach.begin == null ? 0 :
                           getIntValue(startForEach.begin, jexlContext, 
jxpathContext);
  -                    end = startForEach.end == null ? Integer.MAX_VALUE :
  -                        getIntValue(startForEach.end, jexlContext,
  +                    end = startForEach.end == null ? Integer.MAX_VALUE : 
  +                        getIntValue(startForEach.end, jexlContext, 
                                       jxpathContext);
  -                    step = startForEach.step == null ? 1 :
  +                    step = startForEach.step == null ? 1 : 
                           getIntValue(startForEach.step, jexlContext,
                                       jxpathContext);
                   } catch (Exception exc) {
  @@ -3062,7 +3148,7 @@
                                                   null);
                   }
                   int i;
  -                MyJexlContext localJexlContext =
  +                MyJexlContext localJexlContext = 
                       new MyJexlContext(jexlContext);
                   for (i = 0; i < begin && iter.hasNext(); i++) {
                       iter.next();
  @@ -3073,7 +3159,7 @@
                       value = iter.next();
                       if (value instanceof Pointer) {
                           Pointer ptr = (Pointer)value;
  -                        localJXPathContext =
  +                        localJXPathContext = 
                               jxpathContext.getRelativeContext(ptr);
                           try {
                               value = ptr.getNode();
  @@ -3095,7 +3181,7 @@
                               localJXPathContext,
                               startForEach.next,
                               startForEach.endInstruction);
  -                    for (int skip = step-1;
  +                    for (int skip = step-1; 
                            skip > 0 && iter.hasNext(); --skip) {
                           iter.next();
                       }
  @@ -3104,12 +3190,12 @@
                   continue;
               } else if (ev instanceof StartChoose) {
                   StartChoose startChoose = (StartChoose)ev;
  -                StartWhen startWhen = startChoose.firstChoice;
  +                StartWhen startWhen = startChoose.firstChoice; 
                   for (;startWhen != null; startWhen = startWhen.nextChoice) {
                       Object val;
                       try {
                           val = getValue(startWhen.test, jexlContext,
  -                                       jxpathContext);
  +                                       jxpathContext, Boolean.TRUE);
                       } catch (Exception e) {
                           throw new SAXParseException(e.getMessage(),
                                                       ev.location,
  @@ -3158,7 +3244,7 @@
                                            "set",
                                            EMPTY_ATTRS);
                       execute(builder, jexlContext, jxpathContext,
  -                            startSet.next,
  +                            startSet.next, 
                               startSet.endInstruction);
                       builder.endElement(NS,
                                          "set",
  @@ -3175,14 +3261,14 @@
                       }
                       value = nodeArr;
                   }
  -                jxpathContext.getVariables().declareVariable(startSet.var,
  +                jxpathContext.getVariables().declareVariable(startSet.var, 
                                                                value);
                   jexlContext.put(startSet.var, value);
                   ev = startSet.endInstruction.next;
                   continue;
               } else if (ev instanceof StartElement) {
                   StartElement startElement = (StartElement)ev;
  -                StartDefine def =
  +                StartDefine def = 
                       (StartDefine)definitions.get(startElement.qname);
                   if (def != null) {
                       Map attributeMap = new HashMap();
  @@ -3197,18 +3283,18 @@
                               CopyAttribute copy =
                                   (CopyAttribute)attrEvent;
                               attributeValue = copy.value;
  -                        } else if (attrEvent instanceof
  +                        } else if (attrEvent instanceof 
                                      SubstituteAttribute) {
                               SubstituteAttribute substEvent =
                                   (SubstituteAttribute)attrEvent;
                               if (substEvent.substitutions.size() == 1 &&
  -                                substEvent.substitutions.get(0) instanceof
  +                                substEvent.substitutions.get(0) instanceof 
                                   Expression) {
                                   Expression expr = (Expression)
                                       substEvent.substitutions.get(0);
                                   Object val;
                                   try {
  -                                    val =
  +                                    val = 
                                           getNode(expr,
                                                   jexlContext,
                                                   jxpathContext);
  @@ -3233,7 +3319,7 @@
                                           Expression expr = (Expression)subst;
                                           Object val;
                                           try {
  -                                            val =
  +                                            val = 
                                                   getValue(expr,
                                                            jexlContext,
                                                            jxpathContext);
  @@ -3261,19 +3347,19 @@
                                            startElement.localName,
                                            startElement.raw,
                                            EMPTY_ATTRS);
  -                    executeRaw(builder,
  -                               startElement.next,
  +                    executeRaw(builder, 
  +                               startElement.next, 
                                  startElement.endElement);
                       builder.endElement(startElement.namespaceURI,
                                          startElement.localName,
                                          startElement.raw);
                       builder.endDocument();
                       Node node = builder.getDocument().getDocumentElement();
  -                    MyVariables vars =
  +                    MyVariables vars = 
                           (MyVariables)jxpathContext.getVariables();
                       Map saveLocals = vars.localVariables;
                       vars.localVariables = new HashMap();
  -                    MyJexlContext localJexlContext =
  +                    MyJexlContext localJexlContext = 
                           new MyJexlContext(globalJexlContext);
                       // JXPath doesn't handle NodeList, so convert it to
                       // an array
  @@ -3289,7 +3375,7 @@
                       while (iter.hasNext()) {
                           Map.Entry e = (Map.Entry)iter.next();
                           String key = (String)e.getKey();
  -                        StartParameter startParam =
  +                        StartParameter startParam = 
                               (StartParameter)e.getValue();
                           Object default_ = startParam.default_;
                           Object val = attributeMap.get(key);
  @@ -3304,7 +3390,7 @@
                       localJXPathContext.setVariables(vars);
                       call(ev.location,
                            startElement.localName,
  -                         consumer,
  +                         consumer, 
                            localJexlContext, localJXPathContext,
                            def.body, def.endInstruction);
                       vars.localVariables = saveLocals;
  @@ -3324,7 +3410,7 @@
                                              copy.raw,
                                              copy.type,
                                              copy.value);
  -                    } else if (attrEvent instanceof
  +                    } else if (attrEvent instanceof 
                                  SubstituteAttribute) {
                           StringBuffer buf = new StringBuffer();
                           SubstituteAttribute substEvent =
  @@ -3339,14 +3425,14 @@
                                   Expression expr = (Expression)subst;
                                   Object val;
                                   try {
  -                                    val =
  +                                    val = 
                                           getValue(expr,
                                                    jexlContext,
                                                    jxpathContext);
                                   } catch (Exception e) {
                                       throw new 
SAXParseException(e.getMessage(),
                                                                   ev.location,
  -                                                                e);
  +                                                                e); 
                                  }
                                   if (val == null) {
                                       val = "";
  @@ -3364,10 +3450,10 @@
                   consumer.startElement(startElement.namespaceURI,
                                         startElement.localName,
                                         startElement.raw,
  -                                      attrs);
  -
  +                                      attrs); 
  +                
               } else if (ev instanceof StartFormatNumber) {
  -                StartFormatNumber startFormatNumber =
  +                StartFormatNumber startFormatNumber = 
                       (StartFormatNumber)ev;
                   try {
                       String result =
  @@ -3383,7 +3469,7 @@
                                                   e);
                   }
               } else if (ev instanceof StartFormatDate) {
  -                StartFormatDate startFormatDate =
  +                StartFormatDate startFormatDate = 
                       (StartFormatDate)ev;
                   try {
                       String result =
  @@ -3399,19 +3485,19 @@
                                                   e);
                   }
               } else if (ev instanceof StartPrefixMapping) {
  -                StartPrefixMapping startPrefixMapping =
  +                StartPrefixMapping startPrefixMapping = 
                       (StartPrefixMapping)ev;
  -                consumer.startPrefixMapping(startPrefixMapping.prefix,
  +                consumer.startPrefixMapping(startPrefixMapping.prefix, 
                                               startPrefixMapping.uri);
               } else if (ev instanceof Comment) {
                   TextEvent text = (TextEvent)ev;
                   final StringBuffer buf = new StringBuffer();
  -                characters(jexlContext,
  -                           jxpathContext,
  -                           text,
  +                characters(jexlContext, 
  +                           jxpathContext, 
  +                           text, 
                              new CharHandler() {
                                  public void characters(char[] ch, int offset,
  -                                                      int len)
  +                                                      int len) 
                                      throws SAXException {
                                      buf.append(ch, offset, len);
                                  }
  @@ -3440,7 +3526,8 @@
                   try {
                       val = getNode(startOut.compiledExpression,
                                     jexlContext,
  -                                  jxpathContext);
  +                                  jxpathContext,
  +                                  startOut.lenient);
                       if (val instanceof Node) {
                           executeDOM(consumer,
                                      jexlContext,
  @@ -3500,7 +3587,7 @@
                               Expression expr = (Expression)subst;
                               Object val;
                               try {
  -                                val =
  +                                val = 
                                       getValue(expr,
                                                jexlContext,
                                                jxpathContext);
  @@ -3520,13 +3607,13 @@
                           }
                       }
                       uri = buf.toString();
  -
  +                    
                   }
                   Source input = null;
                   StartDocument doc;
                   try {
                       input = resolver.resolveURI(uri);
  -
  +                
                       SourceValidity validity = null;
                       synchronized (cache) {
                           doc = (StartDocument)cache.get(input.getURI());
  @@ -3577,7 +3664,7 @@
                           Object obj = getValue(startImport.select,
                                                 jexlContext,
                                                 jxpathContext);
  -                        selectJXPath =
  +                        selectJXPath = 
                               jxpathContextFactory.newContext(null, obj);
                           selectJXPath.setVariables(variables);
                           selectJexl = new MyJexlContext(globalJexlContext);
  @@ -3592,7 +3679,7 @@
                                                       null);
                       }
                   }
  -                execute(consumer, selectJexl, selectJXPath, doc.next,
  +                execute(consumer, selectJexl, selectJXPath, doc.next, 
                           doc.endDocument);
                   ev = startImport.endInstruction.next;
                   continue;
  
  
  
  1.8       +5 -1      cocoon-2.2/src/webapp/WEB-INF/web.xml
  
  Index: web.xml
  ===================================================================
  RCS file: /home/cvs/cocoon-2.2/src/webapp/WEB-INF/web.xml,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- web.xml   22 Sep 2003 19:12:40 -0000      1.7
  +++ web.xml   7 Nov 2003 13:25:54 -0000       1.8
  @@ -242,7 +242,11 @@
         time to the end of each response. Value 'hide' adds processing time as 
an
         HTML comment. By default, processing time is not added (corresponds to
         value 'no').
  -
  +      NOTE: If you use this feature, Cocoon might generated a wrong content
  +      length header in the response. This is due to the internal processing
  +      of Readers and the Caching. So, this might be the reason if you get
  +      a warning about a wrong content length.
  +      See http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17370.
       <init-param>
         <param-name>show-time</param-name>
         <param-value>hide</param-value>
  
  
  

Reply via email to