santiagopg    2003/11/11 06:40:29

  Modified:    java/src/org/apache/xalan/xsltc/compiler Param.java
                        ParameterRef.java
               java/src/org/apache/xalan/xsltc/runtime
                        AbstractTranslet.java BasisLibrary.java
  Log:
  Patch for Bugzilla 24518 by Mehta Bhakti ([EMAIL PROTECTED]).
  
  Revision  Changes    Path
  1.25      +12 -2     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Param.java
  
  Index: Param.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Param.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- Param.java        23 Jun 2003 18:23:15 -0000      1.24
  +++ Param.java        11 Nov 2003 14:40:28 -0000      1.25
  @@ -81,6 +81,7 @@
   import org.apache.xalan.xsltc.compiler.util.Type;
   import org.apache.xalan.xsltc.compiler.util.TypeCheckError;
   
  +import org.apache.xalan.xsltc.runtime.BasisLibrary;
   final class Param extends VariableBase {
   
       // True if this Param is declared in a simple named template.
  @@ -204,7 +205,16 @@
        if (_ignore) return;
        // _ignore = true;
   
  -     final String name = getVariable();
  +        /*
  +         * To fix bug 24518 related to setting parameters of the form
  +         * {namespaceuri}localName
  +         * which will get mapped to an instance variable in the class
  +         * Hence  a parameter of the form "{http://foo.bar}xyz";
  +         * will be replaced with the corresponding values
  +         * by the BasisLibrary's utility method mapQNametoJavaName
  +         * and thus get mapped to legal java variable names
  +         */
  +     final String name = BasisLibrary.mapQNameToJavaName(_name.toString());
        final String signature = _type.toSignature();
        final String className = _type.getClassName();
   
  
  
  
  1.15      +17 -2     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ParameterRef.java
  
  Index: ParameterRef.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ParameterRef.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- ParameterRef.java 30 Jan 2003 18:46:01 -0000      1.14
  +++ ParameterRef.java 11 Nov 2003 14:40:28 -0000      1.15
  @@ -74,10 +74,14 @@
   import org.apache.xalan.xsltc.compiler.util.MethodGenerator;
   import org.apache.xalan.xsltc.compiler.util.NodeSetType;
   
  +import org.apache.xalan.xsltc.runtime.BasisLibrary;
   final class ParameterRef extends VariableRefBase {
   
  +    QName _name= null ;
       public ParameterRef(Param param) {
        super(param);
  +        _name = param._name;
  +        
       }
   
       public String toString() {
  @@ -88,7 +92,18 @@
        final ConstantPoolGen cpg = classGen.getConstantPool();
        final InstructionList il = methodGen.getInstructionList();
   
  -     final String name = _variable.getVariable();
  +        /*
  +         * To fix bug 24518 related to setting parameters of the form
  +         * {namespaceuri}localName
  +         * which will get mapped to an instance variable in the class
  +         * Hence  a parameter of the form "{http://foo.bar}xyz";
  +         * will be replaced with the corresponding values 
  +         * by the BasisLibrary's utility method mapQNametoJavaName
  +         * and thus get mapped to legal java variable names 
  +         */
  +
  +        final String name = BasisLibrary.mapQNameToJavaName 
(_name.toString());
  +
        final String signature = _type.toSignature();
   
        if (_variable.isLocal()) {
  
  
  
  1.49      +10 -3     
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/AbstractTranslet.java
  
  Index: AbstractTranslet.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/AbstractTranslet.java,v
  retrieving revision 1.48
  retrieving revision 1.49
  diff -u -r1.48 -r1.49
  --- AbstractTranslet.java     25 Jun 2003 19:55:46 -0000      1.48
  +++ AbstractTranslet.java     11 Nov 2003 14:40:29 -0000      1.49
  @@ -176,10 +176,14 @@
   
       /**
        * Add a new global parameter if not already in the current frame.
  +     * To setParameters of the form {http://foo.bar}xyz
  +     * This needs to get mapped to an instance variable in the class
  +     * The mapping  created so that 
  +     * the global variables in the generated class become 
  +     * http$colon$$flash$$flash$foo$dot$bar$colon$xyz
        */
       public final Object addParameter(String name, Object value) {
  -     name = BasisLibrary.replace(name, ".-", 
  -                                 new String[] { "$dot$", "$dash$" });
  +        name = BasisLibrary.mapQNameToJavaName (name);
        return addParameter(name, value, false);
       }
   
  @@ -226,6 +230,9 @@
        * <tt>null</tt> if undefined.
        */
       public final Object getParameter(String name) {
  +
  +        name = BasisLibrary.mapQNameToJavaName (name);
  +
        for (int i = pframe - 1; i >= pbase; i--) {
            final Parameter param = (Parameter)paramsStack.get(i);
            if (param._name.equals(name)) return param._value;
  
  
  
  1.63      +16 -1     
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/BasisLibrary.java
  
  Index: BasisLibrary.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/BasisLibrary.java,v
  retrieving revision 1.62
  retrieving revision 1.63
  diff -u -r1.62 -r1.63
  --- BasisLibrary.java 22 Oct 2003 20:23:48 -0000      1.62
  +++ BasisLibrary.java 11 Nov 2003 14:40:29 -0000      1.63
  @@ -1432,5 +1432,20 @@
        return result.toString();
       }
   
  +
  +    /**
  +     * Utility method to allow setting parameters of the form
  +     * {namespaceuri}localName
  +     * which get mapped to an instance variable in the class
  +     * Hence  a parameter of the form "{http://foo.bar}xyz";
  +     * will be replaced with the corresponding values  
  +     * by the BasisLibrary's utility method mapQNametoJavaName
  +     * and thus get mapped to legal java variable names 
  +     */
  +    public static String mapQNameToJavaName (String base ) {
  +       return replace(base, ".-:/{}?#%*", new String[] { "$dot$", "$dash$" 
,"$colon$", "$flash$","","$colon$","$ques$","$hash$","$per$","$aster$"});
  +
  +    }
  +
       //-- End utility functions
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to