cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
unico 2004/07/06 03:34:36 Modified:src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: qualify template cache-key with the template source uri Revision ChangesPath 1.52 +32 -5 cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java Index: JXTemplateGenerator.java === RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v retrieving revision 1.51 retrieving revision 1.52 diff -u -r1.51 -r1.52 --- JXTemplateGenerator.java 2 Jul 2004 08:33:42 - 1.51 +++ JXTemplateGenerator.java 6 Jul 2004 10:34:36 - 1.52 @@ -42,8 +42,8 @@ import java.util.TimeZone; import org.apache.avalon.framework.parameters.Parameters; -import org.apache.avalon.framework.service.ServiceManager; import org.apache.avalon.framework.service.ServiceException; +import org.apache.avalon.framework.service.ServiceManager; import org.apache.cocoon.ProcessingException; import org.apache.cocoon.caching.CacheableProcessingComponent; import org.apache.cocoon.components.flow.FlowHelper; @@ -54,8 +54,8 @@ import org.apache.cocoon.environment.Request; import org.apache.cocoon.environment.SourceResolver; import org.apache.cocoon.transformation.ServiceableTransformer; -import org.apache.cocoon.xml.XMLConsumer; import org.apache.cocoon.xml.IncludeXMLConsumer; +import org.apache.cocoon.xml.XMLConsumer; import org.apache.cocoon.xml.XMLUtils; import org.apache.cocoon.xml.dom.DOMBuilder; import org.apache.cocoon.xml.dom.DOMStreamer; @@ -3191,17 +3191,21 @@ ev = ev.next; } } + /* (non-Javadoc) * @see org.apache.cocoon.caching.CacheableProcessingComponent#getKey() */ public Serializable getKey() { JXTExpression cacheKeyExpr = (JXTExpression)getCurrentTemplateProperty(CACHE_KEY); try { - return (Serializable) getValue(cacheKeyExpr, globalJexlContext, jxpathContext); +final Serializable templateKey = (Serializable) getValue(cacheKeyExpr, globalJexlContext, jxpathContext); +if (templateKey != null) { + return new JXCacheKey(this.inputSource.getURI(), templateKey); +} } catch (Exception e) { getLogger().error("error evaluating cache key", e); - return null; } + return null; } /* (non-Javadoc) @@ -3236,5 +3240,28 @@ builder.endDocument(); Node node = builder.getDocument().getDocumentElement(); return node.getChildNodes(); + } + + static final class JXCacheKey implements Serializable { + private final String templateUri; + private final Serializable templateKey; + private JXCacheKey(String templateUri, Serializable templateKey) { + this.templateUri = templateUri; + this.templateKey = templateKey; + } + public int hashCode() { + return templateUri.hashCode() + templateKey.hashCode(); + } + public String toString() { + return "TK:" + templateUri + "_" + templateKey; + } + public boolean equals(Object o) { + if (o instanceof JXCacheKey) { + JXCacheKey jxck = (JXCacheKey)o; + return this.templateUri.equals(jxck.templateUri) + && this.templateKey.equals(jxck.templateKey); + } + return false; + } } }
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
antonio 2004/06/28 02:25:39 Modified:src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: Some fixes + formatting code Revision ChangesPath 1.50 +340 -739 cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java http://cvs.apache.org/viewcvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java.diff?r1=1.49&r2=1.50
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
antonio 2004/06/26 01:41:18 Modified:.status.xml src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: [PATCH] Caching JXTemplateGenerator Submitted by: Leszek Gawron Revision ChangesPath 1.372 +4 -1 cocoon-2.1/status.xml Index: status.xml === RCS file: /home/cvs/cocoon-2.1/status.xml,v retrieving revision 1.371 retrieving revision 1.372 diff -u -r1.371 -r1.372 --- status.xml23 Jun 2004 19:14:34 - 1.371 +++ status.xml26 Jun 2004 08:41:18 - 1.372 @@ -204,6 +204,9 @@ + + Apply patch: Caching JXTemplateGenerator. + ResourceReader can now take configuration elements, parameters are deprecated. 1.47 +70 -14 cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java Index: JXTemplateGenerator.java === RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v retrieving revision 1.46 retrieving revision 1.47 diff -u -r1.46 -r1.47 --- JXTemplateGenerator.java 26 Jun 2004 07:31:18 - 1.46 +++ JXTemplateGenerator.java 26 Jun 2004 08:41:18 - 1.47 @@ -20,6 +20,7 @@ import java.io.IOException; import java.io.PrintStream; import java.io.PrintWriter; +import java.io.Serializable; import java.io.StringReader; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; @@ -43,6 +44,7 @@ import org.apache.avalon.framework.service.ServiceManager; import org.apache.avalon.framework.service.ServiceException; import org.apache.cocoon.ProcessingException; +import org.apache.cocoon.caching.CacheableProcessingComponent; import org.apache.cocoon.components.flow.FlowHelper; import org.apache.cocoon.components.flow.WebContinuation; import org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptFlowHelper; @@ -115,7 +117,7 @@ * * @version CVS $Id$ */ -public class JXTemplateGenerator extends ServiceableGenerator { +public class JXTemplateGenerator extends ServiceableGenerator implements CacheableProcessingComponent { private static final JXPathContextFactory jxpathContextFactory = JXPathContextFactory.newInstance(); @@ -711,7 +713,8 @@ final static String PARAMETER = "parameter"; final static String FORMAT_NUMBER = "formatNumber"; final static String FORMAT_DATE = "formatDate"; - +final static String CACHE_KEY = "cache-key"; +final static String VALIDITY = "cache-validity"; /** * Compile a single Jexl expr (contained in ${}) or XPath expression @@ -1116,9 +1119,11 @@ static class StartDocument extends Event { StartDocument(Locator location) { super(location); +templateProperties = new HashMap(); } SourceValidity compileTime; EndDocument endDocument; // null if document fragment +Map templateProperties; } static class EndDocument extends Event { @@ -2182,8 +2187,18 @@ public void startElement(String namespaceURI, String localName, String qname, Attributes attrs) throws SAXException { Event newEvent = null; +AttributesImpl elementAttributes = new AttributesImpl( attrs ); +int attributeCount = elementAttributes.getLength(); +for (int i = 0; i < attributeCount; i++) { + String attributeURI = elementAttributes.getURI(i); + if (StringUtils.equals(attributeURI, NS)) { + getStartEvent().templateProperties.put(elementAttributes.getLocalName(i), + compileExpr(elementAttributes.getValue(i), null, locator)); + elementAttributes.removeAttribute(i--); + } +} StartElement startElement = new StartElement(locator, namespaceURI, - localName, qname, attrs); + localName, qname, elementAttributes); if (NS.equals(namespaceURI)) { if (localName.equals(FOR_EACH)) { String items = attrs.getValue("items"); @@ -2596,8 +2611,10 @@ "Error during resolving of '" + src + "'.", se); } final String uri = inputSource.getURI(); +boolean regenerate = false; +StartDocument startEvent = null; synchronized (cache) { -StartDocument startEvent = (StartDocument)cache.get(uri); +startE
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
antonio 2004/06/26 00:31:18 Modified:src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: Use jakarta commons lang Revision ChangesPath 1.46 +29 -39 cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java Index: JXTemplateGenerator.java === RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v retrieving revision 1.45 retrieving revision 1.46 diff -u -r1.45 -r1.46 --- JXTemplateGenerator.java 24 Jun 2004 20:35:07 - 1.45 +++ JXTemplateGenerator.java 26 Jun 2004 07:31:18 - 1.46 @@ -308,7 +308,7 @@ } Object result = ScriptableObject.getProperty(thisObj, name); if (result == Scriptable.NOT_FOUND) { -result = ScriptableObject.getProperty(thisObj, "get" + name.substring(0, 1).toUpperCase() + (name.length() > 1 ? name.substring(1) : "")); +result = ScriptableObject.getProperty(thisObj, "get" + StringUtils.capitalize(name)); if (result != Scriptable.NOT_FOUND && result instanceof Function) { try { @@ -1605,19 +1605,15 @@ // formatNumber tag (borrows from Jakarta taglibs JSTL) -private static final char HYPHEN = '-'; -private static final char UNDERSCORE = '_'; - private static Locale parseLocale(String locale, String variant) { Locale ret = null; String language = locale; String country = null; -int index = -1; +int index = StringUtils.indexOfAny(locale, "-_"); -if ((index = locale.indexOf(HYPHEN)) > -1 -|| (index = locale.indexOf(UNDERSCORE)) > -1) { +if (index > -1) { language = locale.substring(0, index); -country = locale.substring(index+1); +country = locale.substring(index + 1); } if (StringUtils.isEmpty(language)) { throw new IllegalArgumentException("No language in locale"); @@ -1667,6 +1663,7 @@ currencyClass = Class.forName("java.util.Currency"); // container's runtime is J2SE 1.4 or greater } catch (Exception cnfe) { +// EMPTY } } @@ -1832,23 +1829,21 @@ String code = null; String symbol = null; -if ((currencyCode == null) && (currencySymbol == null)) { -return; -} -if ((currencyCode != null) && (currencySymbol != null)) { -if (currencyClass != null) { -code = currencyCode; -} else { -symbol = currencySymbol; +if (currencyCode == null) { +if (currencySymbol == null) { +return; } -} else if (currencyCode == null) { symbol = currencySymbol; -} else { +} else if (currencySymbol != null) { if (currencyClass != null) { code = currencyCode; } else { -symbol = currencyCode; +symbol = currencySymbol; } +} else if (currencyClass != null) { +code = currencyCode; +} else { +symbol = currencyCode; } if (code != null) { Object[] methodArgs = new Object[1]; @@ -2356,10 +2351,7 @@ // // body // -String namespace = attrs.getValue("targetNamespace"); -if (namespace == null) { -namespace = ""; -} +String namespace = StringUtils.defaultString(attrs.getValue("targetNamespace")); String name = attrs.getValue("name"); if (name != null) { StartDefine startDefine = @@ -3002,8 +2994,6 @@ } consumer.characters(chars, 0, chars.length); } -} else if (ev instanceof EndDocument) { -consumer.endDocument(); } else if (ev instanceof EndElement) { EndElement endElement = (EndElement)ev; StartElement startElement = endElement.startElement; @@ -3028,12 +3018,6 @@ } else if (ev instanceof SkippedEntity) { SkippedEntity skippedEntity = (SkippedEntity)ev; consumer.skippedEntity(skippedEntit
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
antonio 2004/06/24 13:35:07 Modified:src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: Use jakarta commons lang Revision ChangesPath 1.45 +148 -155 cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java Index: JXTemplateGenerator.java === RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v retrieving revision 1.44 retrieving revision 1.45 diff -u -r1.44 -r1.45 --- JXTemplateGenerator.java 27 May 2004 08:23:58 - 1.44 +++ JXTemplateGenerator.java 24 Jun 2004 20:35:07 - 1.45 @@ -55,6 +55,7 @@ import org.apache.cocoon.xml.IncludeXMLConsumer; import org.apache.cocoon.xml.dom.DOMBuilder; import org.apache.cocoon.xml.dom.DOMStreamer; +import org.apache.commons.jexl.Expression; import org.apache.commons.jexl.ExpressionFactory; import org.apache.commons.jexl.JexlContext; import org.apache.commons.jexl.util.Introspector; @@ -71,6 +72,8 @@ import org.apache.commons.jxpath.JXPathIntrospector; import org.apache.commons.jxpath.Pointer; import org.apache.commons.jxpath.Variables; +import org.apache.commons.lang.ArrayUtils; +import org.apache.commons.lang.StringUtils; import org.apache.excalibur.source.Source; import org.apache.excalibur.source.SourceException; import org.apache.excalibur.source.SourceValidity; @@ -117,8 +120,6 @@ private static final JXPathContextFactory jxpathContextFactory = JXPathContextFactory.newInstance(); -private static final char[] EMPTY_CHARS = "".toCharArray(); - private static final Attributes EMPTY_ATTRS = new AttributesImpl(); private static final Iterator EMPTY_ITER = new Iterator() { @@ -717,7 +718,7 @@ * (contained in #{}) */ -private static Expression compileExpr(String expr, String errorPrefix, +private static JXTExpression compileExpr(String expr, String errorPrefix, Locator location) throws SAXParseException { try { return compileExpr(expr); @@ -731,7 +732,7 @@ } } -private static Expression compileExpr(String inStr) throws Exception { +private static JXTExpression compileExpr(String inStr) throws Exception { try { if (inStr == null) { return null; @@ -768,7 +769,7 @@ } // hack: invalid expression? // just return the original and swallow exception -return new Expression(inStr, null); +return new JXTExpression(inStr, null); } } if (inExpr) { @@ -784,16 +785,16 @@ } catch (IOException ignored) { ignored.printStackTrace(); } -return new Expression(inStr, null); +return new JXTExpression(inStr, null); } /* * Compile an integer expression (returns either a Compiled Expression * or an Integer literal) */ -private static Expression compileInt(String val, String msg, +private static JXTExpression compileInt(String val, String msg, Locator location) throws SAXException { -Expression res = compileExpr(val, msg, location); +JXTExpression res = compileExpr(val, msg, location); if (res != null) { if (res.compiledExpression == null) { res.compiledExpression = Integer.valueOf(res.raw); @@ -803,9 +804,9 @@ return null; } -private static Expression compileBoolean(String val, String msg, +private static JXTExpression compileBoolean(String val, String msg, Locator location) throws SAXException { -Expression res = compileExpr(val, msg, location); +JXTExpression res = compileExpr(val, msg, location); if (res != null) { if (res.compiledExpression == null) { res.compiledExpression = Boolean.valueOf(res.raw); @@ -815,7 +816,7 @@ return null; } -private static Expression compile(final String variable, boolean xpath) +private static JXTExpression compile(final String variable, boolean xpath) throws Exception { Object compiled; if (xpath) { @@ -823,10 +824,10 @@ } else { compiled = ExpressionFactory.createExpression(variable); } -return new Expression(variable, compiled); +return new JXTExpression(variable, compiled); } -static private Object getValue(Expression expr, JexlContext jexlContext, +static private Object getValue
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
coliver 2004/04/24 14:35:35 Modified:src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: Allow a nodeset to be returned as the result of xpath evaluation Revision ChangesPath 1.42 +26 -2 cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java Index: JXTemplateGenerator.java === RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v retrieving revision 1.41 retrieving revision 1.42 diff -u -r1.41 -r1.42 --- JXTemplateGenerator.java 24 Apr 2004 15:59:52 - 1.41 +++ JXTemplateGenerator.java 24 Apr 2004 21:35:35 - 1.42 @@ -1136,7 +1136,31 @@ boolean oldLenient = jxpathContext.isLenient(); if (lenient != null) jxpathContext.setLenient(lenient.booleanValue()); try { -return e.getPointer(jxpathContext, expr.raw).getNode(); +Iterator iter = +e.iteratePointers(jxpathContext); +if (!iter.hasNext()) { +return null; +} +Pointer first = (Pointer)iter.next(); +if (!iter.hasNext()) { +return first.getNode(); +} +List result = new LinkedList(); +result.add(first.getNode()); +boolean dom = (first.getNode() instanceof Node); +while (iter.hasNext()) { +Object obj = ((Pointer)iter.next()).getNode(); +dom = dom && (obj instanceof Node); +result.add(obj); +} +Object[] arr; +if (dom) { +arr = new Node[result.size()]; +} else { +arr = new Object[result.size()]; +} +result.toArray(arr); +return arr; } finally { jxpathContext.setLenient(oldLenient); }
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
coliver 2004/04/24 08:59:52 Modified:src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: fixing bug where first element of macro body after parameter list is ignored Revision ChangesPath 1.41 +2 -2 cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java Index: JXTemplateGenerator.java === RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v retrieving revision 1.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- JXTemplateGenerator.java 21 Apr 2004 21:37:49 - 1.40 +++ JXTemplateGenerator.java 24 Apr 2004 15:59:52 - 1.41 @@ -1744,7 +1744,7 @@ if (prev != null) { throw new SAXParseException("duplicate parameter: \""+startParam.name +"\"", location, null); } -e = startParam.endInstruction.next; +e = startParam.endInstruction; } else if (e instanceof IgnorableWhitespace) { } else if (e instanceof Characters) { // check for whitespace
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
coliver 2004/04/21 14:37:50 Modified:src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: Support java.util.Iterator as value for 'items' in forEach Revision ChangesPath 1.40 +6 -3 cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java Index: JXTemplateGenerator.java === RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v retrieving revision 1.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- JXTemplateGenerator.java 1 Apr 2004 16:50:32 - 1.39 +++ JXTemplateGenerator.java 21 Apr 2004 21:37:49 - 1.40 @@ -711,6 +711,9 @@ } }; +} else if (obj instanceof Iterator) { +// support Iterator +return (Iterator)obj; } return super.getIterator(obj, i); } @@ -3284,8 +3287,8 @@ iter = Introspector.getUberspect().getIterator( result, new Info(ev.location.getSystemId(), -ev.location.getLineNumber(), - ev.location.getColumnNumber())); + ev.location.getLineNumber(), + ev.location.getColumnNumber())); } if (iter == null) { iter = EMPTY_ITER;
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
coliver 2004/04/01 08:50:32 Modified:src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: Set up service manager on generator when called from transformer Revision ChangesPath 1.39 +41 -10 cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java Index: JXTemplateGenerator.java === RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v retrieving revision 1.38 retrieving revision 1.39 diff -u -r1.38 -r1.39 --- JXTemplateGenerator.java 5 Mar 2004 13:02:55 - 1.38 +++ JXTemplateGenerator.java 1 Apr 2004 16:50:32 - 1.39 @@ -40,6 +40,8 @@ import java.util.TimeZone; import org.apache.avalon.framework.parameters.Parameters; +import org.apache.avalon.framework.service.ServiceManager; +import org.apache.avalon.framework.service.ServiceException; import org.apache.cocoon.ProcessingException; import org.apache.cocoon.components.flow.FlowHelper; import org.apache.cocoon.components.flow.WebContinuation; @@ -48,7 +50,7 @@ import org.apache.cocoon.environment.ObjectModelHelper; import org.apache.cocoon.environment.Request; import org.apache.cocoon.environment.SourceResolver; -import org.apache.cocoon.transformation.AbstractTransformer; +import org.apache.cocoon.transformation.ServiceableTransformer; import org.apache.cocoon.xml.XMLConsumer; import org.apache.cocoon.xml.IncludeXMLConsumer; import org.apache.cocoon.xml.dom.DOMBuilder; @@ -2248,6 +2250,16 @@ return this.startEvent; } + +void recycle() { +startEvent = null; +lastEvent = null; +stack.clear(); +locator = null; +charLocation = null; +charBuf = null; +} + private void addEvent(Event ev) throws SAXException { if (ev == null) { throw new NullPointerException("null event"); @@ -2680,16 +2692,24 @@ * you effectively recompile the template for every instance document) */ -public static class TransformerAdapter extends AbstractTransformer { +public static class TransformerAdapter extends ServiceableTransformer { static class TemplateConsumer extends Parser implements XMLConsumer { -public TemplateConsumer(SourceResolver resolver, Map objectModel, -String src, Parameters parameters) -throws ProcessingException, SAXException, IOException { +public TemplateConsumer() { this.gen = new JXTemplateGenerator(); +} + +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.gen.service(manager); +} + public void endDocument() throws SAXException { super.endDocument(); gen.performGeneration(gen.getConsumer(), gen.getJexlContext(), @@ -2700,21 +2720,32 @@ gen.setConsumer(consumer); } +void recycle() { +super.recycle(); +gen.recycle(); +} + JXTemplateGenerator gen; } -TemplateConsumer templateConsumer; +TemplateConsumer templateConsumer = new TemplateConsumer(); public void recycle() { super.recycle(); -templateConsumer = null; +templateConsumer.recycle(); } public void setup(SourceResolver resolver, Map objectModel, String src, Parameters parameters) throws ProcessingException, SAXException, IOException { -templateConsumer = new TemplateConsumer(resolver, objectModel, -src, parameters); +super.setup(resolver, objectModel, src, parameters); +templateConsumer.setup(resolver, objectModel, src, parameters); +} + +public void service(ServiceManager manager) +throws ServiceException { +super.service(manager); +templateConsumer.service(manager); } public void setConsumer(XMLConsumer xmlConsumer) {
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
coliver 2004/02/05 11:32:18 Modified:src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: handle Error's Revision ChangesPath 1.36 +84 -12 cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java Index: JXTemplateGenerator.java === RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v retrieving revision 1.35 retrieving revision 1.36 diff -u -r1.35 -r1.36 --- JXTemplateGenerator.java 1 Feb 2004 19:32:33 - 1.35 +++ JXTemplateGenerator.java 5 Feb 2004 19:32:18 - 1.36 @@ -53,6 +53,8 @@ import java.beans.PropertyDescriptor; import java.io.CharArrayReader; import java.io.IOException; +import java.io.PrintStream; +import java.io.PrintWriter; import java.io.StringReader; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; @@ -398,6 +400,33 @@ return this.xmlConsumer; } +public static class ErrorHolder extends Exception { + +private Error err; + +public ErrorHolder(Error err) { +super(err.getMessage()); +this.err = err; +} + +public void printStackTrace(PrintStream ps) { +err.printStackTrace(ps); +} + +public void printStackTrace(PrintWriter pw) { +err.printStackTrace(pw); +} + +public void printStackTrace() { +err.printStackTrace(); +} + +public Error getError() { +return err; +} + +} + /** * Facade to the Locator to be set on the consumer prior to * sending other events, location member changeable @@ -945,7 +974,8 @@ location, exc); } catch (Error err) { throw new SAXParseException(errorPrefix + err.getMessage(), -location, null); +location, +new ErrorHolder(err)); } } @@ -1110,7 +1140,7 @@ if (res != null) { return res.toString(); } -if (expr != null) { +if (expr != null && expr.compiledExpression == null) { return expr.raw; } return null; @@ -1223,6 +1253,11 @@ throw new SAXParseException(exc.getMessage(), this.location, exc); +} catch (Error err) { +throw new SAXParseException(err.getMessage(), + this.location, +new ErrorHolder(err)); + } substitutions.add(new Expression(str, compiledExpression)); @@ -1455,7 +1490,7 @@ } catch (Error err) { throw new SAXParseException( err.getMessage(), location, -null); +new ErrorHolder(err)); } substEvents.add(compiledExpression); buf.setLength(0); @@ -2951,7 +2986,8 @@ event.location, e); } catch (Error err) { throw new SAXParseException(err.getMessage(), -event.location, null); +event.location, +new ErrorHolder(err)); } } handler.characters(chars, 0, chars.length); @@ -3160,7 +3196,8 @@ ev.location, e); } catch (Error err) { throw new SAXParseException(err.getMessage(), -ev.location, null); +ev.location, +new ErrorHolder(err));
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
coliver 2004/02/01 11:32:33 Modified:src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: Fixed typo in error message and added fix for bugzilla 26086 Revision ChangesPath 1.35 +11 -13 cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java Index: JXTemplateGenerator.java === RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v retrieving revision 1.34 retrieving revision 1.35 diff -u -r1.34 -r1.35 --- JXTemplateGenerator.java 31 Jan 2004 15:57:32 - 1.34 +++ JXTemplateGenerator.java 1 Feb 2004 19:32:33 - 1.35 @@ -382,14 +382,14 @@ }; private static final Iterator NULL_ITER = new Iterator() { -public boolean hasNext() { -return true; -} -public Object next() { -return null; -} -public void remove() { -} +public boolean hasNext() { +return true; +} +public Object next() { +return null; +} +public void remove() { +} }; private static final Locator NULL_LOCATOR = new LocatorImpl(); @@ -1195,8 +1195,6 @@ int ch; boolean inExpr = false; boolean xpath = false; -// int line = this.location.getLineNumber(); -// int column = this.location.getColumnNumber(); try { top: while ((ch = in.read()) != -1) { // column++; @@ -1223,7 +1221,7 @@ } } catch (Exception exc) { throw new SAXParseException(exc.getMessage(), -location, + this.location, exc); } substitutions.add(new Expression(str, @@ -3823,7 +3821,7 @@ doc.next, doc.endDocument); } catch (Exception exc) { throw new SAXParseException( -"Exception occured in imported template " +"Exception occurred in imported template " + uri + ": "+ exc.getMessage(), ev.location, exc); }
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
bruno 2004/01/31 07:57:32 Modified:src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: If the result of an expression is an XMLizable object, automatically stream it (like is the case form DOM nodes). Revision ChangesPath 1.34 +8 -1 cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java Index: JXTemplateGenerator.java === RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v retrieving revision 1.33 retrieving revision 1.34 diff -u -r1.33 -r1.34 --- JXTemplateGenerator.java 28 Jan 2004 06:44:26 - 1.33 +++ JXTemplateGenerator.java 31 Jan 2004 15:57:32 - 1.34 @@ -84,6 +84,7 @@ import org.apache.cocoon.environment.SourceResolver; import org.apache.cocoon.transformation.AbstractTransformer; import org.apache.cocoon.xml.XMLConsumer; +import org.apache.cocoon.xml.IncludeXMLConsumer; import org.apache.cocoon.xml.dom.DOMBuilder; import org.apache.cocoon.xml.dom.DOMStreamer; import org.apache.commons.jexl.ExpressionFactory; @@ -105,6 +106,7 @@ import org.apache.excalibur.source.Source; import org.apache.excalibur.source.SourceException; import org.apache.excalibur.source.SourceValidity; +import org.apache.excalibur.xml.sax.XMLizable; import org.mozilla.javascript.Context; import org.mozilla.javascript.Function; import org.mozilla.javascript.JavaScriptException; @@ -3146,6 +3148,9 @@ jxpathContext, n); } continue; +} else if (val instanceof XMLizable) { +((XMLizable)val).toSAX(new IncludeXMLConsumer(consumer)); +continue; } if (val != null) { chars = val.toString().toCharArray(); @@ -3663,6 +3668,8 @@ executeDOM(consumer, jexlContext, jxpathContext, n); } +} else if (val instanceof XMLizable) { +((XMLizable)val).toSAX(new IncludeXMLConsumer(consumer)); } else { if (val == null) { val = "";
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
coliver 2004/01/27 22:44:26 Modified:src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: Use FOM_WebContinuation for cocoon.continuation instead of o.a.c.flow.WebContinuation Revision ChangesPath 1.33 +3 -2 cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java Index: JXTemplateGenerator.java === RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- JXTemplateGenerator.java 27 Jan 2004 21:04:43 - 1.32 +++ JXTemplateGenerator.java 28 Jan 2004 06:44:26 - 1.33 @@ -2849,7 +2849,8 @@ } cocoon.put("context", FOM_JavaScriptFlowHelper.getFOM_Context(objectModel)); -cocoon.put("continuation", kont); +cocoon.put("continuation", + FOM_JavaScriptFlowHelper.getFOM_WebContinuation(objectModel)); cocoon.put("parameters", Parameters.toProperties(parameters)); this.variables = new MyVariables(cocoon, contextObject, kont, request, session, app, parameters);
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
vgritsenko2004/01/27 13:04:44 Modified:src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: comment out unused column variable. trailing spaces removed. Revision ChangesPath 1.32 +317 -318 cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java Index: JXTemplateGenerator.java === RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- JXTemplateGenerator.java 27 Jan 2004 11:39:53 - 1.31 +++ JXTemplateGenerator.java 27 Jan 2004 21:04:43 - 1.32 @@ -1,4 +1,4 @@ -/* +/* The Apache Software License, Version 1.1 @@ -127,12 +127,12 @@ import org.xml.sax.helpers.LocatorImpl; /** - * (JX for http://jakarta.apache.org/commons/jxpath";>Apache JXPath + * (JX for http://jakarta.apache.org/commons/jxpath";>Apache JXPath * and http://jakarta.apache.org/commons/jexl";>Apache Jexl). * Uses the namespace http://apache.org/cocoon/templates/jx/1.0 - * Provides a generic page template with embedded JSTL and XPath + * Provides a generic page template with embedded JSTL and XPath * expression substitution to access data sent by Cocoon Flowscripts. - * 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 * * @@ -141,10 +141,10 @@ * * Embedded JSTL expressions are contained in ${}. * Embedded XPath expressions are contained in #{}. - * Note that since this generator uses - * http://jakarta.apache.org/commons/jxpath";>Apache JXPath - * and http://jakarta.apache.org/commons/jexl";>Apache Jexl, the - * referenced objects may be Java Beans, DOM, JDOM, or JavaScript objects from + * Note that since this generator uses + * http://jakarta.apache.org/commons/jxpath";>Apache JXPath + * and http://jakarta.apache.org/commons/jexl";>Apache Jexl, 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: * @@ -163,15 +163,15 @@ * * * - * The current Web Continuation from the Flowscript - * is also available as a variable named continuation. You would + * The current Web Continuation from the Flowscript + * is also available as a variable named continuation. You would * typically access its id: * * *
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
gianugo 2004/01/27 03:39:53 Modified:src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: Fix a couple of nasty NPEs (note: a source validity object _can_ be null). Revision ChangesPath 1.31 +7 -5 cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java Index: JXTemplateGenerator.java === RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- JXTemplateGenerator.java 11 Jan 2004 02:53:08 - 1.30 +++ JXTemplateGenerator.java 27 Jan 2004 11:39:53 - 1.31 @@ -1191,8 +1191,8 @@ int ch; boolean inExpr = false; boolean xpath = false; -//int line = location.getLineNumber(); -int column = location.getColumnNumber(); +//int line = this.location.getLineNumber(); +int column = this.location.getColumnNumber(); try { top: while ((ch = in.read()) != -1) { column++; @@ -2776,8 +2776,10 @@ synchronized (cache) { StartDocument startEvent = (StartDocument)cache.get(uri); if (startEvent != null) { -int valid = startEvent.compileTime.isValid(); -if ( valid == SourceValidity.UNKNOWN ) { +int valid = SourceValidity.UNKNOWN; +if (startEvent.compileTime != null) +valid = startEvent.compileTime.isValid(); +if ( valid == SourceValidity.UNKNOWN && startEvent.compileTime != null ) { SourceValidity validity = inputSource.getValidity(); valid = startEvent.compileTime.isValid(validity); }
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
antonio 2004/01/10 18:53:08 Modified:src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: Formating code + some performance changes. Revision ChangesPath 1.30 +431 -552 cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java Index: JXTemplateGenerator.java === RCS file: /home/cvs//cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- JXTemplateGenerator.java 6 Jan 2004 12:41:39 - 1.29 +++ JXTemplateGenerator.java 11 Jan 2004 02:53:08 - 1.30 @@ -88,6 +88,7 @@ import org.apache.cocoon.xml.dom.DOMStreamer; import org.apache.commons.jexl.ExpressionFactory; import org.apache.commons.jexl.JexlContext; +import org.apache.commons.jexl.util.Introspector; import org.apache.commons.jexl.util.introspection.Info; import org.apache.commons.jexl.util.introspection.UberspectImpl; import org.apache.commons.jexl.util.introspection.VelMethod; @@ -456,7 +457,8 @@ Object[] newArgs = null; if (args != null) { newArgs = new Object[args.length]; -for (int i = 0; i < args.length; i++) { +int len = args.length; +for (int i = 0; i < len; i++) { newArgs[i] = args[i]; if (args[i] != null && !(args[i] instanceof Number) && @@ -769,7 +771,8 @@ } public boolean containsKey(Object key) { -if (key.equals("this")) { +return this.get(key) !=null; +/* if (key.equals("this")) { return true; } boolean result = super.containsKey(key); @@ -778,7 +781,7 @@ result = closure.containsKey(key); } } -return result; +return result; */ } public Object get(Object key) { @@ -793,7 +796,6 @@ } return result; } - } static class MyVariables implements Variables { @@ -840,7 +842,8 @@ } public boolean isDeclaredVariable(String varName) { -for (int i = 0; i < VARIABLES.length; i++) { +int len = VARIABLES.length; +for (int i = 0; i < len; i++) { if (varName.equals(VARIABLES[i])) { return true; } @@ -930,22 +933,23 @@ */ private static Expression compileExpr(String expr, String errorPrefix, - Locator location) -throws SAXParseException { + Locator location) throws SAXParseException { try { return compileExpr(expr); } catch (Exception exc) { throw new SAXParseException(errorPrefix + exc.getMessage(), -location, exc); +location, exc); } catch (Error err) { throw new SAXParseException(errorPrefix + err.getMessage(), -location, null); +location, null); } } private static Expression compileExpr(String inStr) throws Exception { try { -if (inStr == null) return null; +if (inStr == null) { +return null; +} StringReader in = new StringReader(inStr.trim()); int ch; boolean xpath = false; @@ -1001,28 +1005,32 @@ * 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 { +private static Expression compileInt(String val, String msg, +Locator location) throws SAXException { Expression res = compileExpr(val, msg, location); -if (res == null) return null; -if (res.compiledExpression == null) { -res.compiledExpression = Integer.valueOf(res.raw); +if (res != null) { +if (res.compiledExpression == null) { +res.compiledExpression = Integer.valueOf(res.raw); +} +return res; } -return res; +return null; } -private static Expression compileBoolean(String val, String msg, Locator locat
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
joerg 2004/01/06 04:41:39 Modified:src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: executeRaw() and line are unused - can they be removed? Revision ChangesPath 1.29 +4 -4 cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java Index: JXTemplateGenerator.java === RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- JXTemplateGenerator.java 4 Jan 2004 20:40:26 - 1.28 +++ JXTemplateGenerator.java 6 Jan 2004 12:41:39 - 1.29 @@ -1185,7 +1185,7 @@ int ch; boolean inExpr = false; boolean xpath = false; -int line = location.getLineNumber(); +//int line = location.getLineNumber(); int column = location.getColumnNumber(); try { top: while ((ch = in.read()) != -1) { @@ -3004,7 +3004,7 @@ } } -private void executeRaw(final XMLConsumer consumer, +/*private void executeRaw(final XMLConsumer consumer, Event startEvent, Event endEvent) throws SAXException { Event ev = startEvent; @@ -3091,7 +3091,7 @@ ev = ev.next; } } - +*/ private void executeDOM(final XMLConsumer consumer, MyJexlContext jexlContext, JXPathContext jxpathContext,
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
coliver 2004/01/03 22:39:11 Modified:src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: Fixed variable scoping; added variables 'this' and 'cocoon.consumer' the former references the jexl context (in order to access illegal identifiers, e.g. this['woody-form']), the latter exposes the current XMLConsumer from the pipeline (experimental: I used this to implement woody wt: tags with jx macros); Supported expression subsitution in jx:set var attribute Revision ChangesPath 1.27 +91 -63 cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java Index: JXTemplateGenerator.java === RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- JXTemplateGenerator.java 4 Jan 2004 01:07:53 - 1.26 +++ JXTemplateGenerator.java 4 Jan 2004 06:39:11 - 1.27 @@ -749,32 +749,51 @@ static class MyJexlContext extends HashMap implements JexlContext { + +private MyJexlContext closure; + +MyJexlContext() { +this(null); +} + +MyJexlContext(MyJexlContext closure) { +this.closure = closure; +} + public Map getVars() { return this; } + public void setVars(Map map) { putAll(map); } -public Object get(Object key) { -Object result = super.get(key); -if (result != null) { -return result; + +public boolean containsKey(Object key) { +if (key.equals("this")) { +return true; } -MyJexlContext c = closure; -for (; c != null; c = c.closure) { -result = c.get(key); -if (result != null) { -return result; +boolean result = super.containsKey(key); +if (!result) { +if (closure != null) { +result = closure.containsKey(key); } } return result; } -MyJexlContext closure; -MyJexlContext() { -} -MyJexlContext(MyJexlContext closure) { -this.closure = closure; + +public Object get(Object key) { +if (key.equals("this")) { +return this; +} +Object result = super.get(key); +if (result == null) { +if (closure != null) { +result = closure.get(key); +} +} +return result; } + } static class MyVariables implements Variables { @@ -1773,12 +1792,12 @@ } static class StartSet extends StartInstruction { -StartSet(StartElement raw, String var, Expression value) { +StartSet(StartElement raw, Expression var, Expression value) { super(raw); this.var = var; this.value = value; } -final String var; +final Expression var; final Expression value; } @@ -2584,13 +2603,20 @@ } else if (localName.equals(SET)) { String var = attrs.getValue("var"); String value = attrs.getValue("value"); +Expression varExpr = null; Expression valueExpr = null; +if (var != null) { +varExpr = +compileExpr(var, "set: \"var\":", +locator); +} if (value != null) { valueExpr = compileExpr(value, "set: \"value\":", locator); } -StartSet startSet = new StartSet(startElement, var, valueExpr); +StartSet startSet = new StartSet(startElement, + varExpr, valueExpr); newEvent = startSet; } else if (localName.equals(IMPORT)) { // @@ -2686,11 +2712,11 @@ public void endDocument() throws SAXException { super.endDocument(); -gen.execute(gen.getConsumer(), -gen.getJexlContext(), -gen.getJXPathContext(), -null, -getStartEvent(), null); +gen.performGeneration(gen.getC
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
coliver 2003/12/29 13:26:05 Modified:src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: Handle unterminated ${ and #{ Revision ChangesPath 1.25 +36 -2 cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java Index: JXTemplateGenerator.java === RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- JXTemplateGenerator.java 28 Dec 2003 22:54:07 - 1.24 +++ JXTemplateGenerator.java 29 Dec 2003 21:26:05 - 1.25 @@ -907,9 +907,9 @@ if (inStr == null) return null; StringReader in = new StringReader(inStr.trim()); int ch; -StringBuffer expr = new StringBuffer(); boolean xpath = false; boolean inExpr = false; +StringBuffer expr = new StringBuffer(); while ((ch = in.read()) != -1) { char c = (char)ch; if (inExpr) { @@ -940,6 +940,16 @@ return new Expression(inStr, null); } } +if (inExpr) { +// unclosed #{} or ${} +String msg; +if (xpath) { +msg = "Unterminated #{"; +} else { +msg = "Unterminated ${"; +} +throw new Exception(msg); +} } catch (IOException ignored) { ignored.printStackTrace(); } @@ -1134,13 +1144,17 @@ int ch; boolean inExpr = false; boolean xpath = false; +int line = location.getLineNumber(); +int column = location.getColumnNumber(); try { top: while ((ch = in.read()) != -1) { +column++; char c = (char)ch; processChar: while (true) { if (inExpr) { if (c == '\\') { ch = in.read(); + if (ch == -1) { buf.append('\\'); } else { @@ -1210,6 +1224,16 @@ // won't happen ignored.printStackTrace(); } +if (inExpr) { +// unclosed #{} or ${} +String str; +if (xpath) { +str = "#{"; +} else { +str = "${"; +} +buf.insert(0, str); +} if (buf.length() > 0) { char[] charArray = new char[buf.length()]; @@ -1436,6 +1460,16 @@ } } catch (IOException ignored) { ignored.printStackTrace(); +} +if (inExpr) { +// unclosed #{} or ${} +String msg; +if (xpath) { +msg = "Unterminated #{"; +} else { +msg = "Unterminated ${"; +} +throw new SAXParseException(msg, location, null); } if (buf.length() > 0) { if (substEvents.size() == 0) {
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
coliver 2003/12/28 14:54:07 Modified:src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: Don't treat DOM nodes as JXTemplate's. Just stream them. Revision ChangesPath 1.24 +3 -8 cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java Index: JXTemplateGenerator.java === RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- JXTemplateGenerator.java 12 Dec 2003 05:39:37 - 1.23 +++ JXTemplateGenerator.java 28 Dec 2003 22:54:07 - 1.24 @@ -2970,14 +2970,9 @@ MyJexlContext jexlContext, JXPathContext jxpathContext, Node node) throws SAXException { -Parser parser = new Parser(); -DOMStreamer streamer = new DOMStreamer(parser); +DOMStreamer streamer = new DOMStreamer(consumer); streamer.stream(node); -execute(consumer, -jexlContext, -jxpathContext, -parser.getStartEvent(), null); -} + } private void call(Locator location, String messagePrefix,
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
coliver 2003/12/10 08:43:49 Modified:src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: Fix loop tag status Revision ChangesPath 1.22 +8 -4 cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java Index: JXTemplateGenerator.java === RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- JXTemplateGenerator.java 10 Dec 2003 16:24:35 - 1.21 +++ JXTemplateGenerator.java 10 Dec 2003 16:43:49 - 1.22 @@ -403,8 +403,8 @@ public class LocatorFacade implements Locator { private Locator locator; -public LocatorFacade(Locator intialLocator) { -this.locator = intialLocator; +public LocatorFacade(Locator initialLocator) { +this.locator = initialLocator; } public void setDocumentLocator(Locator newLocator) { @@ -3025,6 +3025,9 @@ public boolean isLast() { return last; } +public int getBegin() { +return begin; +} public int getEnd() { return end; } @@ -3243,6 +3246,7 @@ LoopTagStatus status = null; if (startForEach.varStatus != null) { status = new LoopTagStatus(); +status.begin = begin; status.end = end; status.step = step; status.first = true; @@ -3251,7 +3255,7 @@ localJXPathVariables.declareVariable(startForEach.varStatus, status); } -for (int count = 1; i <= end && iter.hasNext(); i++, count++) { +for (int count = 1; i <= end && iter.hasNext(); i+=step, count++) { Object value; JXPathContext localJXPathContext = null; value = iter.next();
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
vgritsenko2003/12/10 08:24:35 Modified:src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: static access Revision ChangesPath 1.21 +2 -2 cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java Index: JXTemplateGenerator.java === RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- JXTemplateGenerator.java 10 Dec 2003 01:57:09 - 1.20 +++ JXTemplateGenerator.java 10 Dec 2003 16:24:35 - 1.21 @@ -2776,7 +2776,7 @@ cocoon.put("context", FOM_JavaScriptFlowHelper.getFOM_Context(objectModel)); cocoon.put("continuation", kont); -cocoon.put("parameters", parameters.toProperties(parameters)); +cocoon.put("parameters", Parameters.toProperties(parameters)); this.variables = new MyVariables(cocoon, contextObject, kont,
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
coliver 2003/12/06 14:18:33 Modified:src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: Fixed bug in jx:set with literal value Revision ChangesPath 1.19 +2 -2 cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java Index: JXTemplateGenerator.java === RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- JXTemplateGenerator.java 7 Nov 2003 11:53:47 - 1.18 +++ JXTemplateGenerator.java 6 Dec 2003 22:18:33 - 1.19 @@ -965,7 +965,7 @@ (org.apache.commons.jexl.Expression)compiled; return e.evaluate(jexlContext); } -return compiled; +return expr.raw; } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); if (t instanceof Exception) {
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
cziegeler2003/11/06 12:23:04 Modified:src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: Cleaning up code Revision ChangesPath 1.17 +23 -11 cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java Index: JXTemplateGenerator.java === RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- JXTemplateGenerator.java 24 Oct 2003 14:12:18 - 1.16 +++ JXTemplateGenerator.java 6 Nov 2003 20:23:04 - 1.17 @@ -795,8 +795,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"; @@ -875,8 +875,11 @@ } return new Expression(inStr, null); } -// Compile an integer expression (returns either a Compiled Expression -// or an Integer literal) + +/* + * 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); @@ -2103,7 +2106,7 @@ } StartDocument getStartEvent() { -return startEvent; +return this.startEvent; } private void addEvent(Event ev) throws SAXException { @@ -2589,6 +2592,9 @@ return globalJexlContext; } +/* (non-Javadoc) + * @see org.apache.avalon.excalibur.pool.Recyclable#recycle() + */ public void recycle() { if ( this.resolver != null) { this.resolver.release(this.inputSource); @@ -2601,9 +2607,12 @@ 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) { @@ -2612,7 +2621,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) { @@ -2726,9 +2735,12 @@ } } +/* (non-Javadoc) + * @see org.apache.cocoon.generation.Generator#generate() + */ public void generate() -throws IOException, SAXException, ProcessingException { -final String cacheKey = inputSource.getURI(); +throws IOException, SAXException, ProcessingException { +final String cacheKey = this.inputSource.getURI(); StartDocument startEvent; synchronized (cache) { @@ -2738,7 +2750,7 @@ 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); }
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
sylvain 2003/10/24 07:12:19 Modified:src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: Add leniency support to XPath expressions Revision ChangesPath 1.16 +44 -12 cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java Index: JXTemplateGenerator.java === RCS file: /home/cvs/cocoon-2.1/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 20 Oct 2003 10:13:42 - 1.15 +++ JXTemplateGenerator.java 24 Oct 2003 14:12:18 - 1.16 @@ -909,14 +909,22 @@ } 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)compiled; @@ -931,6 +939,10 @@ 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) @@ -980,13 +992,19 @@ // 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)compiled; @@ -1001,6 +1019,10 @@ 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; @@ -1470,19 +1492,21 @@ 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 { @@ -1518,11 +1542,13 @@ } static class StartOut extends StartInstruction { -StartOut(StartElement raw, Expression expr) { +StartOut(StartElement raw, Expression
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
antonio 2003/10/20 03:13:43 Modified:src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: Reorganizing imports Revision ChangesPath 1.15 +26 -4 cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java Index: JXTemplateGenerator.java === RCS file: /home/cvs//cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- JXTemplateGenerator.java 20 Oct 2003 09:17:33 - 1.14 +++ JXTemplateGenerator.java 20 Oct 2003 10:13:42 - 1.15 @@ -57,12 +57,19 @@ import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.text.DateFormat; +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.text.NumberFormat; +import java.text.SimpleDateFormat; import java.util.HashMap; import java.util.Iterator; import java.util.LinkedList; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.Stack; +import java.util.TimeZone; import org.apache.avalon.framework.parameters.Parameters; import org.apache.cocoon.ProcessingException; @@ -85,11 +92,26 @@ import org.apache.commons.jexl.util.introspection.VelMethod; import org.apache.commons.jexl.util.introspection.VelPropertyGet; import org.apache.commons.jexl.util.introspection.VelPropertySet; -import org.apache.commons.jxpath.*; +import org.apache.commons.jxpath.CompiledExpression; +import org.apache.commons.jxpath.DynamicPropertyHandler; +import org.apache.commons.jxpath.JXPathBeanInfo; +import org.apache.commons.jxpath.JXPathContext; +import org.apache.commons.jxpath.JXPathContextFactory; +import org.apache.commons.jxpath.JXPathIntrospector; +import org.apache.commons.jxpath.Pointer; +import org.apache.commons.jxpath.Variables; import org.apache.excalibur.source.Source; import org.apache.excalibur.source.SourceException; import org.apache.excalibur.source.SourceValidity; -import org.mozilla.javascript.*; +import org.mozilla.javascript.Context; +import org.mozilla.javascript.JavaScriptException; +import org.mozilla.javascript.NativeArray; +import org.mozilla.javascript.NativeJavaClass; +import org.mozilla.javascript.ScriptRuntime; +import org.mozilla.javascript.Scriptable; +import org.mozilla.javascript.ScriptableObject; +import org.mozilla.javascript.Undefined; +import org.mozilla.javascript.Wrapper; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.Attributes; @@ -100,8 +122,6 @@ import org.xml.sax.ext.LexicalHandler; import org.xml.sax.helpers.AttributesImpl; import org.xml.sax.helpers.LocatorImpl; -import java.util.*; -import java.text.*; /** * (JX for http://jakarta.apache.org/commons/jxpath";>Apache JXPath @@ -333,6 +353,8 @@ ** * + * + * @version CVS $Id$ */ public class JXTemplateGenerator extends ServiceableGenerator { Ontario
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
bruno 2003/10/16 07:23:01 Modified:src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: Using JXTemplate as transformer gave a java.lang.VerifyError at runtime, apparently caused by accessing gen.xmlConsumer directly. Revision ChangesPath 1.13 +6 -1 cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java Index: JXTemplateGenerator.java === RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- JXTemplateGenerator.java 15 Oct 2003 14:12:45 - 1.12 +++ JXTemplateGenerator.java 16 Oct 2003 14:23:01 - 1.13 @@ -367,6 +367,11 @@ private static final Locator NULL_LOCATOR = new LocatorImpl(); +private XMLConsumer getConsumer() +{ +return this.xmlConsumer; +} + /** * Jexl Introspector that supports Rhino JavaScript objects * as well as Java Objects @@ -2483,7 +2488,7 @@ public void endDocument() throws SAXException { super.endDocument(); -gen.execute(gen.xmlConsumer, +gen.execute(gen.getConsumer(), gen.getJexlContext(), gen.getJXPathContext(), getStartEvent(), null);
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
cziegeler2003/09/25 09:57:44 Modified:.status.xml src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: Fixing release of Source in the JXTemplateGenerator. Revision ChangesPath 1.156 +4 -1 cocoon-2.1/status.xml Index: status.xml === RCS file: /home/cvs/cocoon-2.1/status.xml,v retrieving revision 1.155 retrieving revision 1.156 diff -u -r1.155 -r1.156 --- status.xml25 Sep 2003 05:15:00 - 1.155 +++ status.xml25 Sep 2003 16:57:44 - 1.156 @@ -191,6 +191,9 @@ + + Fixing release of Source in the JXTemplateGenerator. + Update lib commons-lang to 2.0, iText to 1.00 1.10 +44 -43 cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java Index: JXTemplateGenerator.java === RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- JXTemplateGenerator.java 24 Sep 2003 22:04:40 - 1.9 +++ JXTemplateGenerator.java 25 Sep 2003 16:57:44 - 1.10 @@ -2550,13 +2550,16 @@ } public void recycle() { +if ( this.resolver != null) { +this.resolver.release(this.inputSource); +} +this.inputSource = null; +this.consumer = null; +this.jxpathContext = null; +this.globalJexlContext = null; +this.variables = null; +this.definitions = null; super.recycle(); -consumer = null; -jxpathContext = null; -globalJexlContext = null; -variables = null; -inputSource = null; -definitions = null; } public void setup(SourceResolver resolver, Map objectModel, @@ -3522,55 +3525,53 @@ uri = buf.toString(); } -Source input; +Source input = null; +StartDocument doc; try { input = resolver.resolveURI(uri); -} catch (Exception exc) { -throw new SAXParseException(exc.getMessage(), -ev.location, -exc); -} -SourceValidity validity = null; -StartDocument doc; -synchronized (cache) { -doc = (StartDocument)cache.get(input.getURI()); -if (doc != null) { -boolean recompile = false; -if ( doc.compileTime == null) { -recompile = true; -} else { -int valid = doc.compileTime.isValid(); -if ( valid == SourceValidity.UNKNOWN ) { -validity = input.getValidity(); -valid = doc.compileTime.isValid(validity); - -} -if ( valid != SourceValidity.VALID ) { + +SourceValidity validity = null; +synchronized (cache) { +doc = (StartDocument)cache.get(input.getURI()); +if (doc != null) { +boolean recompile = false; +if ( doc.compileTime == null) { recompile = true; +} else { +int valid = doc.compileTime.isValid(); +if ( valid == SourceValidity.UNKNOWN ) { +validity = input.getValidity(); +valid = doc.compileTime.isValid(validity); +} +if ( valid != SourceValidity.VALID ) { +recompile = true; +} +} +if ( recompile ) { +doc = null; // recompile } -} -if ( recompile ) { -doc = null; // recompile } } -} -if (doc == null) { -try { +if (doc == null) {
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
mpo 2003/08/28 07:29:43 Modified:src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: Making sure the continuation is present in the Jexl context even if the flowContext is missing. Revision ChangesPath 1.7 +3 -1 cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java Index: JXTemplateGenerator.java === RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- JXTemplateGenerator.java 11 Aug 2003 12:48:56 - 1.6 +++ JXTemplateGenerator.java 28 Aug 2003 14:29:43 - 1.7 @@ -2662,7 +2662,6 @@ map = globalJexlContext.getVars(); if (contextObject != null) { map.put("flowContext", contextObject); -map.put("continuation", kont); // FIXME (VG): Is this required (what it's used for - examples)? // Here I use Rhino's live-connect objects to allow Jexl to call // java constructors @@ -2670,6 +2669,9 @@ Object pkgs = JavaScriptFlow.getPackages(objectModel); map.put("java", javaPkg); map.put("Packages", pkgs); +} +if (kont!=null) { +map.put("continuation", kont); } map.put("request", request); map.put("response", response);
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
cziegeler2003/08/11 05:48:56 Modified:src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: Use SourceValidity instead of last modified Revision ChangesPath 1.6 +33 -10 cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java Index: JXTemplateGenerator.java === RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- JXTemplateGenerator.java 8 Aug 2003 18:49:06 - 1.5 +++ JXTemplateGenerator.java 11 Aug 2003 12:48:56 - 1.6 @@ -88,6 +88,7 @@ import org.apache.commons.jxpath.*; import org.apache.excalibur.source.Source; import org.apache.excalibur.source.SourceException; +import org.apache.excalibur.source.SourceValidity; import org.mozilla.javascript.*; import org.w3c.dom.Node; import org.w3c.dom.NodeList; @@ -1125,7 +1126,7 @@ StartDocument(Locator location) { super(location); } -long compileTime; +SourceValidity compileTime; EndDocument endDocument; // null if document fragment } @@ -2569,13 +2570,18 @@ } catch (SourceException se) { throw SourceUtil.handle("Error during resolving of '" + src + "'.", se); } -long lastMod = inputSource.getLastModified(); String uri = inputSource.getURI(); synchronized (cache) { StartDocument startEvent = (StartDocument)cache.get(uri); -if (startEvent != null && -lastMod > startEvent.compileTime) { -cache.remove(uri); +if (startEvent != null) { +int valid = startEvent.compileTime.isValid(); +if ( valid == SourceValidity.UNKNOWN ) { +SourceValidity validity = inputSource.getValidity(); +valid = startEvent.compileTime.isValid(validity); +} +if ( valid != SourceValidity.VALID) { +cache.remove(uri); +} } } } @@ -2686,11 +2692,11 @@ startEvent = (StartDocument)cache.get(inputSource.getURI()); } if (startEvent == null) { -long compileTime = inputSource.getLastModified(); +SourceValidity validity = inputSource.getValidity(); Parser parser = new Parser(); SourceUtil.parse(this.manager, this.inputSource, parser); startEvent = parser.getStartEvent(); -startEvent.compileTime = compileTime; +startEvent.compileTime = validity; synchronized (cache) { cache.put(inputSource.getURI(), startEvent); } @@ -3522,12 +3528,26 @@ ev.location, exc); } -long lastMod = input.getLastModified(); +SourceValidity validity = null; StartDocument doc; synchronized (cache) { doc = (StartDocument)cache.get(input.getURI()); if (doc != null) { -if (doc.compileTime < lastMod) { +boolean recompile = false; +if ( doc.compileTime == null) { +recompile = true; +} else { +int valid = doc.compileTime.isValid(); +if ( valid == SourceValidity.UNKNOWN ) { +validity = input.getValidity(); +valid = doc.compileTime.isValid(validity); + +} +if ( valid != SourceValidity.VALID ) { +recompile = true; +} +} +if ( recompile ) { doc = null; // recompile } } @@ -3537,7 +3557,10 @@ Parser parser = new Parser(); SourceUtil.parse(this.manager, input, parser); doc = parser.getStartEvent(); -doc.compileTime = lastMod; +if ( validity == null ) { +validity = input.getValidity(); +} +doc.compileTime = validity; } cat
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
coliver 2003/08/08 11:49:06 Modified:src/documentation/xdocs/userdocs/flow jxtemplate.xml src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: Added JSTL formatNumber and formatDate tags Revision ChangesPath 1.18 +60 -1 cocoon-2.1/src/documentation/xdocs/userdocs/flow/jxtemplate.xml Index: jxtemplate.xml === RCS file: /home/cvs/cocoon-2.1/src/documentation/xdocs/userdocs/flow/jxtemplate.xml,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- jxtemplate.xml20 Jul 2003 05:48:18 - 1.17 +++ jxtemplate.xml8 Aug 2003 18:49:06 - 1.18 @@ -233,12 +233,71 @@ + + +The formatNumber tag is used to display numeric data, including currencies and percentages, in a locale-specific manner. It 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: + + ++ + + +Only the value attribute is required. It is used to specify the numeric value that is to be formatted. + + +The value of the type attribute should be either "number", "currency", or "percentage", and indicates what type of numeric value is being formatted. The default value for this attribute is "number". The pattern attribute takes precedence over the type attribute and allows more precise formatting of numeric values following the pattern conventions of the java.text.DecimalFormat class. + + +When the type attribute has a value of "currency", the currencyCode attribute can be used to explicitly specify the currency for the numerical value being displayed. As with language and country codes, currency codes are governed by an ISO standard. This code is used to determine the currency symbol to display as part of the formatted value. + + +Alternatively, you can use the currencySymbol attribute to explicitly specify the currency symbol. Note that as of JDK 1.4 and the associated introduction of the java.util.Currency class, the currencyCode attribute of formatNumber takes precedence over the currencySymbol attribute. For earlier versions of the JDK, however, the currencySymbol attribute takes precedence. + + +The maxIntegerDigits, minIntegerDigits, maxFractionDigits, and minFractionDigits attributes are used to control the number of significant digits displayed before and after the decimal point. These attributes require integer values. + + +The groupingUsed attribute takes a Boolean value and controls whether digits before the decimal point are grouped. For example, in English-language locales, large numbers have their digits grouped by threes, with each set of three delimited by a comma. Other locales delimit such groupings with a period or a space. The default value for this attribute is true. + + + + +The formatDate tag provides facilities to format Date values: + + + + + + +Only the value attribute is required. Its value should be an instance of the java.util.Date class, specifying the date and/or time data to be formatted and displayed. + +The optional timeZone attribute indicates the time zone in which the date and/or time are to be displayed. If not present, then the JVM's default time zone is used (that is, the time zone setting specified for the local operating system). + +The type attribute indicates which fields of the specified Date instance are to be displayed, and should be either "time", "date", or "both". The default value for this attribute is "date", so if no type attribute is present, the formatDate tag -- true to its name -- will only display the date information associated with the Date instance, specified using the tag's value attribute. + + +The dateStyle and timeStyle attributes indicate how the date and time information should be formatted, respectively. Valid styles are "default", "short", "medium", "long", and "full". The default value is, naturally, "default", indicating that a locale-specific style should be used. The semantics for the other four style values are as defined by the @link{java.text.DateFormat} class. + + +Rather than relying on the built-in styles, you can use the pattern attribute to specify a custom style. When present, the value of the
cvs commit: cocoon-2.1/src/java/org/apache/cocoon/generation JXTemplateGenerator.java
bruno 2003/08/06 04:31:01 Modified:src/java/org/apache/cocoon/generation JXTemplateGenerator.java Log: make sitemap parameters available to jstl expressions patch supplied by Unico Hommes (bugzilla 22165) Revision ChangesPath 1.4 +1 -0 cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java Index: JXTemplateGenerator.java === RCS file: /home/cvs/cocoon-2.1/src/java/org/apache/cocoon/generation/JXTemplateGenerator.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- JXTemplateGenerator.java 4 Aug 2003 03:06:30 - 1.3 +++ JXTemplateGenerator.java 6 Aug 2003 11:31:01 - 1.4 @@ -2035,6 +2035,7 @@ map.put("request", request); map.put("response", response); map.put("context", app); +map.put("parameters", parameters); Object session = request.getSession(false); if (session != null) { map.put("session", session);