You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by js...@apache.org on 2002/06/26 16:50:44 UTC
cvs commit: jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core FileTag.java CoreTagLibrary.java ForEachTag.java
jstrachan 2002/06/26 07:50:44
Modified: jelly/src/test/org/apache/commons/jelly testThread.jelly
jelly/src/test/org/apache/commons/jelly/define
TestDynamicTags.java
jelly build.xml project.xml
jelly/src/java/org/apache/commons/jelly/tags/core
CoreTagLibrary.java ForEachTag.java
Added: jelly/src/test/org/apache/commons/jelly testFile.jelly
jelly project-ng.xml
jelly/src/java/org/apache/commons/jelly/tags/core
FileTag.java
Log:
Patched the <forEach> tag so that it works for simple numerical for loops.
Also added the <file> tag which will generate a file of the given name with the contents of its body, which is good for generating multiple files from inside a Jelly script
Revision Changes Path
1.2 +0 -2 jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/testThread.jelly
Index: testThread.jelly
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/testThread.jelly,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- testThread.jelly 26 Jun 2002 09:17:44 -0000 1.1
+++ testThread.jelly 26 Jun 2002 14:50:43 -0000 1.2
@@ -3,7 +3,6 @@
About to spawn another thread...
-<!--
<j:thread name="thread1" file="target/thread.xml">
<x:parse var="doc">
<web-app>
@@ -39,7 +38,6 @@
There are <x:expr select="$count"/> servlet(s)
</j:whitespace>
</j:thread>
--->
The thread should have started now!
1.1 jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/testFile.jelly
Index: testFile.jelly
===================================================================
<?xml version="1.0"?>
<jelly xmlns="jelly:core">
<forEach var="i" begin="1" end="10">
<file name="target/test_${i}.xml">
<test id="${id}">
a test
</test>
</file>
</forEach>
</jelly>
1.7 +6 -6 jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/define/TestDynamicTags.java
Index: TestDynamicTags.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/define/TestDynamicTags.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- TestDynamicTags.java 25 Jun 2002 19:12:29 -0000 1.6
+++ TestDynamicTags.java 26 Jun 2002 14:50:43 -0000 1.7
@@ -126,7 +126,7 @@
log.info("The output was as follows");
log.info(buffer.toString());
}
-
+
protected void runScript(String name) throws Exception {
InputStream in = new FileInputStream(name);
Script script = parser.parse(in);
1.58 +6 -0 jakarta-commons-sandbox/jelly/build.xml
Index: build.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/build.xml,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- build.xml 26 Jun 2002 09:15:13 -0000 1.57
+++ build.xml 26 Jun 2002 14:50:43 -0000 1.58
@@ -338,6 +338,12 @@
</target>
+ <target name="demo.file" depends="compile"
+ description="Runs the file demo">
+
+ <jelly file="src/test/org/apache/commons/jelly/testFile.jelly"/>
+ </target>
+
<target name="demo.betwixt" depends="compile"
description="Runs a demo using the XML tags to generate a Betwixt descriptor">
1.29 +2 -2 jakarta-commons-sandbox/jelly/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/project.xml,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- project.xml 25 Jun 2002 16:12:33 -0000 1.28
+++ project.xml 26 Jun 2002 14:50:43 -0000 1.29
@@ -189,8 +189,8 @@
<dependency>
<name>commons-messenger</name>
<type>required</type>
- <version>1.0-dev-2</version>
- <jar>commons-messenger-1.0-dev-2.jar</jar>
+ <version>1.0-dev-3</version>
+ <jar>commons-messenger-1.0-dev-3.jar</jar>
</dependency>
<!-- http taglib -->
1.1 jakarta-commons-sandbox/jelly/project-ng.xml
Index: project-ng.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<project>
<pomVersion>3</pomVersion>
<name>commons-jelly</name>
<id>commons-jelly</id>
<currentVersion>1.0-dev</currentVersion>
<organization>
<name>Apache Software Foundation</name>
<url>http://www.apache.org</url>
</organization>
<inceptionYear>2002</inceptionYear>
<package>org.apache.commons.jelly</package>
<shortDescription>Commons Jelly</shortDescription>
<!-- Gump integration -->
<gumpRepositoryId>jakarta</gumpRepositoryId>
<description>
Jelly is a Java and XML based scripting engine.
Jelly combines the best ideas from JSTL, Velocity, DVSL, Ant and Cocoon all together in a simple
yet powerful scripting engine.
</description>
<url>http://jakarta.apache.org/commons/sandbox/jelly/</url>
<issueTrackingUrl>http://nagoya.apache.org/scarab/servlet/scarab/</issueTrackingUrl>
<siteAddress>jakarta.apache.org</siteAddress>
<siteDirectory>/www/jakarta.apache.org/commons/sandbox/jelly/</siteDirectory>
<distributionDirectory>/www/jakarta.apache.org/builds/jakarta-commons-sandbox/jelly/</distributionDirectory>
<repository>
<connection>scm:cvs:pserver:anoncvs@cvs.apache.org:/home/cvspublic:jakarta-commons-sandbox/jelly</connection>
<url>http://cvs.apache.org/viewcvs/jakarta-commons-sandbox/jelly/</url>
</repository>
<versions>
<version>
<id>b1</id>
<name>1.0-b1</name>
<tag>HEAD</tag>
</version>
</versions>
<branches></branches>
<mailingLists>
<mailingList>
<name>Commons Dev List</name>
<subscribe>commons-dev-subscribe@jakarta.apache.org</subscribe>
<unsubscribe>commons-dev-unsubscribe@jakarta.apache.org</unsubscribe>
<archive>http://nagoya.apache.org/eyebrowse/SummarizeList?listName=commons-dev@jakarta.apache.org</archive>
</mailingList>
</mailingLists>
<developers>
<developer>
<name>James Strachan</name>
<id>jstrachan</id>
<email>jstrachan@apache.org</email>
<organization>SpiritSoft, Inc.</organization>
</developer>
<developer>
<name>Geir Magnusson Jr.</name>
<id>geirm</id>
<email>geirm@adeptra.com</email>
<organization>Adeptra, Inc.</organization>
</developer>
<developer>
<name>Bob McWhirter</name>
<id>werken</id>
<email>bob@eng.werken.com</email>
<organization>The Werken Company</organization>
</developer>
<developer>
<name>dIon Gillard</name>
<id>dion</id>
<email>dion@multitask.com.au</email>
<organization>Multitask Consulting</organization>
<roles>
<role>Interested party</role>
</roles>
</developer>
</developers>
<dependencies>
<!--
<dependency>
<id>junit</id>
<version>3.7</version>
</dependency>
-->
<dependency>
<name>ant</name>
<version>1.4.1</version>
<jar>ant-1.4.1.jar</jar>
</dependency>
<dependency>
<name>commons-logging</name>
<type>required</type>
<version>1.0</version>
<jar>commons-logging-1.0.jar</jar>
</dependency>
<dependency>
<name>commons-beanutils</name>
<type>required</type>
<version>1.4-dev</version>
<jar>commons-beanutils-1.4-dev.jar</jar>
</dependency>
<dependency>
<name>commons-collections</name>
<type>required</type>
<version>2.0</version>
<jar>commons-collections-2.0.jar</jar>
</dependency>
<dependency>
<name>commons-digester</name>
<type>required</type>
<version>1.2</version>
<jar>commons-digester-1.2.jar</jar>
</dependency>
<dependency>
<name>dom4j</name>
<type>required</type>
<version>1.4-dev-3</version>
<jar>dom4j-1.4-dev-3.jar</jar>
</dependency>
<dependency>
<name>commons-jexl</name>
<type>required</type>
<version>1.0-dev</version>
<jar>commons-jexl-1.0-dev.jar</jar>
</dependency>
<dependency>
<name>velocity</name>
<type>required</type>
<version>1.4-dev</version>
<jar>velocity-1.4-dev.jar</jar>
</dependency>
<dependency>
<name>jdbc-stdext</name>
<type>required</type>
<version>2.0</version>
<jar>jdbc2_0-stdext.jar</jar>
</dependency>
<dependency>
<name>werkz</name>
<type>required</type>
<version>1.0-beta-2</version>
<jar>werkz-1.0-beta-2.jar</jar>
</dependency>
<!--
|| Optional tag library dependencies
|| These will be sub-projects one day, when Maven handles them gracefully
-->
<!-- beanshell taglib -->
<dependency>
<name>bsh</name>
<type>required</type>
<version>1.2-b3</version>
<jar>bsh-1.2-b3.jar</jar>
</dependency>
<!-- bsf taglib -->
<dependency>
<name>bsf</name>
<type>required</type>
<version>2.2</version>
<jar>bsf-2.2.jar</jar>
</dependency>
<!-- ojb taglib -->
<dependency>
<name>ojb</name>
<type>required</type>
<version>ojb-0.8.375</version>
<jar>ojb-0.8.375.jar</jar>
</dependency>
<!-- jms taglib -->
<dependency>
<name>jms</name>
<type>required</type>
<version>1.0.2b</version>
<jar>jms-1.0.2b.jar</jar>
</dependency>
<dependency>
<name>commons-messenger</name>
<type>required</type>
<version>1.0-dev-2</version>
<jar>commons-messenger-1.0-dev-2.jar</jar>
</dependency>
<!-- http taglib -->
<dependency>
<name>commons-httpclient</name>
<type>required</type>
<version>2.0-dev</version>
<jar>commons-httpclient-2.0-dev.jar</jar>
</dependency>
<!-- validate taglib -->
<dependency>
<name>isorelax</name>
<type>required</type>
<version>20020414</version>
<jar>isorelax-20020414.jar</jar>
</dependency>
<dependency>
<name>msv</name>
<type>required</type>
<version>20020414</version>
<jar>msv-20020414.jar</jar>
</dependency>
<!-- runtime dependency for validate taglib -->
<dependency>
<name>xsdlib</name>
<type>required</type>
<version>20020414</version>
<jar>xsdlib-20020414.jar</jar>
</dependency>
<dependency>
<name>relaxngDatatype</name>
<type>required</type>
<version>20020414</version>
<jar>relaxngDatatype-20020414.jar</jar>
</dependency>
<!-- runtime dependencies for test programs -->
<dependency>
<name>hsqldb</name>
<type>required</type>
<version>1.7.0</version>
<jar>hsqldb-1.7.0.jar</jar>
</dependency>
<!--
<dependency>
<name>xmlParseAPIs</name>
<type>required</type>
<version>2.0.0</version>
<jar>xmlParserAPIs-2.0.0.jar</jar>
</dependency>
<dependency>
<name>xercesImpl</name>
<type>required</type>
<version>2.0.0</version>
<jar>xercesImpl-2.0.0.jar</jar>
</dependency>
<dependency>
<name>xerces</name>
<type>required</type>
<version>1.4.4</version>
<jar>xerces-1.4.4.jar</jar>
</dependency>
-->
</dependencies>
<build>
<nagEmailAddress>commons-dev@jakarta.apache.org</nagEmailAddress>
<sourceDirectory>src/java</sourceDirectory>
<unitTestSourceDirectory>src/test</unitTestSourceDirectory>
<integrationUnitTestSourceDirectory/>
<aspectSourceDirectory/>
<!-- Unit test classes -->
<unitTestPatterns>
<unitTestPattern>include = **/Test*.java</unitTestPattern>
</unitTestPatterns>
<!-- Integration unit test classes -->
<integrationUnitTestPatterns></integrationUnitTestPatterns>
<!-- J A R R E S O U R C E S -->
<!-- Resources that are packaged up inside the JAR file -->
<jarResources>
<jarResource>include = **/*.properties</jarResource>
</jarResources>
<jars></jars>
</build>
</project>
1.13 +6 -5 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/CoreTagLibrary.java
Index: CoreTagLibrary.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/CoreTagLibrary.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- CoreTagLibrary.java 26 Jun 2002 09:14:31 -0000 1.12
+++ CoreTagLibrary.java 26 Jun 2002 14:50:43 -0000 1.13
@@ -100,6 +100,7 @@
registerTag("new", NewTag.class);
registerTag("whitespace", WhitespaceTag.class);
registerTag("thread", ThreadTag.class);
+ registerTag("file", FileTag.class);
}
}
1.15 +20 -5 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ForEachTag.java
Index: ForEachTag.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/ForEachTag.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- ForEachTag.java 26 Jun 2002 09:24:35 -0000 1.14
+++ ForEachTag.java 26 Jun 2002 14:50:43 -0000 1.15
@@ -161,6 +161,21 @@
if ( end == Integer.MAX_VALUE && begin == 0 ) {
throw new MissingAttributeException( "items" );
}
+ else {
+ String varName = var;
+ if ( varName == null ) {
+ varName = indexVar;
+ }
+
+ for (index = begin; index < end; index += step ) {
+
+ if (varName != null) {
+ Object value = new Integer(index);
+ context.setVariable(varName, value);
+ }
+ invokeBody(output);
+ }
+ }
}
}
1.1 jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/core/FileTag.java
Index: FileTag.java
===================================================================
/*
*
* ====================================================================
*
* The Apache Software License, Version 1.1
*
* Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution, if
* any, must include the following acknowlegement:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowlegement may appear in the software itself,
* if and wherever such third-party acknowlegements normally appear.
*
* 4. The names "The Jakarta Project", "Commons", and "Apache Software
* Foundation" must not be used to endorse or promote products derived
* from this software without prior written permission. For written
* permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache"
* nor may "Apache" appear in their names without prior written
* permission of the Apache Group.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.commons.jelly.tags.core;
import java.io.FileOutputStream;
import org.apache.commons.jelly.MissingAttributeException;
import org.apache.commons.jelly.TagSupport;
import org.apache.commons.jelly.XMLOutput;
/**
* A tag that pipes its body to a file.
*
* @author <a href="mailto:vinayc@apache.org">Vinay Chandran</a>
*/
public class FileTag extends TagSupport
{
private String name;
public FileTag(){
}
// Tag interface
//-------------------------------------------------------------------------
public void doTag(final XMLOutput output) throws Exception {
if ( name == null ) {
throw new MissingAttributeException( "name" );
}
XMLOutput newOutput = XMLOutput.createXMLOutput(new FileOutputStream(name));
try {
newOutput.startDocument();
invokeBody(newOutput);
newOutput.endDocument();
}
finally {
newOutput.close();
}
}
/**
* Sets the file name for the output
*/
public void setName(String name) {
this.name = name;
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>