cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lgaw...@apache.org
Subject svn commit: r279071 - in /cocoon/blocks/template/trunk/java/org/apache/cocoon: components/expression/ template/ template/environment/ template/expression/ template/instruction/ template/script/
Date Tue, 06 Sep 2005 19:19:09 GMT
Author: lgawron
Date: Tue Sep  6 12:16:41 2005
New Revision: 279071

URL: http://svn.apache.org/viewcvs?rev=279071&view=rev
Log:
small steps towards pluggable ExpressionCompiler

Added:
    cocoon/blocks/template/trunk/java/org/apache/cocoon/template/expression/JXTExpressionCompiler.java   (with props)
Modified:
    cocoon/blocks/template/trunk/java/org/apache/cocoon/components/expression/ExpressionFactory.java
    cocoon/blocks/template/trunk/java/org/apache/cocoon/template/JXTemplateGenerator.java
    cocoon/blocks/template/trunk/java/org/apache/cocoon/template/TransformerAdapter.java
    cocoon/blocks/template/trunk/java/org/apache/cocoon/template/environment/ExecutionContext.java
    cocoon/blocks/template/trunk/java/org/apache/cocoon/template/expression/JXTExpression.java
    cocoon/blocks/template/trunk/java/org/apache/cocoon/template/expression/Substitutions.java
    cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/Attribute.java
    cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/Call.java
    cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/Eval.java
    cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/ForEach.java
    cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/FormatDate.java
    cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/FormatNumber.java
    cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/If.java
    cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/Import.java
    cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/LocaleAwareInstruction.java
    cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/Out.java
    cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/ParameterInstance.java
    cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/Set.java
    cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/When.java
    cocoon/blocks/template/trunk/java/org/apache/cocoon/template/script/DefaultInstructionFactory.java
    cocoon/blocks/template/trunk/java/org/apache/cocoon/template/script/DefaultScriptManager.java
    cocoon/blocks/template/trunk/java/org/apache/cocoon/template/script/Parser.java

