You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by gr...@locus.apache.org on 2000/11/22 01:03:45 UTC

cvs commit: xml-cocoon/src/org/apache/cocoon/processor/xslt XSLTProcessor.java

greenrd     00/11/21 16:03:45

  Modified:    .        changes.xml
               src/org/apache/cocoon/processor/xslt XSLTProcessor.java
  Log:
  passing headers and cookies to stylesheets
  
  Revision  Changes    Path
  1.155     +5 -0      xml-cocoon/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/changes.xml,v
  retrieving revision 1.154
  retrieving revision 1.155
  diff -u -r1.154 -r1.155
  --- changes.xml	2000/11/21 23:38:22	1.154
  +++ changes.xml	2000/11/22 00:03:44	1.155
  @@ -4,7 +4,7 @@
   
   <!--
     History of Cocoon changes   
  -  $Id: changes.xml,v 1.154 2000/11/21 23:38:22 greenrd Exp $ 
  +  $Id: changes.xml,v 1.155 2000/11/22 00:03:44 greenrd Exp $ 
   -->
   
   <changes title="History of Changes">
  @@ -18,6 +18,11 @@
     </devs>
   
    <release version="@version@" date="@date@">
  +  <action dev="RDG" type="update" due-to="Ovidiu Predescu"
  +   due-to-email="ovidiu@cup.hp.com">
  +   Request headers (prefixed by R_) and cookies (prefixed by C_)
  +   are now passed to stylesheets, as well as request parameters.
  +  </action>
     <action dev="RDG" type="update" due-to="Ovidiu Predescu" 
      due-to-email="ovidiu@cup.hp.com">
      Made caching dependent on all request headers, not just user agent.
  
  
  
  1.19      +28 -8     xml-cocoon/src/org/apache/cocoon/processor/xslt/XSLTProcessor.java
  
  Index: XSLTProcessor.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/processor/xslt/XSLTProcessor.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- XSLTProcessor.java	2000/11/20 22:37:24	1.18
  +++ XSLTProcessor.java	2000/11/22 00:03:45	1.19
  @@ -1,4 +1,4 @@
  -/*-- $Id: XSLTProcessor.java,v 1.18 2000/11/20 22:37:24 greenrd Exp $ --
  +/*-- $Id: XSLTProcessor.java,v 1.19 2000/11/22 00:03:45 greenrd Exp $ --
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -73,7 +73,7 @@
    * This class implements an XSLT processor.
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
  - * @version $Revision: 1.18 $ $Date: 2000/11/20 22:37:24 $
  + * @version $Revision: 1.19 $ $Date: 2000/11/22 00:03:45 $
    */
   
   public class XSLTProcessor implements Actor, Processor, Status, Defaults, Cacheable {
  @@ -121,6 +121,32 @@
           if (parameters != null) {
               while (parameters.hasMoreElements()) {
                   String name = (String) parameters.nextElement();
  +                if (isValidName (name))
  +                    params.put (name, request.getParameter (name));
  +            }
  +        }
  +
  +        Cookie[] cookies = request.getCookies ();
  +        if (cookies != null) {
  +            for (int i = 0; i < cookies.length; i++) {
  +                Cookie cookie = cookies [i];
  +                String name = cookie.getName ();
  +                if (isValidName (name))
  +                    params.put ("C_" + name, cookie.getValue ());
  +            }
  +        }
  +        
  +        Enumeration headers = request.getHeaderNames ();
  +        while (headers.hasMoreElements ()) {
  +            String name = (String) headers.nextElement ();
  +            if (isValidName (name))
  +                params.put ("R_" + name, request.getHeader (name));
  +        }
  +
  +        return params;
  +    }
  +
  +    private boolean isValidName (String name) {
   				StringCharacterIterator iter = new StringCharacterIterator(name);
   				boolean valid_name = true;
   				char c = iter.first();
  @@ -141,14 +167,8 @@
   						c = iter.next();
   					}
   				}
  -				
  -				if (valid_name) {
  -                	params.put(name, request.getParameter(name));
  -				}
  -            }
  -        }
  -        
  -        return params;
  +
  +                                return valid_name;				
       }
       
       private Object getResource(ServletContext context, HttpServletRequest request, Document document, String path, String browser) throws ProcessorException {