mkwan       2003/04/01 13:09:02

  Modified:    java/src/org/apache/xalan/xsltc/compiler
                        AbsolutePathPattern.java AncestorPattern.java
                        CastExpr.java Constants.java CopyOf.java
                        DocumentCall.java ForEach.java GenerateIdCall.java
                        IdKeyPattern.java Key.java KeyCall.java
                        Message.java Mode.java NameBase.java NodeTest.java
                        Output.java ParentLocationPath.java Predicate.java
                        ProcessingInstructionPattern.java Step.java
                        StepPattern.java Stylesheet.java
                        SyntaxTreeNode.java UnionPathExpr.java
                        UnparsedEntityUriCall.java ValueOf.java XSLTC.java
                        xpath.cup
  Log:
  Merging XSLTC_DTM and common serializer to the head
  
  Changes in org.apache.xalan.xsltc.compiler.
  
  Revision  Changes    Path
  1.9       +5 -4      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AbsolutePathPattern.java
  
  Index: AbsolutePathPattern.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AbsolutePathPattern.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- AbsolutePathPattern.java  30 Jan 2003 18:45:59 -0000      1.8
  +++ AbsolutePathPattern.java  1 Apr 2003 21:08:59 -0000       1.9
  @@ -74,12 +74,12 @@
   import org.apache.bcel.generic.InstructionList;
   import org.apache.bcel.generic.LocalVariableGen;
   import org.apache.bcel.generic.PUSH;
  -import org.apache.xalan.xsltc.DOM;
   import org.apache.xalan.xsltc.compiler.util.ClassGenerator;
   import org.apache.xalan.xsltc.compiler.util.MethodGenerator;
   import org.apache.xalan.xsltc.compiler.util.Type;
   import org.apache.xalan.xsltc.compiler.util.TypeCheckError;
   import org.apache.xalan.xsltc.compiler.util.Util;
  +import org.apache.xml.dtm.DTM;
   
   final class AbsolutePathPattern extends LocationPathPattern {
       private final RelativePathPattern _left; // may be null
  @@ -140,7 +140,8 @@
                                                        GET_PARENT,
                                                        GET_PARENT_SIG);
        final int getType = cpg.addInterfaceMethodref(DOM_INTF,
  -                                                   "getType", "(I)I");
  +                                                   "getExpandedTypeID",
  +                                                      "(I)I");
   
        InstructionHandle begin = il.append(methodGen.loadDOM());
        il.append(SWAP);
  @@ -150,7 +151,7 @@
            il.append(SWAP);
        }
        il.append(new INVOKEINTERFACE(getType, 2));
  -     il.append(new PUSH(cpg, DOM.ROOT));
  +     il.append(new PUSH(cpg, DTM.DOCUMENT_NODE));
        
        final BranchHandle skip = il.append(new IF_ICMPEQ(null));
        _falseList.add(il.append(new GOTO_W(null)));
  
  
  
  1.9       +3 -3      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AncestorPattern.java
  
  Index: AncestorPattern.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/AncestorPattern.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- AncestorPattern.java      30 Jan 2003 18:45:59 -0000      1.8
  +++ AncestorPattern.java      1 Apr 2003 21:08:59 -0000       1.9
  @@ -67,7 +67,7 @@
   import org.apache.bcel.generic.BranchHandle;
   import org.apache.bcel.generic.ConstantPoolGen;
   import org.apache.bcel.generic.GOTO;
  -import org.apache.bcel.generic.IFEQ;
  +import org.apache.bcel.generic.IFLT;
   import org.apache.bcel.generic.ILOAD;
   import org.apache.bcel.generic.INVOKEINTERFACE;
   import org.apache.bcel.generic.ISTORE;
  @@ -172,7 +172,7 @@
            
            il.append(DUP);
            il.append(storeLocal);
  -         _falseList.add(il.append(new IFEQ(null)));
  +         _falseList.add(il.append(new IFLT(null)));
            il.append(loadLocal);
   
            _left.translate(classGen, methodGen);
  
  
  
  1.18      +7 -3      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/CastExpr.java
  
  Index: CastExpr.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/CastExpr.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- CastExpr.java     30 Jan 2003 18:45:59 -0000      1.17
  +++ CastExpr.java     1 Apr 2003 21:08:59 -0000       1.18
  @@ -72,6 +72,7 @@
   import org.apache.bcel.generic.SIPUSH;
   import org.apache.xalan.xsltc.compiler.util.BooleanType;
   import org.apache.xalan.xsltc.compiler.util.ClassGenerator;
  +import org.apache.xalan.xsltc.compiler.util.ErrorMsg;
   import org.apache.xalan.xsltc.compiler.util.MethodGenerator;
   import org.apache.xalan.xsltc.compiler.util.MultiHashtable;
   import org.apache.xalan.xsltc.compiler.util.NodeType;
  @@ -218,7 +219,9 @@
        if (InternalTypeMap.maps(tleft, _type) != null) {
            return _type;
        }
  -     throw new TypeCheckError(this); 
  +     // throw new TypeCheckError(this);      
  +     throw new TypeCheckError(new ErrorMsg(
  +         ErrorMsg.DATA_CONVERSION_ERR, tleft.toString(), _type.toString()));
       }
   
       public void translateDesynthesized(ClassGenerator classGen, 
  @@ -234,7 +237,8 @@
            final InstructionList il = methodGen.getInstructionList();
   
            final int idx = cpg.addInterfaceMethodref(DOM_INTF,
  -                                                   "getType", "(I)I");
  +                                                   "getExpandedTypeID",
  +                                                      "(I)I");
            il.append(new SIPUSH((short)((Step)_left).getNodeType()));
            il.append(methodGen.loadDOM());
            il.append(methodGen.loadContextNode());
  
  
  
  1.33      +159 -142  
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.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- Constants.java    21 Mar 2003 13:25:28 -0000      1.32
  +++ Constants.java    1 Apr 2003 21:08:59 -0000       1.33
  @@ -92,19 +92,23 @@
   
       public static final String TRANSLET_INTF
        = "org.apache.xalan.xsltc.Translet";
  -    public static final String TRANSLET_INTF_SIG
  +    public static final String TRANSLET_INTF_SIG        
        = "Lorg/apache/xalan/xsltc/Translet;";
  -
  -    public static final String ATTRIBUTES_SIG
  +    
  +    public static final String ATTRIBUTES_SIG 
        = "Lorg/apache/xalan/xsltc/runtime/Attributes;";
       public static final String NODE_ITERATOR_SIG
  -     = "Lorg/apache/xalan/xsltc/NodeIterator;";
  +     = "Lorg/apache/xml/dtm/DTMAxisIterator;";
       public static final String DOM_INTF_SIG
        = "Lorg/apache/xalan/xsltc/DOM;";
       public static final String DOM_IMPL_CLASS
  -     = "org/apache/xalan/xsltc/dom/DOMImpl";
  +     = "org/apache/xalan/xsltc/DOM"; // 
xml/dtm/ref/DTMDefaultBaseIterators"; //xalan/xsltc/dom/DOMImpl";
  +     public static final String SAX_IMPL_CLASS
  +     = "org/apache/xalan/xsltc/DOM/SAXImpl"; 
       public static final String DOM_IMPL_SIG
  -     = "Lorg/apache/xalan/xsltc/dom/DOMImpl;";
  +     = "Lorg/apache/xalan/xsltc/dom/SAXImpl;"; 
