morten      01/07/09 03:17:59

  Modified:    java/src/org/apache/xalan/xsltc/compiler Constants.java
                        Param.java StepPattern.java Stylesheet.java
                        SyntaxTreeNode.java Variable.java WithParam.java
               java/src/org/apache/xalan/xsltc/dom KeyIndex.java
               java/src/org/apache/xalan/xsltc/runtime
                        AbstractTranslet.java BasisLibrary.java
                        DefaultRun.java Parameter.java TextOutput.java
  Log:
  Loads of small fixes and a good few comments added to the source code.
  The major fixes are one fix for variable/parameter handlingi and one for
  key/id index handling. XSLTC now correctly updates the value of parameters
  with changing default values, such as with
  <xsl:param name="foo" select="current()"/>.
  Also updated bit-arrays to correctly return single node ids, so that the
  key() and id() functions return the correct number of nodes (they would
  sometimes skip the first node in the defined node set for the key/id).
  Added some structure and loads of comments to the Translet base class.
  PR:           n/a
  Obtained from:        n/a
  Submitted by: [EMAIL PROTECTED]
  Reviewed by:  [EMAIL PROTECTED]
  
  Revision  Changes    Path
  1.8       +18 -19    
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Constants.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Constants.java    2001/06/11 12:52:55     1.7
  +++ Constants.java    2001/07/09 10:17:40     1.8
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Constants.java,v 1.7 2001/06/11 12:52:55 morten Exp $
  + * @(#)$Id: Constants.java,v 1.8 2001/07/09 10:17:40 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -416,11 +416,11 @@
   
       public static final String RESET_SIG            
        = "()" + NODE_ITERATOR_SIG;
  -    public static final String GET_PARAMETER         
  +    public static final String GET_PARAMETER      
        = "getParameter";
       public static final String ADD_PARAMETER         
        = "addParameter";
  -    public static final String PUSH_PARAM_FRAME      
  +    public static final String PUSH_PARAM_FRAME
        = "pushParamFrame";
       public static final String PUSH_PARAM_FRAME_SIG  
        = "()V";
  @@ -430,32 +430,31 @@
        = "()V";
       public static final String GET_PARAMETER_SIG     
        = "(" + STRING_SIG + ")" + OBJECT_SIG;
  -    public static final String ADD_PARAMETER_SIG     
  -     = "(" + STRING_SIG + OBJECT_SIG + ")" + OBJECT_SIG;
  -    public static final String PUSH_VAR_FRAME        
  +    public static final String ADD_PARAMETER_SIG
  +     = "(" + STRING_SIG + OBJECT_SIG + "Z)" + OBJECT_SIG;
  +    public static final String PUSH_VAR_FRAME
        = "pushVarFrame";
  -    public static final String PUSH_VAR_FRAME_SIG    
  +    public static final String PUSH_VAR_FRAME_SIG
        = "(I)V";
  -    public static final String POP_VAR_FRAME         
  +    public static final String POP_VAR_FRAME
        = "popVarFrame";
  -    public static final String POP_VAR_FRAME_SIG     
  +    public static final String POP_VAR_FRAME_SIG
        = "()V";
  -    public static final String ADD_VARIABLE          
  +    public static final String ADD_VARIABLE
        = "addVariable";
  -    public static final String ADD_VARIABLE_SIG      
  +    public static final String ADD_VARIABLE_SIG
        = "(I" + OBJECT_SIG + ")V";
  -    public static final String GET_VARIABLE          
  +    public static final String GET_VARIABLE
        = "getVariable";
  -    public static final String GET_VARIABLE_SIG      
  +    public static final String GET_VARIABLE_SIG
        = "(I)" + OBJECT_SIG;
   
  -    public static final int POSITION_INDEX           
  -     = 2;
  -    public static final int LAST_INDEX               
  -     = 3;
  -    public static final String XSLT_URI 
  +    public static final int POSITION_INDEX = 2;
  +    public static final int LAST_INDEX     = 3;
  +
  +    public static final String XSLT_URI
        = "http://www.w3.org/1999/XSL/Transform";;
  -    public static final String TRANSLET_URI 
  +    public static final String TRANSLET_URI
        = "http://xml.apache.org/xalan/xsltc";;
       public static final String FALLBACK_CLASS
        = "org.apache.xalan.xsltc.compiler.Fallback";
  
  
  
  1.7       +32 -71    
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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Param.java        2001/06/29 14:58:55     1.6
  +++ Param.java        2001/07/09 10:17:40     1.7
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Param.java,v 1.6 2001/06/29 14:58:55 morten Exp $
  + * @(#)$Id: Param.java,v 1.7 2001/07/09 10:17:40 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -58,6 +58,7 @@
    *
    * @author Jacek Ambroziak
    * @author Santiago Pericas-Geertsen
  + * @author Morten Jorgensen
    *
    */
   
  @@ -80,6 +81,7 @@
       private boolean    _isLocal;     // true if the param is local
       private Expression _select;
       private Type       _type;
  +
       // a JavaClass construct to refer to a JVM var
       private LocalVariableGen _local;
       // cached JavaClass instruction to push the contents of this var
  @@ -192,47 +194,31 @@
        _type = Type.Reference;
        return Type.Void;
       }
  -
  -    public void compileResultTree(ClassGenerator classGen,
  -                               MethodGenerator methodGen) {
  -     final ConstantPoolGen cpg = classGen.getConstantPool();
  -     final InstructionList il = methodGen.getInstructionList();
  -
  -     // Save the current handler base on the stack
  -     il.append(methodGen.loadHandler());
   
  -     // Create new instance of DOM class (with 64 nodes)
  -     final int init = cpg.addMethodref(DOM_IMPL, "<init>", "(I)V");
  -     il.append(new NEW(cpg.addClass(DOM_IMPL)));
  -     il.append(DUP);
  -     il.append(DUP);
  -     il.append(new PUSH(cpg, 64));
  -     il.append(new INVOKESPECIAL(init));
  -
  -     // Overwrite old handler with DOM handler
  -     final int getOutputDomBuilder =
  -         cpg.addMethodref(DOM_IMPL,
  -                          "getOutputDomBuilder",
  -                          "()" + TRANSLET_OUTPUT_SIG);
  -     il.append(new INVOKEVIRTUAL(getOutputDomBuilder));
  -     il.append(DUP);
  -     il.append(methodGen.storeHandler());
  -
  -     // Call startDocument on the new handler
  -     il.append(methodGen.startDocument());
  -
  -     // Instantiate result tree fragment
  -     translateContents(classGen, methodGen);
  -
  -     // Call endDocument on the new handler
  -     il.append(methodGen.loadHandler());
  -     il.append(methodGen.endDocument());
  -
  -     // Restore old handler base from stack
  -     il.append(SWAP);
  -     il.append(methodGen.storeHandler());
  +    /**
  +     * Compile the value of the parameter, which is either in an expression 
in
  +     * a 'select' attribute, or in the parameter element's body
  +     */
  +    public void translateValue(ClassGenerator classGen,
  +                            MethodGenerator methodGen) {
  +     // Compile expression is 'select' attribute if present
  +     if (_select != null) {
  +         _select.translate(classGen, methodGen);
  +         _select.startResetIterator(classGen, methodGen);
  +     }
  +     // If not, compile result tree from parameter body if present.
  +     else if (hasContents()) {
  +         compileResultTree(classGen, methodGen);
  +     }
  +     // If neither are present then store empty string in parameter slot
  +     else {
  +         final ConstantPoolGen cpg = classGen.getConstantPool();
  +         final InstructionList il = methodGen.getInstructionList();
  +         il.append(new PUSH(cpg, Constants.EMPTYSTRING));
  +     }
       }
   
  +
       public void translate(ClassGenerator classGen, MethodGenerator 
methodGen) {
        final ConstantPoolGen cpg = classGen.getConstantPool();
        final InstructionList il = methodGen.getInstructionList();
  @@ -245,26 +231,13 @@
   
            il.append(classGen.loadTranslet());
            il.append(new PUSH(cpg, name));
  -
  -         if (_select == null) {
  -             if (hasContents()) {
  -                 compileResultTree(classGen, methodGen);     
  -             }
  -             else {
  -                 // If no select and no contents push the empty string
  -                 il.append(new PUSH(cpg, Constants.EMPTYSTRING));
  -             }
  -         }
  -         else {
  -             _select.translate(classGen, methodGen);
  -             _select.startResetIterator(classGen, methodGen);
  -         }
  +         translateValue(classGen, methodGen);
  +         il.append(new PUSH(cpg, true));
   
            // Call addParameter() from this class
  -         final int addParameter = cpg.addMethodref(TRANSLET_CLASS,
  -                                                   ADD_PARAMETER,
  -                                                   ADD_PARAMETER_SIG);
  -         il.append(new INVOKEVIRTUAL(addParameter));
  +         il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
  +                                                      ADD_PARAMETER,
  +                                                      ADD_PARAMETER_SIG)));
   
            if (_refs.isEmpty()) { // nobody uses the value
                il.append(_type.POP());
  @@ -288,20 +261,8 @@
            il.append(classGen.loadTranslet());
            il.append(DUP);
            il.append(new PUSH(cpg, name));
  -
  -         if (_select == null) {
  -             if (hasContents()) {
  -                 compileResultTree(classGen, methodGen);     
  -             }
  -             else {
  -                 // If no select and no contents push the empty string
  -                 il.append(new PUSH(cpg, Constants.EMPTYSTRING));
  -             }
  -         }
  -         else {
  -             _select.translate(classGen, methodGen);
  -             _select.startResetIterator(classGen, methodGen);
  -         }
  +         translateValue(classGen, methodGen);
  +         il.append(new PUSH(cpg, true));
   
            // Call addParameter() from this class
            il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
  
  
  
  1.2       +2 -2      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/StepPattern.java
  
  Index: StepPattern.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/StepPattern.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StepPattern.java  2001/04/17 18:51:47     1.1
  +++ StepPattern.java  2001/07/09 10:17:41     1.2
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: StepPattern.java,v 1.1 2001/04/17 18:51:47 sboag Exp $
  + * @(#)$Id: StepPattern.java,v 1.2 2001/07/09 10:17:41 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -170,7 +170,7 @@
       }
   
       private String getNextFieldName() {
  -     return  "%step_pattern_iter%" + getXSLTC().nextStepPatternSerial();
  +     return  "__step_pattern_iter_" + getXSLTC().nextStepPatternSerial();
       }
   
       public Type typeCheck(SymbolTable stable) throws TypeCheckError {
  
  
  
  1.10      +4 -4      
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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Stylesheet.java   2001/06/28 15:36:19     1.9
  +++ Stylesheet.java   2001/07/09 10:17:41     1.10
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Stylesheet.java,v 1.9 2001/06/28 15:36:19 morten Exp $
  + * @(#)$Id: Stylesheet.java,v 1.10 2001/07/09 10:17:41 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -16,7 +16,7 @@
    *
    * 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
  + *    the documentation and/or other makterials provided with the
    *    distribution.
    *
    * 3. The end-user documentation included with the redistribution,
  @@ -179,7 +179,7 @@
       
       public void setParser(Parser parser) {
        super.setParser(parser);
  -     _name = makeStylesheetName("%stylesheet%");
  +     _name = makeStylesheetName("__stylesheet_");
       }
       
       public void setParentStylesheet(Stylesheet parent) {
  @@ -264,7 +264,7 @@
   
       /**
        * Parse the version and uri fields of the stylesheet and add an
  -     * entry to the symbol table mapping the name <tt>%stylesheet%</tt>
  +     * entry to the symbol table mapping the name <tt>__stylesheet_</tt>
        * to an instance of this class.
        */
       public void parseContents(Parser parser) {
  
  
  
  1.7       +77 -1     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/SyntaxTreeNode.java
  
  Index: SyntaxTreeNode.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/SyntaxTreeNode.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SyntaxTreeNode.java       2001/06/19 10:44:11     1.6
  +++ SyntaxTreeNode.java       2001/07/09 10:17:42     1.7
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: SyntaxTreeNode.java,v 1.6 2001/06/19 10:44:11 morten Exp $
  + * @(#)$Id: SyntaxTreeNode.java,v 1.7 2001/07/09 10:17:42 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -73,8 +73,12 @@
   
   import org.xml.sax.*;
   
  +import org.apache.xalan.xsltc.compiler.util.Type;
  +import org.apache.xalan.xsltc.compiler.util.ReferenceType;
  +import de.fub.bytecode.generic.*;
   import org.apache.xalan.xsltc.compiler.util.*;
   
  +
   public abstract class SyntaxTreeNode implements Constants {
   
       // Reference to the AST parser
  @@ -352,6 +356,78 @@
            final SyntaxTreeNode item = (SyntaxTreeNode)_contents.elementAt(i);
            item.translate(classGen, methodGen);
        }
  +    }
  +
  +    /**
  +     * Utility method used by parameters and variables to store result trees
  +     */
  +    public void compileResultTree(ClassGenerator classGen,
  +                               MethodGenerator methodGen) {
  +
  +     final ConstantPoolGen cpg = classGen.getConstantPool();
  +     final InstructionList il = methodGen.getInstructionList();
  +
  +     // Save the current handler base on the stack
  +     il.append(methodGen.loadHandler());
  +
  +     final String DOM_CLASS = classGen.getDOMClass();
  +
  +     // Create new instance of DOM class (with 64 nodes)
  +     int index = cpg.addMethodref(DOM_IMPL, "<init>", "(I)V");
  +     il.append(new NEW(cpg.addClass(DOM_IMPL)));
  +     il.append(DUP);
  +     il.append(DUP);
  +     il.append(new PUSH(cpg, 64));
  +     il.append(new INVOKESPECIAL(index));
  +
  +     // Overwrite old handler with DOM handler
  +     index = cpg.addMethodref(DOM_IMPL,
  +                              "getOutputDomBuilder",
  +                              "()" + TRANSLET_OUTPUT_SIG);
  +     il.append(new INVOKEVIRTUAL(index));
  +     il.append(DUP);
  +     il.append(methodGen.storeHandler());
  +
  +     // Call startDocument on the new handler
  +     il.append(methodGen.startDocument());
  +
  +     // Instantiate result tree fragment
  +     translateContents(classGen, methodGen);
  +
  +     // Call endDocument on the new handler
  +     il.append(methodGen.loadHandler());
  +     il.append(methodGen.endDocument());
  +
  +     // Check if we need to wrap the DOMImpl object in a DOMAdapter object
  +     if (!DOM_CLASS.equals(DOM_IMPL_CLASS)) {
  +         // new org.apache.xalan.xsltc.dom.DOMAdapter(DOMImpl,String[]);
  +         index = cpg.addMethodref(DOM_ADAPTER_CLASS, "<init>",
  +                                  "("+DOM_IMPL_SIG+
  +                                  "["+STRING_SIG+
  +                                  "["+STRING_SIG+")V");
  +         il.append(new NEW(cpg.addClass(DOM_ADAPTER_CLASS)));
  +         il.append(new DUP_X1());
  +         il.append(SWAP);
  +         il.append(new ICONST(0));
  +         il.append(new ANEWARRAY(cpg.addClass(STRING)));
  +         il.append(DUP);
  +         il.append(new INVOKESPECIAL(index)); // leave DOMAdapter on stack
  +         
  +         // Must we wrap the DOMAdapter object in an MultiDOM object?
  +         if (DOM_CLASS.equals("org.apache.xalan.xsltc.dom.MultiDOM")) {
  +             // new org.apache.xalan.xsltc.dom.MultiDOM(DOMAdapter);
  +             index = cpg.addMethodref(MULTI_DOM_CLASS, "<init>",
  +                                      "("+DOM_ADAPTER_SIG+")V");
  +             il.append(new NEW(cpg.addClass(MULTI_DOM_CLASS)));
  +             il.append(new DUP_X1());
  +             il.append(SWAP);
  +             il.append(new INVOKESPECIAL(index)); // leave MultiDOM on stack
  +         }
  +     }
  +
  +     // Restore old handler base from stack
  +     il.append(SWAP);
  +     il.append(methodGen.storeHandler());
       }
   
       /**
  
  
  
  1.8       +65 -129   
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Variable.java
  
  Index: Variable.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Variable.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Variable.java     2001/06/29 14:58:55     1.7
  +++ Variable.java     2001/07/09 10:17:43     1.8
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Variable.java,v 1.7 2001/06/29 14:58:55 morten Exp $
  + * @(#)$Id: Variable.java,v 1.8 2001/07/09 10:17:43 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -179,6 +179,9 @@
        return _stackIndex;
       }
   
  +    /**
  +     * Parse the contents of the variable
  +     */
       public void parseContents(Parser parser) {
        // parse attributes name and select (if present)
        final String name = getAttribute("name");
  @@ -233,30 +236,39 @@
        }
       }
   
  +    /**
  +     * Runs a type check on either the variable element body or the
  +     * expression in the 'select' attribute
  +     */
       public Type typeCheck(SymbolTable stable) throws TypeCheckError {
  -     if (_select == null) {
  +     // Type check the 'select' expression if present
  +     if (_select != null) {
  +         _type = _select.typeCheck(stable);
  +     }
  +     // Type check the element contents otherwise
  +     else {
            typeCheckContents(stable);
  +         // Compile into a method if variable value is not context dependant
            if (dependentContents() == false) {
  -             _methodName = "%rt%" + getXSLTC().nextVariableSerial();
  +             _methodName = "__rt_" + getXSLTC().nextVariableSerial();
                _type = new ResultTreeType(_methodName);
            }
            else {
                _type = Type.ResultTree;
            }
        }
  -     else {
  -         _type = _select.typeCheck(stable);
  -     }
        return Type.Void;
       }
   
  -    private void compileRtMethod(ClassGenerator classGen,
  -                              MethodGenerator methodGen) {
  +    /**
  +     * Compiles a method that generates the value of the variable
  +     */
  +    private void compileResultTreeMethod(ClassGenerator classGen) {
        final ConstantPoolGen cpg = classGen.getConstantPool();
        final InstructionList il = new InstructionList();
        final String DOM_CLASS_SIG = classGen.getDOMClassSig();
        
  -     final RtMethodGenerator rtMethodGen =
  +     final RtMethodGenerator methodGen =
            new RtMethodGenerator(ACC_PROTECTED,
                                  de.fub.bytecode.generic.Type.VOID, 
                                  new de.fub.bytecode.generic.Type[] {
  @@ -270,84 +282,16 @@
                                  _methodName,
                                  classGen.getClassName(),
                                  il, cpg);
  -     rtMethodGen.addException("org.apache.xalan.xsltc.TransletException");
  +     methodGen.addException("org.apache.xalan.xsltc.TransletException");
   
  -     translateContents(classGen, rtMethodGen);
  -     il.append(RETURN);
  -
  -     rtMethodGen.stripAttributes(true);
  -     rtMethodGen.setMaxLocals();
  -     rtMethodGen.setMaxStack();
  -     rtMethodGen.removeNOPs();
  -     classGen.addMethod(rtMethodGen.getMethod());
  -    }
  -
  -    public void compileRtDom(ClassGenerator classGen,
  -                          MethodGenerator methodGen) {
  -     final ConstantPoolGen cpg = classGen.getConstantPool();
  -     final InstructionList il = methodGen.getInstructionList();
  -
  -     // Save the current handler base on the stack
  -     il.append(methodGen.loadHandler());
  -
  -     final String DOM_CLASS = classGen.getDOMClass();
  -
  -     // Create new instance of DOM class (with 64 nodes)
  -     int index = cpg.addMethodref(DOM_IMPL, "<init>", "(I)V");
  -     il.append(new NEW(cpg.addClass(DOM_IMPL)));
  -     il.append(DUP);
  -     il.append(DUP);
  -     il.append(new PUSH(cpg, 64));
  -     il.append(new INVOKESPECIAL(index));
  -
  -     // Overwrite old handler with DOM handler
  -     index = cpg.addMethodref(DOM_IMPL,
  -                              "getOutputDomBuilder",
  -                              "()" + TRANSLET_OUTPUT_SIG);
  -     il.append(new INVOKEVIRTUAL(index));
  -     il.append(DUP);
  -     il.append(methodGen.storeHandler());
  -
  -     // Call startDocument on the new handler
  -     il.append(methodGen.startDocument());
  -
  -     // Instantiate result tree fragment
        translateContents(classGen, methodGen);
  -
  -     // Call endDocument on the new handler
  -     il.append(methodGen.loadHandler());
  -     il.append(methodGen.endDocument());
  -
  -     // Check if we need to wrap the DOMImpl object in a DOMAdapter object
  -     if (!DOM_CLASS.equals(DOM_IMPL_CLASS)) {
  -         // new org.apache.xalan.xsltc.dom.DOMAdapter(DOMImpl,String[]);
  -         index = cpg.addMethodref(DOM_ADAPTER_CLASS, "<init>",
  -                                  "("+DOM_IMPL_SIG+
  -                                  "["+STRING_SIG+
  -                                  "["+STRING_SIG+")V");
  -         il.append(new NEW(cpg.addClass(DOM_ADAPTER_CLASS)));
  -         il.append(new DUP_X1());
  -         il.append(SWAP);
  -         il.append(new ICONST(0));
  -         il.append(new ANEWARRAY(cpg.addClass(STRING)));
  -         il.append(DUP);
  -         il.append(new INVOKESPECIAL(index)); // leave DOMAdapter on stack
  -         
  -         // Must we wrap the DOMAdapter object in an MultiDOM object?
  -         if (DOM_CLASS.equals("org.apache.xalan.xsltc.dom.MultiDOM")) {
  -             // new org.apache.xalan.xsltc.dom.MultiDOM(DOMAdapter);
  -             index = cpg.addMethodref(MULTI_DOM_CLASS, "<init>",
  -                                      "("+DOM_ADAPTER_SIG+")V");
  -             il.append(new NEW(cpg.addClass(MULTI_DOM_CLASS)));
  -             il.append(new DUP_X1());
  -             il.append(SWAP);
  -             il.append(new INVOKESPECIAL(index)); // leave MultiDOM on stack
  -         }
  -     }
  +     il.append(RETURN);
   
  -     // Restore old handler base from stack
  -     il.append(SWAP);
  -     il.append(methodGen.storeHandler());
  +     methodGen.stripAttributes(true);
  +     methodGen.setMaxLocals();
  +     methodGen.setMaxStack();
  +     methodGen.removeNOPs();
  +     classGen.addMethod(methodGen.getMethod());
       }
   
       /**
  @@ -374,49 +318,60 @@
                (_type instanceof BooleanType))
                il.append(new ICONST(0)); // 0 for node-id, integer and boolean
            else if (_type instanceof RealType)
  -             il.append(new FCONST(0)); // 0.0 for floating point numbers
  +             il.append(new DCONST(0)); // 0.0 for floating point numbers
            else
                il.append(new ACONST_NULL()); // and 'null' for anything else
            il.append(_type.STORE(_local.getIndex()));
        }
       }
   
  +    /**
  +     * Compile the value of the variable, which is either in an expression in
  +     * a 'select' attribute, or in the variable elements body
  +     */
  +    public void translateValue(ClassGenerator classGen,
  +                            MethodGenerator methodGen) {
  +     // Compile expression is 'select' attribute if present
  +     if (_select != null) {
  +         _select.translate(classGen, methodGen);
  +         _select.startResetIterator(classGen, methodGen);
  +     }
  +     // If not, compile result tree from parameter body if present.
  +     else if (hasContents()) {
  +         compileResultTree(classGen, methodGen);
  +     }
  +     // If neither are present then store empty string in variable
  +     else {
  +         final ConstantPoolGen cpg = classGen.getConstantPool();
  +         final InstructionList il = methodGen.getInstructionList();
  +         il.append(new PUSH(cpg, Constants.EMPTYSTRING));
  +     }
  +    }
   
       public void translate(ClassGenerator classGen, MethodGenerator 
methodGen) {
        final ConstantPoolGen cpg = classGen.getConstantPool();
        final InstructionList il = methodGen.getInstructionList();
        final String name = _name.getLocalPart();
   
  +     // Make sure that a variable instance is only compiled once
        if (_compiled) return;
        _compiled = true;
   
  -     if (isLocal()) {
  -         // If rt implemented as method then compile and return
  -         if (_select == null && _type != Type.ResultTree) {
  -             compileRtMethod(classGen, methodGen);
  -             return;
  -         }
  +     // If a result tree is implemented as method then compile and return
  +     if ((_select == null) && (_type != Type.ResultTree)) {
  +         compileResultTreeMethod(classGen);
  +         return;
  +     }
   
  +     if (isLocal()) {
            // Push args to call addVariable()
            if (_escapes) {
                il.append(classGen.loadTranslet());
                il.append(new PUSH(cpg, _stackIndex));
            }
   
  -         // Compile rt or expression and store in local
  -         if (_select == null) {
  -             if (hasContents()) {
  -                 compileRtDom(classGen, methodGen);
  -             }
  -             else {
  -                 // If no select and no contents push the empty string
  -                 il.append(new PUSH(cpg, Constants.EMPTYSTRING));
  -             }
  -         }
  -         else {
  -             _select.translate(classGen, methodGen);
  -             _select.startResetIterator(classGen, methodGen);
  -         }
  +         // Compile variable value computation
  +         translateValue(classGen, methodGen);
   
            // Dup value only when needed
            if (_escapes) {
  @@ -442,22 +397,15 @@
                _type.translateBox(classGen, methodGen);
                il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
                                                             ADD_VARIABLE,
  -                                                          ADD_VARIABLE_SIG)
  -                                         ));
  +                                                          
ADD_VARIABLE_SIG)));
            }
        }
        else {
  -         // If rt implemented as method then compile and return
  -         if (_select == null && _type != Type.ResultTree) {
  -             compileRtMethod(classGen, methodGen);
  -             return;
  -         }
  -
            String signature = _type.toSignature();
            if (signature.equals(DOM_IMPL_SIG))
                signature = classGen.getDOMClassSig();
   
  -         // Add a new field to this class
  +         // Global variables are store in class fields
            if (classGen.containsField(name) == null) {
                classGen.addField(new Field(ACC_PUBLIC, 
                                            cpg.addUtf8(name),
  @@ -466,21 +414,9 @@
   
                // Push a reference to "this" for putfield
                il.append(classGen.loadTranslet());
  -
  -             // Compile rt or expression and store in field
  -             if (_select == null) {
  -                 if (hasContents()) {
  -                     compileRtDom(classGen, methodGen);
  -                 }
  -                 else {
  -                     // If no select and no contents push the empty string
  -                     il.append(new PUSH(cpg, Constants.EMPTYSTRING));
  -                 }
  -             }
  -             else {
  -                 _select.translate(classGen, methodGen);
  -                 _select.startResetIterator(classGen, methodGen);
  -             }
  +             // Compile variable value computation
  +             translateValue(classGen, methodGen);
  +             // Store the variable in the allocated field
                il.append(new PUTFIELD(cpg.addFieldref(classGen.getClassName(),
                                                       name, signature)));
            }
  
  
  
  1.4       +50 -53    
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/WithParam.java
  
  Index: WithParam.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/WithParam.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- WithParam.java    2001/06/06 10:45:42     1.3
  +++ WithParam.java    2001/07/09 10:17:44     1.4
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: WithParam.java,v 1.3 2001/06/06 10:45:42 morten Exp $
  + * @(#)$Id: WithParam.java,v 1.4 2001/07/09 10:17:44 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -58,6 +58,7 @@
    *
    * @author Jacek Ambroziak
    * @author Santiago Pericas-Geertsen
  + * @author Morten Jorgensen
    *
    */
   
  @@ -69,9 +70,13 @@
   import org.apache.xalan.xsltc.compiler.util.*;
   
   final class WithParam extends Instruction {
  +
       private QName _name;
       private Expression _select;
   
  +    /**
  +     * Displays the contents of this element
  +     */
       public void display(int indent) {
        indent(indent);
        Util.println("with-param " + _name);
  @@ -82,6 +87,10 @@
        displayContents(indent + IndentIncrement);
       }
   
  +    /**
  +     * The contents of a <xsl:with-param> elements are either in the 
element's
  +     * 'select' attribute (this has precedence) or in the element body.
  +     */
       public void parseContents(Parser parser) {
        final String name = getAttribute("name");
        if (name.length() > 0) {
  @@ -99,6 +108,10 @@
        parseChildren(parser);
       }
   
  +    /**
  +     * Type-check either the select attribute or the element body, depending
  +     * on which is in use.
  +     */
       public Type typeCheck(SymbolTable stable) throws TypeCheckError {
        if (_select != null) {
            final Type tselect = _select.typeCheck(stable);
  @@ -111,68 +124,52 @@
        }
        return Type.Void;
       }
  -
  -    public void compileResultTree(ClassGenerator classGen,
  -                               MethodGenerator methodGen) {
  -     final ConstantPoolGen cpg = classGen.getConstantPool();
  -     final InstructionList il = methodGen.getInstructionList();
  -
  -     // Save the current handler base on the stack
  -     il.append(methodGen.loadHandler());
   
  -     // Create new instance of DOM class (with 64 nodes)
  -     int index = cpg.addMethodref(DOM_IMPL, "<init>", "(I)V");
  -     il.append(new NEW(cpg.addClass(DOM_IMPL)));
  -     il.append(DUP);
  -     il.append(DUP);
  -     il.append(new PUSH(cpg, 64));
  -     il.append(new INVOKESPECIAL(index));
  -
  -     // Overwrite old handler with DOM handler
  -     index = cpg.addMethodref(DOM_IMPL,
  -                              "getOutputDomBuilder",
  -                              "()" + TRANSLET_OUTPUT_SIG);
  -     il.append(new INVOKEVIRTUAL(index));
  -     il.append(DUP);
  -     il.append(methodGen.storeHandler());
  -
  -     // Call startDocument on the new handler
  -     il.append(methodGen.startDocument());
  -
  -     // Instantiate result tree fragment
  -     translateContents(classGen, methodGen);
  -
  -     // Call endDocument on the new handler
  -     il.append(methodGen.loadHandler());
  -     il.append(methodGen.endDocument());
  -
  -     // Restore old handler base from stack
  -     il.append(SWAP);
  -     il.append(methodGen.storeHandler());
  +    /**
  +     * Compile the value of the parameter, which is either in an expression 
in
  +     * a 'select' attribute, or in the with-param element's body
  +     */
  +    public void translateValue(ClassGenerator classGen,
  +                            MethodGenerator methodGen) {
  +     // Compile expression is 'select' attribute if present
  +     if (_select != null) {
  +         _select.translate(classGen, methodGen);
  +         _select.startResetIterator(classGen, methodGen);
  +     }
  +     // If not, compile result tree from parameter body if present.
  +     else if (hasContents()) {
  +         compileResultTree(classGen, methodGen);
  +     }
  +     // If neither are present then store empty string in parameter slot
  +     else {
  +         final ConstantPoolGen cpg = classGen.getConstantPool();
  +         final InstructionList il = methodGen.getInstructionList();
  +         il.append(new PUSH(cpg, Constants.EMPTYSTRING));
  +     }
       }
  -    
  +
  +    /**
  +     * This code generates a sequence of bytecodes that call the
  +     * addParameter() method in AbstractTranslet. The method call will add
  +     * (or update) the parameter frame with the new parameter value.
  +     */
       public void translate(ClassGenerator classGen, MethodGenerator 
methodGen) {
        final ConstantPoolGen cpg = classGen.getConstantPool();
        final InstructionList il = methodGen.getInstructionList();
   
  +     // Load reference to the translet (method is in AbstractTranslet)
        il.append(classGen.loadTranslet());
  -     il.append(new PUSH(cpg, _name.getLocalPart())); // TODO: namespace ?
   
  -     if (_select == null) {
  -         if (hasContents()) {
  -             compileResultTree(classGen, methodGen);
  -         }
  -         else {
  -             il.append(new PUSH(cpg,""));
  -         }
  -     }
  -     else {
  -         _select.translate(classGen, methodGen);
  -         _select.startResetIterator(classGen, methodGen);
  -     }
  +     // Load the name of the parameter
  +     il.append(new PUSH(cpg, _name.getLocalPart())); // TODO: namespace ?
  +     // Generete the value of the parameter (use value in 'select' by def.)
  +     translateValue(classGen, methodGen);
  +     // Mark this parameter value is not being the default value
  +     il.append(new PUSH(cpg, false));
  +     // Pass the parameter to the template
        il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
                                                     ADD_PARAMETER,
                                                     ADD_PARAMETER_SIG)));
  -     il.append(POP);
  +     il.append(POP); // cleanup stack
       }
   }
  
  
  
  1.3       +14 -8     
xml-xalan/java/src/org/apache/xalan/xsltc/dom/KeyIndex.java
  
  Index: KeyIndex.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/KeyIndex.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- KeyIndex.java     2001/05/22 17:26:40     1.2
  +++ KeyIndex.java     2001/07/09 10:17:50     1.3
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: KeyIndex.java,v 1.2 2001/05/22 17:26:40 morten Exp $
  + * @(#)$Id: KeyIndex.java,v 1.3 2001/07/09 10:17:50 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -17,7 +17,7 @@
    * 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.
  + *    distribution
    *
    * 3. The end-user documentation included with the redistribution,
    *    if any, must include the following acknowledgment:
  @@ -113,8 +113,9 @@
            if (other._nodes != null) {
                // Create new Vector for nodes if this set is empty
                if (_nodes == null)
  -                 _nodes = new BitArray(_arraySize);
  -             _nodes = _nodes.merge(other._nodes);
  +                 _nodes = other._nodes;
  +             else
  +                 _nodes = _nodes.merge(other._nodes);
            }
        }
       }
  @@ -188,7 +189,7 @@
        * Resets the iterator to the last start node.
        */
       public NodeIterator reset() {
  -     _pos = -1;
  +     _pos = _start;
        _node = _start - 1;
        return(this);
       }
  @@ -200,7 +201,7 @@
        if (_nodes == null)
            return(0);
        else
  -         return(_nodes.size());
  +         return(_nodes.size()); // TODO: count actual nodes
       }
   
       /**
  @@ -231,8 +232,13 @@
        * i.e. subsequent call to next() should return END.
        */
       public NodeIterator setStartNode(int start) {
  -     if (_nodes != null) {
  -         _start = _nodes.getBitNumber(start);
  +     if (start == END) {
  +         _nodes = null;
  +     }
  +     else if (_nodes != null) {
  +         // Node count starts with 1, while bit arrays count from 0. Must
  +         // subtract one from 'start' to initialize bit array correctly.
  +         _start = _nodes.getBitNumber(start-1); 
            _node = _start - 1;
        }
        return((NodeIterator)this);
  
  
  
  1.10      +347 -189  
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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- AbstractTranslet.java     2001/06/27 15:27:25     1.9
  +++ AbstractTranslet.java     2001/07/09 10:17:52     1.10
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: AbstractTranslet.java,v 1.9 2001/06/27 15:27:25 tmiller Exp $
  + * @(#)$Id: AbstractTranslet.java,v 1.10 2001/07/09 10:17:52 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -75,6 +75,7 @@
   import org.apache.xalan.xsltc.dom.DOMImpl;
   import org.apache.xalan.xsltc.dom.StripWhitespaceFilter;
   import org.apache.xalan.xsltc.dom.KeyIndex;
  +import org.apache.xalan.xsltc.dom.DTDMonitor;
   
   // GTM added all these
   import org.apache.xalan.xsltc.runtime.DefaultSAXOutputHandler;
  @@ -86,13 +87,14 @@
   import javax.xml.transform.TransformerException;
   import javax.xml.transform.URIResolver;
   import javax.xml.transform.ErrorListener;
  +import javax.xml.transform.OutputKeys;
   import java.lang.IllegalArgumentException;
   import java.util.Properties;
   import java.lang.IllegalArgumentException;
   import javax.xml.parsers.SAXParserFactory;
   import javax.xml.parsers.SAXParser;
   import org.xml.sax.XMLReader;
  -import org.apache.xalan.xsltc.dom.DTDMonitor;
  +import org.xml.sax.ContentHandler;
   import java.io.File;
   import java.io.Writer;
   import java.io.OutputStream;
  @@ -103,32 +105,22 @@
   // END.
   
   public abstract class AbstractTranslet extends Transformer implements 
Translet {
  -
  -    protected String _encoding = "utf-8";
   
  -    //!!! to be added only as needed
  -    protected StringValueHandler stringValueHandler = new 
StringValueHandler();
  -
  -    //!! different handshake needed
  +    // DOM/translet handshaking - the arrays are set by the compiled translet
       protected String[] namesArray;
       protected String[] namespaceArray;
  -
  -    //!!! Temporary approach. To be added to translet only when needed. !!!
  -    public Hashtable _formatSymbols = new Hashtable();
  -    public Hashtable _unparsedEntities = null;
   
  -    // Container for all indexes for xsl:key elements
  -    private Hashtable _keyIndexes = new Hashtable();
  -    private KeyIndex  _emptyKeyIndex = new KeyIndex(1);
  -    private int _indexSize = 0;
  -
  -    private MessageHandler _msgHandler = null;
  -
  -    private DOMCache _domCache = null;
  +    // TODO - these should only be instanciated when needed
  +    protected StringValueHandler stringValueHandler = new 
StringValueHandler();
   
  +    // Use one empty string instead of constantly instanciating String("");
       private final static String EMPTYSTRING = "";
  -
   
  +    /**
  +     * Wrap the initial input DOM in a dom adapter. This adapter is wrapped 
in
  +     * a DOM multiplexer if the document() function is used (handled by 
compiled
  +     * code in the translet - see compiler/Stylesheet.compileTransform()).
  +     */
       public final DOMAdapter makeDOMAdapter(DOM dom)
        throws TransletException {
        if (dom instanceof DOMImpl) {
  @@ -139,30 +131,17 @@
        }
       }
   
  -    public final void setMessageHandler(MessageHandler handler) {
  -     _msgHandler = handler;
  -    }
  +    /************************************************************************
  +     * Variable and parameter handling
  +     
************************************************************************/
   
  -    public final void displayMessage(String msg) {
  -     if (_msgHandler == null) {
  -            System.err.println(msg);
  -     }
  -     else {
  -         _msgHandler.displayMessage(msg);
  -     }
  -    }
  -
  -    /**
  -     * Variable's stack: <tt>vbase</tt> and <tt>vframe</tt> are used 
  -     * to denote the current variable frame.
  -     */
  +    // Variable's stack: <tt>vbase</tt> and <tt>vframe</tt> are used 
  +    // to denote the current variable frame.
       protected int vbase = 0, vframe = 0;
       protected Vector varsStack = new Vector();
   
  -    /**
  -     * Parameter's stack: <tt>pbase</tt> and <tt>pframe</tt> are used 
  -     * to denote the current parameter frame.
  -     */
  +    // Parameter's stack: <tt>pbase</tt> and <tt>pframe</tt> are used 
  +    // to denote the current parameter frame.
       protected int pbase = 0, pframe = 0;
       protected Vector paramsStack = new Vector();
   
  @@ -185,18 +164,38 @@
       }
   
       /**
  -     * Add a new parameter if not already in the current frame.
  -     * Returns the old value if already defined and the new value
  -     * if added.
  +     * Add a new global parameter if not already in the current frame.
        */
       public final Object addParameter(String name, Object value) {
  +     return addParameter(name, value, false);
  +    }
  +
  +    /**
  +     * Add a new global or local parameter if not already in the current 
frame.
  +     * The 'isDefault' parameter is set to true if the value passed is the
  +     * default value from the <xsl:parameter> element's select attribute or
  +     * element body.
  +     */
  +    public final Object addParameter(String name, Object value,
  +                                  boolean isDefault) {
  +     // Local parameters need to be re-evaluated for each iteration
        for (int i = pframe - 1; i >= pbase; i--) {
            final Parameter param = (Parameter) paramsStack.elementAt(i);
  -         if (param.name.equals(name)) {
  -             return param.value;
  +         if (param._name.equals(name)) {
  +             // Only overwrite if current value is the default value and
  +             // the new value is _NOT_ the default value.
  +             if ((param._isDefault == true) || (!isDefault)) {
  +                 param._value = value;
  +                 param._isDefault = isDefault;
  +                 return value;
  +             }
  +             return param._value;
            }
        }
  -     paramsStack.insertElementAt(new Parameter(name, value), pframe++);
  +
  +     // Add new parameter to parameter stack
  +     final Parameter param = new Parameter(name, value, isDefault);
  +     paramsStack.insertElementAt(param, pframe++);
        return value;
       }
   
  @@ -207,8 +206,8 @@
       public final Object getParameter(String name) {
        for (int i = pframe - 1; i >= pbase; i--) {
            final Parameter param = (Parameter)paramsStack.elementAt(i);
  -         if (param.name.equals(name)) {
  -             return param.value;
  +         if (param._name.equals(name)) {
  +             return param._value;
            }
        }
        return null;
  @@ -247,14 +246,52 @@
        varsStack.insertElementAt(value, vbase + vindex);
       }
   
  +    /************************************************************************
  +     * Message handling - implementation of <xsl:message>
  +     
************************************************************************/
  +
  +    // Holds the translet's message handler - used for <xsl:message>.
  +    // The deault message handler dumps a string stdout, but anything can be
  +    // used, such as a dialog box for applets, etc.
  +    private MessageHandler _msgHandler = null;
  +
  +    /**
  +     * Set the translet's message handler - must implement MessageHandler
  +     */
  +    public final void setMessageHandler(MessageHandler handler) {
  +     _msgHandler = handler;
  +    }
  +
       /**
  +     * Pass a message to the message handler - used by Message class.
  +     */
  +    public final void displayMessage(String msg) {
  +     if (_msgHandler == null) {
  +            System.err.println(msg);
  +     }
  +     else {
  +         _msgHandler.displayMessage(msg);
  +     }
  +    }
  +
  +    /************************************************************************
  +     * Decimal number format symbol handling
  +     
************************************************************************/
  +
  +    // Contains decimal number formatting symbols used by FormatNumberCall
  +    public Hashtable _formatSymbols = null;
  +
  +    /**
        * Adds a DecimalFormat object to the _formatSymbols hashtable.
        * The entry is created with the input DecimalFormatSymbols.
        */
       public void addDecimalFormat(String name, DecimalFormatSymbols symbols) {
  -     // Remove any existing entries with the same name.
  +     // Instanciate hashtable for formatting symbols if needed
  +     if (_formatSymbols == null) _formatSymbols = new Hashtable();
  +
  +     // The name cannot be null - use empty string instead
        if (name == null) name = EMPTYSTRING;
  -     _formatSymbols.remove(name);
  +
        // Construct a DecimalFormat object containing the symbols we got
        final DecimalFormat df = new DecimalFormat();
        if (symbols != null) {
  @@ -267,17 +304,40 @@
        * Retrieves a named DecimalFormat object from _formatSymbols hashtable.
        */
       public final DecimalFormat getDecimalFormat(String name) {
  -     if (name == null) name = EMPTYSTRING;
  -     final DecimalFormat df = (DecimalFormat)_formatSymbols.get(name);
  -     if (df == null) {
  -         // This should really result in an error
  -         return((DecimalFormat)_formatSymbols.get(EMPTYSTRING));
  -     }
  -     else {
  -         return df;
  +
  +     if (_formatSymbols != null) {
  +         // The name cannot be null - use empty string instead
  +         if (name == null) name = EMPTYSTRING;
  +
  +         final DecimalFormat df = (DecimalFormat)_formatSymbols.get(name);
  +         if (df != null)
  +             return df;
  +         else
  +             return((DecimalFormat)_formatSymbols.get(EMPTYSTRING));
        }
  +     return(null);
  +    }
  +
  +    /************************************************************************
  +     * Unparsed entity URI handling - implements unparsed-entity-uri()
  +     
************************************************************************/
  +
  +    // Keeps all unparsed entity URIs specified in the XML input
  +    public Hashtable _unparsedEntities = null;
  +
  +    /**
  +     * Get the value of an unparsed entity URI.
  +     * This method is used by the compiler/UnparsedEntityUriCall class.
  +     */
  +    public final String getUnparsedEntity(String name) {
  +     final String uri = (String)_unparsedEntities.get(name);
  +     return uri == null ? EMPTYSTRING : uri;
       }
   
  +    /**
  +     * Add an unparsed entity URI. The URI/value pairs are passed from the
  +     * DOM builder to the translet.
  +     */
       public final void addUnparsedEntity(String name, String uri) {
        if (_unparsedEntities == null)
            _unparsedEntities = new Hashtable();
  @@ -285,15 +345,10 @@
            _unparsedEntities.put(name, uri);
       }
       
  -    public final String getUnparsedEntity(String name) {
  -     final String uri = (String)_unparsedEntities.get(name);
  -     return uri == null ? EMPTYSTRING : uri;
  -    }
  -
  -    public final void setDTDMonitor(DTDMonitor monitor) {
  -     setUnparsedEntityURIs(monitor.getUnparsedEntityURIs());
  -    }
  -
  +    /**
  +     * Add an unparsed entity URI. The URI/value pairs are passed from the
  +     * DOM builder to the translet.
  +     */
       public final void setUnparsedEntityURIs(Hashtable table) {
        if (_unparsedEntities == null)
            _unparsedEntities = table;
  @@ -306,15 +361,114 @@
        }
       }
   
  -    public abstract void transform(DOM document, NodeIterator iterator,
  -                                TransletOutputHandler handler)
  -     throws TransletException;
  -     
  -    protected TransletOutputHandler[] handlers;
  +    /**
  +     * The DTD monitor used by the DOM builder scans the input document DTD
  +     * for unparsed entity URIs. These are passed to the translet using
  +     * this method.
  +     */
  +    public final void setDTDMonitor(DTDMonitor monitor) {
  +     setUnparsedEntityURIs(monitor.getUnparsedEntityURIs());
  +    }
  +
  +    /************************************************************************
  +     * Index(es) for <xsl:key> / key() / id()
  +     
************************************************************************/
  +
  +    // Container for all indexes for xsl:key elements
  +    private Hashtable _keyIndexes = null;
  +    private KeyIndex  _emptyKeyIndex = new KeyIndex(1);
  +    private int       _indexSize = 0;
  +
  +    /**
  +     * This method is used to pass the largest DOM size to the translet.
  +     * Needed to make sure that the translet can index the whole DOM.
  +     */
  +    public void setIndexSize(int size) {
  +     if (size > _indexSize) _indexSize = size;
  +    }
  +
  +    /**
  +     * Creates a KeyIndex object of the desired size - don't want to 
resize!!!
  +     */
  +    public KeyIndex createKeyIndex() {
  +     return(new KeyIndex(_indexSize));
  +    }
  +
  +    /**
  +     * Adds a value to a key/id index
  +     *   @name is the name of the index (the key or ##id)
  +     *   @node is the node id of the node to insert
  +     *   @value is the value that will look up the node in the given index
  +     */
  +    public void buildKeyIndex(String name, int node, String value) {
  +     if (_keyIndexes == null) _keyIndexes = new Hashtable();
  +
  +     KeyIndex index = (KeyIndex)_keyIndexes.get(name);
  +     if (index == null) {
  +         _keyIndexes.put(name, index = new KeyIndex(_indexSize));
  +     }
  +     index.add(value, node);
  +    }
  +
  +    /**
  +     * Returns the index for a given key (or id).
  +     * The index implements our internal iterator interface
  +     */
  +    public KeyIndex getKeyIndex(String name) {
  +     // Return an empty key index iterator if none are defined
  +     if (_keyIndexes == null) return(_emptyKeyIndex);
  +
  +     // Look up the requested key index
  +     final KeyIndex index = (KeyIndex)_keyIndexes.get(name);
  +
  +     // Return an empty key index iterator if the requested index not found
  +     if (index == null) return(_emptyKeyIndex);
  +
  +     return(index);
  +    }
  +
  +    /**
  +     * This method builds key indexes - it is overridden in the compiled
  +     * translet in cases where the <xsl:key> element is used
  +     */
  +    public void buildKeys(DOM document, NodeIterator iterator,
  +                       TransletOutputHandler handler,
  +                       int root) throws TransletException {
  +    }
  +
  +    /************************************************************************
  +     * DOM cache handling
  +     
************************************************************************/
  +
  +    // Hold the DOM cache (if any) used with this translet
  +    private DOMCache _domCache = null;
  +
  +    /**
  +     * Sets the DOM cache used for additional documents loaded using the
  +     * document() function.
  +     */
  +    public void setDOMCache(DOMCache cache) {
  +     _domCache = cache;
  +    }
  +
  +    /**
  +     * Returns the DOM cache used for this translet. Used by the LoadDocument
  +     * class (if present) when the document() function is used.
  +     */
  +    public DOMCache getDOMCache() {
  +     return(_domCache);
  +    }
  +
  +    /************************************************************************
  +     * Start of an implementation of a multiple output extension.
  +     * See compiler/TransletOutput for actual implementation.
  +     
************************************************************************/
   
  +    protected TransletOutputHandler[] _handlers;
  +
       protected final TransletOutputHandler getOutputHandler(double port) {
        try {
  -         return handlers[(int) port];
  +         return _handlers[(int) port];
        }
        catch (IndexOutOfBoundsException e) {
            BasisLibrary.runTimeError("Output port " + (int)port 
  @@ -323,96 +477,81 @@
        }
       }
   
  +    /************************************************************************
  +     * Native API transformation methods - _NOT_ JAXP/TrAX
  +     
************************************************************************/
  +
  +    /**
  +     * Main transform() method - this is overridden by the compiled translet
  +     */
  +    public abstract void transform(DOM document, NodeIterator iterator,
  +                                TransletOutputHandler handler)
  +     throws TransletException;
  +
  +    /**
  +     * Calls transform() with a given output handler
  +     */
       public final void transform(DOM document, TransletOutputHandler handler) 
        throws TransletException {
  -     handlers = new TransletOutputHandler[] { handler };
  +     _handlers = new TransletOutputHandler[] { handler };
        transform(document, document.getIterator(), handler);
       }
        
  +    /**
  +     * Calls transform() with a set of given output handlers
  +     */
       public final void transform(DOM document,
                                TransletOutputHandler[] handlers) 
        throws TransletException {
  -     this.handlers = handlers;
  +     _handlers = handlers;
        transform(document, document.getIterator(), handlers[0]);
       }
  -    
  -    private char[] _characterArray = new char[32];
   
  +    /**
  +     * Used by some compiled code as a shortcut for passing strings to the
  +     * output handler
  +     */
       public final void characters(final String string,
                                 TransletOutputHandler handler) 
        throws TransletException {
  -     if (string == null) return;
        final int length = string.length();
  -     if (length > _characterArray.length) {
  -         _characterArray = new char[length];
  -     }
  -     string.getChars(0, length, _characterArray, 0);
  -     handler.characters(_characterArray, 0, length);
  +     handler.characters(string.toCharArray(), 0, length);
       }
   
  +    // Holds output encoding - set by code compiled by compiler/Output
  +    protected String _encoding = "utf-8";
  +
       /**
        * Pass the output encoding setting to the output handler.
        */
       public String getOutputEncoding() {
                return _encoding; 
       } 
  -
  -    public void setIndexSize(int size) {
  -     if (size > _indexSize)
  -         _indexSize = size;
  -    }
  -
  -    public void buildKeyIndex(String name, int node, String value) {
  -     KeyIndex index = (KeyIndex)_keyIndexes.get(name);
  -     if (index == null) {
  -         _keyIndexes.put(name, index = new KeyIndex(_indexSize));
  -     }
  -     index.add(value, node);
  -    }
   
  -    public KeyIndex createKeyIndex() {
  -     return(new KeyIndex(_indexSize));
  -    }
  -
  -    public KeyIndex getKeyIndex(String name) {
  -     final KeyIndex index = (KeyIndex)_keyIndexes.get(name);
  -     return index != null ? index : _emptyKeyIndex;
  -    }
  -
  -    public void buildKeys(DOM document, NodeIterator iterator,
  -                       TransletOutputHandler handler,
  -                       int root) throws TransletException {
  -    }
  -
  -    public void setDOMCache(DOMCache cache) {
  -     _domCache = cache;
  -    }
  -
  -    public DOMCache getDOMCache() {
  -     return(_domCache);
  -    }
  -
  +    // Holds the translet's name - God only knows what it is used for
       private String _transletName;
   
  +    /**
  +     * Set the translet's name (default is class name)
  +     */
       public void setTransletName(String name) {
        _transletName = name;
       }
   
  +    /**
  +     * Get the translet's name (default is class name)
  +     */
       public String getTransletName() {
        return _transletName;
       }
   
  -    /*********************************************************
  -     *  Transformer methods
  -     *********************************************************/
  +    /************************************************************************
  +     * JAXP/TrAX Transformer interface implementation + etc. TrAX/JAXP stuff
  +     * This will be moved to org/apache/xalan/xsltc/trax/Transformer
  +     
************************************************************************/
   
       public void transform(Source xmlsrc, Result outputTarget)
  -     throws TransformerException 
  -    {
  -     /********************
  -        doTransform( xmlsrc.getSystemId(), 
  -                    ((StreamResult)outputTarget).getOutputStream() ); 
  -     *******************************/
  +     throws TransformerException {
   
        // try to get the encoding from Translet
        final Translet translet = (Translet)this;
  @@ -463,11 +602,9 @@
       }
    
       private void doTransform(String xmlDocName, 
  -                  DefaultSAXOutputHandler saxHandler, String encoding) 
  -    {
  +                          ContentHandler saxHandler,
  +                          String encoding) {
        try {
  -         final Translet translet = (Translet)this; // GTM added
  -
            // Create a SAX parser and get the XMLReader object it uses
            final SAXParserFactory factory = SAXParserFactory.newInstance();
            final SAXParser parser = factory.newSAXParser();
  @@ -491,13 +628,12 @@
            setIndexSize(dom.getSize());
            // If there are any elements with ID attributes, build an index
            dtdMonitor.buildIdIndex(dom, 0, this);
  - 
  +         // Pass unparsed entity URIs to the translet (this)
            setDTDMonitor(dtdMonitor);
    
            // Transform the document
            TextOutput textOutput = new TextOutput(saxHandler, encoding);
  -         translet.transform(dom, textOutput);
  -         textOutput.flush();
  +         transform(dom, textOutput);
        }
        catch (TransletException e) {
            if (_errorListener != null) {
  @@ -517,10 +653,9 @@
        }
        catch (FileNotFoundException e) {
            if (_errorListener != null) {
  -             postErrorToListener("File Not Found: " + e.getMessage());
  +             postErrorToListener("File not found: " + e.getMessage());
            } else {
  -               //System.err.println("Error:File or URI '"+_fileName+"' 
  -            //    not found.");
  +             System.err.println("Error: File not found:"+e.getMessage());
            }
            System.exit(1);
        }
  @@ -528,16 +663,16 @@
            if (_errorListener != null) {
                postErrorToListener("Malformed URL: " + e.getMessage());
            } else {
  -             //System.err.println("Error: Invalid URI '"+_fileName+"'.");
  +             System.err.println("Error: Malformed URL: "+e.getMessage());
            }
            System.exit(1);
        }
        catch (UnknownHostException e) {
            if (_errorListener != null) {
  -             postErrorToListener("Can't resolve URI: " + e.getMessage());
  +             postErrorToListener("Cannot resolve URI: " + e.getMessage());
            } else {
  -             //System.err.println("Error: Can't resolve URI specification '"+
  -             //_fileName+"'.");
  +             System.err.println("Error: Cannot resolve URI: "+
  +                                e.getMessage());
            }
            System.exit(1);
        }
  @@ -545,27 +680,28 @@
            if (_errorListener != null) {
                postErrorToListener("Internal error: " + e.getMessage()); 
            } else {
  -             System.err.println("Error: internal error.");
  +             System.err.println("Internal error: "+e.getMessage());
                e.printStackTrace();
            }
            System.exit(1);
        }
       }
   
  -    public void clearParameters() {  
  -     paramsStack.clear();
  -    }
  -
       // TrAX support methods, get/setErrorListener
       private ErrorListener _errorListener = null;
   
  +    /**
  +     * Get the TrAX error listener
  +     */
       public ErrorListener getErrorListener() {  
        return _errorListener; 
       }
   
  -    public void setErrorListener(ErrorListener listener) throws 
  -        IllegalArgumentException 
  -    {
  +    /**
  +     * Set the TrAX error listener
  +     */
  +    public void setErrorListener(ErrorListener listener)
  +     throws IllegalArgumentException {
           if (listener == null) {
               throw new IllegalArgumentException(
                  "Error: setErrorListener() call where ErrorListener is null");
  @@ -574,7 +710,7 @@
       }
   
       /**
  -     * inform TrAX error listener of this error
  +     * Inform TrAX error listener of an error
        */
       private void postErrorToListener(String msg) {
           try {
  @@ -586,7 +722,7 @@
       }
   
       /**
  -     * inform TrAX error listener of this warning
  +     * Inform TrAX error listener of a warning
        */
       private void postWarningToListener(String msg) {
           try {
  @@ -597,51 +733,73 @@
           }
       }
   
  -
  +    /**
  +     * Implements JAXP's Transformer.getOutputProperties().
  +     * Returns a copy of the output properties for the transformation.
  +     */
       public Properties getOutputProperties() throws IllegalArgumentException 
{ 
  -        /*TBD*/ 
  -     throw new IllegalArgumentException(
  -            "AbstractTranslet:getOutputProperties() " +
  -            "not implemented yet.");
  -     //return null; 
  -    }
  -
  -    public String getOutputProperty(String name) throws 
  -     IllegalArgumentException
  -    { 
  -        /*TBD*/ 
  -        throw new IllegalArgumentException(
  -            "AbstractTranslet:getOutputProperty(String) " +
  -            "not implemented yet.");
  -     //return ""; 
  -    }
  -
  -    public void setOutputProperties(Properties props) throws 
  -     IllegalArgumentException 
  -    { 
  -     /*TBD */ 
  -        throw new IllegalArgumentException(
  -            "AbstractTranslet:setOutputProperty(Properties) " +
  -            "not implemented yet.");
  -    }
  -
  -    public void setOutputProperty(String name, String value) throws 
  -     IllegalArgumentException 
  -    {
  -     /*TBD*/
  -     throw new IllegalArgumentException(
  -         "AbstractTranslet:setOutputProperty(String,String) " +
  -         "not implemented yet."); 
  +     // TODO
  +     return(null);
  +    }
  +
  +    /**
  +     * Implements JAXP's Transformer.getOutputProperty().
  +     * Set an output property that will be in effect for the transformation.
  +     */
  +    public String getOutputProperty(String name)
  +     throws IllegalArgumentException { 
  +     // TODO
  +     return(null);
       }
   
  -    public URIResolver getURIResolver() { /*TBD*/ return null; }
  +    /**
  +     * Implements JAXP's Transformer.setOutputProperties().
  +     * Set the output properties for the transformation. These properties
  +     * will override properties set in the Templates with xsl:output.
  +     */
  +    public void setOutputProperties(Properties props)
  +     throws IllegalArgumentException {
  +     // TODO
  +    }
   
  +    /**
  +     * Implements JAXP's Transformer.setOutputProperty().
  +     * Get an output property that is in effect for the transformation. The
  +     * property specified may be a property that was set with
  +     * setOutputProperty(), or it may be a property specified in the 
stylesheet.
  +     */
  +    public void setOutputProperty(String name, String value)
  +     throws  IllegalArgumentException  {
  +     // TODO
  +    }
  +
  +    /**
  +     * Implements JAXP's Transformer.setParameter()
  +     * Add a parameter for the transformation.
  +     */
       public void setParameter(String name, Object value) { 
  -     addParameter(name, value);
  +     addParameter(name, value, false);
  +    }
  +
  +    /**
  +     * Implements JAXP's Transformer.clearParameters()
  +     * Clears the parameter stack.
  +     */
  +    public void clearParameters() {  
  +     paramsStack.clear();
  +    }
  +
  +    /**
  +     * These two methods need to pass the URI resolver to the 
dom/LoadDocument
  +     * class, which again must use the URI resolver if present.
  +     */
  +    public URIResolver getURIResolver() {
  +     // TBD
  +     return null;
       }
   
       public void setURIResolver(URIResolver resolver) { 
  -     /*TBD*/
  +     // TBD
       }
   
   }
  
  
  
  1.7       +3 -3      
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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- BasisLibrary.java 2001/06/19 10:44:18     1.6
  +++ BasisLibrary.java 2001/07/09 10:17:52     1.7
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: BasisLibrary.java,v 1.6 2001/06/19 10:44:18 morten Exp $
  + * @(#)$Id: BasisLibrary.java,v 1.7 2001/07/09 10:17:52 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -642,8 +642,8 @@
                     left instanceof Integer || right instanceof Integer) {
                result = numberF(left, dom) == numberF(right, dom);
            }
  -         else {              // compare them as strings
  -             result = stringF(left, dom) == stringF(right, dom);
  +         else { // compare them as strings
  +             result = stringF(left, dom).equals(stringF(right, dom));
            }
   
            if (op == Operators.NE) {
  
  
  
  1.8       +2 -3      
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/DefaultRun.java
  
  Index: DefaultRun.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/DefaultRun.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DefaultRun.java   2001/06/08 12:57:55     1.7
  +++ DefaultRun.java   2001/07/09 10:17:53     1.8
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: DefaultRun.java,v 1.7 2001/06/08 12:57:55 morten Exp $
  + * @(#)$Id: DefaultRun.java,v 1.8 2001/07/09 10:17:53 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -161,7 +161,7 @@
            int n = _params.size();
            for (int i = 0; i < n; i++) {
                Parameter param = (Parameter) _params.elementAt(i);
  -             translet.addParameter(param.name, param.value); 
  +             translet.addParameter(param._name, param._value);
            }
   
            // Transform the document
  @@ -173,7 +173,6 @@
                DefaultSAXOutputHandler(System.out, encoding);
            TextOutput textOutput = new TextOutput(saxHandler, encoding);
            translet.transform(dom, textOutput);
  -         textOutput.flush();
   
            if (_debug) {
                TransletOutputBase handler = new TransletOutputBase();
  
  
  
  1.2       +17 -7     
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/Parameter.java
  
  Index: Parameter.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/Parameter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Parameter.java    2001/04/17 18:52:45     1.1
  +++ Parameter.java    2001/07/09 10:17:55     1.2
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Parameter.java,v 1.1 2001/04/17 18:52:45 sboag Exp $
  + * @(#)$Id: Parameter.java,v 1.2 2001/07/09 10:17:55 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -58,17 +58,27 @@
    *
    * @author Jacek Ambroziak
    * @author Santiago Pericas-Geertsen
  + * @author Morten Jorgensen
    *
    */
   
   package org.apache.xalan.xsltc.runtime;
   
   public class Parameter {
  -     public String name;
  -     public Object value;
   
  -     public Parameter(String nm, Object val) {
  -             name = nm;
  -             value = val;
  -     }
  +    public String  _name;
  +    public Object  _value;
  +    public boolean _isDefault;
  +
  +    public Parameter(String name, Object value) {
  +     _name = name;
  +     _value = value;
  +     _isDefault = true;
  +    }
  +
  +    public Parameter(String name, Object value, boolean isDefault) {
  +     _name = name;
  +     _value = value;
  +     _isDefault = isDefault;
  +    }
   }
  
  
  
  1.11      +35 -48    
xml-xalan/java/src/org/apache/xalan/xsltc/runtime/TextOutput.java
  
  Index: TextOutput.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/TextOutput.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- TextOutput.java   2001/06/12 09:40:22     1.10
  +++ TextOutput.java   2001/07/09 10:17:56     1.11
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: TextOutput.java,v 1.10 2001/06/12 09:40:22 morten Exp $
  + * @(#)$Id: TextOutput.java,v 1.11 2001/07/09 10:17:56 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -23,7 +23,7 @@
    *    if any, must include the following acknowledgment:
    *       "This product includes software developed by the
    *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowledgment may appear in the software itself,
  + *    Alternately, this acknowledgment may appear in the software itself
    *    if and wherever such third-party acknowledgments normally appear.
    *
    * 4. The names "Xalan" and "Apache Software Foundation" must
  @@ -174,6 +174,7 @@
       public void setType(int type)  {
        try {
            _outputType = type;
  +         if (_encoding == null) _encoding = "utf-8";
            if (_saxHandler instanceof DefaultSAXOutputHandler)
                ((DefaultSAXOutputHandler)_saxHandler).setOutputType(type);
        }
  @@ -182,6 +183,17 @@
        }
       }
   
  +    private void setTypeInternal(int type) {
  +     if (type == XML) {
  +         _escapeChars = true;
  +     }
  +     else if (type == HTML) {
  +         _escapeChars = true;
  +         setIndent(true);
  +     }
  +     setType(type);
  +    }
  +
       /**
        * Emit header through the SAX handler
        */
  @@ -212,7 +224,6 @@
   
       /**
        * Directive to turn xml header declaration  on/off. 
  -     * bug fix # 1406.
        */
       public void omitXmlDecl(boolean value) {
        if (_saxHandler instanceof DefaultSAXOutputHandler) {
  @@ -274,41 +285,35 @@
        * CDATA sections in output XML documents.
        */
       public boolean setEscaping(boolean escape) throws TransletException {
  -     try {
  -         boolean oldSetting = _escapeChars;
  -         if (_outputType == UNKNOWN) {
  -             setType(XML);
  -             emitHeader();
  -             oldSetting = true;
  -         }
  -         _escapeChars = escape;
  +     // Set output type to XML (the default) if still unknown.
  +     if (_outputType == UNKNOWN) setTypeInternal(XML);
   
  -         // bug # 1403, see also compiler/Text.java::translate method.
  -         if (_outputType == TEXT) { 
  -             _escapeChars = false; 
  -         }
  +     boolean oldSetting = _escapeChars;
  +     _escapeChars = escape;
   
  -         return(oldSetting);
  -             
  -     }
  -     catch (SAXException e) {
  -         throw(new TransletException(e));
  -     }
  +     // bug # 1403, see also compiler/Text.java::translate method.
  +     if (_outputType == TEXT) _escapeChars = false; 
  +
  +     return(oldSetting);
       }
   
       /**
        * Output document stream flush
        */ 
  +    /*
       public void flush() throws IOException {
        //_saxHandler.flush();
       }
  +    */
   
       /**
        * Output document stream close
        */ 
  +    /*
       public void close() throws IOException {
        //_saxHandler.close();
       }
  +    */
   
       /**
        * The <xsl:output method="xml"/> instruction can specify that certain
  @@ -329,7 +334,6 @@
           try {
               _saxHandler.startDocument();
               if (_outputType == XML) {
  -             emitHeader();
                   _escapeChars = true;
               }
           } catch (SAXException e) {
  @@ -342,6 +346,9 @@
        */
       public void endDocument() throws TransletException {
           try {
  +            // Set output type to XML (the default) if still unknown.
  +            if (_outputType == UNKNOWN) setTypeInternal(XML);
  +
            // Close any open start tag
            if (_startTagOpen) {
                closeStartTag();
  @@ -351,12 +358,6 @@
                   _cdataTagOpen = false;
               }
   
  -            // Set output type to XML (the default) if still unknown.
  -            if (_outputType == UNKNOWN) {
  -             setType(XML);
  -             emitHeader();
  -            }
  -
            // Close output document
               _saxHandler.endDocument();
           } catch (SAXException e) {
  @@ -395,11 +396,7 @@
               }
   
               // Set output type to XML (the default) if still unknown.
  -            if (_outputType == UNKNOWN) {
  -                setType(XML);
  -             emitHeader();
  -                _escapeChars = true;
  -            }
  +            if (_outputType == UNKNOWN) setTypeInternal(XML);
   
            int limit = off + len;
            int offset = off;
  @@ -489,16 +486,10 @@
            // If we don't know the output type yet we need to examine
            // the very first element to see if it is "html".
            if (_outputType == UNKNOWN) {
  -             if (elementName.toLowerCase().equals("html")) {
  -                 setType(HTML);
  -                 setIndent(true);
  -                 _escapeChars = true;
  -             }
  -             else {
  -                 setType(XML);
  -                 emitHeader();
  -                 _escapeChars = true;
  -             }
  +             if (elementName.toLowerCase().equals("html"))
  +                 setTypeInternal(HTML);
  +             else
  +                 setTypeInternal(XML);
            }
   
               _depth++;
  @@ -641,11 +632,7 @@
               }
   
               // Set output type to XML (the default) if still unknown.
  -            if (_outputType == UNKNOWN) {
  -                setType(XML);
  -             emitHeader();
  -                _escapeChars = true;
  -            }
  +            if (_outputType == UNKNOWN) setTypeInternal(XML);
   
               // ...and then output the comment.
               characters(BEGCOMM);
  
  
  

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

Reply via email to