santiagopg    02/04/26 11:14:29

  Modified:    java/src/org/apache/xalan/xsltc/compiler Stylesheet.java
  Log:
  Ensured that global vars are initialized in the order in which they
  were defined, whenever possible. This order may be altered due to
  the existence of dependencies between the vars.
  
  Revision  Changes    Path
  1.39      +24 -13    
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Stylesheet.java
  
  Index: Stylesheet.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Stylesheet.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- Stylesheet.java   24 Apr 2002 17:03:15 -0000      1.38
  +++ Stylesheet.java   26 Apr 2002 18:14:28 -0000      1.39
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Stylesheet.java,v 1.38 2002/04/24 17:03:15 santiagopg Exp $
  + * @(#)$Id: Stylesheet.java,v 1.39 2002/04/26 18:14:28 santiagopg Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -704,9 +704,10 @@
       }
   
       /**
  -     * This method returns a vector with variables in the order in which
  -     * they are to be compiled. The order is determined by the dependencies
  -     * between them. The first step is to close the input vector under
  +     * This method returns a vector with variables in the order in 
  +     * which they are to be compiled. The order is determined by the 
  +     * dependencies between them and the order in which they were defined 
  +     * in the stylesheet. The first step is to close the input vector under
        * the dependence relation (this is usually needed when variables are
        * defined inside other variables in a RTF).
        */
  @@ -726,19 +727,21 @@
            }
        }
   
  +     /* DEBUG CODE - INGORE
  +     for (int i = 0; i < input.size(); i++) {
  +         final VariableBase var = (VariableBase) input.elementAt(i);
  +         System.out.println("var = " + var);
  +     }
  +     System.out.println("=================================");
  +     */
  +
        Vector result = new Vector();
  -     int zeroDep = 0;
        while (input.size() > 0) {
            boolean changed = false;
            for (int i = 0; i < input.size(); ) {
                final VariableBase var = (VariableBase)input.elementAt(i);
                final Vector dep = var.getDependencies();
  -             if (dep == null) {
  -                 result.insertElementAt(var, zeroDep++);
  -                 input.remove(i);
  -                 changed = true;
  -             }
  -             else if (result.containsAll(dep)) {
  +             if (dep == null || result.containsAll(dep)) {
                    result.addElement(var);
                    input.remove(i);
                    changed = true;
  @@ -748,7 +751,6 @@
                }
            }
   
  -
            // If nothing was changed in this pass then we have a circular ref
            if (!changed) {
                ErrorMsg err = new ErrorMsg(ErrorMsg.CIRCULAR_VARIABLE_ERR,
  @@ -757,7 +759,16 @@
                return(result);
            }
        }
  -     return(result);
  +
  +     /* DEBUG CODE - INGORE
  +     System.out.println("=================================");
  +     for (int i = 0; i < result.size(); i++) {
  +         final VariableBase var = (VariableBase) result.elementAt(i);
  +         System.out.println("var = " + var);
  +     }
  +     */
  +
  +     return result;
       }
   
       /**
  
  
  

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

Reply via email to