Modified: cocoon/blocks/template/trunk/java/org/apache/cocoon/components/expression/ExpressionFactory.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/template/trunk/java/org/apache/cocoon/components/expression/ExpressionFactory.java?rev=279071&r1=279070&r2=279071&view=diff
==============================================================================
--- cocoon/blocks/template/trunk/java/org/apache/cocoon/components/expression/ExpressionFactory.java (original)
+++ cocoon/blocks/template/trunk/java/org/apache/cocoon/components/expression/ExpressionFactory.java Tue Sep  6 12:16:41 2005
@@ -30,7 +30,7 @@
     extends AbstractLogEnabled
     implements Disposable, Serviceable, ThreadSafe {
     public static String ROLE = ExpressionFactory.class.getName();
-    public static String DEFAULT ="default";
+    public static String DEFAULT_EXPRESSION_LANGUAGE ="default";
 
     /** The component manager */
     protected ServiceManager manager;
@@ -70,7 +70,7 @@
     }
 
     public Expression getExpression(String expression) throws ExpressionException {
-        String language = DEFAULT;
+        String language = DEFAULT_EXPRESSION_LANGUAGE;
         int end = expression.indexOf(':');
         if (end != -1) {
             language = expression.substring(0, end);

Modified: cocoon/blocks/template/trunk/java/org/apache/cocoon/template/JXTemplateGenerator.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/template/trunk/java/org/apache/cocoon/template/JXTemplateGenerator.java?rev=279071&r1=279070&r2=279071&view=diff
==============================================================================
--- cocoon/blocks/template/trunk/java/org/apache/cocoon/template/JXTemplateGenerator.java (original)
+++ cocoon/blocks/template/trunk/java/org/apache/cocoon/template/JXTemplateGenerator.java Tue Sep  6 12:16:41 2005
@@ -26,6 +26,7 @@
 import org.apache.cocoon.ProcessingException;
 import org.apache.cocoon.caching.CacheableProcessingComponent;
 import org.apache.cocoon.components.expression.ExpressionContext;
+import org.apache.cocoon.components.expression.ExpressionFactory;
 import org.apache.cocoon.environment.SourceResolver;
 import org.apache.cocoon.generation.ServiceableGenerator;
 import org.apache.cocoon.template.environment.ExecutionContext;
@@ -59,8 +60,7 @@
  * @version SVN $Id: JXTemplateGenerator.java 169169 2005-05-08 21:23:28Z
  *          lgawron $
  */
-public class JXTemplateGenerator extends ServiceableGenerator implements
-        CacheableProcessingComponent {
+public class JXTemplateGenerator extends ServiceableGenerator implements CacheableProcessingComponent {
     /** The namespace used by this generator */
     public final static String NS = "http://apache.org/cocoon/templates/jx/1.0";
 
@@ -69,6 +69,7 @@
 
     private ExpressionContext expressionContext;
     private ScriptManager scriptManager;
+
     private StartDocument startDocument;
     private Map definitions;
 
@@ -78,7 +79,7 @@
 
     public void service(ServiceManager manager) throws ServiceException {
         super.service(manager);
-        scriptManager = (ScriptManager) this.manager.lookup(ScriptManager.ROLE);
+        this.scriptManager = (ScriptManager) this.manager.lookup(ScriptManager.ROLE);
     }
 
     public void dispose() {
@@ -93,34 +94,29 @@
         super.recycle();
     }
 
-    public void setup(SourceResolver resolver, Map objectModel, String src,
-            Parameters parameters) throws ProcessingException, SAXException,
-            IOException {
+    public void setup(SourceResolver resolver, Map objectModel, String src, Parameters parameters)
+            throws ProcessingException, SAXException, IOException {
 
         super.setup(resolver, objectModel, src, parameters);
         if (src != null)
             startDocument = scriptManager.resolveTemplate(src);
 
-        this.expressionContext = FlowObjectModelHelper.getFOMExpressionContext(
-                objectModel, parameters);
+        this.expressionContext = FlowObjectModelHelper.getFOMExpressionContext(objectModel, parameters);
         this.definitions = new HashMap();
     }
 
-    public void generate() throws IOException, SAXException,
-            ProcessingException {
+    public void generate() throws IOException, SAXException, ProcessingException {
         performGeneration(this.startDocument, null);
 
         // no need to reference compiled script anymore
         this.startDocument = null;
     }
 
-    public void performGeneration(Event startEvent, Event endEvent)
-            throws SAXException {
-        XMLConsumer consumer = new AttributeAwareXMLConsumerImpl(
-                new RedundantNamespacesFilter(this.xmlConsumer));
+    public void performGeneration(Event startEvent, Event endEvent) throws SAXException {
+        XMLConsumer consumer = new AttributeAwareXMLConsumerImpl(new RedundantNamespacesFilter(this.xmlConsumer));
         ((Map) expressionContext.get("cocoon")).put("consumer", consumer);
-        Invoker.execute(consumer, this.expressionContext, new ExecutionContext(
-                this.definitions, this.scriptManager, this.manager), null, startEvent, null);
+        Invoker.execute(consumer, this.expressionContext, new ExecutionContext(this.definitions, this.scriptManager,
+                this.manager), null, startEvent, null);
     }
 
     public Serializable getKey() {
@@ -129,8 +125,7 @@
         if (cacheKeyExpr == null)
             return null;
         try {
-            final Serializable templateKey = (Serializable) cacheKeyExpr
-                    .getValue(this.expressionContext);
+            final Serializable templateKey = (Serializable) cacheKeyExpr.getValue(this.expressionContext);
             if (templateKey != null) {
                 return new JXCacheKey(this.startDocument.getUri(), templateKey);
             }
@@ -146,10 +141,8 @@
         if (validityExpr == null)
             return null;
         try {
-            final SourceValidity sourceValidity = this.startDocument
-                    .getSourceValidity();
-            final SourceValidity templateValidity = (SourceValidity) validityExpr
-                    .getValue(this.expressionContext);
+            final SourceValidity sourceValidity = this.startDocument.getSourceValidity();
+            final SourceValidity templateValidity = (SourceValidity) validityExpr.getValue(this.expressionContext);
             if (sourceValidity != null && templateValidity != null) {
                 return new JXSourceValidity(sourceValidity, templateValidity);
             }

Modified: cocoon/blocks/template/trunk/java/org/apache/cocoon/template/TransformerAdapter.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/template/trunk/java/org/apache/cocoon/template/TransformerAdapter.java?rev=279071&r1=279070&r2=279071&view=diff
==============================================================================
--- cocoon/blocks/template/trunk/java/org/apache/cocoon/template/TransformerAdapter.java (original)
+++ cocoon/blocks/template/trunk/java/org/apache/cocoon/template/TransformerAdapter.java Tue Sep  6 12:16:41 2005
@@ -24,6 +24,7 @@
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.Serviceable;
 import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.components.expression.ExpressionFactory;
 import org.apache.cocoon.environment.SourceResolver;
 import org.apache.cocoon.template.script.InstructionFactory;
 import org.apache.cocoon.template.script.Parser;
@@ -39,31 +40,28 @@
  * @version SVN $Id$
  */
 public class TransformerAdapter extends ServiceableTransformer {
-    static class TemplateConsumer extends Parser implements XMLConsumer,
-            Serviceable, Disposable {
-
-        private InstructionFactory instructionFactory;
+    static class TemplateConsumer extends Parser implements XMLConsumer, Serviceable, Disposable {
         private ServiceManager manager;
 
         public TemplateConsumer() {
             this.gen = new JXTemplateGenerator();
         }
 
-        public void setup(SourceResolver resolver, Map objectModel, String src,
-                Parameters parameters) throws ProcessingException,
-                SAXException, IOException {
+        public void setup(SourceResolver resolver, Map objectModel, String src, Parameters parameters)
+                throws ProcessingException, SAXException, IOException {
             this.gen.setup(resolver, objectModel, null, parameters);
         }
 
         public void service(ServiceManager manager) throws ServiceException {
             this.manager = manager;
             this.gen.service(manager);
-            this.instructionFactory = (InstructionFactory) manager
-                    .lookup(InstructionFactory.ROLE);
+            this.instructionFactory = (InstructionFactory) this.manager.lookup(InstructionFactory.ROLE);
+            this.expressionFactory = (ExpressionFactory) this.manager.lookup(ExpressionFactory.ROLE);
         }
 
         public void dispose() {
-            this.manager.release(instructionFactory);
+            this.manager.release(this.instructionFactory);
+            this.manager.release(this.expressionFactory);
         }
 
         public void endDocument() throws SAXException {
@@ -90,9 +88,8 @@
         templateConsumer.recycle();
     }
 
-    public void setup(SourceResolver resolver, Map objectModel, String src,
-            Parameters parameters) throws ProcessingException, SAXException,
-            IOException {
+    public void setup(SourceResolver resolver, Map objectModel, String src, Parameters parameters)
+            throws ProcessingException, SAXException, IOException {
         super.setup(resolver, objectModel, src, parameters);
         templateConsumer.setup(resolver, objectModel, src, parameters);
     }

Modified: cocoon/blocks/template/trunk/java/org/apache/cocoon/template/environment/ExecutionContext.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/template/trunk/java/org/apache/cocoon/template/environment/ExecutionContext.java?rev=279071&r1=279070&r2=279071&view=diff
==============================================================================
--- cocoon/blocks/template/trunk/java/org/apache/cocoon/template/environment/ExecutionContext.java (original)
+++ cocoon/blocks/template/trunk/java/org/apache/cocoon/template/environment/ExecutionContext.java Tue Sep  6 12:16:41 2005
@@ -27,7 +27,7 @@
     private Map definitions;
     private ScriptManager scriptManager;
     private ServiceManager serviceManager;
-    
+
     public ExecutionContext(Map definitions, ScriptManager scriptManager, ServiceManager serviceManager) {
         this.definitions = definitions;
         this.scriptManager = scriptManager;
@@ -41,7 +41,7 @@
     public ScriptManager getScriptManager() {
         return this.scriptManager;
     }
-    
+
     public ServiceManager getServiceManager() {
         return serviceManager;
     }

Modified: cocoon/blocks/template/trunk/java/org/apache/cocoon/template/expression/JXTExpression.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/template/trunk/java/org/apache/cocoon/template/expression/JXTExpression.java?rev=279071&r1=279070&r2=279071&view=diff
==============================================================================
--- cocoon/blocks/template/trunk/java/org/apache/cocoon/template/expression/JXTExpression.java (original)
+++ cocoon/blocks/template/trunk/java/org/apache/cocoon/template/expression/JXTExpression.java Tue Sep  6 12:16:41 2005
@@ -15,148 +15,33 @@
  */
 package org.apache.cocoon.template.expression;
 
-import java.io.IOException;
-import java.io.StringReader;
 import java.util.Iterator;
 
 import org.apache.cocoon.components.expression.Expression;
 import org.apache.cocoon.components.expression.ExpressionContext;
-import org.apache.cocoon.components.expression.jexl.JexlCompiler;
-import org.apache.cocoon.components.expression.jxpath.JXPathCompiler;
 import org.apache.cocoon.components.expression.jxpath.JXPathExpression;
-import org.apache.cocoon.template.environment.ErrorHolder;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
 
 /**
  * @version SVN $Id$
  */
 public class JXTExpression extends Subst {
-
     private String raw;
     private Object compiledExpression;
 
-    private static JXPathCompiler jxpathCompiler = new JXPathCompiler();
-    private static JexlCompiler jexlCompiler = new JexlCompiler();
-    private static String JXPATH = "jxpath";
-    private static String JEXL = "jexl";
-
-    // Factory methods
-
-    public static JXTExpression compile(final String expression, boolean xpath)
-        throws Exception {
-        Expression compiled;
-        if (xpath) {
-            compiled = jxpathCompiler.compile(JXPATH, expression);
-        } else {
-            compiled = jexlCompiler.compile(JEXL, expression);
-        }
-        return new JXTExpression(expression, compiled);
-    }
-
-    public static JXTExpression compileBoolean(String val, String msg,
-                                               Locator location) throws SAXException {
-        JXTExpression res = compileExpr(val, msg, location);
-        if (res != null && res.getCompiledExpression() == null && res.getRaw() != null) {
-            res.setCompiledExpression(Boolean.valueOf(res.getRaw()));
-        }
-        return res;
-    }
-
-    /*
-     * Compile an integer expression (returns either a Compiled Expression or an
-     * Integer literal)
-     */
-    public static JXTExpression compileInt(String val, String msg,
-            Locator location) throws SAXException {
-        JXTExpression res = compileExpr(val, msg, location);
-        if (res != null && res.getCompiledExpression() == null && res.getRaw() != null) {
-            res.setCompiledExpression(Integer.valueOf(res.getRaw()));
-        }
-        return res;
-    }
-
-    public static JXTExpression compileExpr(String inStr) throws Exception {
-        try {
-            if (inStr == null) {
-                return null;
-            }
-            StringReader in = new StringReader(inStr.trim());
-            int ch;
-            boolean xpath = false;
-            boolean inExpr = false;
-            StringBuffer expr = new StringBuffer();
-            while ((ch = in.read()) != -1) {
-                char c = (char) ch;
-                if (inExpr) {
-                    if (c == '\\') {
-                        ch = in.read();
-                        expr.append((ch == -1) ? '\\' : (char) ch);
-                    } else if (c == '}') {
-                        return compile(expr.toString(), xpath);
-                    } else {
-                        expr.append(c);
-                    }
-                } else {
-                    if (c == '$' || c == '#') {
-                        ch = in.read();
-                        if (ch == '{') {
-                            inExpr = true;
-                            xpath = c == '#';
-                            continue;
-                        }
-                    }
-                    // hack: invalid expression?
-                    // just return the original and swallow exception
-                    return new JXTExpression(inStr, null);
-                }
-            }
-            if (inExpr) {
-                // unclosed #{} or ${}
-                throw new Exception("Unterminated " + (xpath ? "#" : "$") + "{");
-            }
-        } catch (IOException ignored) {
-            ignored.printStackTrace();
-        }
-        return new JXTExpression(inStr, null);
-    }
-
-    /**
-     * Compile a single Jexl expr (contained in ${}) or XPath expression
-     * (contained in #{})
-     */
-
-    public static JXTExpression compileExpr(String expr, String errorPrefix,
-                                            Locator location) throws SAXParseException {
-        try {
-            return compileExpr(expr);
-        } catch (Exception exc) {
-            throw new SAXParseException(errorPrefix + exc.getMessage(),
-                    location, exc);
-        } catch (Error err) {
-            throw new SAXParseException(errorPrefix + err.getMessage(),
-                    location, new ErrorHolder(err));
-        }
-    }
-
-
-    // Members
-
-    private JXTExpression(String raw, Object expr) {
+    public JXTExpression(String raw, Object expr) {
         this.raw = raw;
         this.compiledExpression = expr;
     }
 
-    private Object getCompiledExpression() {
+    public Object getCompiledExpression() {
         return compiledExpression;
     }
 
-    private void setCompiledExpression(Object compiledExpression) {
+    public void setCompiledExpression(Object compiledExpression) {
         this.compiledExpression = compiledExpression;
     }
 
-    private String getRaw() {
+    public String getRaw() {
         return raw;
     }
 
@@ -254,6 +139,7 @@
 
     public void setLenient(Boolean lenient) {
         if (this.compiledExpression instanceof Expression)
+            //TODO: hack! bases on particular expression implementation.
             ((Expression)this.compiledExpression).setProperty(JXPathExpression.LENIENT, lenient);
     }
 

Added: cocoon/blocks/template/trunk/java/org/apache/cocoon/template/expression/JXTExpressionCompiler.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/template/trunk/java/org/apache/cocoon/template/expression/JXTExpressionCompiler.java?rev=279071&view=auto
==============================================================================
--- cocoon/blocks/template/trunk/java/org/apache/cocoon/template/expression/JXTExpressionCompiler.java (added)
+++ cocoon/blocks/template/trunk/java/org/apache/cocoon/template/expression/JXTExpressionCompiler.java Tue Sep  6 12:16:41 2005
@@ -0,0 +1,130 @@
+/*
+ * $Id$
+ *
+ * Created on 2005-09-06
+ *
+ * Copyright (c) 2005, MobileBox sp. z o.o.
+ * All rights reserved.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package org.apache.cocoon.template.expression;
+
+import java.io.IOException;
+import java.io.StringReader;
+
+import org.apache.cocoon.components.expression.Expression;
+import org.apache.cocoon.components.expression.jexl.JexlCompiler;
+import org.apache.cocoon.components.expression.jxpath.JXPathCompiler;
+import org.apache.cocoon.template.environment.ErrorHolder;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+public class JXTExpressionCompiler {
+    public static JXPathCompiler jxpathCompiler = new JXPathCompiler();
+    public static JexlCompiler jexlCompiler = new JexlCompiler();
+    public static String JXPATH = "jxpath";
+    public static String JEXL = "jexl";
+    public static JXTExpression compile(final String expression, boolean xpath)
+        throws Exception {
+        Expression compiled;
+        if (xpath) {
+            compiled = jxpathCompiler.compile(JXPATH, expression);
+        } else {
+            compiled = jexlCompiler.compile(JEXL, expression);
+        }
+        return new JXTExpression(expression, compiled);
+    }
+    public static JXTExpression compileBoolean(String val, String msg,
+                                               Locator location) throws SAXException {
+        JXTExpression res = JXTExpressionCompiler.compileExpr(val, msg, location);
+        if (res != null && res.getCompiledExpression() == null && res.getRaw() != null) {
+            res.setCompiledExpression(Boolean.valueOf(res.getRaw()));
+        }
+        return res;
+    }
+    /*
+     * Compile an integer expression (returns either a Compiled Expression or an
+     * Integer literal)
+     */
+    public static JXTExpression compileInt(String val, String msg,
+            Locator location) throws SAXException {
+        JXTExpression res = JXTExpressionCompiler.compileExpr(val, msg, location);
+        if (res != null && res.getCompiledExpression() == null && res.getRaw() != null) {
+            res.setCompiledExpression(Integer.valueOf(res.getRaw()));
+        }
+        return res;
+    }
+    public static JXTExpression compileExpr(String inStr) throws Exception {
+        try {
+            if (inStr == null) {
+                return null;
+            }
+            StringReader in = new StringReader(inStr.trim());
+            int ch;
+            boolean xpath = false;
+            boolean inExpr = false;
+            StringBuffer expr = new StringBuffer();
+            while ((ch = in.read()) != -1) {
+                char c = (char) ch;
+                if (inExpr) {
+                    if (c == '\\') {
+                        ch = in.read();
+                        expr.append((ch == -1) ? '\\' : (char) ch);
+                    } else if (c == '}') {
+                        return compile(expr.toString(), xpath);
+                    } else {
+                        expr.append(c);
+                    }
+                } else {
+                    if (c == '$' || c == '#') {
+                        ch = in.read();
+                        if (ch == '{') {
+                            inExpr = true;
+                            xpath = c == '#';
+                            continue;
+                        }
+                    }
+                    // hack: invalid expression?
+                    // just return the original and swallow exception
+                    return new JXTExpression(inStr, null);
+                }
+            }
+            if (inExpr) {
+                // unclosed #{} or ${}
+                throw new Exception("Unterminated " + (xpath ? "#" : "$") + "{");
+            }
+        } catch (IOException ignored) {
+            ignored.printStackTrace();
+        }
+        return new JXTExpression(inStr, null);
+    }
+    /**
+     * Compile a single Jexl expr (contained in ${}) or XPath expression
+     * (contained in #{})
+     */
+    public static JXTExpression compileExpr(String expr, String errorPrefix,
+                                            Locator location) throws SAXParseException {
+        try {
+            return compileExpr(expr);
+        } catch (Exception exc) {
+            throw new SAXParseException(errorPrefix + exc.getMessage(),
+                    location, exc);
+        } catch (Error err) {
+            throw new SAXParseException(errorPrefix + err.getMessage(),
+                    location, new ErrorHolder(err));
+        }
+    }
+
+}

Propchange: cocoon/blocks/template/trunk/java/org/apache/cocoon/template/expression/JXTExpressionCompiler.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/blocks/template/trunk/java/org/apache/cocoon/template/expression/JXTExpressionCompiler.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/blocks/template/trunk/java/org/apache/cocoon/template/expression/Substitutions.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/template/trunk/java/org/apache/cocoon/template/expression/Substitutions.java?rev=279071&r1=279070&r2=279071&view=diff
==============================================================================
--- cocoon/blocks/template/trunk/java/org/apache/cocoon/template/expression/Substitutions.java (original)
+++ cocoon/blocks/template/trunk/java/org/apache/cocoon/template/expression/Substitutions.java Tue Sep  6 12:16:41 2005
@@ -68,7 +68,7 @@
                             String str = buf.toString();
                             JXTExpression compiledExpression;
                             try {
-                                compiledExpression = JXTExpression.compile(str, xpath);
+                                compiledExpression = JXTExpressionCompiler.compile(str, xpath);
                             } catch (Exception exc) {
                                 throw new SAXParseException(exc.getMessage(),
                                                             location, exc);

Modified: cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/Attribute.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/Attribute.java?rev=279071&r1=279070&r2=279071&view=diff
==============================================================================
--- cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/Attribute.java (original)
+++ cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/Attribute.java Tue Sep  6 12:16:41 2005
@@ -8,6 +8,7 @@
 import org.apache.cocoon.components.expression.ExpressionContext;
 import org.apache.cocoon.template.environment.ExecutionContext;
 import org.apache.cocoon.template.expression.JXTExpression;
+import org.apache.cocoon.template.expression.JXTExpressionCompiler;
 import org.apache.cocoon.template.script.event.Event;
 import org.apache.cocoon.template.script.event.StartElement;
 import org.apache.cocoon.template.xml.AttributeAwareXMLConsumer;
@@ -34,7 +35,7 @@
             throw new SAXParseException("parameter: \"name\" is required",
                     locator, null);
         }
-        this.name = JXTExpression.compileExpr(name, "parameter: \"name\": ",
+        this.name = JXTExpressionCompiler.compileExpr(name, "parameter: \"name\": ",
                 locator);
 
         String value = attrs.getValue("value");
@@ -42,7 +43,7 @@
             throw new SAXParseException("parameter: \"value\" is required",
                     locator, null);
 
-        this.value = JXTExpression.compileExpr(value, "parameter: \"value\": ",
+        this.value = JXTExpressionCompiler.compileExpr(value, "parameter: \"value\": ",
                 locator);
     }
 

Modified: cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/Call.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/Call.java?rev=279071&r1=279070&r2=279071&view=diff
==============================================================================
--- cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/Call.java (original)
+++ cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/Call.java Tue Sep  6 12:16:41 2005
@@ -24,6 +24,7 @@
 import org.apache.cocoon.template.environment.ErrorHolder;
 import org.apache.cocoon.template.environment.ExecutionContext;
 import org.apache.cocoon.template.expression.JXTExpression;
+import org.apache.cocoon.template.expression.JXTExpressionCompiler;
 import org.apache.cocoon.template.script.Invoker;
 import org.apache.cocoon.template.script.event.AttributeEvent;
 import org.apache.cocoon.template.script.event.Characters;
@@ -73,12 +74,12 @@
             throw new SAXParseException("if: \"test\" is required", locator,
                     null);
         }
-        this.macro = JXTExpression.compileExpr(name, "call: \"macro\": ",
+        this.macro = JXTExpressionCompiler.compileExpr(name, "call: \"macro\": ",
                 locator);
 
         String namespace = StringUtils.defaultString(attrs
                 .getValue("targetNamespace"));
-        this.targetNamespace = JXTExpression.compileExpr(namespace,
+        this.targetNamespace = JXTExpressionCompiler.compileExpr(namespace,
                 "call: \"targetNamespace\": ", locator);
     }
 

Modified: cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/Eval.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/Eval.java?rev=279071&r1=279070&r2=279071&view=diff
==============================================================================
--- cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/Eval.java (original)
+++ cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/Eval.java Tue Sep  6 12:16:41 2005
@@ -21,6 +21,7 @@
 import org.apache.cocoon.template.environment.ErrorHolder;
 import org.apache.cocoon.template.environment.ExecutionContext;
 import org.apache.cocoon.template.expression.JXTExpression;
+import org.apache.cocoon.template.expression.JXTExpressionCompiler;
 import org.apache.cocoon.template.script.Invoker;
 import org.apache.cocoon.template.script.event.Event;
 import org.apache.cocoon.template.script.event.StartElement;
@@ -41,7 +42,7 @@
         super(raw);
 
         String select = attrs.getValue("select");
-        this.value = JXTExpression.compileExpr(select, "eval: \"select\":", getLocation());
+        this.value = JXTExpressionCompiler.compileExpr(select, "eval: \"select\":", getLocation());
     }
 
     public Event execute(final XMLConsumer consumer,

Modified: cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/ForEach.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/ForEach.java?rev=279071&r1=279070&r2=279071&view=diff
==============================================================================
--- cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/ForEach.java (original)
+++ cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/ForEach.java Tue Sep  6 12:16:41 2005
@@ -22,6 +22,7 @@
 import org.apache.cocoon.template.environment.ErrorHolder;
 import org.apache.cocoon.template.environment.ExecutionContext;
 import org.apache.cocoon.template.expression.JXTExpression;
+import org.apache.cocoon.template.expression.JXTExpressionCompiler;
 import org.apache.cocoon.template.script.Invoker;
 import org.apache.cocoon.template.script.event.Event;
 import org.apache.cocoon.template.script.event.StartElement;
@@ -54,11 +55,11 @@
 
         String items = attrs.getValue("items");
         String select = attrs.getValue("select");
-        this.var = JXTExpression.compileExpr(attrs.getValue("var"), null, locator);
-        this.varStatus = JXTExpression.compileExpr(attrs.getValue("varStatus"), null, locator);
-        this.begin = JXTExpression.compileInt(attrs.getValue("begin"), name, locator);
-        this.end = JXTExpression.compileInt(attrs.getValue("end"), name, locator);
-        this.step = JXTExpression.compileInt(attrs.getValue("step"), name, locator);
+        this.var = JXTExpressionCompiler.compileExpr(attrs.getValue("var"), null, locator);
+        this.varStatus = JXTExpressionCompiler.compileExpr(attrs.getValue("varStatus"), null, locator);
+        this.begin = JXTExpressionCompiler.compileInt(attrs.getValue("begin"), name, locator);
+        this.end = JXTExpressionCompiler.compileInt(attrs.getValue("end"), name, locator);
+        this.step = JXTExpressionCompiler.compileInt(attrs.getValue("step"), name, locator);
         String lenientValue = attrs.getValue("lenient");
         this.lenient = (lenientValue == null) ? null : Boolean.valueOf(lenientValue);
 
@@ -72,7 +73,7 @@
                                         locator, null);
         }
         
-        this.items = JXTExpression.compileExpr(items == null ? select : items, null, locator);
+        this.items = JXTExpressionCompiler.compileExpr(items == null ? select : items, null, locator);
     }
 
     public Event execute(final XMLConsumer consumer,

Modified: cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/FormatDate.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/FormatDate.java?rev=279071&r1=279070&r2=279071&view=diff
==============================================================================
--- cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/FormatDate.java (original)
+++ cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/FormatDate.java Tue Sep  6 12:16:41 2005
@@ -25,6 +25,7 @@
 import org.apache.cocoon.template.environment.ErrorHolder;
 import org.apache.cocoon.template.environment.ExecutionContext;
 import org.apache.cocoon.template.expression.JXTExpression;
+import org.apache.cocoon.template.expression.JXTExpressionCompiler;
 import org.apache.cocoon.template.script.event.Event;
 import org.apache.cocoon.template.script.event.StartElement;
 import org.apache.cocoon.xml.XMLConsumer;
@@ -54,13 +55,13 @@
 
         Locator locator = getLocation();
 
-        this.var = JXTExpression.compileExpr(attrs.getValue("var"), null, locator);
-        this.value = JXTExpression.compileExpr(attrs.getValue("value"), null, locator);
-        this.type = JXTExpression.compileExpr(attrs.getValue("type"), null, locator);
-        this.pattern = JXTExpression.compileExpr(attrs.getValue("pattern"), null, locator);
-        this.timeZone = JXTExpression.compileExpr(attrs.getValue("timeZone"), null, locator);
-        this.dateStyle = JXTExpression.compileExpr(attrs.getValue("dateStyle"), null, locator);
-        this.timeStyle = JXTExpression.compileExpr(attrs.getValue("timeStyle"), null, locator);
+        this.var = JXTExpressionCompiler.compileExpr(attrs.getValue("var"), null, locator);
+        this.value = JXTExpressionCompiler.compileExpr(attrs.getValue("value"), null, locator);
+        this.type = JXTExpressionCompiler.compileExpr(attrs.getValue("type"), null, locator);
+        this.pattern = JXTExpressionCompiler.compileExpr(attrs.getValue("pattern"), null, locator);
+        this.timeZone = JXTExpressionCompiler.compileExpr(attrs.getValue("timeZone"), null, locator);
+        this.dateStyle = JXTExpressionCompiler.compileExpr(attrs.getValue("dateStyle"), null, locator);
+        this.timeStyle = JXTExpressionCompiler.compileExpr(attrs.getValue("timeStyle"), null, locator);
     }
 
     public Event execute(final XMLConsumer consumer,

Modified: cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/FormatNumber.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/FormatNumber.java?rev=279071&r1=279070&r2=279071&view=diff
==============================================================================
--- cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/FormatNumber.java (original)
+++ cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/FormatNumber.java Tue Sep  6 12:16:41 2005
@@ -26,6 +26,7 @@
 import org.apache.cocoon.template.environment.ErrorHolder;
 import org.apache.cocoon.template.environment.ExecutionContext;
 import org.apache.cocoon.template.expression.JXTExpression;
+import org.apache.cocoon.template.expression.JXTExpressionCompiler;
 import org.apache.cocoon.template.script.event.Event;
 import org.apache.cocoon.template.script.event.StartElement;
 import org.apache.cocoon.xml.XMLConsumer;
@@ -74,24 +75,24 @@
 
         Locator locator = getLocation();
 
-        this.value = JXTExpression.compileExpr(attrs.getValue("value"), null, locator);
-        this.type = JXTExpression.compileExpr(attrs.getValue("type"), null, locator);
-        this.pattern = JXTExpression.compileExpr(attrs.getValue("pattern"), null, locator);
+        this.value = JXTExpressionCompiler.compileExpr(attrs.getValue("value"), null, locator);
+        this.type = JXTExpressionCompiler.compileExpr(attrs.getValue("type"), null, locator);
+        this.pattern = JXTExpressionCompiler.compileExpr(attrs.getValue("pattern"), null, locator);
         this.currencyCode =
-            JXTExpression.compileExpr(attrs.getValue("currencyCode"), null, locator);
+            JXTExpressionCompiler.compileExpr(attrs.getValue("currencyCode"), null, locator);
         this.currencySymbol =
-            JXTExpression.compileExpr(attrs.getValue("currencySymbol"), null, locator);
+            JXTExpressionCompiler.compileExpr(attrs.getValue("currencySymbol"), null, locator);
         this.isGroupingUsed =
-            JXTExpression.compileBoolean(attrs.getValue("isGroupingUsed"), null, locator);
+            JXTExpressionCompiler.compileBoolean(attrs.getValue("isGroupingUsed"), null, locator);
         this.maxIntegerDigits =
-            JXTExpression.compileInt(attrs.getValue("maxIntegerDigits"), null, locator);
+            JXTExpressionCompiler.compileInt(attrs.getValue("maxIntegerDigits"), null, locator);
         this.minIntegerDigits =
-            JXTExpression.compileInt(attrs.getValue("minIntegerDigits"), null, locator);
+            JXTExpressionCompiler.compileInt(attrs.getValue("minIntegerDigits"), null, locator);
         this.maxFractionDigits =
-            JXTExpression.compileInt(attrs.getValue("maxFractionDigits"), null, locator);
+            JXTExpressionCompiler.compileInt(attrs.getValue("maxFractionDigits"), null, locator);
         this.minFractionDigits =
-            JXTExpression.compileInt(attrs.getValue("minFractionDigits"), null, locator);
-        this.var = JXTExpression.compileExpr(attrs.getValue("var"), null, locator);
+            JXTExpressionCompiler.compileInt(attrs.getValue("minFractionDigits"), null, locator);
+        this.var = JXTExpressionCompiler.compileExpr(attrs.getValue("var"), null, locator);
     }
 
     public Event execute(final XMLConsumer consumer,
@@ -148,7 +149,6 @@
             formatted = formatter.format(input);
         } else {
             // no formatting locale available, use toString()
-            //TODO: locale is never null, default in worst case. What's this code for? 
             formatted = input.toString();
         }
         if (var != null) {

Modified: cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/If.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/If.java?rev=279071&r1=279070&r2=279071&view=diff
==============================================================================
--- cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/If.java (original)
+++ cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/If.java Tue Sep  6 12:16:41 2005
@@ -21,6 +21,7 @@
 import org.apache.cocoon.template.environment.ErrorHolder;
 import org.apache.cocoon.template.environment.ExecutionContext;
 import org.apache.cocoon.template.expression.JXTExpression;
+import org.apache.cocoon.template.expression.JXTExpressionCompiler;
 import org.apache.cocoon.template.script.event.Event;
 import org.apache.cocoon.template.script.event.StartElement;
 import org.apache.cocoon.xml.XMLConsumer;
@@ -43,7 +44,7 @@
         Locator locator = getLocation();
         String test = attrs.getValue("test");
         if (test != null) {
-            this.test = JXTExpression.compileExpr(test, "if: \"test\": ", locator);
+            this.test = JXTExpressionCompiler.compileExpr(test, "if: \"test\": ", locator);
             // Why is test lenient?
             this.test.setLenient(Boolean.TRUE);
         } else {

Modified: cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/Import.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/Import.java?rev=279071&r1=279070&r2=279071&view=diff
==============================================================================
--- cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/Import.java (original)
+++ cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/Import.java Tue Sep  6 12:16:41 2005
@@ -24,6 +24,7 @@
 import org.apache.cocoon.template.environment.ErrorHolder;
 import org.apache.cocoon.template.environment.ExecutionContext;
 import org.apache.cocoon.template.expression.JXTExpression;
+import org.apache.cocoon.template.expression.JXTExpressionCompiler;
 import org.apache.cocoon.template.expression.Literal;
 import org.apache.cocoon.template.expression.Subst;
 import org.apache.cocoon.template.script.Invoker;
@@ -69,7 +70,7 @@
             // as the context object in the imported template
             String context = attrs.getValue("context");
             if (context != null) {
-                select = JXTExpression.compileExpr(context, "import: \"context\": ", locator);
+                select = JXTExpressionCompiler.compileExpr(context, "import: \"context\": ", locator);
             }
         } else {
             throw new SAXParseException("import: \"uri\" is required", locator, null);

Modified: cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/LocaleAwareInstruction.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/LocaleAwareInstruction.java?rev=279071&r1=279070&r2=279071&view=diff
==============================================================================
--- cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/LocaleAwareInstruction.java (original)
+++ cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/LocaleAwareInstruction.java Tue Sep  6 12:16:41 2005
@@ -21,6 +21,7 @@
 import org.apache.cocoon.components.expression.ExpressionContext;
 import org.apache.cocoon.template.environment.ValueHelper;
 import org.apache.cocoon.template.expression.JXTExpression;
+import org.apache.cocoon.template.expression.JXTExpressionCompiler;
 import org.apache.cocoon.template.script.event.StartElement;
 import org.xml.sax.Attributes;
 import org.xml.sax.SAXException;
@@ -33,7 +34,7 @@
 
     public LocaleAwareInstruction(StartElement raw, Attributes attrs, Stack stack) throws SAXException {
         super(raw);
-        this.locale = JXTExpression.compileExpr(attrs.getValue("locale"), null, getLocation());
+        this.locale = JXTExpressionCompiler.compileExpr(attrs.getValue("locale"), null, getLocation());
     }
 
     protected Locale getLocale(ExpressionContext expressionContext) throws Exception {

Modified: cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/Out.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/Out.java?rev=279071&r1=279070&r2=279071&view=diff
==============================================================================
--- cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/Out.java (original)
+++ cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/Out.java Tue Sep  6 12:16:41 2005
@@ -22,6 +22,7 @@
 import org.apache.cocoon.components.expression.ExpressionContext;
 import org.apache.cocoon.template.environment.ExecutionContext;
 import org.apache.cocoon.template.expression.JXTExpression;
+import org.apache.cocoon.template.expression.JXTExpressionCompiler;
 import org.apache.cocoon.template.script.Invoker;
 import org.apache.cocoon.template.script.event.Event;
 import org.apache.cocoon.template.script.event.StartElement;
@@ -54,7 +55,7 @@
         if (value == null)
             throw new SAXParseException("out: \"value\" is required", locator, null);
 
-        this.compiledExpression = JXTExpression.compileExpr(value, "out: \"value\": ", locator);
+        this.compiledExpression = JXTExpressionCompiler.compileExpr(value, "out: \"value\": ", locator);
         String lenientValue = attrs.getValue("lenient");
         Boolean lenient = lenientValue == null ? null : Boolean.valueOf(lenientValue);
 

Modified: cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/ParameterInstance.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/ParameterInstance.java?rev=279071&r1=279070&r2=279071&view=diff
==============================================================================
--- cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/ParameterInstance.java (original)
+++ cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/ParameterInstance.java Tue Sep  6 12:16:41 2005
@@ -20,6 +20,7 @@
 import org.apache.cocoon.components.expression.ExpressionContext;
 import org.apache.cocoon.template.environment.ErrorHolder;
 import org.apache.cocoon.template.expression.JXTExpression;
+import org.apache.cocoon.template.expression.JXTExpressionCompiler;
 import org.apache.cocoon.template.script.event.AttributeEvent;
 import org.apache.cocoon.template.script.event.CopyAttribute;
 import org.apache.cocoon.template.script.event.StartElement;
@@ -55,7 +56,7 @@
                 throw new SAXParseException("parameter: \"value\" is required",
                         locator, null);
 
-            this.value = JXTExpression.compileExpr(val,
+            this.value = JXTExpressionCompiler.compileExpr(val,
                     "parameter: \"value\": ", locator);
         }
     }

Modified: cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/Set.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/Set.java?rev=279071&r1=279070&r2=279071&view=diff
==============================================================================
--- cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/Set.java (original)
+++ cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/Set.java Tue Sep  6 12:16:41 2005
@@ -20,6 +20,7 @@
 import org.apache.cocoon.components.expression.ExpressionContext;
 import org.apache.cocoon.template.environment.ExecutionContext;
 import org.apache.cocoon.template.expression.JXTExpression;
+import org.apache.cocoon.template.expression.JXTExpressionCompiler;
 import org.apache.cocoon.template.script.Invoker;
 import org.apache.cocoon.template.script.event.Event;
 import org.apache.cocoon.template.script.event.StartElement;
@@ -50,10 +51,10 @@
         JXTExpression varExpr = null;
         JXTExpression valueExpr = null;
         if (var != null) {
-            varExpr = JXTExpression.compileExpr(var, "set: \"var\":", locator);
+            varExpr = JXTExpressionCompiler.compileExpr(var, "set: \"var\":", locator);
         }
         if (value != null) {
-            valueExpr = JXTExpression.compileExpr(value, "set: \"value\":", locator);
+            valueExpr = JXTExpressionCompiler.compileExpr(value, "set: \"value\":", locator);
         }
         this.var = varExpr;
         this.value = valueExpr;

Modified: cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/When.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/When.java?rev=279071&r1=279070&r2=279071&view=diff
==============================================================================
--- cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/When.java (original)
+++ cocoon/blocks/template/trunk/java/org/apache/cocoon/template/instruction/When.java Tue Sep  6 12:16:41 2005
@@ -18,6 +18,7 @@
 import java.util.Stack;
 
 import org.apache.cocoon.template.expression.JXTExpression;
+import org.apache.cocoon.template.expression.JXTExpressionCompiler;
 import org.apache.cocoon.template.script.event.StartElement;
 import org.xml.sax.Attributes;
 import org.xml.sax.Locator;
@@ -43,7 +44,7 @@
         }
         String test = attrs.getValue("test");
         if (test != null) {
-            this.test = JXTExpression.compileExpr(test, "when: \"test\": ", locator);
+            this.test = JXTExpressionCompiler.compileExpr(test, "when: \"test\": ", locator);
             // Why is test lenient?
             this.test.setLenient(Boolean.TRUE);
             

Modified: cocoon/blocks/template/trunk/java/org/apache/cocoon/template/script/DefaultInstructionFactory.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/template/trunk/java/org/apache/cocoon/template/script/DefaultInstructionFactory.java?rev=279071&r1=279070&r2=279071&view=diff
==============================================================================
--- cocoon/blocks/template/trunk/java/org/apache/cocoon/template/script/DefaultInstructionFactory.java (original)
+++ cocoon/blocks/template/trunk/java/org/apache/cocoon/template/script/DefaultInstructionFactory.java Tue Sep  6 12:16:41 2005
@@ -123,8 +123,6 @@
     }
 
     public void configure(Configuration omitted) throws ConfigurationException {
-        // do NOT use configuration from cocoon.xconf!
-        // TODO: can we do it in more elegant way?
         SourceResolver resolver = null;
         Source source = null;
         try {

Modified: cocoon/blocks/template/trunk/java/org/apache/cocoon/template/script/DefaultScriptManager.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/template/trunk/java/org/apache/cocoon/template/script/DefaultScriptManager.java?rev=279071&r1=279070&r2=279071&view=diff
==============================================================================
--- cocoon/blocks/template/trunk/java/org/apache/cocoon/template/script/DefaultScriptManager.java (original)
+++ cocoon/blocks/template/trunk/java/org/apache/cocoon/template/script/DefaultScriptManager.java Tue Sep  6 12:16:41 2005
@@ -21,6 +21,7 @@
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.Serviceable;
 import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.components.expression.ExpressionFactory;
 import org.apache.cocoon.components.source.SourceUtil;
 import org.apache.cocoon.template.script.event.StartDocument;
 import org.apache.excalibur.source.Source;
@@ -32,14 +33,15 @@
 import org.xml.sax.SAXParseException;
 
 /**
- * @version SVN $Id$
+ * @version SVN $Id: DefaultScriptManager.java 169632 2005-05-11 12:08:34Z
+ *          lgawron $
  */
-public class DefaultScriptManager extends AbstractLogEnabled implements
-        Serviceable, Disposable, ScriptManager {
+public class DefaultScriptManager extends AbstractLogEnabled implements Serviceable, Disposable, ScriptManager {
     private ServiceManager manager;
     private final static String JX_STORE_PREFIX = "jxtg:";
     private Store store;
     private InstructionFactory instructionFactory;
+    private ExpressionFactory expressionFactory;
 
     public DefaultScriptManager() {
     }
@@ -47,32 +49,30 @@
     public void service(ServiceManager manager) throws ServiceException {
         this.manager = manager;
         this.store = (Store) this.manager.lookup(Store.TRANSIENT_STORE);
-        this.instructionFactory = (InstructionFactory) this.manager
-                .lookup(InstructionFactory.ROLE);
+        this.instructionFactory = (InstructionFactory) this.manager.lookup(InstructionFactory.ROLE);
+        this.expressionFactory = (ExpressionFactory) this.manager.lookup(ExpressionFactory.ROLE);
     }
 
     public void dispose() {
         this.manager.release(this.store);
         this.manager.release(this.instructionFactory);
+        this.manager.release(this.expressionFactory);
     }
 
     private Store getStore() {
         return store;
     }
 
-    public StartDocument resolveTemplate(String uri) throws SAXParseException,
-            ProcessingException {
+    public StartDocument resolveTemplate(String uri) throws SAXParseException, ProcessingException {
         return resolveTemplate(uri, null);
     }
 
-    public StartDocument resolveTemplate(String uri, Locator location)
-            throws SAXParseException, ProcessingException {
+    public StartDocument resolveTemplate(String uri, Locator location) throws SAXParseException, ProcessingException {
         Source input = null;
         StartDocument doc = null;
         SourceResolver resolver = null;
         try {
-            resolver = (SourceResolver) this.manager
-                    .lookup(SourceResolver.ROLE);
+            resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
             input = resolver.resolveURI(uri);
             SourceValidity validity = null;
 
@@ -100,8 +100,7 @@
             }
 
             if (doc == null) {
-                Parser parser = new Parser();
-                parser.setInstructionFactory(instructionFactory);
+                Parser parser = new Parser(this.expressionFactory, this.instructionFactory);
                 // call getValidity before using the stream is faster if
                 // the source is a SitemapSource
                 if (validity == null) {
@@ -115,8 +114,7 @@
                 getStore().store(storeUri, doc);
             }
         } catch (SourceException se) {
-            throw SourceUtil.handle("Error during resolving of '" + uri + "'.",
-                    se);
+            throw SourceUtil.handle("Error during resolving of '" + uri + "'.", se);
         } catch (Exception exc) {
             throw new SAXParseException(exc.getMessage(), location, exc);
         } finally {

Modified: cocoon/blocks/template/trunk/java/org/apache/cocoon/template/script/Parser.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/template/trunk/java/org/apache/cocoon/template/script/Parser.java?rev=279071&r1=279070&r2=279071&view=diff
==============================================================================
--- cocoon/blocks/template/trunk/java/org/apache/cocoon/template/script/Parser.java (original)
+++ cocoon/blocks/template/trunk/java/org/apache/cocoon/template/script/Parser.java Tue Sep  6 12:16:41 2005
@@ -17,8 +17,9 @@
 
 import java.util.Stack;
 
+import org.apache.cocoon.components.expression.ExpressionFactory;
 import org.apache.cocoon.template.JXTemplateGenerator;
-import org.apache.cocoon.template.expression.JXTExpression;
+import org.apache.cocoon.template.expression.JXTExpressionCompiler;
 import org.apache.cocoon.template.instruction.Instruction;
 import org.apache.cocoon.template.script.event.*;
 import org.apache.commons.lang.StringUtils;
@@ -42,14 +43,24 @@
     StringBuffer charBuf;
 
     public static final Locator NULL_LOCATOR = new LocatorImpl();
-    private InstructionFactory instructionFactory;
-
+    protected InstructionFactory instructionFactory;
+    protected ExpressionFactory expressionFactory;
+    
     public Parser() {
     }
 
+    public Parser(ExpressionFactory expressionFactory, InstructionFactory instructionFactory) {
+        this.expressionFactory = expressionFactory;
+        this.instructionFactory = instructionFactory;
+    }
+
     public void setInstructionFactory(InstructionFactory factory) {
         this.instructionFactory = factory;
     }
+    
+    public void setExpressionFactory(ExpressionFactory factory) {
+        this.expressionFactory = factory;
+    }
 
     public StartDocument getStartEvent() {
         return this.startEvent;
@@ -170,7 +181,7 @@
                 // root
                 getStartEvent().getTemplateProperties().put(
                         elementAttributes.getLocalName(i),
-                        JXTExpression.compileExpr(
+                        JXTExpressionCompiler.compileExpr(
                                 elementAttributes.getValue(i), null, locator));
                 elementAttributes.removeAttribute(i--);
             }



Mime
View raw message