[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xml-cocoon-cvs
Subject:    cvs commit: xml-cocoon/src/org/apache/cocoon/filters XalanFilter.java
From:       balld () locus ! apache ! org
Date:       2000-06-24 20:16:10
[Download RAW message or body]

balld       00/06/24 13:16:10

  Modified:    src/org/apache/cocoon/filters Tag: xml-cocoon2
                        XalanFilter.java
  Log:
  added automatic inclusion of valid request parameters as stylesheet parameters
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +33 -1     xml-cocoon/src/org/apache/cocoon/filters/Attic/XalanFilter.java
  
  Index: XalanFilter.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/filters/Attic/XalanFilter.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- XalanFilter.java	2000/02/28 18:39:50	1.1.2.1
  +++ XalanFilter.java	2000/06/24 20:16:10	1.1.2.2
  @@ -8,6 +8,8 @@
   package org.apache.cocoon.filters;
   
   import java.io.IOException;
  +import java.util.Enumeration;
  +import java.text.StringCharacterIterator;
   import org.apache.arch.Component;
   import org.apache.arch.ComponentManager;
   import org.apache.arch.Composer;
  @@ -33,7 +35,7 @@
    *
    * @author <a href="mailto:fumagalli@exoffice.com">Pierpaolo Fumagalli</a>
    *         (Apache Software Foundation, Exoffice Technologies)
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2000/02/28 18:39:50 $
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2000/06/24 20:16:10 $
    */
   public class XalanFilter extends DocumentHandlerWrapper
   implements Filter, Composer {
  @@ -68,6 +70,14 @@
           // Create the processor and set it as this documenthandler
           this.processor=XSLTProcessorFactory.getProcessor();
           this.processor.setStylesheet(stylesheet);
  +		Enumeration enum = req.getParameterNames();
  +		while (enum.hasMoreElements()) {
  +			String name = (String)enum.nextElement();
  +			if (isValidXSLTParameterName(name)) {
  +				String value = req.getParameter(name);
  +				processor.setStylesheetParam(name,this.processor.createXString(value));
  +			}
  +		}
           this.setDocumentHandler(this.processor);
   
       }
  @@ -112,4 +122,26 @@
        */
       public void setLexicalHandler(LexicalHandler lexical) {
       }
  +
  +	public static boolean isValidXSLTParameterName(String name) {
  +		StringCharacterIterator iter = new StringCharacterIterator(name);
  +		char c = iter.first();
  +		if (!(Character.isLetter(c) || c == '_')) {
  +			return false;
  +		} else {
  +			c = iter.next();
  +		}
  +		while (c != iter.DONE) {
  +			if (!(Character.isLetterOrDigit(c) ||
  +				c == '-' ||
  +				c == '_' ||
  +				c == '.')) {
  +				return false;
  +			} else {
  +				c = iter.next();
  +			}
  +		}
  +		return true;
  +	}
  +
   }
  
  
  

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic