commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject cvs commit: jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl BeanTagScript.java
Date Sat, 25 May 2002 18:27:22 GMT
jstrachan    02/05/25 11:27:22

  Modified:    jelly/src/java/org/apache/commons/jelly jelly.properties
                        TagSupport.java
               jelly/src/java/org/apache/commons/jelly/tags/xml
                        ForEachTag.java XPathTagSupport.java
               jelly    TODO.txt build.xml
               jelly/src/test/org/apache/commons/jelly/xml example.jelly
               jelly/src/java/org/apache/commons/jelly/impl
                        BeanTagScript.java
  Added:       jelly/src/java/org/apache/commons/jelly/tags/jsl
                        package.html JSLTagSupport.java
                        ApplyTemplatesTag.java StylesheetTag.java
                        JSLTagLibrary.java TemplateTag.java
                        XPathPatternExpression.java
               jelly/src/test/org/apache/commons/jelly/jsl example.jelly
                        example2.jelly
               jelly/src/java/org/apache/commons/jelly/tags/xml
                        XPathSource.java
  Log:
  Added support for Jelly Stylesheet Language tags (JSL) which are an implementation of an XSLT style declarative transformation engine. 
  
  The whole thing uses 3 tags, <jsl:stylesheet>, <jsl:template> and <jsl:applyTemplates> that work neatly with the XML taglib from JSTL.
  This allows XSLT like processing to be cleanly mixed with JSTL tags in a single Jelly script; also JSL is totally dynamic, so the stylesheet can be dynamically created and invoked.
  
  There are example targets demo.jsl and demo.jsl2 that demonstrate JSL in action
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jsl/package.html
  
  Index: package.html
  ===================================================================
  <html>
  <head>
  </head>
  <body>
  
    <h1>The Jelly StylesheetLibrary (JSL)</h1>
    
    <p>The JSL tag library implements an XSLT-like declarative XML based processing engine which allows 
    	dynamic stylesheets and a free mix and match of all Jelly tags within the script.
    </p>
    
  </body>
  </html>
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jsl/JSLTagSupport.java
  
  Index: JSLTagSupport.java
  ===================================================================
  /*
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 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", "Tomcat", 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.jsl;
  
  import org.dom4j.rule.Stylesheet;
  
  import org.apache.commons.jelly.tags.xml.XPathTagSupport;
  
  
  /** 
   * A common base class useful for implementation inheritence
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.8 $
   */
  public abstract class JSLTagSupport extends XPathTagSupport {
      
      public JSLTagSupport() {
      }
  
      
      // Helper methods
      //-------------------------------------------------------------------------                
  
      public Stylesheet getStylesheet() {
          StylesheetTag tag  = (StylesheetTag) findAncestorWithClass( 
              this, StylesheetTag.class 
          );
          if ( tag != null ) {
              return tag.getStylesheet();
          }
          else {
              return null;
          }
      }
  
      
      // Implementation methods
      //-------------------------------------------------------------------------                
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jsl/ApplyTemplatesTag.java
  
  Index: ApplyTemplatesTag.java
  ===================================================================
  /*
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 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", "Tomcat", 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.jsl;
  
  import org.apache.commons.jelly.JellyContext;
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.XMLOutput;
  
  import org.dom4j.rule.Stylesheet;
  
  import org.jaxen.XPath;
  
  /** 
   * Implements the apply templates function in the stylesheet, similar to the XSLT equivalent.
   * a JSP include.
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.8 $
   */
  public class ApplyTemplatesTag extends JSLTagSupport {
  
      /** Holds value of property mode. */
      private String mode;    
  
      /** Holds the XPath object */
      private XPath select;
      
  
      public ApplyTemplatesTag() {
      }
  
      // Tag interface
      //------------------------------------------------------------------------- 
      /** By default just evaluate the body */
      public void doTag(XMLOutput output) throws Exception {
          Stylesheet stylesheet = getStylesheet();        
          if ( stylesheet == null ) {
              throw new JellyException( 
                  "<applyTemplates> tag must be inside a <stylesheet> tag"
              );
          }
          Object context = getXPathContext();
          if ( select != null ) {
              stylesheet.applyTemplates( context, select );
          }
          else {
              stylesheet.applyTemplates( context );
          }
          
          // #### should support MODE!!!
          
      }
  
      // Properties
      //-------------------------------------------------------------------------                
  
      public void setSelect( XPath select ) {
          this.select = select;
      }
      
      /** Setter for property mode.
       * @param mode New value of property mode.
       */
      public void setMode(String mode) {
          this.mode = mode;
      }    
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jsl/StylesheetTag.java
  
  Index: StylesheetTag.java
  ===================================================================
  /*
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 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", "Tomcat", 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.jsl;
  
  import org.apache.commons.jelly.JellyContext;
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.XMLOutput;
  
  import org.dom4j.Node;
  //import org.dom4j.XPath;
  import org.dom4j.rule.Action;
  import org.dom4j.rule.Rule;
  import org.dom4j.rule.Stylesheet;
  
  /** 
   * This tag implements a JSL stylesheet which is similar to an 
   * XSLT stylesheet but can use Jelly tags inside it. a JSP include.
   *
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.8 $
   */
  public class StylesheetTag extends JSLTagSupport {
  
      /** Holds the stylesheet which will be applied to the source context. */
      private Stylesheet stylesheet = new Stylesheet();
      
      /** Holds value of property mode. */
      private String mode;    
  
      /** store the current output instance for use by inner classes */
      private XMLOutput output;
  
      /** the source on which the stylesheet will operate */
      private Object source;
      
      /** The variable which the stylesheet will be output as */
      private String var;
          
      public StylesheetTag() {
          // add default actions
          stylesheet.setValueOfAction( 
              new Action() {
                  public void run(Node node) throws Exception {
                      String text = node.getStringValue();
                      if ( text != null && text.length() > 0 ) {
                          output.write( text );
                      }
                  }
              }
          );                    
          
      }
          
  
  
      /** 
       * Adds a new template rule to this stylesheet
       */    
      public void addTemplate( Rule rule ) {
          stylesheet.addRule( rule );
      }
      
      
      // Tag interface
      //-------------------------------------------------------------------------                    
      public void doTag(XMLOutput output) throws Exception {
          // for use by inner classes
          this.output = output;
          
          try {        
              // run the body to add the rules
              getBody().run(context, output);
              
              stylesheet.setModeName( getMode() );
              stylesheet.run( source );
          }
          finally {
              
              // help the GC
              this.output = null;
              stylesheet.clear();        
          }
      }
      
      
      // Properties
      //-------------------------------------------------------------------------                
      
      /** 
       * Getter for property mode.
       * @return Value of property mode.
       */
      public String getMode() {
          return mode;
      }
      
      /** 
       * Setter for property mode.
       * @param mode New value of property mode.
       */
      public void setMode(String mode) {
          this.mode = mode;
      }   
  
      /** Sets the source on which the stylesheet will run
       */
      public void setSource(Object source) {
          this.source = source;
      }    
      
      public Stylesheet getStylesheet() {
          return stylesheet;
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jsl/JSLTagLibrary.java
  
  Index: JSLTagLibrary.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/XMLTagLibrary.java,v 1.6 2002/05/17 18:04:00 jstrachan Exp $
   * $Revision: 1.6 $
   * $Date: 2002/05/17 18:04:00 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: XMLTagLibrary.java,v 1.6 2002/05/17 18:04:00 jstrachan Exp $
   */
  package org.apache.commons.jelly.tags.jsl;
  
  import java.io.IOException;
  import java.io.Writer;
  import java.util.Iterator;
  import java.util.List;
  
  import org.apache.commons.jelly.JellyContext;
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.Script;
  import org.apache.commons.jelly.TagLibrary;
  import org.apache.commons.jelly.expression.Expression;
  import org.apache.commons.jelly.expression.ExpressionFactory;
  import org.apache.commons.jelly.tags.xml.XPathExpression;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  import org.dom4j.DocumentHelper;
  import org.dom4j.rule.Pattern;
  
  import org.jaxen.JaxenException;
  import org.jaxen.XPath;
  import org.jaxen.dom4j.Dom4jXPath;
  
  /** Describes the Taglib. This class could be generated by XDoclet
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.6 $
    */
  public class JSLTagLibrary extends TagLibrary {
  
      /** The Log to which logging calls will be made. */
      private Log log = LogFactory.getLog(JSLTagLibrary.class);
      
      public JSLTagLibrary() {
          registerTag("stylesheet", StylesheetTag.class);
          registerTag("template", TemplateTag.class);
          registerTag("applyTemplates", ApplyTemplatesTag.class);
      }
  
      public Expression createExpression(
          ExpressionFactory factory,
          String tagName,
          String attributeName,
          String attributeValue) throws Exception {
  
          // #### may need to include some namespace URI information in the XPath instance?
          
          if (attributeName.equals("select")) {            
              if ( log.isDebugEnabled() ) {
                  log.debug( "Parsing XPath expression: " + attributeValue );
              }
              
              try {
                  XPath xpath = new Dom4jXPath(attributeValue);
                  return new XPathExpression(xpath);
              }
              catch (JaxenException e) {
                  throw new JellyException( "Could not parse XPath expression: \"" + attributeValue + "\" reason: " + e, e );            
              }            
          }
          
          if (attributeName.equals("match")) {
              if ( log.isDebugEnabled() ) {
                  log.debug( "Parsing XPath pattern: " + attributeValue );
              }
              
              try {
                  Pattern pattern = DocumentHelper.createPattern( attributeValue );
                  return new XPathPatternExpression(pattern);
              }
              catch (Exception e) {
                  throw new JellyException( "Could not parse XPath expression: \"" + attributeValue + "\" reason: " + e, e );            
              }            
          }
          
          // will use the default expression instead
          return super.createExpression(factory, tagName, attributeName, attributeValue);
      }
      
      
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jsl/TemplateTag.java
  
  Index: TemplateTag.java
  ===================================================================
  /*
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999 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", "Tomcat", 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.jsl;
  
  import org.apache.commons.jelly.JellyContext;
  import org.apache.commons.jelly.JellyException;
  import org.apache.commons.jelly.XMLOutput;
  import org.apache.commons.jelly.tags.xml.XPathSource;
  
  import org.dom4j.Node;
  import org.dom4j.rule.Action;
  import org.dom4j.rule.Pattern;
  import org.dom4j.rule.Rule;
  
  /** 
   * This tag represents a declarative matching rule, similar to the template tag in XSLT.
   * 
   * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
   * @version $Revision: 1.8 $
   */
  public class TemplateTag extends JSLTagSupport implements XPathSource {
  
      /** Holds value of property name. */
      private String name;
      
      /** Holds value of property mode. */
      private String mode;    
      
      /** Holds value of property priority. */
      private double priority;
      
      /** Holds value of property rule. */
      private Rule rule;    
  
      /** Holds value of property action. */
      private Action action;
  
      /** The pattern to match */
      private Pattern match;
      
      /** store the current output instance for use by inner classes */
      private XMLOutput output;
  
      /** The source XPath context for any child tags */
      private Object xpathSource;
      
      
      public TemplateTag() {
      }
  
      // Tag interface
      //------------------------------------------------------------------------- 
      public void doTag(XMLOutput output) throws Exception {
          // for use by inner classes
          this.output = output;
          
          StylesheetTag tag = (StylesheetTag) findAncestorWithClass( StylesheetTag.class );
          if (tag == null) {
              throw new JellyException( "This <template> tag must be used inside a <stylesheet> tag" );
          }
          
          Rule rule = getRule();
          if ( rule != null && tag != null) {
              rule.setMode( mode );
              tag.addTemplate( rule );
          }
      }
  
      // XPathSource interface
      //-------------------------------------------------------------------------                    
  
      /**
       * @return the current XPath iteration value
       *  so that any other XPath aware child tags to use
       */
      public Object getXPathSource() {
          return xpathSource;
      }
      
  
      // Properties
      //-------------------------------------------------------------------------                
  
      public void setMatch(Pattern match) {
          this.match = match;
      }
      
      /** Getter for property priority.
       * @return Value of property priority.
       */
      public double getPriority() {
          return priority;
      }
      
      /** Setter for property priority.
       * @param priority New value of property priority.
       */
      public void setPriority(double priority) {
          this.priority = priority;
      }
      
      /** Getter for property name.
       * @return Value of property name.
       */
      public String getName() {
          return name;
      }
      
      /** Setter for property name.
       * @param name New value of property name.
       */
      public void setName(String name) {
          this.name = name;
      }
      
      
      /** Getter for property action.
       * @return Value of property action.
       */
      public Action getAction() {
          if ( action == null ) {
              action = createAction();
          }
          return action;
      }
      
      /** Setter for property action.
       * @param action New value of property action.
       */
      public void setAction(Action action) {
          this.action = action;
      }
      
      /** Setter for property mode.
       * @param mode New value of property mode.
       */
      public void setMode(String mode) {
          this.mode = mode;
      }
      
      /** Getter for property rule.
       * @return Value of property rule.
       */
      public Rule getRule() {
          if ( rule == null ) {
              rule = createRule();
          }
          return rule;
      }
      
      
      
      // Implementation methods
      //------------------------------------------------------------------------- 
      protected Rule createRule() {
          return new Rule( match, getAction() );
      }
      
      protected Action createAction() {
          return new Action() {
              public void run(Node node) throws Exception {
                  xpathSource = node;
                  
                  getBody().run(context, output);
              }
          };                    
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/jsl/XPathPatternExpression.java
  
  Index: XPathPatternExpression.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/XPathExpression.java,v 1.4 2002/05/17 15:18:13 jstrachan Exp $
   * $Revision: 1.4 $
   * $Date: 2002/05/17 15:18:13 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: XPathExpression.java,v 1.4 2002/05/17 15:18:13 jstrachan Exp $
   */
  package org.apache.commons.jelly.tags.jsl;
  
  import java.io.IOException;
  import java.io.Writer;
  
  import org.apache.commons.jelly.JellyContext;
  import org.apache.commons.jelly.Script;
  import org.apache.commons.jelly.Tag;
  import org.apache.commons.jelly.expression.ExpressionSupport;
  
  import org.dom4j.rule.Pattern;
  
  import org.jaxen.VariableContext;
  
  /** An expression which returns an XPath based Pattern (like an XSLT pattern).
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.4 $
    */
  public class XPathPatternExpression extends ExpressionSupport implements VariableContext {
      
      private Pattern pattern;
      private JellyContext context;
      
      public XPathPatternExpression() {
      }
      public XPathPatternExpression(Pattern pattern) {
          this.pattern = pattern;
      }
      
      // Expression interface
      //------------------------------------------------------------------------- 
      public Object evaluate(JellyContext context) {
          this.context = context;
          //pattern.setVariableContext(this);
          return pattern;
      }
      
      // VariableContext interface
      //------------------------------------------------------------------------- 
      public Object getVariableValue(
          String namespaceURI,
          String prefix,
          String localName) {
              
          Object value = context.getVariable(localName);
          
          //log.info( "Looking up XPath variable of name: " + localName + " value is: " + value );            
          
          return value;
      }
  }
  
  
  
  1.8       +2 -0      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/jelly.properties
  
  Index: jelly.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/jelly.properties,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- jelly.properties	17 May 2002 15:18:12 -0000	1.7
  +++ jelly.properties	25 May 2002 18:27:21 -0000	1.8
  @@ -3,7 +3,9 @@
   define      = org.apache.commons.jelly.tags.define.DefineTagLibrary
   xml         = org.apache.commons.jelly.tags.xml.XMLTagLibrary
   sql         = org.apache.commons.jelly.tags.sql.SqlTagLibrary
  +
   # optional taglibs
  +jsl			= org.apache.commons.jelly.tags.jsl.JSLTagLibrary
   ojb			= org.apache.commons.jelly.tags.ojb.OjbTagLibrary
   beanshell   = org.apache.commons.jelly.tags.beanshell.BeanShellTagLibrary
   bsf         = org.apache.commons.jelly.tags.bsf.BSFTagLibrary
  
  
  
  1.7       +5 -10     jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/TagSupport.java
  
  Index: TagSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/TagSupport.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TagSupport.java	17 May 2002 15:18:12 -0000	1.6
  +++ TagSupport.java	25 May 2002 18:27:21 -0000	1.7
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/TagSupport.java,v 1.6 2002/05/17 15:18:12 jstrachan Exp $
  - * $Revision: 1.6 $
  - * $Date: 2002/05/17 15:18:12 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/TagSupport.java,v 1.7 2002/05/25 18:27:21 jstrachan Exp $
  + * $Revision: 1.7 $
  + * $Date: 2002/05/25 18:27:21 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: TagSupport.java,v 1.6 2002/05/17 15:18:12 jstrachan Exp $
  + * $Id: TagSupport.java,v 1.7 2002/05/25 18:27:21 jstrachan Exp $
    */
   package org.apache.commons.jelly;
   
  @@ -68,7 +68,7 @@
     * inherit from if developing your own tag.</p>
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.6 $
  +  * @version $Revision: 1.7 $
     */
   
   public abstract class TagSupport implements Tag {
  @@ -128,11 +128,6 @@
       /** Sets the context in which the tag will be run */
       public void setContext(JellyContext context) {
           this.context = context;
  -    }
  -    
  -    /** By default just evaluate the body */
  -    public void doTag(XMLOutput output) throws Exception {
  -        getBody().run(context, output);
       }
       
       // Implementation methods
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/jsl/example.jelly
  
  Index: example.jelly
  ===================================================================
  <?xml version="1.0"?>
<j:jelly xmlns:j="jelly:core" xmlns:x="jelly:xml" xmlns:jsl="jelly:jsl">

<html>
<body>
	
  <x:parse var="doc">
  <simpleDocument author="James Elson">

    <title>I am a title!</title>

    <synopsis>Twas a dark, rainy night...</synopsis>

    <para>dfjsdfjsdf</para>
    <para>fdsfsdfhdsff gyuf uysgf ds</para>

  </simpleDocument>
  </x:parse>


<h1>Output</h1>


<jsl:stylesheet source="${doc}">

  <jsl:template match="/">
    <jsl:applyTemplates/>
  </jsl:template>

  <jsl:template match="*">
    <small><jsl:applyTemplates/></small>
  </jsl:template>

  <jsl:template match="title">
    <h2><jsl:applyTemplates/></h2>
  </jsl:template>


  <jsl:template match="para">
    <p><jsl:applyTemplates/></p>
  </jsl:template>

</jsl:stylesheet>

</body>
</html>

</j:jelly>

  
  
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/jsl/example2.jelly
  
  Index: example2.jelly
  ===================================================================
  <?xml version="1.0"?>
<j:jelly xmlns:j="jelly:core" xmlns:x="jelly:xml" xmlns:jsl="jelly:jsl">

<html>
<body>
	
  <x:parse var="doc">
  <simpleDocument author="James Elson">

    <title>I am a title!</title>

    <synopsis>Twas a dark, rainy night...</synopsis>

    <para>dfjsdfjsdf</para>
    <para>fdsfsdfhdsff gyuf uysgf ds</para>

  </simpleDocument>
  </x:parse>


<h1>Output of first stylesheet1</h1>

<jsl:stylesheet source="${doc}">

  <jsl:template match="/">
    <jsl:applyTemplates/>
  </jsl:template>

  <jsl:template match="title">
    <h2><jsl:applyTemplates/></h2>
  </jsl:template>


  <jsl:template match="para">
    <p><jsl:applyTemplates/></p>
  </jsl:template>

  <jsl:template match="*">
    <small><jsl:applyTemplates/></small>
  </jsl:template>

</jsl:stylesheet>

<hr />

<h1>Output of stylesheet2</h1>

<jsl:stylesheet source="${doc}">

  <jsl:template match="/">
    <jsl:applyTemplates/>
  </jsl:template>

  <jsl:template match="*">
    <small><jsl:applyTemplates/></small>
  </jsl:template>

  <jsl:template match="title">
    <h2><jsl:applyTemplates/></h2>
  </jsl:template>


  <jsl:template match="para">
    <p><jsl:applyTemplates/></p>
  </jsl:template>

</jsl:stylesheet>

<hr />

<h1>Output of stylesheet3</h1>


<jsl:stylesheet source="${doc}">

  <jsl:template match="/simpleDocument">
   <h2>Book review</h2>
   <b>Title:</b> <jsl:applyTemplates select="title"/><br />
   <b>Author:</b> <jsl:applyTemplates select="@author"/><br />
   <b>Summary:</b> <em><jsl:applyTemplates select="synopsis"/></em><br />
  </jsl:template>

  <jsl:template match="title">
    <span style="color:blue"><jsl:applyTemplates/></span>
  </jsl:template>


  <jsl:template match="para">
    <p><jsl:applyTemplates/></p>
  </jsl:template>

</jsl:stylesheet>


</body>
</html>

</j:jelly>

  
  
  1.8       +18 -13    jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/ForEachTag.java
  
  Index: ForEachTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/ForEachTag.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ForEachTag.java	17 May 2002 15:18:13 -0000	1.7
  +++ ForEachTag.java	25 May 2002 18:27:21 -0000	1.8
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/ForEachTag.java,v 1.7 2002/05/17 15:18:13 jstrachan Exp $
  - * $Revision: 1.7 $
  - * $Date: 2002/05/17 15:18:13 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/ForEachTag.java,v 1.8 2002/05/25 18:27:21 jstrachan Exp $
  + * $Revision: 1.8 $
  + * $Date: 2002/05/25 18:27:21 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    * 
  - * $Id: ForEachTag.java,v 1.7 2002/05/17 15:18:13 jstrachan Exp $
  + * $Id: ForEachTag.java,v 1.8 2002/05/25 18:27:21 jstrachan Exp $
    */
   package org.apache.commons.jelly.tags.xml;
   
  @@ -74,9 +74,9 @@
   /** A tag which performs an iteration over the results of an XPath expression
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.7 $
  +  * @version $Revision: 1.8 $
     */
  -public class ForEachTag extends XPathTagSupport {
  +public class ForEachTag extends XPathTagSupport implements XPathSource {
   
       /** Holds the XPath selector. */
       private XPath select;
  @@ -106,6 +106,18 @@
               }
           }
       }
  +    
  +    // XPathSource interface
  +    //-------------------------------------------------------------------------                    
  +
  +    /**
  +     * @return the current XPath iteration value
  +     *  so that any other XPath aware child tags to use
  +     */
  +    public Object getXPathSource() {
  +        return iterationValue;
  +    }
  +    
       // Properties
       //-------------------------------------------------------------------------                    
       /** Sets the XPath selection expression
  @@ -119,11 +131,4 @@
           this.var = var;
       }
       
  -    /**
  -     * @return the current XPath iteration value
  -     *  so that any other XPath aware child tags to use
  -     */
  -    public Object getIterationValue() {
  -        return iterationValue;
  -    }
   }
  
  
  
  1.2       +2 -2      jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/XPathTagSupport.java
  
  Index: XPathTagSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/XPathTagSupport.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- XPathTagSupport.java	20 May 2002 10:09:28 -0000	1.1
  +++ XPathTagSupport.java	25 May 2002 18:27:21 -0000	1.2
  @@ -76,9 +76,9 @@
       // Implementation methods
       //-------------------------------------------------------------------------                
       protected Object getXPathContext() {
  -        ForEachTag tag = (ForEachTag) findAncestorWithClass( ForEachTag.class );    
  +        XPathSource tag = (XPathSource) findAncestorWithClass( XPathSource.class );    
           if ( tag != null ) {
  -            return tag.getIterationValue();
  +            return tag.getXPathSource();
           }
           return null;
       }    
  
  
  
  1.1                  jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/XPathSource.java
  
  Index: XPathSource.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/tags/xml/ExprTag.java,v 1.5 2002/05/16 16:29:55 jstrachan Exp $
   * $Revision: 1.5 $
   * $Date: 2002/05/16 16:29:55 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2002 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   * 
   * $Id: ExprTag.java,v 1.5 2002/05/16 16:29:55 jstrachan Exp $
   */
  package org.apache.commons.jelly.tags.xml;
  
  import org.apache.commons.jelly.JellyContext;
  import org.apache.commons.jelly.Script;
  import org.apache.commons.jelly.TagSupport;
  import org.apache.commons.jelly.XMLOutput;
  
  /** An abstract base class useful for implementation inheritence
    *
    * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision: 1.5 $
    */
  public interface XPathSource {
  
      public Object getXPathSource();
      
  }
  
  
  
  1.11      +10 -0     jakarta-commons-sandbox/jelly/TODO.txt
  
  Index: TODO.txt
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/TODO.txt,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- TODO.txt	17 May 2002 18:06:19 -0000	1.10
  +++ TODO.txt	25 May 2002 18:27:21 -0000	1.11
  @@ -1,6 +1,16 @@
   TO DO LIST
   ==========
   
  +* consider using <jsl:stylesheet var="foo"> then reusing the stylesheet later via 
  +
  +	<style stylesheet="${foo}">
  +		xml goes there...
  +	</style>
  +	
  +* add JSL test cases to test for ordering of patterns and that the correct output comes out.
  +
  +* seems to be a bug in JSL stylesheet 3 - <jsl:applyAttributes select="@author">
  +
   * rename the DynaTag interface to be DynamicAttributes along with JSP1.3, also add a namespace URI parameter
   
   * add JUnit tags along these lines...
  
  
  
  1.29      +71 -51    jakarta-commons-sandbox/jelly/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/build.xml,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- build.xml	23 May 2002 22:28:46 -0000	1.28
  +++ build.xml	25 May 2002 18:27:21 -0000	1.29
  @@ -17,159 +17,159 @@
     <!-- maven:start -->
     
     <!-- ================================================================== -->
  +  <!-- D E F I N E   A N T   T A S K S                                    -->
  +  <!-- ================================================================== -->
  +  <taskdef
  +	name="maven-ant"
  +	classname="org.apache.maven.ant.Ant">
  +	<classpath>
  +      <pathelement location="${lib.repo}/maven.jar"/>
  +	</classpath>
  +  </taskdef>
  +
  +        
  +  <!-- ================================================================== -->
     <!-- D E L E G A T O R S                                                -->
     <!-- ================================================================== -->
           
   	<target name="maven:gump-descriptor">
  -	  <ant antfile="${maven.home}/plugins/core/build.xml" target="gump-descriptor"/>
  +	  <maven-ant antfile="${maven.home}/plugins/core/build.xml" target="gump-descriptor"/>
   	</target>
   	
   	<target name="maven:maven-update">
  -	  <ant antfile="${maven.home}/plugins/core/build.xml" target="maven-update"/>
  +	  <maven-ant antfile="${maven.home}/plugins/core/build.xml" target="maven-update"/>
   	</target>
   	
   	<target name="maven:update-jars">
  -	  <ant antfile="${maven.home}/plugins/core/build.xml" target="update-jars"/>
  +	  <maven-ant antfile="${maven.home}/plugins/core/build.xml" target="update-jars"/>
   	</target>
   	
   	<target name="maven:jar">
  -	  <ant antfile="${maven.home}/plugins/core/build.xml" target="jar"/>
  +	  <maven-ant antfile="${maven.home}/plugins/core/build.xml" target="jar"/>
   	</target>
   	
   	<target name="maven:docs-quick">
  -	  <ant antfile="${maven.home}/plugins/docs/build.xml" target="docs-quick"/>
  +	  <maven-ant antfile="${maven.home}/plugins/docs/build.xml" target="docs-quick"/>
   	</target>
   	
   	<target name="maven:run-singletest">
  -	  <ant antfile="${maven.home}/plugins/test/build.xml" target="run-singletest"/>
  +	  <maven-ant antfile="${maven.home}/plugins/test/build.xml" target="run-singletest"/>
   	</target>
   	
   	<target name="maven:compile">
  -	  <taskdef
  -    	name="maven-ant"
  -    	classname="org.apache.maven.ant.Ant">
  -    	<classpath>
  -          <pathelement location="${lib.repo}/maven.jar"/>
  -    	</classpath>
  -	  </taskdef>
  -
  -	  <maven-ant 
  -	  	antfile="${maven.home}/plugins/core/build.xml" 
  -	  	target="compile" 
  -	  	exportRefs="true" 
  -	  	exportAll="true"/>
  +	  <maven-ant antfile="${maven.home}/plugins/core/build.xml" target="compile"/>
   	</target>
   	
   	<target name="maven:jar-resources">
  -	  <ant antfile="${maven.home}/plugins/core/build.xml" target="jar-resources"/>
  +	  <maven-ant antfile="${maven.home}/plugins/core/build.xml" target="jar-resources"/>
   	</target>
   	
   	<target name="maven:fo">
  -	  <ant antfile="${maven.home}/plugins/docs/build.xml" target="fo"/>
  +	  <maven-ant antfile="${maven.home}/plugins/docs/build.xml" target="fo"/>
   	</target>
   	
   	<target name="maven:cvs-change-log">
  -	  <ant antfile="${maven.home}/plugins/docs/build.xml" target="cvs-change-log"/>
  +	  <maven-ant antfile="${maven.home}/plugins/docs/build.xml" target="cvs-change-log"/>
   	</target>
   	
   	<target name="maven:war">
  -	  <ant antfile="${maven.home}/plugins/j2ee/build.xml" target="war"/>
  +	  <maven-ant antfile="${maven.home}/plugins/j2ee/build.xml" target="war"/>
   	</target>
   	
   	<target name="maven:generate-reactor">
  -	  <ant antfile="${maven.home}/plugins/reactor/build.xml" target="generate-reactor"/>
  +	  <maven-ant antfile="${maven.home}/plugins/reactor/build.xml" target="generate-reactor"/>
   	</target>
   	
   	<target name="maven:cross-ref">
  -	  <ant antfile="${maven.home}/plugins/docs/build.xml" target="cross-ref"/>
  +	  <maven-ant antfile="${maven.home}/plugins/docs/build.xml" target="cross-ref"/>
   	</target>
   	
   	<target name="maven:deploy-site">
  -	  <ant antfile="${maven.home}/plugins/docs/build.xml" target="deploy-site"/>
  +	  <maven-ant antfile="${maven.home}/plugins/docs/build.xml" target="deploy-site"/>
   	</target>
   	
   	<target name="maven:ear">
  -	  <ant antfile="${maven.home}/plugins/j2ee/build.xml" target="ear"/>
  +	  <maven-ant antfile="${maven.home}/plugins/j2ee/build.xml" target="ear"/>
   	</target>
   	
   	<target name="maven:install-jar">
  -	  <ant antfile="${maven.home}/plugins/core/build.xml" target="install-jar"/>
  +	  <maven-ant antfile="${maven.home}/plugins/core/build.xml" target="install-jar"/>
   	</target>
   	
   	<target name="maven:task-list">
  -	  <ant antfile="${maven.home}/plugins/docs/build.xml" target="task-list"/>
  +	  <maven-ant antfile="${maven.home}/plugins/docs/build.xml" target="task-list"/>
   	</target>
   	
   	<target name="maven:docs">
  -	  <ant antfile="${maven.home}/plugins/docs/build.xml" target="docs"/>
  +	  <maven-ant antfile="${maven.home}/plugins/docs/build.xml" target="docs"/>
   	</target>
   	
   	<target name="maven:site">
  -	  <ant antfile="${maven.home}/plugins/docs/build.xml" target="site"/>
  +	  <maven-ant antfile="${maven.home}/plugins/docs/build.xml" target="site"/>
   	</target>
   	
   	<target name="maven:deploy-dist">
  -	  <ant antfile="${maven.home}/plugins/core/build.xml" target="deploy-dist"/>
  +	  <maven-ant antfile="${maven.home}/plugins/core/build.xml" target="deploy-dist"/>
   	</target>
   	
   	<target name="maven:javadocs">
  -	  <ant antfile="${maven.home}/plugins/docs/build.xml" target="javadocs"/>
  +	  <maven-ant antfile="${maven.home}/plugins/docs/build.xml" target="javadocs"/>
   	</target>
   	
   	<target name="maven:announce">
  -	  <ant antfile="${maven.home}/plugins/core/build.xml" target="announce"/>
  +	  <maven-ant antfile="${maven.home}/plugins/core/build.xml" target="announce"/>
   	</target>
   	
   	<target name="maven:check-source">
  -	  <ant antfile="${maven.home}/plugins/core/build.xml" target="check-source"/>
  +	  <maven-ant antfile="${maven.home}/plugins/core/build.xml" target="check-source"/>
   	</target>
   	
   	<target name="maven:dist">
  -	  <ant antfile="${maven.home}/plugins/core/build.xml" target="dist"/>
  +	  <maven-ant antfile="${maven.home}/plugins/core/build.xml" target="dist"/>
   	</target>
   	
   	<target name="maven:dist-build">
  -	  <ant antfile="${maven.home}/plugins/core/build.xml" target="dist-build"/>
  +	  <maven-ant antfile="${maven.home}/plugins/core/build.xml" target="dist-build"/>
   	</target>
   	
   	<target name="maven:metrics">
  -	  <ant antfile="${maven.home}/plugins/metrics/build.xml" target="metrics"/>
  +	  <maven-ant antfile="${maven.home}/plugins/metrics/build.xml" target="metrics"/>
   	</target>
   	
   	<target name="maven:clean">
  -	  <ant antfile="${maven.home}/plugins/core/build.xml" target="clean"/>
  +	  <maven-ant antfile="${maven.home}/plugins/core/build.xml" target="clean"/>
   	</target>
   	
   	<target name="maven:env">
  -	  <ant antfile="${maven.home}/plugins/core/build.xml" target="env"/>
  +	  <maven-ant antfile="${maven.home}/plugins/core/build.xml" target="env"/>
   	</target>
   	
   	<target name="maven:test">
  -	  <ant antfile="${maven.home}/plugins/test/build.xml" target="test"/>
  +	  <maven-ant antfile="${maven.home}/plugins/test/build.xml" target="test"/>
   	</target>
   	
   	<target name="maven:pdf">
  -	  <ant antfile="${maven.home}/plugins/docs/build.xml" target="pdf"/>
  +	  <maven-ant antfile="${maven.home}/plugins/docs/build.xml" target="pdf"/>
   	</target>
   	
   	<target name="maven:iutest">
  -	  <ant antfile="${maven.home}/plugins/uitest/build.xml" target="iutest"/>
  +	  <maven-ant antfile="${maven.home}/plugins/uitest/build.xml" target="iutest"/>
   	</target>
   	
   	<target name="maven:activity-log">
  -	  <ant antfile="${maven.home}/plugins/docs/build.xml" target="activity-log"/>
  +	  <maven-ant antfile="${maven.home}/plugins/docs/build.xml" target="activity-log"/>
   	</target>
   	
   	<target name="maven:verify-project">
  -	  <ant antfile="${maven.home}/plugins/core/build.xml" target="verify-project"/>
  +	  <maven-ant antfile="${maven.home}/plugins/core/build.xml" target="verify-project"/>
   	</target>
   	
   	<target name="maven:validate-pom">
  -	  <ant antfile="${maven.home}/plugins/core/build.xml" target="validate-pom"/>
  +	  <maven-ant antfile="${maven.home}/plugins/core/build.xml" target="validate-pom"/>
   	</target>
   	
   	<target name="maven:validate-war">
  -	  <ant antfile="${maven.home}/plugins/j2ee/build.xml" target="validate-war"/>
  +	  <maven-ant antfile="${maven.home}/plugins/j2ee/build.xml" target="validate-war"/>
   	</target>
   	
   
  @@ -181,10 +181,6 @@
   	  <delete file="velocity.log"/>
   	</target>
   	
  -	<target name="site" depends="maven:site"/>
  -	
  -	<target name="test" depends="maven:test"/>
  -
   	<target name="compile" depends="maven:compile, maven:jar-resources">
   	
   	  <path id="test.classpath">
  @@ -200,7 +196,10 @@
         
       </target>	
   
  +	<target name="compile.test" depends="compile"/>
  +	<target name="test" depends="maven:test"/>
   	<target name="dist" depends="maven:dist"/>
  +	<target name="site" depends="maven:site"/>
   	
   <!-- ========== Sample Program Targets ==================================== -->
   
  @@ -215,6 +214,27 @@
         description="Runs demo which displays Ant properties">
         
   	<jelly file="src/test/org/apache/commons/jelly/show_ant_properties.jelly" output="target/ant.html"/>
  +	
  +   </target>
  +
  +   <target name="demo.xml" depends="compile" 
  +      description="Runs a simple demo of the XML tags">
  +      
  +	<jelly file="src/test/org/apache/commons/jelly/xml/example.jelly"/> 
  +	
  +   </target>
  +
  +   <target name="demo.jsl" depends="compile" 
  +      description="Runs a simple demo of the JSL tags">
  +      
  +	<jelly file="src/test/org/apache/commons/jelly/jsl/example.jelly"/> 
  +	
  +   </target>
  +
  +   <target name="demo.jsl2" depends="compile" 
  +      description="Runs demo #2 of the JSL tags">
  +      
  +	<jelly file="src/test/org/apache/commons/jelly/jsl/example2.jelly"/> 
   	
      </target>
   
  
  
  
  1.2       +7 -9      jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/xml/example.jelly
  
  Index: example.jelly
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/xml/example.jelly,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- example.jelly	20 May 2002 10:09:28 -0000	1.1
  +++ example.jelly	25 May 2002 18:27:22 -0000	1.2
  @@ -1,12 +1,10 @@
  -<?xml version="1.0"?>

  -

  -<j:jelly xmlns:j="jelly:core" xmlns:x="jelly:xml">

  -  <x:parse var="doc">

  -    <html>

  -      <title>It works!</title>

  -      <body>

  -      </body>

  -    </html>

  +<?xml version="1.0"?>
<j:jelly xmlns:j="jelly:core" xmlns:x="jelly:xml">
  +
  <x:parse var="doc">
  +    <html>
  +      <title>It works!</title>
  +      <body>
  +      </body>
  +    </html>
     </x:parse>

     <x:expr select="$doc/html/title"/>

   </j:jelly>

  
  
  
  1.7       +11 -9     jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/BeanTagScript.java
  
  Index: BeanTagScript.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/BeanTagScript.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- BeanTagScript.java	23 May 2002 23:35:20 -0000	1.6
  +++ BeanTagScript.java	25 May 2002 18:27:22 -0000	1.7
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/BeanTagScript.java,v 1.6 2002/05/23 23:35:20 jstrachan Exp $
  - * $Revision: 1.6 $
  - * $Date: 2002/05/23 23:35:20 $
  + * $Header: /home/cvs/jakarta-commons-sandbox/jelly/src/java/org/apache/commons/jelly/impl/BeanTagScript.java,v 1.7 2002/05/25 18:27:22 jstrachan Exp $
  + * $Revision: 1.7 $
  + * $Date: 2002/05/25 18:27:22 $
    *
    * ====================================================================
    *
  @@ -57,7 +57,7 @@
    * information on the Apache Software Foundation, please see
    * <http://www.apache.org/>.
    *
  - * $Id: BeanTagScript.java,v 1.6 2002/05/23 23:35:20 jstrachan Exp $
  + * $Id: BeanTagScript.java,v 1.7 2002/05/25 18:27:22 jstrachan Exp $
    */
   
   package org.apache.commons.jelly.impl;
  @@ -91,7 +91,7 @@
   /** <p><code>TagScript</code> evaluates a custom tag.</p>
     *
     * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  -  * @version $Revision: 1.6 $
  +  * @version $Revision: 1.7 $
     */
   
   public class BeanTagScript extends TagScript {
  @@ -207,10 +207,12 @@
               // convert value to correct type
               if (value != null) {
                   value = convertType(value, type);
  -            }
  -            
  -            // ### should check types are valid before we invoke...
  -            
  +
  +                Class theClass = value.getClass();
  +                if ( ! type.isAssignableFrom( theClass ) ) {
  +                    log.warn( "Cannot call method: " + method.getName() + " as I cannot convert: " + value + " of type: " + theClass.getName() + " into type: " + type.getName() );
  +                }
  +            }            
               Object[] arguments = { value };
               method.invoke(tag, arguments);
           }
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message