//xml/dtm/ref/DTMDefaultBaseIterators"; //xalan/xsltc/dom/DOMImpl;";
  +     public static final String SAX_IMPL_SIG
  +     = "Lorg/apache/xalan/xsltc/dom/SAXImpl;";
       public static final String DOM_ADAPTER_CLASS
        = "org/apache/xalan/xsltc/dom/DOMAdapter";
       public static final String DOM_ADAPTER_SIG
  @@ -114,76 +118,72 @@
       public static final String MULTI_DOM_SIG
        = "Lorg/apache/xalan/xsltc/dom/MultiDOM;";
   
  -    public static final String STRING
  +    public static final String STRING    
        = "java.lang.String";
   
  -    public static final int ACC_PUBLIC
  +    public static final int ACC_PUBLIC    
        = org.apache.bcel.Constants.ACC_PUBLIC;
  -    public static final int ACC_SUPER
  +    public static final int ACC_SUPER     
        = org.apache.bcel.Constants.ACC_SUPER;
  -    public static final int ACC_FINAL
  +    public static final int ACC_FINAL     
        = org.apache.bcel.Constants.ACC_FINAL;
  -    public static final int ACC_PRIVATE
  +    public static final int ACC_PRIVATE   
        = org.apache.bcel.Constants.ACC_PRIVATE;
  -    public static final int ACC_PROTECTED
  +    public static final int ACC_PROTECTED 
        = org.apache.bcel.Constants.ACC_PROTECTED;
       public static final int ACC_STATIC
        = org.apache.bcel.Constants.ACC_STATIC;
   
  -    public static final String STRING_SIG
  +    public static final String STRING_SIG         
        = "Ljava/lang/String;";
  -    public static final String STRING_BUFFER_SIG
  +    public static final String STRING_BUFFER_SIG  
        = "Ljava/lang/StringBuffer;";
  -    public static final String OBJECT_SIG
  +    public static final String OBJECT_SIG         
        = "Ljava/lang/Object;";
  -    public static final String DOUBLE_SIG
  +    public static final String DOUBLE_SIG         
        = "Ljava/lang/Double;";
  -    public static final String INTEGER_SIG
  +    public static final String INTEGER_SIG        
        = "Ljava/lang/Integer;";
       public static final String COLLATOR_CLASS
           = "java/text/Collator";
       public static final String COLLATOR_SIG
           = "Ljava/text/Collator;";
   
  -    public static final String NODE
  +    public static final String NODE               
        = "int";
  -    public static final String NODE_ITERATOR
  -     = "org.apache.xalan.xsltc.NodeIterator";
  +    public static final String NODE_ITERATOR      
  +     = "org.apache.xml.dtm.DTMAxisIterator";
       public static final String NODE_ITERATOR_BASE
  -     = "org.apache.xalan.xsltc.dom.NodeIteratorBase";
  -    public static final String SORT_ITERATOR
  +     = "org.apache.xml.dtm.ref.DTMAxisIteratorBase";
  +    public static final String SORT_ITERATOR      
        = "org.apache.xalan.xsltc.dom.SortingIterator";
  -    public static final String SORT_ITERATOR_SIG
  +    public static final String SORT_ITERATOR_SIG     
        = "Lorg.apache.xalan.xsltc.dom.SortingIterator;";
  -    public static final String FORWARD_POSITION_ITERATOR
  +    public static final String FORWARD_POSITION_ITERATOR      
        = "org.apache.xalan.xsltc.dom.ForwardPositionIterator";
  -    public static final String NODE_SORT_RECORD
  +    public static final String NODE_SORT_RECORD 
        = "org.apache.xalan.xsltc.dom.NodeSortRecord";
       public static final String NODE_SORT_FACTORY
        = "org/apache/xalan/xsltc/dom/NodeSortRecordFactory";
  -    public static final String NODE_SORT_RECORD_SIG
  +    public static final String NODE_SORT_RECORD_SIG 
        = "Lorg/apache/xalan/xsltc/dom/NodeSortRecord;";
       public static final String NODE_SORT_FACTORY_SIG
        = "Lorg/apache/xalan/xsltc/dom/NodeSortRecordFactory;";
       public static final String LOCALE_CLASS
  -     = "java.util.Locale";
  -    public static final String LOCALE_SIG
  +        = "java.util.Locale";
  +    public static final String LOCALE_SIG 
        = "Ljava/util/Locale;";
       public static final String STRING_VALUE_HANDLER
        = "org.apache.xalan.xsltc.runtime.StringValueHandler";
  -    public static final String STRING_VALUE_HANDLER_SIG
  +    public static final String STRING_VALUE_HANDLER_SIG 
        = "Lorg/apache/xalan/xsltc/runtime/StringValueHandler;";
       public static final String OUTPUT_HANDLER
  -     = "org/apache/xalan/xsltc/TransletOutputHandler";
  +     = "org/apache/xml/serializer/SerializationHandler";
       public static final String OUTPUT_HANDLER_SIG
  -     = "Lorg/apache/xalan/xsltc/TransletOutputHandler;";
  -    public static final String OUTPUT_BASE
  -        = "org/apache/xalan/xsltc/runtime/output/OutputBase";
  -    public static final String STREAM_XML_OUTPUT
  -        = "org/apache/xalan/xsltc/runtime/output/StreamXMLOutput";
  -    public static final String FILTER_INTERFACE
  +     = "Lorg/apache/xml/serializer/SerializationHandler;";
  +    public static final String FILTER_INTERFACE   
        = "org.apache.xalan.xsltc.dom.Filter";
  -    public static final String FILTER_INTERFACE_SIG
  +    public static final String FILTER_INTERFACE_SIG   
        = "Lorg/apache/xalan/xsltc/dom/Filter;";
       public static final String UNION_ITERATOR_CLASS
        = "org.apache.xalan.xsltc.dom.UnionIterator";
  @@ -199,67 +199,75 @@
        = "org.apache.xalan.xsltc.dom.CurrentNodeListIterator";
       public static final String CURRENT_NODE_LIST_FILTER
        = "org.apache.xalan.xsltc.dom.CurrentNodeListFilter";
  -    public static final String CURRENT_NODE_LIST_ITERATOR_SIG
  +    public static final String CURRENT_NODE_LIST_ITERATOR_SIG 
        = "Lorg/apache/xalan/xsltc/dom/CurrentNodeListIterator;";
       public static final String CURRENT_NODE_LIST_FILTER_SIG
        = "Lorg/apache/xalan/xsltc/dom/CurrentNodeListFilter;";
  -    public static final String FILTER_STEP_ITERATOR
  +    public static final String FILTER_STEP_ITERATOR 
        = "org.apache.xalan.xsltc.dom.FilteredStepIterator";
  -    public static final String FILTER_ITERATOR
  +    public static final String FILTER_ITERATOR 
        = "org.apache.xalan.xsltc.dom.FilterIterator";
  -    public static final String SINGLETON_ITERATOR
  +    public static final String SINGLETON_ITERATOR 
        = "org.apache.xalan.xsltc.dom.SingletonIterator";
  -    public static final String MATCHING_ITERATOR
  +    public static final String MATCHING_ITERATOR 
        = "org.apache.xalan.xsltc.dom.MatchingIterator";
  -    public static final String NODE_SIG
  +    public static final String NODE_SIG           
        = "I";
  -    public static final String GET_PARENT
  +    public static final String GET_PARENT         
        = "getParent";
  -    public static final String GET_PARENT_SIG
  +    public static final String GET_PARENT_SIG     
        = "(" + NODE_SIG + ")" + NODE_SIG;
  -    public static final String NEXT_SIG
  +    public static final String NEXT_SIG           
        = "()" + NODE_SIG;
  -    public static final String NEXT
  +    public static final String NEXT               
        = "next";
  -    public static final String MAKE_NODE
  +     public static final String NEXTID               
  +     = "nextNodeID";
  +    public static final String MAKE_NODE          
        = "makeNode";
  -    public static final String MAKE_NODE_LIST
  +    public static final String MAKE_NODE_LIST     
        = "makeNodeList";
  -    public static final String STRING_TO_REAL
  +    public static final String GET_UNPARSED_ENTITY_URI
  +        = "getUnparsedEntityURI";
  +    public static final String STRING_TO_REAL     
        = "stringToReal";
  -    public static final String STRING_TO_REAL_SIG
  +    public static final String STRING_TO_REAL_SIG 
        = "(" + STRING_SIG + ")D";
  -    public static final String STRING_TO_INT
  +    public static final String STRING_TO_INT     
        = "stringToInt";
  -    public static final String STRING_TO_INT_SIG
  +    public static final String STRING_TO_INT_SIG 
        = "(" + STRING_SIG + ")I";
   
  -    public static final String XSLT_PACKAGE
  +    public static final String XSLT_PACKAGE       
        = "org.apache.xalan.xsltc";
  -    public static final String COMPILER_PACKAGE
  +    public static final String COMPILER_PACKAGE   
        = XSLT_PACKAGE + ".compiler";
  -    public static final String RUNTIME_PACKAGE
  +    public static final String RUNTIME_PACKAGE    
        = XSLT_PACKAGE + ".runtime";
  -    public static final String TRANSLET_CLASS
  +    public static final String TRANSLET_CLASS     
        = RUNTIME_PACKAGE + ".AbstractTranslet";
   
  -    public static final String TRANSLET_SIG
  +    public static final String TRANSLET_SIG        
        = "Lorg/apache/xalan/xsltc/runtime/AbstractTranslet;";
  -    public static final String UNION_ITERATOR_SIG
  +    public static final String UNION_ITERATOR_SIG  
        = "Lorg/apache/xalan/xsltc/dom/UnionIterator;";
  -    public static final String TRANSLET_OUTPUT_BASE_SIG
  -     = "Lorg/apache/xalan/xsltc/TransletOutputBase;";
  -    public static final String TRANSLET_OUTPUT_SIG
  -     = "Lorg/apache/xalan/xsltc/TransletOutputHandler;";
  -    public static final String MAKE_NODE_SIG
  +    public static final String TRANSLET_OUTPUT_SIG    
  +     = "Lorg/apache/xml/serializer/SerializationHandler;";
  +    public static final String MAKE_NODE_SIG       
        = "(I)Lorg/w3c/dom/Node;";
  -    public static final String MAKE_NODE_SIG2
  +    public static final String MAKE_NODE_SIG2      
        = "(" + NODE_ITERATOR_SIG + ")Lorg/w3c/dom/Node;";
  -    public static final String MAKE_NODE_LIST_SIG
  +    public static final String MAKE_NODE_LIST_SIG  
        = "(I)Lorg/w3c/dom/NodeList;";
  -    public static final String MAKE_NODE_LIST_SIG2
  +    public static final String MAKE_NODE_LIST_SIG2 
        = "(" + NODE_ITERATOR_SIG + ")Lorg/w3c/dom/NodeList;";
  -
  +    
  +    public static final String STREAM_XML_OUTPUT
  +    = "org.apache.xml.serializer.ToXMLStream";
  +    
  +    public static final String OUTPUT_BASE
  +    = "org.apache.xml.serializer.SerializerBase";
  +    
       public static final String LOAD_DOCUMENT_CLASS
        = "org.apache.xalan.xsltc.dom.LoadDocument";
   
  @@ -271,12 +279,14 @@
       public static final String DOM_INTF
        = "org.apache.xalan.xsltc.DOM";
       public static final String DOM_IMPL
  -     = "org.apache.xalan.xsltc.dom.DOMImpl";
  -    public static final String STRING_CLASS
  +     = "org.apache.xalan.xsltc.dom.SAXImpl";
  +     public static final String SAX_IMPL
  +     = "org.apache.xalan.xsltc.dom.SAXImpl";
  +    public static final String STRING_CLASS          
        = "java.lang.String";
  -    public static final String OBJECT_CLASS
  +    public static final String OBJECT_CLASS          
        = "java.lang.Object";
  -    public static final String BOOLEAN_CLASS
  +    public static final String BOOLEAN_CLASS                 
        = "java.lang.Boolean";
       public static final String STRING_BUFFER_CLASS
        = "java.lang.StringBuffer";
  @@ -285,85 +295,85 @@
       public static final String WRITER_SIG
           = "Ljava/io/Writer;";
   
  -    public static final String TRANSLET_OUTPUT_BASE
  +    public static final String TRANSLET_OUTPUT_BASE       
        = "org.apache.xalan.xsltc.TransletOutputBase";
       // output interface
       public static final String TRANSLET_OUTPUT_INTERFACE
  -     = "org.apache.xalan.xsltc.TransletOutputHandler";
  -    public static final String BASIS_LIBRARY_CLASS
  +     = "org.apache.xml.serializer.SerializationHandler";
  +    public static final String BASIS_LIBRARY_CLASS 
        = "org.apache.xalan.xsltc.runtime.BasisLibrary";
  -    public static final String ATTRIBUTE_LIST_IMPL_CLASS
  +    public static final String ATTRIBUTE_LIST_IMPL_CLASS 
        = "org.apache.xalan.xsltc.runtime.AttributeListImpl";
  -    public static final String DOUBLE_CLASS
  +    public static final String DOUBLE_CLASS       
        = "java.lang.Double";
  -    public static final String INTEGER_CLASS
  +    public static final String INTEGER_CLASS      
        = "java.lang.Integer";
  -    public static final String RUNTIME_NODE_CLASS
  +    public static final String RUNTIME_NODE_CLASS 
        = "org.apache.xalan.xsltc.runtime.Node";
  -    public static final String MATH_CLASS
  +    public static final String MATH_CLASS         
        = "java.lang.Math";
   
  -    public static final String BOOLEAN_VALUE
  +    public static final String BOOLEAN_VALUE      
        = "booleanValue";
  -    public static final String BOOLEAN_VALUE_SIG
  +    public static final String BOOLEAN_VALUE_SIG  
        = "()Z";
  -    public static final String INT_VALUE
  +    public static final String INT_VALUE          
        = "intValue";
  -    public static final String INT_VALUE_SIG
  +    public static final String INT_VALUE_SIG      
        = "()I";
  -    public static final String DOUBLE_VALUE
  +    public static final String DOUBLE_VALUE       
        = "doubleValue";
  -    public static final String DOUBLE_VALUE_SIG
  +    public static final String DOUBLE_VALUE_SIG   
        = "()D";
   
  -    public static final String NODE_PNAME
  +    public static final String NODE_PNAME         
        = "node";
  -    public static final String TRANSLET_OUTPUT_PNAME
  +    public static final String TRANSLET_OUTPUT_PNAME 
        = "handler";
  -    public static final String ITERATOR_PNAME
  +    public static final String ITERATOR_PNAME     
        = "iterator";
  -    public static final String DOCUMENT_PNAME
  +    public static final String DOCUMENT_PNAME     
        = "document";
  -    public static final String TRANSLET_PNAME
  +    public static final String TRANSLET_PNAME     
        = "translet";
   
  -    public static final String GET_NODE_NAME
  -     = "getNodeName";
  -    public static final String CHARACTERSW
  +    public static final String GET_NODE_NAME      
  +     = "getNodeNameX";
  +    public static final String CHARACTERSW        
        = "characters";
  -    public static final String GET_CHILDREN
  +    public static final String GET_CHILDREN       
        = "getChildren";
  -    public static final String GET_TYPED_CHILDREN
  +    public static final String GET_TYPED_CHILDREN 
        = "getTypedChildren";
  -    public static final String CHARACTERS
  +    public static final String CHARACTERS         
        = "characters";
  -    public static final String APPLY_TEMPLATES
  +    public static final String APPLY_TEMPLATES    
        = "applyTemplates";
  -    public static final String GET_NODE_TYPE
  +    public static final String GET_NODE_TYPE      
        = "getNodeType";
  -    public static final String GET_NODE_VALUE
  -     = "getNodeValue";
  -    public static final String GET_ELEMENT_VALUE
  +    public static final String GET_NODE_VALUE     
  +     = "getStringValueX";
  +    public static final String GET_ELEMENT_VALUE  
        = "getElementValue";
  -    public static final String GET_ATTRIBUTE_VALUE
  +    public static final String GET_ATTRIBUTE_VALUE  
        = "getAttributeValue";
  -    public static final String HAS_ATTRIBUTE
  +    public static final String HAS_ATTRIBUTE      
        = "hasAttribute";
  -    public static final String ADD_ITERATOR
  +    public static final String ADD_ITERATOR       
        = "addIterator";
  -    public static final String SET_START_NODE
  +    public static final String SET_START_NODE     
        = "setStartNode";
  -    public static final String RESET
  +    public static final String RESET             
        = "reset";
   
       public static final String ATTR_SET_SIG
        = "(" + TRANSLET_OUTPUT_SIG + NODE_ITERATOR_SIG + ")V";
   
  -    public static final String GET_NODE_NAME_SIG
  +    public static final String GET_NODE_NAME_SIG   
        = "(" + NODE_SIG + ")" + STRING_SIG;
  -    public static final String CHARACTERSW_SIG
  +    public static final String CHARACTERSW_SIG     
        = "("  + STRING_SIG + TRANSLET_OUTPUT_SIG + ")V";
  -    public static final String CHARACTERS_SIG
  +    public static final String CHARACTERS_SIG     
        = "(" + NODE_SIG + TRANSLET_OUTPUT_SIG + ")V";
       public static final String GET_CHILDREN_SIG
        = "(" + NODE_SIG +")" + NODE_ITERATOR_SIG;
  @@ -390,73 +400,77 @@
        = "namespaceArray";
       public static final String NAMESPACE_INDEX_SIG
        = "[" + STRING_SIG;
  +    public static final String HASIDCALL_INDEX
  +        = "_hasIdCall";
  +    public static final String HASIDCALL_INDEX_SIG
  +        = "Z";
   
       public static final String DOM_FIELD
        = "_dom";
  -    public static final String FORMAT_SYMBOLS_FIELD
  +    public static final String FORMAT_SYMBOLS_FIELD   
        = "format_symbols";
   
  -    public static final String ITERATOR_FIELD_SIG
  +    public static final String ITERATOR_FIELD_SIG      
        = NODE_ITERATOR_SIG;
  -    public static final String NODE_FIELD
  +    public static final String NODE_FIELD             
        = "node";
  -    public static final String NODE_FIELD_SIG
  +    public static final String NODE_FIELD_SIG                 
        = "I";
  -
  -    public static final String EMPTYATTR_FIELD
  +     
  +    public static final String EMPTYATTR_FIELD            
        = "EmptyAttributes";
  -    public static final String ATTRIBUTE_LIST_FIELD
  +    public static final String ATTRIBUTE_LIST_FIELD    
        = "attributeList";
  -    public static final String CLEAR_ATTRIBUTES
  +    public static final String CLEAR_ATTRIBUTES        
        = "clear";
  -    public static final String ADD_ATTRIBUTE
  +    public static final String ADD_ATTRIBUTE           
        = "addAttribute";
  -    public static final String ATTRIBUTE_LIST_IMPL_SIG
  +    public static final String ATTRIBUTE_LIST_IMPL_SIG 
        = "Lorg/apache/xalan/xsltc/runtime/AttributeListImpl;";
  -    public static final String CLEAR_ATTRIBUTES_SIG
  +    public static final String CLEAR_ATTRIBUTES_SIG    
        = "()" + ATTRIBUTE_LIST_IMPL_SIG;
  -    public static final String ADD_ATTRIBUTE_SIG
  +    public static final String ADD_ATTRIBUTE_SIG   
        = "(" + STRING_SIG + STRING_SIG + ")" + ATTRIBUTE_LIST_IMPL_SIG;
  -
  -    public static final String ADD_ITERATOR_SIG
  +     
  +    public static final String ADD_ITERATOR_SIG   
        = "(" + NODE_ITERATOR_SIG +")" + UNION_ITERATOR_SIG;
   
       public static final String ORDER_ITERATOR
        = "orderNodes";
       public static final String ORDER_ITERATOR_SIG
        = "("+NODE_ITERATOR_SIG+"I)"+NODE_ITERATOR_SIG;
  -
  -    public static final String SET_START_NODE_SIG
  +     
  +    public static final String SET_START_NODE_SIG   
        = "(" + NODE_SIG + ")" + NODE_ITERATOR_SIG;
   
  -    public static final String NODE_COUNTER
  +    public static final String NODE_COUNTER 
        = "org.apache.xalan.xsltc.dom.NodeCounter";
  -    public static final String NODE_COUNTER_SIG
  +    public static final String NODE_COUNTER_SIG 
        = "Lorg/apache/xalan/xsltc/dom/NodeCounter;";
  -    public static final String DEFAULT_NODE_COUNTER
  +    public static final String DEFAULT_NODE_COUNTER 
        = "org.apache.xalan.xsltc.dom.DefaultNodeCounter";
  -    public static final String DEFAULT_NODE_COUNTER_SIG
  +    public static final String DEFAULT_NODE_COUNTER_SIG 
        = "Lorg/apache/xalan/xsltc/dom/DefaultNodeCounter;";
  -    public static final String TRANSLET_FIELD
  +    public static final String TRANSLET_FIELD 
        = "translet";
  -    public static final String TRANSLET_FIELD_SIG
  +    public static final String TRANSLET_FIELD_SIG 
        = TRANSLET_SIG;
   
  -    public static final String RESET_SIG
  +    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
  +    public static final String ADD_PARAMETER         
        = "addParameter";
       public static final String PUSH_PARAM_FRAME
        = "pushParamFrame";
  -    public static final String PUSH_PARAM_FRAME_SIG
  +    public static final String PUSH_PARAM_FRAME_SIG  
        = "()V";
  -    public static final String POP_PARAM_FRAME
  +    public static final String POP_PARAM_FRAME       
        = "popParamFrame";
  -    public static final String POP_PARAM_FRAME_SIG
  +    public static final String POP_PARAM_FRAME_SIG   
        = "()V";
  -    public static final String GET_PARAMETER_SIG
  +    public static final String GET_PARAMETER_SIG     
        = "(" + STRING_SIG + ")" + OBJECT_SIG;
       public static final String ADD_PARAMETER_SIG
        = "(" + STRING_SIG + OBJECT_SIG + "Z)" + OBJECT_SIG;
  @@ -475,12 +489,15 @@
       public static final String GET_NODE_VALUE_ITERATOR_SIG
        = "("+NODE_ITERATOR_SIG+"I"+STRING_SIG+"Z)"+NODE_ITERATOR_SIG;
   
  +    public static final String GET_UNPARSED_ENTITY_URI_SIG
  +        = "("+STRING_SIG+")"+STRING_SIG;
  +
       public static final int POSITION_INDEX = 2;
       public static final int LAST_INDEX     = 3;
   
       public static final String XMLNS_PREFIX = "xmlns";
       public static final String XMLNS_STRING = "xmlns:";
  -    public static final String XMLNS_URI
  +    public static final String XMLNS_URI 
        = "http://www.w3.org/2000/xmlns/";;
       public static final String XSLT_URI
        = "http://www.w3.org/1999/XSL/Transform";;
  @@ -493,5 +510,5 @@
       public static final String FALLBACK_CLASS
        = "org.apache.xalan.xsltc.compiler.Fallback";
   
  -    public static final int RTF_INITIAL_SIZE = 64;
  +    public static final int RTF_INITIAL_SIZE = 32;
   }
  
  
  
  1.13      +7 -2      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/CopyOf.java
  
  Index: CopyOf.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/CopyOf.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- CopyOf.java       30 Jan 2003 18:45:59 -0000      1.12
  +++ CopyOf.java       1 Apr 2003 21:08:59 -0000       1.13
  @@ -122,6 +122,10 @@
   
        final String CPY2_SIG = "("+NODE_SIG+TRANSLET_OUTPUT_SIG+")V";
        final int cpy2 = cpg.addInterfaceMethodref(DOM_INTF, "copy", CPY2_SIG);
  +     
  +     final String getDoc_SIG = "()"+NODE_SIG;
  +     final int getDoc = cpg.addInterfaceMethodref(DOM_INTF, "getDocument", 
getDoc_SIG);
  +
   
        if (tselect instanceof NodeSetType) {
            il.append(methodGen.loadDOM());
  @@ -143,7 +147,8 @@
        else if (tselect instanceof ResultTreeType) {
            _select.translate(classGen, methodGen);     
            // We want the whole tree, so we start with the root node
  -         il.append(ICONST_1);
  +         il.append(DUP); //need a pointer to the DOM ;
  +         il.append(new INVOKEINTERFACE(getDoc,1)); //ICONST_0);
            il.append(methodGen.loadHandler());
            il.append(new INVOKEINTERFACE(cpy2, 3));
        }
  
  
  
  1.16      +21 -4     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/DocumentCall.java
  
  Index: DocumentCall.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/DocumentCall.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- DocumentCall.java 30 Jan 2003 18:45:59 -0000      1.15
  +++ DocumentCall.java 1 Apr 2003 21:08:59 -0000       1.16
  @@ -172,15 +172,32 @@
            _uri.startResetIterator(classGen, methodGen);
   
        // The base of the URI may be given as a second argument (a node-set)
  -     il.append(methodGen.loadDOM());
  +     //il.append(methodGen.loadDOM());
        if (_base != null) {
  +             il.append(methodGen.loadDOM());
            _base.translate(classGen, methodGen);
            il.append(new INVOKEINTERFACE(nextIdx, 1));
  +         il.append(new INVOKEINTERFACE(uriIdx, 2));
        }
        else {
  -          il.append(methodGen.loadContextNode());
  +             //TODO: (MM) Need someone to double check me on this
  +             // but I think this code was wrong because it would
  +             // resolve document() relative to the input xml
  +             // rather than relative to the input xsl when there
  +             // is no second argument!!!
  +             // The context node here would be at runtime in the xml
  +             // I think the reason this worked was because if the
  +             // xml fails, then the xsl is tried in the current code. 
  +          //il.append(methodGen.loadContextNode());
  +          // Instead just pass in the current stylesheet
  +          // I think this get the stylesheet associated with the
  +          // context node, but...
  +          if (_uriType == Type.NodeSet)
  +          il.append(new PUSH(cpg,""));
  +          else
  +          il.append(new PUSH(cpg, getStylesheet().getSystemId()));        
        }
  -     il.append(new INVOKEINTERFACE(uriIdx, 2));
  +     //il.append(new INVOKEINTERFACE(uriIdx, 2));
        il.append(new PUSH(cpg, getStylesheet().getSystemId()));
   
        // Feck the rest of the parameters on the stack
  
  
  
  1.16      +3 -3      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ForEach.java
  
  Index: ForEach.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ForEach.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- ForEach.java      30 Jan 2003 18:46:00 -0000      1.15
  +++ ForEach.java      1 Apr 2003 21:08:59 -0000       1.16
  @@ -70,7 +70,7 @@
   import org.apache.bcel.generic.BranchHandle;
   import org.apache.bcel.generic.ConstantPoolGen;
   import org.apache.bcel.generic.GOTO;
  -import org.apache.bcel.generic.IFNE;
  +import org.apache.bcel.generic.IFGT;
   import org.apache.bcel.generic.InstructionHandle;
   import org.apache.bcel.generic.InstructionList;
   import org.apache.xalan.xsltc.compiler.util.ClassGenerator;
  @@ -197,7 +197,7 @@
        il.append(methodGen.nextNode());
        il.append(DUP);
        il.append(methodGen.storeCurrentNode());
  -     il.append(new IFNE(loop));
  +     il.append(new IFGT(loop));
   
        // Restore current DOM (if result tree was used instead for this loop)
        if ((_type != null) && (_type instanceof ResultTreeType)) {
  
  
  
  1.6       +1 -2      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/GenerateIdCall.java
  
  Index: GenerateIdCall.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/GenerateIdCall.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- GenerateIdCall.java       11 Feb 2003 17:06:35 -0000      1.5
  +++ GenerateIdCall.java       1 Apr 2003 21:08:59 -0000       1.6
  @@ -66,7 +66,6 @@
   import java.util.Vector;
   
   import org.apache.bcel.generic.ConstantPoolGen;
  -import org.apache.bcel.generic.ILOAD;
   import org.apache.bcel.generic.INVOKESTATIC;
   import org.apache.bcel.generic.InstructionList;
   import org.apache.xalan.xsltc.compiler.util.ClassGenerator;
  
  
  
  1.9       +19 -1     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/IdKeyPattern.java
  
  Index: IdKeyPattern.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/IdKeyPattern.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- IdKeyPattern.java 30 Jan 2003 18:46:00 -0000      1.8
  +++ IdKeyPattern.java 1 Apr 2003 21:08:59 -0000       1.9
  @@ -66,6 +66,7 @@
   import org.apache.bcel.generic.ConstantPoolGen;
   import org.apache.bcel.generic.GOTO;
   import org.apache.bcel.generic.IFNE;
  +import org.apache.bcel.generic.INVOKEINTERFACE;
   import org.apache.bcel.generic.INVOKEVIRTUAL;
   import org.apache.bcel.generic.InstructionList;
   import org.apache.bcel.generic.PUSH;
  @@ -134,6 +135,9 @@
        final int lookupKey = cpg.addMethodref(KEY_INDEX_CLASS,
                                               "containsKey",
                                               "(ILjava/lang/Object;)I");
  +     final int getNodeIdent = cpg.addInterfaceMethodref(DOM_INTF,
  +                                                        "getNodeIdent",
  +                                                        "(I)"+NODE_SIG);     
                               
   
        // Call getKeyIndex in AbstractTranslet with the name of the key
        // to get the index for this key (which is also a node iterator).
  @@ -146,9 +150,23 @@
        il.append(SWAP);
        il.append(new PUSH(cpg,_value));
        if (this instanceof IdPattern)
  +     {
  +             il.append(SWAP);
  +             il.append(methodGen.loadDOM());
  +             il.append(SWAP);
  +         il.append(new INVOKEINTERFACE(getNodeIdent, 2));
  +         il.append(SWAP);
            il.append(new INVOKEVIRTUAL(lookupId));
  +     }
        else
  +     {
  +             il.append(SWAP);
  +             il.append(methodGen.loadDOM());
  +             il.append(SWAP);
  +         il.append(new INVOKEINTERFACE(getNodeIdent, 2));
  +         il.append(SWAP);
            il.append(new INVOKEVIRTUAL(lookupKey));
  +     }
   
        _trueList.add(il.append(new IFNE(null)));
        _falseList.add(il.append(new GOTO(null)));
  
  
  
  1.15      +47 -8     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Key.java
  
  Index: Key.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Key.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- Key.java  30 Jan 2003 18:46:00 -0000      1.14
  +++ Key.java  1 Apr 2003 21:08:59 -0000       1.15
  @@ -67,7 +67,8 @@
   import org.apache.bcel.generic.ConstantPoolGen;
   import org.apache.bcel.generic.GOTO;
   import org.apache.bcel.generic.IFEQ;
  -import org.apache.bcel.generic.IFNE;
  +import org.apache.bcel.generic.IFGE;
  +import org.apache.bcel.generic.IFGT;
   import org.apache.bcel.generic.ILOAD;
   import org.apache.bcel.generic.INVOKEINTERFACE;
   import org.apache.bcel.generic.INVOKEVIRTUAL;
  @@ -168,10 +169,20 @@
        final ConstantPoolGen cpg = classGen.getConstantPool();
        final InstructionList il = methodGen.getInstructionList();
   
  -     // DOM.getNodeValue(nodeIndex) => String
  +     // DOM.getStringValueX(nodeIndex) => String
        final int getNodeValue = cpg.addInterfaceMethodref(DOM_INTF,
  -                                                        "getNodeValue",
  +                                                        GET_NODE_VALUE,
                                                           "(I)"+STRING_SIG);
  +                                                        
  +     final int getNodeIdent = cpg.addInterfaceMethodref(DOM_INTF,
  +                                                        "getNodeIdent",
  +                                                        "(I)"+NODE_SIG);     
  +                                                        
  +     // AbstractTranslet.SetKeyIndexDom(name, Dom) => void
  +     final int keyDom = cpg.addMethodref(TRANSLET_CLASS,
  +                                      "setKeyIndexDom",
  +                                      "("+STRING_SIG+DOM_INTF_SIG+")V");     
                         
  +                                                                             
           
   
        // This variable holds the id of the node we found with the "match"
        // attribute of xsl:key. This is the id we store, with the value we
  @@ -182,6 +193,10 @@
                                       il.getEnd(), null);
   
        // Get the 'parameter' from the stack and store it in a local var.
  +     il.append(new ISTORE(parentNode.getIndex()));   
  +     il.append(methodGen.loadDOM());
  +     il.append(new ILOAD(parentNode.getIndex()));    
  +     il.append(new INVOKEINTERFACE(getNodeIdent, 2));
        il.append(new ISTORE(parentNode.getIndex()));
   
        // Save current node and current iterator on the stack
  @@ -204,17 +219,22 @@
        // Now get the node value and feck it on the parameter stack
        il.append(methodGen.loadDOM());
        il.append(methodGen.loadCurrentNode());
  -     il.append(new INVOKEINTERFACE(getNodeValue, 2));
  +     il.append(new INVOKEINTERFACE(getNodeValue, 2));                
   
        // Finally do the call to add an entry in the index for this key.
        il.append(new INVOKEVIRTUAL(buildKeyIndex));
  +     
  +     il.append(classGen.loadTranslet());
  +     il.append(new PUSH(cpg, getName()));
  +     il.append(methodGen.loadDOM());
  +     il.append(new INVOKEVIRTUAL(keyDom));
   
        nextNode.setTarget(il.append(methodGen.loadIterator()));
  -     il.append(methodGen.nextNode());
  +     il.append(methodGen.nextNode());        
   
        il.append(DUP);
        il.append(methodGen.storeCurrentNode());
  -     il.append(new IFNE(loop)); // Go on to next matching node....
  +     il.append(new IFGE(loop)); // Go on to next matching node....
   
        // Restore current node and current iterator from the stack
        il.append(methodGen.storeIterator());
  @@ -235,6 +255,15 @@
        final int key = cpg.addMethodref(TRANSLET_CLASS,
                                         "buildKeyIndex",
                                         "("+STRING_SIG+"I"+OBJECT_SIG+")V");
  +                                      
  +     // AbstractTranslet.SetKeyIndexDom(name, Dom) => void
  +     final int keyDom = cpg.addMethodref(TRANSLET_CLASS,
  +                                      "setKeyIndexDom",
  +                                      "("+STRING_SIG+DOM_INTF_SIG+")V");
  +                                      
  +     final int getNodeIdent = cpg.addInterfaceMethodref(DOM_INTF,
  +                                                        "getNodeIdent",
  +                                                        "(I)"+NODE_SIG);     
                                                                 
   
        // DOM.getAxisIterator(root) => NodeIterator
        final int git = cpg.addInterfaceMethodref(DOM_INTF,
  @@ -272,10 +301,20 @@
        }
        else {
            il.append(classGen.loadTranslet());
  +         il.append(DUP);
            il.append(new PUSH(cpg, _name.toString()));
  +         il.append(DUP_X1);
            il.append(methodGen.loadCurrentNode());
            _use.translate(classGen, methodGen);
  +         il.append(SWAP);
  +         il.append(methodGen.loadDOM());
  +         il.append(SWAP);
  +         il.append(new INVOKEINTERFACE(getNodeIdent, 2));
  +         il.append(SWAP);
            il.append(new INVOKEVIRTUAL(key));
  +         
  +         il.append(methodGen.loadDOM());
  +         il.append(new INVOKEVIRTUAL(keyDom));
        }
        
        // Get the next node from the iterator and do loop again...
  @@ -285,7 +324,7 @@
        il.append(methodGen.nextNode());
        il.append(DUP);
        il.append(methodGen.storeCurrentNode());
  -     il.append(new IFNE(loop));
  +     il.append(new IFGT(loop));
   
        // Restore current node and current iterator from the stack
        il.append(methodGen.storeIterator());
  
  
  
  1.13      +22 -6     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/KeyCall.java
  
  Index: KeyCall.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/KeyCall.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- KeyCall.java      26 Mar 2003 17:39:33 -0000      1.12
  +++ KeyCall.java      1 Apr 2003 21:08:59 -0000       1.13
  @@ -70,7 +70,7 @@
   import org.apache.bcel.generic.BranchHandle;
   import org.apache.bcel.generic.ConstantPoolGen;
   import org.apache.bcel.generic.GOTO;
  -import org.apache.bcel.generic.IFNE;
  +import org.apache.bcel.generic.IFGT;
   import org.apache.bcel.generic.INVOKEINTERFACE;
   import org.apache.bcel.generic.INVOKESPECIAL;
   import org.apache.bcel.generic.INVOKEVIRTUAL;
  @@ -171,7 +171,8 @@
        // be added to the resulting node-set.
        _valueType = _value.typeCheck(stable);
   
  -     if (_valueType != Type.NodeSet && _valueType != Type.String) {
  +     if (_valueType != Type.NodeSet && _valueType != Type.String) 
  +     {
            _value = new CastExpr(_value, Type.String);
        }
   
  @@ -193,16 +194,22 @@
                          MethodGenerator methodGen) {
        final ConstantPoolGen cpg = classGen.getConstantPool();
        final InstructionList il = methodGen.getInstructionList();
  +                                              
  +     final int getNodeHandle = cpg.addInterfaceMethodref(DOM_INTF,
  +                                                        "getNodeHandle",
  +                                                        "(I)"+NODE_SIG);     
   
        // Wrap the KeyIndex (iterator) inside a duplicate filter iterator
        // to pre-read the indexed nodes and cache them.
        final int dupInit = cpg.addMethodref(DUP_FILTERED_ITERATOR,
                                             "<init>",
                                             "("+NODE_ITERATOR_SIG+")V");
  -     il.append(new NEW(cpg.addClass(DUP_FILTERED_ITERATOR)));
  +                                          
  +     il.append(new NEW(cpg.addClass(DUP_FILTERED_ITERATOR)));        
        il.append(DUP);
        translateCall(classGen, methodGen);
        il.append(new INVOKESPECIAL(dupInit));
  +     
       }
   
       /**
  @@ -218,7 +225,7 @@
   
        // Returns the string value for a node in the DOM
        final int getNodeValue = cpg.addInterfaceMethodref(DOM_INTF,
  -                                                        "getNodeValue",
  +                                                        GET_NODE_VALUE,
                                                           "(I)"+STRING_SIG);
   
        // Returns the KeyIndex object of a given name
  @@ -244,6 +251,12 @@
        final int indexConstructor = cpg.addMethodref(TRANSLET_CLASS,
                                                      "createKeyIndex",
                                                      "()"+KEY_INDEX_SIG);
  +                                                   
  +     // KeyIndex.setDom(Dom) => void
  +     final int keyDom = cpg.addMethodref(XSLT_PACKAGE + ".dom.KeyIndex",
  +                                      "setDom",
  +                                      "("+DOM_INTF_SIG+")V");                
                 
  +                                                   
        
        // This local variable holds the index/iterator we will return
        final LocalVariableGen returnIndex =
  @@ -273,6 +286,9 @@
            // Create the KeyIndex object (the iterator) we'll return
            il.append(classGen.loadTranslet());
            il.append(new INVOKEVIRTUAL(indexConstructor));
  +         il.append(DUP);
  +         il.append(methodGen.loadDOM());
  +         il.append(new INVOKEVIRTUAL(keyDom));
            il.append(new ASTORE(returnIndex.getIndex()));
   
            // Initialise the index specified in the first parameter of key()
  @@ -321,7 +337,7 @@
            il.append(methodGen.nextNode());
            il.append(DUP);
            il.append(methodGen.storeCurrentNode());
  -         il.append(new IFNE(loop));
  +         il.append(new IFGT(loop));
   
            // LOOP ENDS HERE
   
  
  
  
  1.10      +21 -10    
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Message.java
  
  Index: Message.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Message.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- Message.java      21 Feb 2003 17:28:51 -0000      1.9
  +++ Message.java      1 Apr 2003 21:08:59 -0000       1.10
  @@ -65,7 +65,6 @@
   package org.apache.xalan.xsltc.compiler;
   
   import org.apache.bcel.generic.ConstantPoolGen;
  -import org.apache.bcel.generic.INVOKEINTERFACE;
   import org.apache.bcel.generic.INVOKESPECIAL;
   import org.apache.bcel.generic.INVOKEVIRTUAL;
   import org.apache.bcel.generic.InstructionList;
  @@ -114,7 +113,7 @@
                   // Push current output handler onto the stack
                   il.append(methodGen.loadHandler());
   
  -                // Replace the current output handler by a StreamXMLOutput
  +                // Replace the current output handler by a ToXMLStream
                   il.append(new NEW(cpg.addClass(STREAM_XML_OUTPUT)));
                   il.append(methodGen.storeHandler());
   
  @@ -125,19 +124,31 @@
                   il.append(new INVOKESPECIAL(
                       cpg.addMethodref(STRING_WRITER, "<init>", "()V")));
   
  -                // Load StreamXMLOutput
  +                // Load ToXMLStream
                   il.append(methodGen.loadHandler());
  -                il.append(SWAP);
  -                il.append(new PUSH(cpg, "UTF-8"));   // other encodings?
                   il.append(new INVOKESPECIAL(
                       cpg.addMethodref(STREAM_XML_OUTPUT, "<init>",
  -                    "(" + WRITER_SIG + STRING_SIG + ")V")));
  +                                     "()V")));
  +
  +                // Invoke output.setWriter(STRING_WRITER)
  +                il.append(methodGen.loadHandler());
  +                il.append(SWAP);
  +                il.append(new INVOKEVIRTUAL(
  +                    cpg.addMethodref(OUTPUT_BASE, "setWriter",
  +                                     "("+WRITER_SIG+")V")));
  +
  +                // Invoke output.setEncoding("UTF-8")
  +                il.append(methodGen.loadHandler());
  +                il.append(new PUSH(cpg, "UTF-8"));   // other encodings?
  +                il.append(new INVOKEVIRTUAL(
  +                    cpg.addMethodref(OUTPUT_BASE, "setEncoding",
  +                                     "("+STRING_SIG+")V")));
   
  -                // Invoke output.omitHeader(true)
  +                // Invoke output.setOmitXMLDeclaration(true)
                   il.append(methodGen.loadHandler());
                   il.append(ICONST_1);
                   il.append(new INVOKEVIRTUAL(
  -                    cpg.addMethodref(OUTPUT_BASE, "omitHeader",
  +                    cpg.addMethodref(OUTPUT_BASE, "setOmitXMLDeclaration",
                                        "(Z)V")));
   
                   il.append(methodGen.loadHandler());
  @@ -156,7 +167,7 @@
                   // Call toString() on StringWriter
                   il.append(new INVOKEVIRTUAL(
                       cpg.addMethodref(STRING_WRITER, "toString",
  -                    "()" + STRING_SIG)));
  +                                     "()" + STRING_SIG)));
   
                   // Restore old output handler
                   il.append(SWAP);
  
  
  
  1.29      +117 -66   
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Mode.java
  
  Index: Mode.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Mode.java,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- Mode.java 30 Jan 2003 18:46:01 -0000      1.28
  +++ Mode.java 1 Apr 2003 21:08:59 -0000       1.29
  @@ -74,7 +74,7 @@
   import org.apache.bcel.generic.ConstantPoolGen;
   import org.apache.bcel.generic.DUP;
   import org.apache.bcel.generic.GOTO_W;
  -import org.apache.bcel.generic.IFEQ;
  +import org.apache.bcel.generic.IFLT;
   import org.apache.bcel.generic.ILOAD;
   import org.apache.bcel.generic.INVOKEINTERFACE;
   import org.apache.bcel.generic.INVOKEVIRTUAL;
  @@ -91,6 +91,7 @@
   import org.apache.xalan.xsltc.compiler.util.NamedMethodGenerator;
   import org.apache.xalan.xsltc.compiler.util.Util;
   import org.apache.xalan.xsltc.dom.Axis;
  +import org.apache.xml.dtm.DTM;
   
   /**
    * Mode gathers all the templates belonging to a given mode; 
  @@ -483,23 +484,23 @@
        * sequences, and of "@*" to all attribute test sequences.
        */
       private void prepareTestSequences() {
  -     final Vector starGroup = _patternGroups[DOM.ELEMENT];
  -     final Vector atStarGroup = _patternGroups[DOM.ATTRIBUTE];
  +     final Vector starGroup = _patternGroups[DTM.ELEMENT_NODE];
  +     final Vector atStarGroup = _patternGroups[DTM.ATTRIBUTE_NODE];
   
        // Complete test sequence for "text()" with "child::node()"
  -     completeTestSequences(DOM.TEXT, _childNodeGroup);
  +     completeTestSequences(DTM.TEXT_NODE, _childNodeGroup);
        
        // Complete test sequence for "*" with "child::node()"
  -     completeTestSequences(DOM.ELEMENT, _childNodeGroup);
  +     completeTestSequences(DTM.ELEMENT_NODE, _childNodeGroup);
        
        // Complete test sequence for "pi()" with "child::node()"
  -     completeTestSequences(DOM.PROCESSING_INSTRUCTION, _childNodeGroup);
  +     completeTestSequences(DTM.PROCESSING_INSTRUCTION_NODE, _childNodeGroup);
        
        // Complete test sequence for "comment()" with "child::node()"
  -     completeTestSequences(DOM.COMMENT, _childNodeGroup);
  +     completeTestSequences(DTM.COMMENT_NODE, _childNodeGroup);
        
        // Complete test sequence for "@*" with "attribute::node()"
  -     completeTestSequences(DOM.ATTRIBUTE, _attribNodeGroup);
  +     completeTestSequences(DTM.ATTRIBUTE_NODE, _attribNodeGroup);
   
        final Vector names = _stylesheet.getXSLTC().getNamesIndex();
        if (starGroup != null || atStarGroup != null || 
  @@ -508,10 +509,10 @@
            final int n = _patternGroups.length;
   
            // Complete test sequence for user-defined types
  -         for (int i = DOM.NTYPES; i < n; i++) {
  +         for (int i = DTM.NTYPES; i < n; i++) {
                if (_patternGroups[i] == null) continue;
   
  -             final String name = (String) names.elementAt(i - DOM.NTYPES);
  +             final String name = (String) names.elementAt(i - DTM.NTYPES);
   
                if (isAttributeName(name)) {
                    // If an attribute then copy "@*" to its test sequence
  @@ -530,7 +531,7 @@
            }
        }
   
  -     _testSeq = new TestSeq[DOM.NTYPES + names.size()];
  +     _testSeq = new TestSeq[DTM.NTYPES + names.size()];
        
        final int n = _patternGroups.length;
        for (int i = 0; i < n; i++) {
  @@ -746,9 +747,9 @@
            }
   
            // Add test sequences for known namespace types
  -         for (int i = DOM.NTYPES; i < (DOM.NTYPES+namesCount); i++) {
  +         for (int i = DTM.NTYPES; i < (DTM.NTYPES+namesCount); i++) {
                if ((isNamespace[i]) && (isAttribute[i] == attrFlag)) {
  -                 String name = (String)names.elementAt(i-DOM.NTYPES);
  +                 String name = (String)names.elementAt(i-DTM.NTYPES);
                    String namespace = name.substring(0,name.lastIndexOf(':'));
                    final int type = xsltc.registerNamespace(namespace);
                    
  @@ -796,7 +797,7 @@
        argTypes[0] = Util.getJCRefType(DOM_INTF_SIG);
        argTypes[1] = Util.getJCRefType(NODE_ITERATOR_SIG);
        argTypes[2] = Util.getJCRefType(TRANSLET_OUTPUT_SIG);
  -
  +     
        final String[] argNames = new String[3];
        argNames[0] = DOCUMENT_PNAME;
        argNames[1] = ITERATOR_PNAME;
  @@ -833,7 +834,7 @@
   
        // The body of this code can get very large - large than can be handled
        // by a single IFNE(body.getStart()) instruction - need workaround:
  -        final BranchHandle ifeq = ilLoop.append(new IFEQ(null));
  +        final BranchHandle ifeq = ilLoop.append(new IFLT(null));
        final BranchHandle loop = ilLoop.append(new GOTO_W(null));
        ifeq.setTarget(ilLoop.append(RETURN));  // applyTemplates() ends here!
        final InstructionHandle ihLoop = ilLoop.getStart();
  @@ -849,7 +850,7 @@
        InstructionHandle ihText = ilText.getStart();
   
        // Distinguish attribute/element/namespace tests for further processing
  -     final int[] types = new int[DOM.NTYPES + names.size()];
  +     final int[] types = new int[DTM.NTYPES + names.size()];
        for (int i = 0; i < types.length; i++) {
            types[i] = i;
        }
  @@ -859,21 +860,21 @@
        final boolean[] isNamespace = new boolean[types.length];
        for (int i = 0; i < names.size(); i++) {
            final String name = (String)names.elementAt(i);
  -         isAttribute[i + DOM.NTYPES] = isAttributeName(name);
  -         isNamespace[i + DOM.NTYPES] = isNamespaceName(name);
  +         isAttribute[i + DTM.NTYPES] = isAttributeName(name);
  +         isNamespace[i + DTM.NTYPES] = isNamespaceName(name);
        }
   
        // Compile all templates - regardless of pattern type
        compileTemplates(classGen, methodGen, ihLoop);
   
        // Handle template with explicit "*" pattern
  -     final TestSeq elemTest = _testSeq[DOM.ELEMENT];
  +     final TestSeq elemTest = _testSeq[DTM.ELEMENT_NODE];
        InstructionHandle ihElem = ihRecurse;
        if (elemTest != null)
            ihElem = elemTest.compile(classGen, methodGen, ihRecurse);
   
        // Handle template with explicit "@*" pattern
  -     final TestSeq attrTest = _testSeq[DOM.ATTRIBUTE];
  +     final TestSeq attrTest = _testSeq[DTM.ATTRIBUTE_NODE];
        InstructionHandle ihAttr = ihText;
        if (attrTest != null)
            ihAttr = attrTest.compile(classGen, methodGen, ihAttr);
  @@ -908,7 +909,7 @@
            }
   
            // Compare priorities of node() and text()
  -         final TestSeq textTest = _testSeq[DOM.TEXT];
  +         final TestSeq textTest = _testSeq[DTM.TEXT_NODE];
            double textPrio = (0 - Double.MAX_VALUE);
            int    textPos  = Integer.MIN_VALUE;
   
  @@ -920,7 +921,7 @@
                (textPrio == nodePrio && textPos < nodePos)) 
            {
                ihText = _childNodeTestSeq.compile(classGen, methodGen, ihLoop);
  -             _testSeq[DOM.TEXT] = _childNodeTestSeq;
  +             _testSeq[DTM.TEXT_NODE] = _childNodeTestSeq;
            }
        }
   
  @@ -940,7 +941,7 @@
   
        // Handle templates with "ns:elem" or "ns:@attr" pattern
        final InstructionHandle[] targets = new InstructionHandle[types.length];
  -     for (int i = DOM.NTYPES; i < targets.length; i++) {
  +     for (int i = DTM.NTYPES; i < targets.length; i++) {
            final TestSeq testSeq = _testSeq[i];
            // Jump straight to namespace tests ?
            if (isNamespace[i]) {
  @@ -965,43 +966,67 @@
   
   
        // Handle pattern with match on root node - default: traverse children
  -     targets[DOM.ROOT] = _rootPattern != null
  +     targets[DTM.ROOT_NODE] = _rootPattern != null
            ? getTemplateInstructionHandle(_rootPattern.getTemplate())
            : ihRecurse;
  -     
  +
  +        // Handle pattern with match on root node - default: traverse 
children
  +     targets[DTM.DOCUMENT_NODE] = _rootPattern != null
  +         ? getTemplateInstructionHandle(_rootPattern.getTemplate())
  +         : ihRecurse;
  +
        // Handle any pattern with match on text nodes - default: output text
  -     targets[DOM.TEXT] = _testSeq[DOM.TEXT] != null
  -         ? _testSeq[DOM.TEXT].compile(classGen, methodGen, ihText)
  +     targets[DTM.TEXT_NODE] = _testSeq[DTM.TEXT_NODE] != null
  +         ? _testSeq[DTM.TEXT_NODE].compile(classGen, methodGen, ihText)
            : ihText;
   
        // This DOM-type is not in use - default: process next node
  -     targets[DOM.NAMESPACE] = ihLoop;
  +     targets[DTM.NAMESPACE_NODE] = ihLoop;
   
        // Match unknown element in DOM - default: check for namespace match
  -     targets[DOM.ELEMENT] = elemNamespaceHandle;
  +     targets[DTM.ELEMENT_NODE] = elemNamespaceHandle;
   
        // Match unknown attribute in DOM - default: check for namespace match
  -     targets[DOM.ATTRIBUTE] = attrNamespaceHandle;
  +     targets[DTM.ATTRIBUTE_NODE] = attrNamespaceHandle;
   
        // Match on processing instruction - default: process next node
        InstructionHandle ihPI = ihLoop;
        if (_childNodeTestSeq != null) ihPI = ihElem;
  -     if (_testSeq[DOM.PROCESSING_INSTRUCTION] != null)
  -         targets[DOM.PROCESSING_INSTRUCTION] =
  -             _testSeq[DOM.PROCESSING_INSTRUCTION].
  +     if (_testSeq[DTM.PROCESSING_INSTRUCTION_NODE] != null)
  +         targets[DTM.PROCESSING_INSTRUCTION_NODE] =
  +             _testSeq[DTM.PROCESSING_INSTRUCTION_NODE].
                compile(classGen, methodGen, ihPI);
        else
  -         targets[DOM.PROCESSING_INSTRUCTION] = ihPI;
  +         targets[DTM.PROCESSING_INSTRUCTION_NODE] = ihPI;
        
        // Match on comments - default: process next node
        InstructionHandle ihComment = ihLoop;
        if (_childNodeTestSeq != null) ihComment = ihElem;
  -     targets[DOM.COMMENT] = _testSeq[DOM.COMMENT] != null
  -         ? _testSeq[DOM.COMMENT].compile(classGen, methodGen, ihComment)
  +     targets[DTM.COMMENT_NODE] = _testSeq[DTM.COMMENT_NODE] != null
  +         ? _testSeq[DTM.COMMENT_NODE].compile(classGen, methodGen, ihComment)
            : ihComment;
  +         
  +         // This DOM-type is not in use - default: process next node
  +     targets[DTM.CDATA_SECTION_NODE] = ihLoop;
  +
  +     // This DOM-type is not in use - default: process next node
  +     targets[DTM.DOCUMENT_FRAGMENT_NODE] = ihLoop;
  +     
  +     // This DOM-type is not in use - default: process next node
  +     targets[DTM.DOCUMENT_TYPE_NODE] = ihLoop;
  +
  +     // This DOM-type is not in use - default: process next node
  +     targets[DTM.ENTITY_NODE] = ihLoop;
  +
  +     // This DOM-type is not in use - default: process next node
  +     targets[DTM.ENTITY_REFERENCE_NODE] = ihLoop;
  +     
  +     // This DOM-type is not in use - default: process next node
  +     targets[DTM.NOTATION_NODE] = ihLoop;
  +
   
        // Now compile test sequences for various match patterns:
  -     for (int i = DOM.NTYPES; i < targets.length; i++) {
  +     for (int i = DTM.NTYPES; i < targets.length; i++) {
            final TestSeq testSeq = _testSeq[i];
            // Jump straight to namespace tests ?
            if ((testSeq == null) || (isNamespace[i])) {
  @@ -1025,7 +1050,8 @@
   
        // Append first code in applyTemplates() - get type of current node
        final int getType = cpg.addInterfaceMethodref(DOM_INTF,
  -                                                   "getType", "(I)I");
  +                                                   "getExpandedTypeID",
  +                                                      "(I)I");
        body.append(methodGen.loadDOM());
        body.append(new ILOAD(_currentIndex));
        body.append(new INVOKEINTERFACE(getType, 2));
  @@ -1167,7 +1193,7 @@
   
        // The body of this code can get very large - large than can be handled
        // by a single IFNE(body.getStart()) instruction - need workaround:
  -        final BranchHandle ifeq = ilLoop.append(new IFEQ(null));
  +        final BranchHandle ifeq = ilLoop.append(new IFLT(null));
        final BranchHandle loop = ilLoop.append(new GOTO_W(null));
        ifeq.setTarget(ilLoop.append(RETURN)); // applyTemplates() ends here!
        final InstructionHandle ihLoop = ilLoop.getStart();
  @@ -1183,7 +1209,7 @@
        InstructionHandle ihText = ilText.getStart();
   
        // Distinguish attribute/element/namespace tests for further processing
  -     final int[] types = new int[DOM.NTYPES + names.size()];
  +     final int[] types = new int[DTM.NTYPES + names.size()];
        for (int i = 0; i < types.length; i++) {
            types[i] = i;
        }
  @@ -1192,22 +1218,22 @@
        final boolean[] isNamespace = new boolean[types.length];
        for (int i = 0; i < names.size(); i++) {
            final String name = (String)names.elementAt(i);
  -         isAttribute[i+DOM.NTYPES] = isAttributeName(name);
  -         isNamespace[i+DOM.NTYPES] = isNamespaceName(name);
  +         isAttribute[i+DTM.NTYPES] = isAttributeName(name);
  +         isNamespace[i+DTM.NTYPES] = isNamespaceName(name);
        }
   
        // Compile all templates - regardless of pattern type
        compileTemplateCalls(classGen, methodGen, ihLoop, min, max);
   
        // Handle template with explicit "*" pattern
  -     final TestSeq elemTest = _testSeq[DOM.ELEMENT];
  +     final TestSeq elemTest = _testSeq[DTM.ELEMENT_NODE];
        InstructionHandle ihElem = ihRecurse;
        if (elemTest != null) {
            ihElem = elemTest.compile(classGen, methodGen, ihLoop);
        }
   
        // Handle template with explicit "@*" pattern
  -     final TestSeq attrTest = _testSeq[DOM.ATTRIBUTE];
  +     final TestSeq attrTest = _testSeq[DTM.ATTRIBUTE_NODE];
        InstructionHandle ihAttr = ihLoop;
        if (attrTest != null) {
            ihAttr = attrTest.compile(classGen, methodGen, ihAttr);
  @@ -1244,7 +1270,7 @@
            }
   
            // Compare priorities of node() and text()
  -         final TestSeq textTest = _testSeq[DOM.TEXT];
  +         final TestSeq textTest = _testSeq[DTM.TEXT_NODE];
            double textPrio = (0 - Double.MAX_VALUE);
            int    textPos  = Integer.MIN_VALUE;
   
  @@ -1257,7 +1283,7 @@
                (textPrio == nodePrio && textPos < nodePos)) 
            {
                ihText = _childNodeTestSeq.compile(classGen, methodGen, ihLoop);
  -             _testSeq[DOM.TEXT] = _childNodeTestSeq;
  +             _testSeq[DTM.TEXT_NODE] = _childNodeTestSeq;
            }
        }
   
  @@ -1277,7 +1303,7 @@
   
        // Handle templates with "ns:elem" or "ns:@attr" pattern
        final InstructionHandle[] targets = new InstructionHandle[types.length];
  -     for (int i = DOM.NTYPES; i < targets.length; i++) {
  +     for (int i = DTM.NTYPES; i < targets.length; i++) {
            final TestSeq testSeq = _testSeq[i];
            // Jump straight to namespace tests ?
            if (isNamespace[i]) {
  @@ -1301,45 +1327,69 @@
        }
   
        // Handle pattern with match on root node - default: traverse children
  -     targets[DOM.ROOT] = _rootPattern != null
  +     targets[DTM.ROOT_NODE] = _rootPattern != null
            ? getTemplateInstructionHandle(_rootPattern.getTemplate())
            : ihRecurse;
  +     // Handle pattern with match on root node - default: traverse children
  +     targets[DTM.DOCUMENT_NODE] = _rootPattern != null
  +         ? getTemplateInstructionHandle(_rootPattern.getTemplate())
  +         : ihRecurse;    // %HZ%:  Was ihLoop in XSLTC_DTM branch
        
        // Handle any pattern with match on text nodes - default: loop
  -     targets[DOM.TEXT] = _testSeq[DOM.TEXT] != null
  -         ? _testSeq[DOM.TEXT].compile(classGen, methodGen, ihText)
  +     targets[DTM.TEXT_NODE] = _testSeq[DTM.TEXT_NODE] != null
  +         ? _testSeq[DTM.TEXT_NODE].compile(classGen, methodGen, ihText)
            : ihText;
   
        // This DOM-type is not in use - default: process next node
  -     targets[DOM.NAMESPACE] = ihLoop;
  +     targets[DTM.NAMESPACE_NODE] = ihLoop;
   
        // Match unknown element in DOM - default: check for namespace match
  -     targets[DOM.ELEMENT] = elemNamespaceHandle;
  +     targets[DTM.ELEMENT_NODE] = elemNamespaceHandle;
   
        // Match unknown attribute in DOM - default: check for namespace match
  -     targets[DOM.ATTRIBUTE] = attrNamespaceHandle;
  +     targets[DTM.ATTRIBUTE_NODE] = attrNamespaceHandle;
   
        // Match on processing instruction - default: loop
        InstructionHandle ihPI = ihLoop;
        if (_childNodeTestSeq != null) ihPI = ihElem;
  -     if (_testSeq[DOM.PROCESSING_INSTRUCTION] != null) {
  -         targets[DOM.PROCESSING_INSTRUCTION] =
  -             _testSeq[DOM.PROCESSING_INSTRUCTION].
  +     if (_testSeq[DTM.PROCESSING_INSTRUCTION_NODE] != null) {
  +         targets[DTM.PROCESSING_INSTRUCTION_NODE] =
  +             _testSeq[DTM.PROCESSING_INSTRUCTION_NODE].
                compile(classGen, methodGen, ihPI);
        }
        else {
  -         targets[DOM.PROCESSING_INSTRUCTION] = ihPI;
  +         targets[DTM.PROCESSING_INSTRUCTION_NODE] = ihPI;
        }
        
        // Match on comments - default: process next node
        InstructionHandle ihComment = ihLoop;
        if (_childNodeTestSeq != null) ihComment = ihElem;
  -     targets[DOM.COMMENT] = _testSeq[DOM.COMMENT] != null
  -         ? _testSeq[DOM.COMMENT].compile(classGen, methodGen, ihComment)
  +     targets[DTM.COMMENT_NODE] = _testSeq[DTM.COMMENT_NODE] != null
  +         ? _testSeq[DTM.COMMENT_NODE].compile(classGen, methodGen, ihComment)
            : ihComment;
  +         
  +             // This DOM-type is not in use - default: process next node
  +     targets[DTM.CDATA_SECTION_NODE] = ihLoop;
  +
  +     // This DOM-type is not in use - default: process next node
  +     targets[DTM.DOCUMENT_FRAGMENT_NODE] = ihLoop;
  +     
  +     // This DOM-type is not in use - default: process next node
  +     targets[DTM.DOCUMENT_TYPE_NODE] = ihLoop;
  +
  +     // This DOM-type is not in use - default: process next node
  +     targets[DTM.ENTITY_NODE] = ihLoop;
  +
  +     // This DOM-type is not in use - default: process next node
  +     targets[DTM.ENTITY_REFERENCE_NODE] = ihLoop;
  +     
  +     // This DOM-type is not in use - default: process next node
  +     targets[DTM.NOTATION_NODE] = ihLoop;
  +
  +
   
        // Now compile test sequences for various match patterns:
  -     for (int i = DOM.NTYPES; i < targets.length; i++) {
  +     for (int i = DTM.NTYPES; i < targets.length; i++) {
            final TestSeq testSeq = _testSeq[i];
            // Jump straight to namespace tests ?
            if ((testSeq == null) || (isNamespace[i])) {
  @@ -1363,7 +1413,8 @@
   
        // Append first code in applyTemplates() - get type of current node
        final int getType = cpg.addInterfaceMethodref(DOM_INTF,
  -                                                   "getType", "(I)I");
  +                                                   "getExpandedTypeID",
  +                                                      "(I)I");
        body.append(methodGen.loadDOM());
        body.append(new ILOAD(_currentIndex));
        body.append(new INVOKEINTERFACE(getType, 2));
  @@ -1408,8 +1459,8 @@
        * Peephole optimization: Remove sequences of [ALOAD, POP].
        */
       private void peepHoleOptimization(MethodGenerator methodGen) {
  -     InstructionList il = methodGen.getInstructionList();
  -     InstructionFinder find = new InstructionFinder(il);
  +    InstructionList il = methodGen.getInstructionList();
  +    InstructionFinder find = new InstructionFinder(il);
        InstructionHandle ih;
        String pattern;
   
  @@ -1447,7 +1498,7 @@
                   // TODO: move target down into the list
               }
           }
  -
  +        
           // Replace sequences of ALOAD_1, ALOAD_1 with ALOAD_1, DUP 
        pattern = "`ALOAD_1'`ALOAD_1'`Instruction'";
           for(Iterator iter=find.search(pattern); iter.hasNext();){
  @@ -1464,7 +1515,7 @@
                   // TODO: move target down into the list
               }
           }
  -
  +        
       }
   
       public InstructionHandle getTemplateInstructionHandle(Template template) 
{
  
  
  
  1.10      +5 -4      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/NameBase.java
  
  Index: NameBase.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/NameBase.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- NameBase.java     30 Jan 2003 18:46:01 -0000      1.9
  +++ NameBase.java     1 Apr 2003 21:08:59 -0000       1.10
  @@ -150,9 +150,10 @@
            il.append(new INVOKESTATIC(cpg.addMethodref
                                       (BASIS_LIBRARY_CLASS,
                                        "referenceToNodeSet",
  -                                     "(Ljava/lang/Object;)" +
  -                                     "Lorg/apache/xalan/xsltc/" +
  -                                     "NodeIterator;")));
  +                                     "("
  +                                     + OBJECT_SIG
  +                                     + ")"
  +                                     + NODE_ITERATOR_SIG)));
            il.append(methodGen.nextNode());
        }
        // Function was called with node-set parameter
  
  
  
  1.3       +9 -8      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/NodeTest.java
  
  Index: NodeTest.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/NodeTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- NodeTest.java     27 Jan 2003 18:44:38 -0000      1.2
  +++ NodeTest.java     1 Apr 2003 21:09:00 -0000       1.3
  @@ -64,17 +64,18 @@
   package org.apache.xalan.xsltc.compiler;
   
   import org.apache.xalan.xsltc.DOM;
  +import org.apache.xml.dtm.DTM;
   
   public interface NodeTest {
  -    public static final int TEXT      = DOM.TEXT;
  -    public static final int COMMENT   = DOM.COMMENT;
  -    public static final int PI        = DOM.PROCESSING_INSTRUCTION;
  -    public static final int ROOT      = DOM.ROOT;
  -    public static final int ELEMENT   = DOM.ELEMENT;
  -    public static final int ATTRIBUTE = DOM.ATTRIBUTE;
  +    public static final int TEXT      = DTM.TEXT_NODE;
  +    public static final int COMMENT   = DTM.COMMENT_NODE;
  +    public static final int PI        = DTM.PROCESSING_INSTRUCTION_NODE;
  +    public static final int ROOT      = DTM.DOCUMENT_NODE;
  +    public static final int ELEMENT   = DTM.ELEMENT_NODE;
  +    public static final int ATTRIBUTE = DTM.ATTRIBUTE_NODE;
       
       // generalized type
  -    public static final int GTYPE     = DOM.NTYPES;
  +    public static final int GTYPE     = DTM.NTYPES;
       
       public static final int ANODE     = DOM.FIRST_TYPE - 1;
   }
  
  
  
  1.22      +5 -4      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Output.java
  
  Index: Output.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Output.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- Output.java       30 Jan 2003 18:46:01 -0000      1.21
  +++ Output.java       1 Apr 2003 21:09:00 -0000       1.22
  @@ -79,7 +79,7 @@
   import org.apache.xalan.xsltc.compiler.util.ErrorMsg;
   import org.apache.xalan.xsltc.compiler.util.MethodGenerator;
   import org.apache.xalan.xsltc.compiler.util.Util;
  -import org.apache.xalan.xsltc.runtime.output.StreamOutput;
  +import org.apache.xml.serializer.Encodings;
   
   final class Output extends TopLevelElement {
   
  @@ -177,9 +177,10 @@
        else {
            try {
                // Create a write to verify encoding support
  +        String canonicalEncoding;
  +        canonicalEncoding = Encodings.convertMime2JavaEncoding(_encoding);
                OutputStreamWriter writer =
  -                 new OutputStreamWriter(System.out, 
  -                    StreamOutput.getCanonicalEncoding(_encoding));
  +                 new OutputStreamWriter(System.out, canonicalEncoding); 
            }
            catch (java.io.UnsupportedEncodingException e) {
                ErrorMsg msg = new ErrorMsg(ErrorMsg.UNSUPPORTED_ENCODING,
  
  
  
  1.22      +3 -3      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ParentLocationPath.java
  
  Index: ParentLocationPath.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ParentLocationPath.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- ParentLocationPath.java   30 Jan 2003 18:46:01 -0000      1.21
  +++ ParentLocationPath.java   1 Apr 2003 21:09:00 -0000       1.22
  @@ -69,12 +69,12 @@
   import org.apache.bcel.generic.INVOKEVIRTUAL;
   import org.apache.bcel.generic.InstructionList;
   import org.apache.bcel.generic.NEW;
  -import org.apache.xalan.xsltc.DOM;
   import org.apache.xalan.xsltc.compiler.util.ClassGenerator;
   import org.apache.xalan.xsltc.compiler.util.MethodGenerator;
   import org.apache.xalan.xsltc.compiler.util.Type;
   import org.apache.xalan.xsltc.compiler.util.TypeCheckError;
   import org.apache.xalan.xsltc.dom.Axis;
  +import org.apache.xml.dtm.DTM;
   
   final class ParentLocationPath extends RelativeLocationPath {
       private Expression _step;
  @@ -191,7 +191,7 @@
            // one attribute that matches the left step.
            if (_path instanceof Step) {
                int type = ((Step)_path).getNodeType();
  -             if (type == DOM.ATTRIBUTE) return true;
  +             if (type == DTM.ATTRIBUTE_NODE) return true;
            }
        }
   
  
  
  
  1.28      +26 -14    
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Predicate.java
  
  Index: Predicate.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Predicate.java,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- Predicate.java    30 Jan 2003 18:46:01 -0000      1.27
  +++ Predicate.java    1 Apr 2003 21:09:00 -0000       1.28
  @@ -266,18 +266,8 @@
                (parent instanceof Pattern) ||
                (parent instanceof FilterExpr)) {
   
  -             final QName position = 
getParser().getQNameIgnoreDefaultNs("position");
  -             final PositionCall positionCall = new PositionCall(position);
  -             positionCall.setParser(getParser());
  -             positionCall.setParent(this);
  -
  -             _exp = new EqualityExpr(EqualityExpr.EQ, positionCall, _exp);
  -             if (_exp.typeCheck(stable) != Type.Boolean) {
  -                 _exp = new CastExpr(_exp, Type.Boolean);
  -             }
  -
  -             if (parent instanceof Pattern) {
  -                 _nthPositionFilter = true;
  +             if (parent instanceof Pattern && !(_exp instanceof LastCall)) {
  +                 _nthPositionFilter = _canOptimize;
                }
                else if (parent instanceof FilterExpr) {
                    FilterExpr filter = (FilterExpr)parent;
  @@ -298,7 +288,29 @@
                    if (_canOptimize)
                        _nthPositionFilter = true;
                }
  -             return _type = Type.Boolean;
  +
  +                // If this case can be optimized, leave the expression as
  +                // an integer.  Otherwise, turn it into a comparison with
  +                // the position() function.
  +                if (_nthPositionFilter) {
  +                   return _type = Type.NodeSet;
  +                } else {
  +                   final QName position =
  +                                
getParser().getQNameIgnoreDefaultNs("position");
  +
  +                   final PositionCall positionCall =
  +                                               new PositionCall(position);
  +                   positionCall.setParser(getParser());
  +                   positionCall.setParent(this);
  +
  +                   _exp = new EqualityExpr(EqualityExpr.EQ, positionCall,
  +                                            _exp);
  +                   if (_exp.typeCheck(stable) != Type.Boolean) {
  +                       _exp = new CastExpr(_exp, Type.Boolean);
  +                   }
  +
  +                   return _type = Type.Boolean;
  +                }
            }
            // Use NthPositionIterator to handle [position()] or [a]
            else {
  
  
  
  1.6       +6 -5      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ProcessingInstructionPattern.java
  
  Index: ProcessingInstructionPattern.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ProcessingInstructionPattern.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ProcessingInstructionPattern.java 17 Mar 2003 20:24:21 -0000      1.5
  +++ ProcessingInstructionPattern.java 1 Apr 2003 21:09:00 -0000       1.6
  @@ -72,12 +72,12 @@
   import org.apache.bcel.generic.InstructionHandle;
   import org.apache.bcel.generic.InstructionList;
   import org.apache.bcel.generic.PUSH;
  -import org.apache.xalan.xsltc.DOM;
   import org.apache.xalan.xsltc.compiler.util.ClassGenerator;
   import org.apache.xalan.xsltc.compiler.util.MethodGenerator;
   import org.apache.xalan.xsltc.compiler.util.Type;
   import org.apache.xalan.xsltc.compiler.util.TypeCheckError;
   import org.apache.xalan.xsltc.dom.Axis;
  +import org.apache.xml.dtm.DTM;
   
   final class ProcessingInstructionPattern extends StepPattern {
   
  @@ -88,7 +88,7 @@
        * Handles calls with no parameter (current node is implicit parameter).
        */
       public ProcessingInstructionPattern(String name) {
  -     super(Axis.CHILD, DOM.PROCESSING_INSTRUCTION, null);
  +     super(Axis.CHILD, DTM.PROCESSING_INSTRUCTION_NODE, null);
        _name = name;
        //if (_name.equals("*")) _typeChecked = true; no wildcard allowed!
       }
  @@ -148,11 +148,12 @@
        if (!_typeChecked) {
            il.append(methodGen.loadCurrentNode());
            final int getType = cpg.addInterfaceMethodref(DOM_INTF,
  -                                                       "getType", "(I)I");
  +                                                       "getExpandedTypeID",
  +                                                          "(I)I");
            il.append(methodGen.loadDOM());
            il.append(methodGen.loadCurrentNode());
            il.append(new INVOKEINTERFACE(getType, 2));
  -         il.append(new PUSH(cpg, DOM.PROCESSING_INSTRUCTION));
  +         il.append(new PUSH(cpg, DTM.PROCESSING_INSTRUCTION_NODE));
            _falseList.add(il.append(new IF_ICMPEQ(null)));
        }
   
  
  
  
  1.43      +4 -3      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Step.java
  
  Index: Step.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Step.java,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- Step.java 30 Jan 2003 18:46:02 -0000      1.42
  +++ Step.java 1 Apr 2003 21:09:00 -0000       1.43
  @@ -80,6 +80,7 @@
   import org.apache.xalan.xsltc.compiler.util.Type;
   import org.apache.xalan.xsltc.compiler.util.TypeCheckError;
   import org.apache.xalan.xsltc.dom.Axis;
  +import org.apache.xml.dtm.DTM;
   
   final class Step extends RelativeLocationPath {
   
  @@ -324,8 +325,8 @@
                String name = null;
                int star = 0;
                
  -             if (_nodeType >= DOM.NTYPES) {
  -                 name = (String)ni.elementAt(_nodeType-DOM.NTYPES);
  +             if (_nodeType >= DTM.NTYPES) {
  +                 name = (String)ni.elementAt(_nodeType-DTM.NTYPES);
                    star = name.lastIndexOf('*');
                }
                
  
  
  
  1.22      +49 -37    
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.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- StepPattern.java  30 Jan 2003 18:46:02 -0000      1.21
  +++ StepPattern.java  1 Apr 2003 21:09:00 -0000       1.22
  @@ -74,7 +74,7 @@
   import org.apache.bcel.generic.GETFIELD;
   import org.apache.bcel.generic.GOTO;
   import org.apache.bcel.generic.GOTO_W;
  -import org.apache.bcel.generic.IFEQ;
  +import org.apache.bcel.generic.IFLT;
   import org.apache.bcel.generic.IFNE;
   import org.apache.bcel.generic.IFNONNULL;
   import org.apache.bcel.generic.IF_ICMPEQ;
  @@ -90,13 +90,13 @@
   import org.apache.bcel.generic.NEW;
   import org.apache.bcel.generic.PUSH;
   import org.apache.bcel.generic.PUTFIELD;
  -import org.apache.xalan.xsltc.DOM;
   import org.apache.xalan.xsltc.compiler.util.ClassGenerator;
   import org.apache.xalan.xsltc.compiler.util.MethodGenerator;
   import org.apache.xalan.xsltc.compiler.util.Type;
   import org.apache.xalan.xsltc.compiler.util.TypeCheckError;
   import org.apache.xalan.xsltc.compiler.util.Util;
   import org.apache.xalan.xsltc.dom.Axis;
  +import org.apache.xml.dtm.DTM;
   
   class StepPattern extends RelativePathPattern {
   
  @@ -203,7 +203,8 @@
   
        for (int i = 0; i < n && noContext; i++) {
            final Predicate pred = (Predicate)_predicates.elementAt(i);
  -         if (pred.getExpr().hasPositionCall()) {
  +         if (pred.getExpr().hasPositionCall()
  +                || pred.isNthPositionFilter()) {
                noContext = false;
            }
        }
  @@ -222,33 +223,43 @@
       }
   
       public Type typeCheck(SymbolTable stable) throws TypeCheckError {
  -     if (hasPredicates()) {
  -         // Type check all the predicates (e -> position() = e)
  -         final int n = _predicates.size();
  -         for (int i = 0; i < n; i++) {
  -             final Predicate pred = (Predicate)_predicates.elementAt(i);
  -             pred.typeCheck(stable);
  -         }
  -
  -         // Analyze context cases
  -         _contextCase = analyzeCases();
  -
  -         // Create an instance of Step to do the translation
  -         if (_contextCase == SIMPLE_CONTEXT) {
  -             _step = new Step(_axis, _nodeType, null);
  -             _step.setParser(getParser());
  -             _step.typeCheck(stable);
  -         }
  -         else if (_contextCase == GENERAL_CONTEXT) {
  -             final int len = _predicates.size();
  -             for (int i = 0; i < len; i++)
  -                 ((Predicate)_predicates.elementAt(i)).dontOptimize();
  -             _step = new Step(_axis, _nodeType, _predicates);
  -             _step.setParser(getParser());
  -             _step.typeCheck(stable);
  -         }
  -     }
  -     return _axis == Axis.CHILD ? Type.Element : Type.Attribute;
  +        if (hasPredicates()) {
  +            // Type check all the predicates (e -> position() = e)
  +            final int n = _predicates.size();
  +            for (int i = 0; i < n; i++) {
  +                final Predicate pred = (Predicate)_predicates.elementAt(i);
  +                pred.typeCheck(stable);
  +            }
  +
  +            // Analyze context cases
  +            _contextCase = analyzeCases();
  +
  +            Step step = null;
  +
  +            // Create an instance of Step to do the translation
  +            if (_contextCase == SIMPLE_CONTEXT) {
  +                Predicate pred = (Predicate)_predicates.elementAt(0);
  +                if (pred.isNthPositionFilter()) {
  +                    _contextCase = GENERAL_CONTEXT;
  +                    step = new Step(_axis, _nodeType, _predicates);
  +                } else {
  +                    step = new Step(_axis, _nodeType, null);
  +                }
  +            } else if (_contextCase == GENERAL_CONTEXT) {
  +                final int len = _predicates.size();
  +                for (int i = 0; i < len; i++) {
  +                    ((Predicate)_predicates.elementAt(i)).dontOptimize();
  +                }
  +
  +                step = new Step(_axis, _nodeType, _predicates);
  +            }
  +            if (step != null) {
  +                step.setParser(getParser());
  +                step.typeCheck(stable);
  +                _step = step;
  +            }
  +        }
  +        return _axis == Axis.CHILD ? Type.Element : Type.Attribute;
       }
   
       private void translateKernel(ClassGenerator classGen, 
  @@ -256,7 +267,7 @@
        final ConstantPoolGen cpg = classGen.getConstantPool();
        final InstructionList il = methodGen.getInstructionList();
        
  -     if (_nodeType == DOM.ELEMENT) {
  +     if (_nodeType == DTM.ELEMENT_NODE) {
            final int check = cpg.addInterfaceMethodref(DOM_INTF,
                                                        "isElement", "(I)Z");
            il.append(methodGen.loadDOM());
  @@ -268,7 +279,7 @@
            _falseList.add(il.append(new GOTO_W(null)));
            icmp.setTarget(il.append(NOP));
        }
  -     else if (_nodeType == DOM.ATTRIBUTE) {
  +     else if (_nodeType == DTM.ATTRIBUTE_NODE) {
            final int check = cpg.addInterfaceMethodref(DOM_INTF,
                                                        "isAttribute", "(I)Z");
            il.append(methodGen.loadDOM());
  @@ -282,11 +293,12 @@
        }
        else {
            // context node is on the stack
  -         final int getType = cpg.addInterfaceMethodref(DOM_INTF,
  -                                                       "getType", "(I)I");
  +         final int getEType = cpg.addInterfaceMethodref(DOM_INTF,
  +                                                       "getExpandedTypeID",
  +                                                          "(I)I");
            il.append(methodGen.loadDOM());
            il.append(SWAP);
  -         il.append(new INVOKEINTERFACE(getType, 2));
  +         il.append(new INVOKEINTERFACE(getEType, 2));
            il.append(new PUSH(cpg, _nodeType));
        
            // Need to allow for long jumps here
  @@ -489,7 +501,7 @@
        begin = il.append(methodGen.nextNode());
        il.append(DUP);
        il.append(new ISTORE(node2.getIndex()));
  -     _falseList.add(il.append(new IFEQ(null)));      // NodeIterator.END
  +     _falseList.add(il.append(new IFLT(null)));      // NodeIterator.END
   
        il.append(new ILOAD(node2.getIndex()));
        il.append(new ILOAD(node.getIndex()));
  
  
  
  1.46      +34 -26    
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.45
  retrieving revision 1.46
  diff -u -r1.45 -r1.46
  --- Stylesheet.java   30 Jan 2003 18:46:02 -0000      1.45
  +++ Stylesheet.java   1 Apr 2003 21:09:00 -0000       1.46
  @@ -72,7 +72,6 @@
   import java.util.Vector;
   
   import org.apache.bcel.generic.ANEWARRAY;
  -import org.apache.bcel.generic.ASTORE;
   import org.apache.bcel.generic.ConstantPoolGen;
   import org.apache.bcel.generic.FieldGen;
   import org.apache.bcel.generic.GETFIELD;
  @@ -88,13 +87,13 @@
   import org.apache.bcel.generic.PUTFIELD;
   import org.apache.bcel.generic.TargetLostException;
   import org.apache.bcel.util.InstructionFinder;
  -import org.apache.xalan.xsltc.DOM;
   import org.apache.xalan.xsltc.compiler.util.ClassGenerator;
   import org.apache.xalan.xsltc.compiler.util.ErrorMsg;
   import org.apache.xalan.xsltc.compiler.util.MethodGenerator;
   import org.apache.xalan.xsltc.compiler.util.Type;
   import org.apache.xalan.xsltc.compiler.util.TypeCheckError;
   import org.apache.xalan.xsltc.compiler.util.Util;
  +import org.apache.xml.dtm.DTM;
   
   public final class Stylesheet extends SyntaxTreeNode {
   
  @@ -138,6 +137,8 @@
       private boolean _templateInlining = true;
   
       private boolean _forwardReference = false;
  +    
  +    private boolean _hasIdCall = false;
   
       private Properties _outputProperties = null;
   
  @@ -161,6 +162,10 @@
        _simplified = true;
       }
       
  +    public void setHasIdCall(boolean flag) {
  +        _hasIdCall = flag;
  +    }
  +    
       public void setOutputProperty(String key, String value) {
        if (_outputProperties == null) {
            _outputProperties = new Properties();
  @@ -612,6 +617,14 @@
                                               NAMESPACE_INDEX,
                                               NAMESPACE_INDEX_SIG)));
   
  +     if (_hasIdCall) {
  +         il.append(classGen.loadTranslet());
  +         il.append(new PUSH(cpg, Boolean.TRUE));
  +         il.append(new PUTFIELD(cpg.addFieldref(TRANSLET_CLASS,
  +                                                HASIDCALL_INDEX,
  +                                                HASIDCALL_INDEX_SIG)));
  +     }
  +     
        // Compile in code to set the output configuration from <xsl:output>
        if (output != null) {
            // Set all the output settings files in the translet
  @@ -672,7 +685,7 @@
                               "setFilter",
                               "(Lorg/apache/xalan/xsltc/StripFilter;)V");
   
  -     il.append(new PUSH(cpg, DOM.ROOTNODE));
  +     il.append(new PUSH(cpg, DTM.ROOT_NODE));
        il.append(new ISTORE(current.getIndex()));
   
        // Resolve any forward referenes and translate global variables/params
  @@ -817,15 +830,7 @@
                                "buildKeys", _className, il,
                                classGen.getConstantPool());
   
  -     final int domField = cpg.addFieldref(getClassName(),
  -                                          DOM_FIELD,
  -                                          DOM_INTF_SIG);
  -
        buildKeys.addException("org.apache.xalan.xsltc.TransletException");
  -
  -     il.append(classGen.loadTranslet());
  -     il.append(new GETFIELD(domField));  // The DOM reference
  -     il.append(new ASTORE(1));
        
        final Enumeration elements = elements();
        // Compile code for other top-level elements
  @@ -928,7 +933,7 @@
        il.append(new PUTFIELD(domField));
   
        // continue with globals initialization
  -     il.append(new PUSH(cpg, DOM.ROOTNODE));
  +     il.append(new PUSH(cpg, DTM.ROOT_NODE));
        il.append(new ISTORE(current.getIndex()));
   
        // Transfer the output settings to the output post-processor
  @@ -939,19 +944,7 @@
                                           "("+OUTPUT_HANDLER_SIG+")V");
        il.append(new INVOKEVIRTUAL(index));
   
  -     // Compile buildKeys -- TODO: omit if not needed
  -     final String keySig = compileBuildKeys(classGen);
  -     final int    keyIdx = cpg.addMethodref(getClassName(),
  -                                            "buildKeys", keySig);
  -     il.append(classGen.loadTranslet());     // The 'this' pointer
  -     il.append(classGen.loadTranslet());
  -     il.append(new GETFIELD(domField));      // The DOM reference
  -     il.append(transf.loadIterator());       // Not really used, but...
  -     il.append(transf.loadHandler());        // The output handler
  -     il.append(new PUSH(cpg, DOM.ROOTNODE)); // Start with the root node
  -     il.append(new INVOKEVIRTUAL(keyIdx));
  -
  -     // Look for top-level elements that need handling
  +    // Look for top-level elements that need handling
        final Enumeration toplevel = elements();
        if ((_globals.size() > 0) || (toplevel.hasMoreElements())) {
            // Compile method for handling top-level elements
  @@ -969,6 +962,21 @@
            il.append(new INVOKEVIRTUAL(topLevelIdx));
        }
        
  +     // Compile buildKeys -- TODO: omit if not needed                
  +     
  +     final String keySig = compileBuildKeys(classGen);
  +     final int    keyIdx = cpg.addMethodref(getClassName(),
  +                                            "buildKeys", keySig);
  +     il.append(classGen.loadTranslet());     // The 'this' pointer
  +     il.append(classGen.loadTranslet());
  +     il.append(new GETFIELD(domField));      // The DOM reference
  +     il.append(transf.loadIterator());       // Not really used, but...
  +     il.append(transf.loadHandler());        // The output handler
  +     il.append(new PUSH(cpg, DTM.ROOT_NODE)); // Start with the root node
  +     il.append(new INVOKEVIRTUAL(keyIdx));
  +
  +
  +
        // start document
        il.append(transf.loadHandler());
        il.append(transf.startDocument());
  
  
  
  1.26      +122 -12   
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.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- SyntaxTreeNode.java       19 Mar 2003 22:14:08 -0000      1.25
  +++ SyntaxTreeNode.java       1 Apr 2003 21:09:00 -0000       1.26
  @@ -77,6 +77,7 @@
   import org.apache.bcel.generic.DUP_X1;
   import org.apache.bcel.generic.GETFIELD;
   import org.apache.bcel.generic.ICONST;
  +import org.apache.bcel.generic.INVOKEINTERFACE;
   import org.apache.bcel.generic.INVOKESPECIAL;
   import org.apache.bcel.generic.INVOKEVIRTUAL;
   import org.apache.bcel.generic.InstructionList;
  @@ -87,6 +88,8 @@
   import org.apache.xalan.xsltc.compiler.util.MethodGenerator;
   import org.apache.xalan.xsltc.compiler.util.Type;
   import org.apache.xalan.xsltc.compiler.util.TypeCheckError;
  +import org.apache.xalan.xsltc.DOM;
  +
   import org.xml.sax.Attributes;
   
   
  @@ -537,6 +540,94 @@
            }
        }
       }
  +    
  +    /**
  +     * Return true if the node represents a simple RTF.
  +     *
  +     * A node is a simple RTF if all children only produce Text value.
  +     *
  +     * @param node A node
  +     * @return true if the node content can be considered as a simple RTF.
  +     */
  +    private boolean isSimpleRTF(SyntaxTreeNode node) {
  +        
  +        Vector contents = node.getContents();
  +        for (int i = 0; i < contents.size(); i++) {
  +            SyntaxTreeNode item = (SyntaxTreeNode)contents.elementAt(i);
  +            if (!isTextElement(item, false))
  +                return false;
  +        }
  +        
  +        return true;
  +    }
  + 
  +     /**
  +     * Return true if the node represents an adaptive RTF.
  +     *
  +     * A node is an adaptive RTF if each children is a Text element
  +     * or it is <xsl:call-template> or <xsl:apply-templates>.
  +     *
  +     * @param node A node
  +     * @return true if the node content can be considered as an adaptive RTF.
  +     */
  +    private boolean isAdaptiveRTF(SyntaxTreeNode node) {
  +        
  +        Vector contents = node.getContents();
  +        for (int i = 0; i < contents.size(); i++) {
  +            SyntaxTreeNode item = (SyntaxTreeNode)contents.elementAt(i);
  +            if (!isTextElement(item, true))
  +                return false;
  +        }
  +        
  +        return true;
  +    }
  +   
  +    /**
  +     * Return true if the node only produces Text content.
  +     *
  +     * A node is a Text element if it is Text, xsl:value-of, xsl:number, 
  +     * or a combination of these nested in a control instruction (xsl:if or
  +     * xsl:choose).
  +     *
  +     * If the doExtendedCheck flag is true, xsl:call-template and 
xsl:apply-templates
  +     * are also considered as Text elements.
  +     *
  +     * @param node A node
  +     * @param doExtendedCheck If this flag is true, <xsl:call-template> and 
  +     * <xsl:apply-templates> are also considered as Text elements.
  +     *
  +     * @return true if the node of Text type
  +     */
  +    private boolean isTextElement(SyntaxTreeNode node, boolean 
doExtendedCheck) {
  +        if (node instanceof ValueOf || node instanceof Number
  +            || node instanceof Text)
  +        {
  +            return true;
  +        }
  +        else if (node instanceof If) {
  +            return doExtendedCheck ? isAdaptiveRTF(node) : isSimpleRTF(node);
  +        }
  +        else if (node instanceof Choose) {
  +            Vector contents = node.getContents();
  +            for (int i = 0; i < contents.size(); i++) {
  +                SyntaxTreeNode item = (SyntaxTreeNode)contents.elementAt(i);
  +                if (item instanceof Text || 
  +                     ((item instanceof When || item instanceof Otherwise)
  +                     && ((doExtendedCheck && isAdaptiveRTF(item))
  +                         || (!doExtendedCheck && isSimpleRTF(item)))))
  +                    continue;
  +                else
  +                    return false;
  +            }
  +            return true;
  +        }
  +        else if (doExtendedCheck && 
  +                  (node instanceof CallTemplate
  +                   || node instanceof ApplyTemplates))
  +            return true;
  +        else
  +            return false;
  +    }
   
       /**
        * Utility method used by parameters and variables to store result trees
  @@ -550,25 +641,41 @@
        final InstructionList il = methodGen.getInstructionList();
        final Stylesheet stylesheet = classGen.getStylesheet();
   
  +     boolean isSimple = isSimpleRTF(this);
  +     boolean isAdaptive = false;
  +     if (!isSimple) {
  +         isAdaptive = isAdaptiveRTF(this);
  +     }
  +     
  +     int rtfType = isSimple ? DOM.SIMPLE_RTF
  +                            : (isAdaptive ? DOM.ADAPTIVE_RTF : DOM.TREE_RTF);
  +     
        // Save the current handler base on the stack
        il.append(methodGen.loadHandler());
   
        final String DOM_CLASS = classGen.getDOMClass();
   
  -     // Create new instance of DOM class
  -     int index = cpg.addMethodref(DOM_IMPL, "<init>", "(I)V");
  -     il.append(new NEW(cpg.addClass(DOM_IMPL)));
  -     il.append(DUP);
  -     il.append(DUP);
  +     // Create new instance of DOM class (with RTF_INITIAL_SIZE nodes)
  +     //int index = cpg.addMethodref(DOM_IMPL, "<init>", "(I)V");
  +     //il.append(new NEW(cpg.addClass(DOM_IMPL)));
  +     
  +     il.append(methodGen.loadDOM());
  +     int index = cpg.addInterfaceMethodref(DOM_INTF,
  +                              "getResultTreeFrag",
  +                              "(II)" + DOM_INTF_SIG);
        il.append(new PUSH(cpg, RTF_INITIAL_SIZE));
  -     il.append(new INVOKESPECIAL(index));
  +     il.append(new PUSH(cpg, rtfType));
  +     il.append(new INVOKEINTERFACE(index,3));
  +
  +     
  +     il.append(DUP);
   
        // Overwrite old handler with DOM handler
  -     index = cpg.addMethodref(DOM_IMPL,
  +     index = cpg.addInterfaceMethodref(DOM_INTF,
                                 "getOutputDomBuilder",
                                 "()" + TRANSLET_OUTPUT_SIG);
   
  -     il.append(new INVOKEVIRTUAL(index));
  +     il.append(new INVOKEINTERFACE(index,1));
        il.append(DUP);
        il.append(methodGen.storeHandler());
   
  @@ -582,12 +689,15 @@
        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)) {
  +     // Check if we need to wrap the DOMImpl object in a DOMAdapter object.
  +     // DOMAdapter is not needed if the RTF is a simple RTF and the nodeset()
  +     // function is not used.
  +     if ((!isSimple || stylesheet.callsNodeset())
  +         && !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+
  +                                  "("+DOM_INTF_SIG+
                                     "["+STRING_SIG+
                                     "["+STRING_SIG+")V");
            il.append(new NEW(cpg.addClass(DOM_ADAPTER_CLASS)));
  
  
  
  1.9       +3 -3      
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/UnionPathExpr.java
  
  Index: UnionPathExpr.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/UnionPathExpr.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- UnionPathExpr.java        30 Jan 2003 18:46:02 -0000      1.8
  +++ UnionPathExpr.java        1 Apr 2003 21:09:00 -0000       1.9
  @@ -71,12 +71,12 @@
   import org.apache.bcel.generic.INVOKEVIRTUAL;
   import org.apache.bcel.generic.InstructionList;
   import org.apache.bcel.generic.NEW;
  -import org.apache.xalan.xsltc.DOM;
   import org.apache.xalan.xsltc.compiler.util.ClassGenerator;
   import org.apache.xalan.xsltc.compiler.util.MethodGenerator;
   import org.apache.xalan.xsltc.compiler.util.Type;
   import org.apache.xalan.xsltc.compiler.util.TypeCheckError;
   import org.apache.xalan.xsltc.dom.Axis;
  +import org.apache.xml.dtm.DTM;
   
   final class UnionPathExpr extends Expression {
   
  @@ -107,7 +107,7 @@
                final int axis = step.getAxis();
                final int type = step.getNodeType();
                // Put attribute iterators first
  -             if ((axis == Axis.ATTRIBUTE) || (type == DOM.ATTRIBUTE)) {
  +             if ((axis == Axis.ATTRIBUTE) || (type == DTM.ATTRIBUTE_NODE)) {
                    _components[i] = _components[0];
                    _components[0] = step;
                }
  
  
  
  1.5       +21 -20    
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/UnparsedEntityUriCall.java
  
  Index: UnparsedEntityUriCall.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/UnparsedEntityUriCall.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- UnparsedEntityUriCall.java        30 Jan 2003 18:46:02 -0000      1.4
  +++ UnparsedEntityUriCall.java        1 Apr 2003 21:09:00 -0000       1.5
  @@ -67,7 +67,7 @@
   import java.util.Vector;
   
   import org.apache.bcel.generic.ConstantPoolGen;
  -import org.apache.bcel.generic.INVOKEVIRTUAL;
  +import org.apache.bcel.generic.INVOKEINTERFACE;
   import org.apache.bcel.generic.InstructionList;
   import org.apache.xalan.xsltc.compiler.util.ClassGenerator;
   import org.apache.xalan.xsltc.compiler.util.MethodGenerator;
  @@ -79,29 +79,30 @@
       private Expression _entity;
   
       public UnparsedEntityUriCall(QName fname, Vector arguments) {
  -     super(fname, arguments);
  -     _entity = argument();
  +        super(fname, arguments);
  +        _entity = argument();
       }
   
       public Type typeCheck(SymbolTable stable) throws TypeCheckError {
  -     final Type entity = _entity.typeCheck(stable);
  -     if (entity instanceof StringType == false) {
  -         _entity = new CastExpr(_entity, Type.String);
  -     }
  -     return _type = Type.String;
  +        final Type entity = _entity.typeCheck(stable);
  +        if (entity instanceof StringType == false) {
  +            _entity = new CastExpr(_entity, Type.String);
  +        }
  +        return _type = Type.String;
       }
       
       public void translate(ClassGenerator classGen, MethodGenerator 
methodGen) {
  -     final ConstantPoolGen cpg = classGen.getConstantPool();
  -     final InstructionList il = methodGen.getInstructionList();
  -     // Feck the this pointer on the stack...
  -     il.append(classGen.loadTranslet());
  -     // ...then the entity name...
  -     _entity.translate(classGen, methodGen);
  -     // ...to get the value from the hashtable in AbstractTranslet.
  -     il.append(new INVOKEVIRTUAL(cpg.addMethodref(TRANSLET_CLASS,
  -                                                  "getUnparsedEntity",
  -                                                  "(Ljava/lang/String;)"+
  -                                                  "Ljava/lang/String;")));
  +        final ConstantPoolGen cpg = classGen.getConstantPool();
  +        final InstructionList il = methodGen.getInstructionList();
  +        // Feck the this pointer on the stack...
  +        il.append(methodGen.loadDOM());
  +        // ...then the entity name...
  +        _entity.translate(classGen, methodGen);
  +        // ...to get the URI from the DOM object.
  +        il.append(new INVOKEINTERFACE(
  +                         cpg.addInterfaceMethodref(DOM_INTF,
  +                                                   GET_UNPARSED_ENTITY_URI,
  +                                                   
GET_UNPARSED_ENTITY_URI_SIG),
  +                         2));
       }
   }
  
  
  
  1.10      +80 -43    
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ValueOf.java
  
  Index: ValueOf.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/ValueOf.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ValueOf.java      30 Jan 2003 18:46:02 -0000      1.9
  +++ ValueOf.java      1 Apr 2003 21:09:00 -0000       1.10
  @@ -79,61 +79,98 @@
   final class ValueOf extends Instruction {
       private Expression _select;
       private boolean _escaping = true;
  -     
  +    private boolean _isString = false;
  +
       public void display(int indent) {
  -     indent(indent);
  -     Util.println("ValueOf");
  -     indent(indent + IndentIncrement);
  -     Util.println("select " + _select.toString());
  +        indent(indent);
  +        Util.println("ValueOf");
  +        indent(indent + IndentIncrement);
  +        Util.println("select " + _select.toString());
       }
  -             
  +
       public void parseContents(Parser parser) {
  -     _select = parser.parseExpression(this, "select", null);
  +        _select = parser.parseExpression(this, "select", null);
   
           // make sure required attribute(s) have been set
           if (_select.isDummy()) {
  -         reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "select");
  -         return;
  +            reportError(this, parser, ErrorMsg.REQUIRED_ATTR_ERR, "select");
  +            return;
           }
           final String str = getAttribute("disable-output-escaping");
  -     if ((str != null) && (str.equals("yes"))) _escaping = false;
  +        if ((str != null) && (str.equals("yes"))) _escaping = false;
       }
   
       public Type typeCheck(SymbolTable stable) throws TypeCheckError {
  -     Type type = _select.typeCheck(stable);
  -     if ((type != null) && (type.identicalTo(Type.String) == false))
  -         _select = new CastExpr(_select, Type.String);
  -     return Type.Void;
  +        Type type = _select.typeCheck(stable);
  +
  +        // Prefer to handle the value as a node; fall back to String, 
otherwise
  +        if (type != null && !type.identicalTo(Type.Node)) {
  +            /***
  +             *** %HZ% Would like to treat result-tree fragments in the same
  +             *** %HZ% way as node sets for value-of, but that's running into
  +             *** %HZ% some snags.  Instead, they'll be converted to String
  +            if (type.identicalTo(Type.ResultTree)) {
  +                _select = new CastExpr(new CastExpr(_select, Type.NodeSet),
  +                                       Type.Node);
  +            } else
  +            ***/
  +            if (type.identicalTo(Type.NodeSet)) {
  +                _select = new CastExpr(_select, Type.Node);
  +            } else {
  +                _isString = true;
  +                if (!type.identicalTo(Type.String)) {
  +                    _select = new CastExpr(_select, Type.String);
  +                }
  +                _isString = true;
  +            }
  +        }
  +        return Type.Void;
       }
   
       public void translate(ClassGenerator classGen, MethodGenerator 
methodGen) {
  -     final ConstantPoolGen cpg = classGen.getConstantPool();
  -     final InstructionList il = methodGen.getInstructionList();
  -     final int setEscaping = cpg.addInterfaceMethodref(OUTPUT_HANDLER,
  -                                                       "setEscaping","(Z)Z");
  -     final int characters = cpg.addMethodref(TRANSLET_CLASS,
  -                                             CHARACTERSW,
  -                                             CHARACTERSW_SIG);
  -
  -     // Turn off character escaping if so is wanted.
  -     if (!_escaping) {
  -         il.append(methodGen.loadHandler());
  -         il.append(new PUSH(cpg,false));
  -         il.append(new INVOKEINTERFACE(setEscaping,2));
  -     }
  -
  -     // Translate the contents.
  -     il.append(classGen.loadTranslet());
  -     _select.translate(classGen, methodGen); 
  -     il.append(methodGen.loadHandler());
  -     il.append(new INVOKEVIRTUAL(characters));
  -
  -     // Restore character escaping setting to whatever it was.
  -     if (!_escaping) {
  -         il.append(methodGen.loadHandler());
  -         il.append(SWAP);
  -         il.append(new INVOKEINTERFACE(setEscaping,2));
  -         il.append(POP);
  -     }
  +        final ConstantPoolGen cpg = classGen.getConstantPool();
  +        final InstructionList il = methodGen.getInstructionList();
  +        final int setEscaping = cpg.addInterfaceMethodref(OUTPUT_HANDLER,
  +                                                          
"setEscaping","(Z)Z");
  +
  +        // Turn off character escaping if so is wanted.
  +        if (!_escaping) {
  +            il.append(methodGen.loadHandler());
  +            il.append(new PUSH(cpg,false));
  +            il.append(new INVOKEINTERFACE(setEscaping,2));
  +        }
  +
  +        // Translate the contents.  If the value is a string, use the
  +        // translet.characters(String, TranslatOutputHandler) method.
  +        // Otherwise, the value is a node, and the
  +        // dom.characters(int node, TransletOutputHandler) method can 
dispatch
  +        // the string value of the node to the output handler more 
efficiently.
  +        if (_isString) {
  +            final int characters = cpg.addMethodref(TRANSLET_CLASS,
  +                                                    CHARACTERSW,
  +                                                    CHARACTERSW_SIG);
  +
  +            il.append(classGen.loadTranslet());
  +            _select.translate(classGen, methodGen);
  +            il.append(methodGen.loadHandler());
  +            il.append(new INVOKEVIRTUAL(characters));
  +        } else {
  +            final int characters = cpg.addInterfaceMethodref(DOM_INTF,
  +                                                             CHARACTERS,
  +                                                             CHARACTERS_SIG);
  +
  +            il.append(methodGen.loadDOM());
  +            _select.translate(classGen, methodGen);
  +            il.append(methodGen.loadHandler());
  +            il.append(new INVOKEINTERFACE(characters, 3));
  +        }
  +
  +        // Restore character escaping setting to whatever it was.
  +        if (!_escaping) {
  +            il.append(methodGen.loadHandler());
  +            il.append(SWAP);
  +            il.append(new INVOKEINTERFACE(setEscaping,2));
  +            il.append(POP);
  +        }
       }
   }
  
  
  
  1.51      +17 -5     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XSLTC.java
  
  Index: XSLTC.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/XSLTC.java,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- XSLTC.java        31 Mar 2003 13:13:08 -0000      1.50
  +++ XSLTC.java        1 Apr 2003 21:09:00 -0000       1.51
  @@ -84,9 +84,10 @@
   import java.util.jar.Manifest;
   
   import org.apache.bcel.classfile.JavaClass;
  -import org.apache.xalan.xsltc.DOM;
   import org.apache.xalan.xsltc.compiler.util.ErrorMsg;
   import org.apache.xalan.xsltc.compiler.util.Util;
  +import org.apache.xml.dtm.DTM;
  +
   import org.xml.sax.InputSource;
   import org.xml.sax.XMLReader;
   
  @@ -146,6 +147,7 @@
       private Vector  _bcelClasses;
       private boolean _callsNodeset = false;
       private boolean _multiDocument = false;
  +    private boolean _hasIdCall = false;
   
       /**
        * Set to true if template inlining is requested. Template
  @@ -168,7 +170,7 @@
       public Parser getParser() {
           return _parser;
       }
  -    
  +
       /**
        * Only for user by the internal TrAX implementation.
        */
  @@ -197,7 +199,7 @@
        * Initializes the compiler to produce a new translet
        */
       private void reset() {
  -     _nextGType      = DOM.NTYPES;
  +     _nextGType      = DTM.NTYPES;
        _elements       = new Hashtable();
        _attributes     = new Hashtable();
        _namespaces     = new Hashtable();
  @@ -212,6 +214,7 @@
        _helperClassSerial  = 0;
        _attributeSetSerial = 0;
        _multiDocument      = false;
  +     _hasIdCall          = false;
        _numberFieldIndexes = new int[] {
            -1,         // LEVEL_SINGLE
            -1,         // LEVEL_MULTIPLE
  @@ -353,6 +356,7 @@
            if ((!_parser.errorsFound()) && (_stylesheet != null)) {
                _stylesheet.setCallsNodeset(_callsNodeset);
                _stylesheet.setMultiDocument(_multiDocument);
  +             _stylesheet.setHasIdCall(_hasIdCall);
   
                // Class synchronization is needed for BCEL
                synchronized (getClass()) {
  @@ -361,7 +365,7 @@
            }
        }
        catch (Exception e) {
  -         if (_debug) e.printStackTrace();
  +         /*if (_debug)*/ e.printStackTrace();
            _parser.reportError(Constants.FATAL, new ErrorMsg(e));
        }
        catch (Error e) {
  @@ -516,6 +520,14 @@
   
       public boolean callsNodeset() {
        return _callsNodeset;
  +    }
  +    
  +    protected void setHasIdCall(boolean flag) {
  +     _hasIdCall = flag;
  +    }
  +    
  +    public boolean hasIdCall() {
  +     return _hasIdCall;
       }
   
       /**
  
  
  
  1.47      +16 -7     
xml-xalan/java/src/org/apache/xalan/xsltc/compiler/xpath.cup
  
  Index: xpath.cup
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/xpath.cup,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- xpath.cup 27 Jan 2003 18:44:40 -0000      1.46
  +++ xpath.cup 1 Apr 2003 21:09:00 -0000       1.47
  @@ -70,6 +70,7 @@
   import java.io.StringReader;
   import java_cup.runtime.*;
   
  +import org.apache.xml.dtm.DTM;
   import org.apache.xalan.xsltc.DOM;
   import org.apache.xalan.xsltc.dom.Axis;
   import org.apache.xalan.xsltc.runtime.Operators;
  @@ -129,6 +130,11 @@
             _xsltc.setCallsNodeset(flag);
       }
   
  +    public void setHasIdCall(boolean flag) {
  +          _xsltc.setHasIdCall(flag); 
  +    }
  +    
  +
       /**
        * This method is similar to findNodeType(int, Object) except that it
        * creates a StepPattern instead of just returning a node type. It also 
  @@ -412,7 +418,9 @@
               {: RESULT = rpp; :};
   
   IdKeyPattern ::= ID LPAREN Literal:l RPAREN
  -            {: RESULT = new IdPattern(l); :}
  +            {: RESULT = new IdPattern(l);
  +               parser.setHasIdCall(true);
  +            :}
   
               | KEY LPAREN Literal:l1 COMMA Literal:l2 RPAREN
               {: RESULT = new KeyPattern(l1, l2); :};
  @@ -606,7 +614,7 @@
           if (rlp instanceof Step && 
               parser.isElementAxis(((Step) rlp).getAxis())) 
           {
  -            nodeType = DOM.ELEMENT;
  +            nodeType = DTM.ELEMENT_NODE;
           }
              final Step step = new Step(Axis.DESCENDANTORSELF, nodeType, null);
              FilterParentPath fpp = new FilterParentPath(fexp, step);
  @@ -676,14 +684,14 @@
                      // Expand './/step' -> 'descendant-or-self::*/step'
                      if (rlp instanceof Step && 
((Step)rlp).isAbbreviatedDot()) {
                          Step left = new Step(Axis.DESCENDANTORSELF, 
  -                         DOM.ELEMENT, null);
  +                         DTM.ELEMENT_NODE, null);
                          RESULT = new ParentLocationPath(left, right);
                      }
                      else {
                          // Expand 'rlp//step' -> 
'rlp/descendant-or-self::*/step'
                          RelativeLocationPath left = (RelativeLocationPath)rlp;
                          Step mid = new Step(Axis.DESCENDANTORSELF, 
  -                         DOM.ELEMENT, null);
  +                         DTM.ELEMENT_NODE, null);
                          ParentLocationPath ppl = new ParentLocationPath(mid, 
right);
                          RESULT = new ParentLocationPath(left, ppl);
                      }
  @@ -693,7 +701,7 @@
                  // Expand 'rlp//step' -> 'rlp/descendant-or-self::*/step'
                  RelativeLocationPath left = (RelativeLocationPath)rlp;
                  Step middle = new Step(Axis.DESCENDANTORSELF, 
  -                 DOM.ELEMENT, null);
  +                 DTM.ELEMENT_NODE, null);
                  ParentLocationPath ppl = new ParentLocationPath(middle, 
right);
                  RESULT = new ParentLocationPath(left, ppl);
           }
  @@ -718,7 +726,7 @@
           if (rlp instanceof Step && 
               parser.isElementAxis(((Step) rlp).getAxis())) 
           {
  -            nodeType = DOM.ELEMENT;
  +            nodeType = DTM.ELEMENT_NODE;
           }
           final Step step = new Step(Axis.DESCENDANTORSELF, nodeType, null);
           RESULT = new AbsoluteLocationPath(parser.insertStep(step, 
  @@ -979,6 +987,7 @@
          }
             else if (fname == parser.getQNameIgnoreDefaultNs("id")) {
               RESULT = new KeyCall(fname, argl);
  +            parser.setHasIdCall(true);
          }
             else if (fname == parser.getQNameIgnoreDefaultNs("ceiling")) {
               RESULT = new CeilingCall(fname, argl);
  
  
  

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

Reply via email to