xml-xalan-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mk...@apache.org
Subject cvs commit: xml-xalan/java/src/org/apache/xalan/xsltc/dom AdaptiveResultTreeImpl.java DOMWSFilter.java SAXImpl.java SimpleResultTreeImpl.java XSLTCDTMManager.java AbsoluteIterator.java AnyNodeCounter.java Axis.java BitArray.java CollatorFactoryBase.java CurrentNodeListFilter.java CurrentNodeListIterator.java DOMAdapter.java DOMBuilder.java DocumentCache.java DupFilterIterator.java EmptyFilter.java ExtendedSAX.java Filter.java FilterIterator.java FilteredStepIterator.java ForwardPositionIterator.java KeyIndex.java LoadDocument.java MatchingIterator.java MultiDOM.java MultipleNodeCounter.java NodeCounter.java NodeIteratorBase.java NodeSortRecord.java NodeSortRecordFactory.java NthIterator.java SingleNodeCounter.java SingletonIterator.java SortingIterator.java StepIterator.java StripWhitespaceFilter.java UnionIterator.java DOMImpl.java DTDMonitor.java
Date Tue, 01 Apr 2003 21:39:27 GMT
mkwan       2003/04/01 13:39:27

  Modified:    java/src/org/apache/xalan/xsltc/dom AbsoluteIterator.java
                        AnyNodeCounter.java Axis.java BitArray.java
                        CollatorFactoryBase.java CurrentNodeListFilter.java
                        CurrentNodeListIterator.java DOMAdapter.java
                        DOMBuilder.java DocumentCache.java
                        DupFilterIterator.java EmptyFilter.java
                        ExtendedSAX.java Filter.java FilterIterator.java
                        FilteredStepIterator.java
                        ForwardPositionIterator.java KeyIndex.java
                        LoadDocument.java MatchingIterator.java
                        MultiDOM.java MultipleNodeCounter.java
                        NodeCounter.java NodeIteratorBase.java
                        NodeSortRecord.java NodeSortRecordFactory.java
                        NthIterator.java SingleNodeCounter.java
                        SingletonIterator.java SortingIterator.java
                        StepIterator.java StripWhitespaceFilter.java
                        UnionIterator.java
  Added:       java/src/org/apache/xalan/xsltc/dom
                        AdaptiveResultTreeImpl.java DOMWSFilter.java
                        SAXImpl.java SimpleResultTreeImpl.java
                        XSLTCDTMManager.java
  Removed:     java/src/org/apache/xalan/xsltc/dom DOMImpl.java
                        DTDMonitor.java
  Log:
  Merging XSLTC_DTM and common serializer to the head
  
  Adapt all dom classes in org.apache.xalan.xsltc.dom to
  the DTM model.
  
  Removed DOMImpl, DTDMonitor.
  Added a few new classes for the new DOM model. The core
  DOM class is SAXImpl.
  
  Revision  Changes    Path
  1.10      +12 -24    xml-xalan/java/src/org/apache/xalan/xsltc/dom/AbsoluteIterator.java
  
  Index: AbsoluteIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/AbsoluteIterator.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- AbsoluteIterator.java	8 Oct 2002 21:44:14 -0000	1.9
  +++ AbsoluteIterator.java	1 Apr 2003 21:39:16 -0000	1.10
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -63,9 +63,10 @@
   
   package org.apache.xalan.xsltc.dom;
   
  -import org.apache.xalan.xsltc.DOM;
  -import org.apache.xalan.xsltc.NodeIterator;
   import org.apache.xalan.xsltc.runtime.BasisLibrary;
  +import org.apache.xml.dtm.DTMAxisIterator;
  +import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
  +import org.apache.xml.dtm.ref.DTMDefaultBase;
   
   /**
    * Absolute iterators ignore the node that is passed to setStartNode(). 
  @@ -78,24 +79,14 @@
    * nodes from other DOMs will have no effect (i.e. this iterator cannot 
    * migrate between DOMs).
    */
  -public final class AbsoluteIterator extends NodeIteratorBase {
  -
  -    /**
  -     * Initial value for DOM masks.
  -     */
  -    private static final int NO_MASK = -1;
  +public final class AbsoluteIterator extends DTMAxisIteratorBase {
   
       /**
        * Source for this iterator.
        */
  -    private NodeIterator _source;
  +    private DTMAxisIterator _source;
   
  -    /**
  -     * DOM mask cached after first call to setStartNode().
  -     */
  -    private int _mask = NO_MASK;
  -	
  -    public AbsoluteIterator(NodeIterator source) {
  +    public AbsoluteIterator(DTMAxisIterator source) {
   	_source = source;
   // System.out.println("AI source = " + source + " this = " + this);
       }
  @@ -105,12 +96,9 @@
   	_source.setRestartable(isRestartable);
       }
   
  -    public NodeIterator setStartNode(int node) {
  +    public DTMAxisIterator setStartNode(int node) {
  +	_startNode = DTMDefaultBase.ROOTNODE;
   	if (_isRestartable) {
  -	    if (_mask == NO_MASK) {
  -		_mask = node & 0xFF000000;
  -	    }
  -	    _startNode = _mask | DOM.ROOTNODE;
   	    _source.setStartNode(_startNode);
   	    resetPosition();
   	}
  @@ -121,7 +109,7 @@
   	return returnNode(_source.next());
       }
   
  -    public NodeIterator cloneIterator() {
  +    public DTMAxisIterator cloneIterator() {
   	try {
   	    final AbsoluteIterator clone = (AbsoluteIterator) super.clone();
   	    clone._source = _source.cloneIterator();	// resets source
  @@ -136,7 +124,7 @@
   	}
       }
   
  -    public NodeIterator reset() {
  +    public DTMAxisIterator reset() {
   	_source.reset();
   	return resetPosition();
       }
  
  
  
  1.3       +32 -13    xml-xalan/java/src/org/apache/xalan/xsltc/dom/AnyNodeCounter.java
  
  Index: AnyNodeCounter.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/AnyNodeCounter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AnyNodeCounter.java	30 Jan 2003 18:46:10 -0000	1.2
  +++ AnyNodeCounter.java	1 Apr 2003 21:39:16 -0000	1.3
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -64,18 +64,18 @@
   package org.apache.xalan.xsltc.dom;
   
   import org.apache.xalan.xsltc.DOM;
  -import org.apache.xalan.xsltc.NodeIterator;
   import org.apache.xalan.xsltc.Translet;
  +import org.apache.xml.dtm.DTMAxisIterator;
   
   public abstract class AnyNodeCounter extends NodeCounter {
       public AnyNodeCounter(Translet translet,
  -			  DOM document, NodeIterator iterator) {
  +			  DOM document, DTMAxisIterator iterator) {
   	super(translet, document, iterator);
       }
   	
       public NodeCounter setStartNode(int node) {
   	_node = node;
  -	_nodeType = _document.getType(node);
  +	_nodeType = _document.getExpandedTypeID(node);
   	return this;
       }
   
  @@ -85,13 +85,24 @@
   	    result = _value;
   	}
   	else {
  -	    int next = _node;
  +	    int next = _node; 
  +            final int root = _document.getDocument();
   	    result = 0;
  -	    while (next >= 0 && !matchesFrom(next)) {
  +	    while (next >= root && !matchesFrom(next)) {
   		if (matchesCount(next)) {
   		    ++result;	
   		}
  -		--next;
  +		next--;
  +//%HZ%:  Is this the best way of finding the root?  Is it better to check
  +//%HZ%:  parent(next)?
  +		/*
  +		if (next == root) {
  +		    break;
  +                }
  +		else {
  +		    --next;		
  +                }
  +                */
   	    }
   	}
   	return formatNumbers(result);
  @@ -99,13 +110,13 @@
   
       public static NodeCounter getDefaultNodeCounter(Translet translet,
   						    DOM document,
  -						    NodeIterator iterator) {
  +						    DTMAxisIterator iterator) {
   	return new DefaultAnyNodeCounter(translet, document, iterator);
       }
   
       static class DefaultAnyNodeCounter extends AnyNodeCounter {
   	public DefaultAnyNodeCounter(Translet translet,
  -				     DOM document, NodeIterator iterator) {
  +				     DOM document, DTMAxisIterator iterator) {
   	    super(translet, document, iterator);
   	}
   
  @@ -117,12 +128,20 @@
   	    else {
   		int next = _node;
   		result = 0;
  -		final int ntype = _document.getType(_node); 
  +		final int ntype = _document.getExpandedTypeID(_node);
  +                final int root = _document.getDocument();
   		while (next >= 0) {
  -		    if (ntype == _document.getType(next)) {
  +		    if (ntype == _document.getExpandedTypeID(next)) {
   			result++;
   		    }
  -		    next--;
  +//%HZ%:  Is this the best way of finding the root?  Is it better to check
  +//%HZ%:  parent(next)?
  +		    if (next == root) {
  +		        break;
  +                    }
  +		    else {
  +		        --next;
  +                    }
   		}
   	    }
   	    return formatNumbers(result);
  
  
  
  1.4       +4 -36     xml-xalan/java/src/org/apache/xalan/xsltc/dom/Axis.java
  
  Index: Axis.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/Axis.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- Axis.java	8 Nov 2001 12:59:42 -0000	1.3
  +++ Axis.java	1 Apr 2003 21:39:16 -0000	1.4
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -69,40 +69,8 @@
    * org.apache.xml.dtm.Axis (very similar)
    */
   
  -public interface Axis {
  -
  -    public static final int ANCESTOR         =  0;
  -    public static final int ANCESTORORSELF   =  1;
  -    public static final int ATTRIBUTE        =  2;
  -    public static final int CHILD            =  3;
  -    public static final int DESCENDANT       =  4;
  -    public static final int DESCENDANTORSELF =  5;
  -    public static final int FOLLOWING        =  6;
  -    public static final int FOLLOWINGSIBLING =  7;
  -    public static final int NAMESPACEDECLS   =  8;
  -    public static final int NAMESPACE        =  9;
  -    public static final int PARENT           = 10;
  -    public static final int PRECEDING        = 11;
  -    public static final int PRECEDINGSIBLING = 12;
  -    public static final int SELF             = 13;
  -	
  -    public static final String[] names = {
  -	"ancestor",
  -	"ancestor-or-self",
  -	"attribute",
  -	"child",
  -	"descendant",
  -	"descendant-or-self",
  -	"following",
  -	"following-sibling",
  -	"namespace",
  -	"namespace-decls",
  -	"parent",
  -	"preceding",
  -	"preceding-sibling",
  -	"self"
  -    };
  -
  +public interface Axis extends org.apache.xml.dtm.Axis
  +{
       public static final boolean[] isReverse = {
   	true,  // ancestor
   	true,  // ancestor-or-self
  
  
  
  1.6       +42 -29    xml-xalan/java/src/org/apache/xalan/xsltc/dom/BitArray.java
  
  Index: BitArray.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/BitArray.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- BitArray.java	30 Jan 2003 18:46:10 -0000	1.5
  +++ BitArray.java	1 Apr 2003 21:39:16 -0000	1.6
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -67,7 +67,7 @@
   import java.io.ObjectInput;
   import java.io.ObjectOutput;
   
  -import org.apache.xalan.xsltc.NodeIterator;
  +import org.apache.xml.dtm.DTMAxisIterator;
   
   
   public class BitArray implements Externalizable {
  @@ -89,6 +89,8 @@
   	0x00000080, 0x00000040, 0x00000020, 0x00000010,
   	0x00000008, 0x00000004, 0x00000002, 0x00000001 };
   
  +    private final static boolean DEBUG_ASSERTIONS = false;
  +    
       /**
        * Constructor. Defines the initial size of the bit array (in bits).
        */
  @@ -96,11 +98,11 @@
   	this(32);
       }
   
  -    public BitArray(int size) {
  -	if (size < 32) size = 32;
  -	_bitSize = size;
  -	_intSize = (_bitSize >>> 5) + 1;
  -	_bits = new int[_intSize + 1];
  +    public BitArray(int size) {        
  +        if (size < 32) size = 32;
  +        _bitSize = size;
  +        _intSize = (_bitSize >>> 5) + 1;
  +        _bits = new int[_intSize + 1];
       }
   
       public BitArray(int size, int[] bits) {
  @@ -136,25 +138,32 @@
        * Returns true if the given bit is set
        */
       public final boolean getBit(int bit) {
  -	return((_bits[bit>>>5] & _masks[bit%32]) != 0);
  +        if (DEBUG_ASSERTIONS) {
  +            if (bit >= _bitSize) {
  +                throw new Error(
  +                             "Programmer's assertion in  BitArray.getBit");
  +            }
  +        }
  +
  +        return((_bits[bit>>>5] & _masks[bit%32]) != 0);
       }
   
       /**
        * Returns the next set bit from a given position
        */
       public final int getNextBit(int startBit) {
  -	for (int i = (startBit >>> 5) ; i<=_intSize; i++) {
  -	    int bits = _bits[i];
  -	    if (bits != 0) {
  -		for (int b = (startBit % 32); b<32; b++) {
  -		    if ((bits & _masks[b]) != 0) {
  -			return((i << 5) + b);
  -		    }
  -		}
  -	    }
  -	    startBit = 0;
  -	}
  -	return(NodeIterator.END);
  +        for (int i = (startBit >>> 5) ; i<=_intSize; i++) {
  +            int bits = _bits[i];
  +            if (bits != 0) {
  +                for (int b = (startBit % 32); b<32; b++) {
  +                    if ((bits & _masks[b]) != 0) {
  +                        return((i << 5) + b);
  +                    }
  +                }
  +            }
  +            startBit = 0;
  +        }
  +        return(DTMAxisIterator.END);
       }
   
       /**
  @@ -211,11 +220,18 @@
        * Sets a given bit
        */
       public final void setBit(int bit) {
  -	if (bit >= _bitSize) return;
  -	final int i = (bit >>> 5);
  -	if (i < _first) _first = i;
  -	if (i > _last) _last = i;
  -	_bits[i] |= _masks[bit % 32];
  +        if (DEBUG_ASSERTIONS) {
  +            if (bit >= _bitSize) {
  +                throw new Error(
  +                             "Programmer's assertion in  BitArray.getBit");
  +            }
  +        }
  +
  +        if (bit >= _bitSize) return;
  +        final int i = (bit >>> 5);
  +        if (i < _first) _first = i;
  +        if (i > _last) _last = i;
  +        _bits[i] |= _masks[bit % 32];
       }
   
       /**
  @@ -285,6 +301,3 @@
       }
   
   }
  -
  -
  -    
  
  
  
  1.2       +8 -2      xml-xalan/java/src/org/apache/xalan/xsltc/dom/CollatorFactoryBase.java
  
  Index: CollatorFactoryBase.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/CollatorFactoryBase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CollatorFactoryBase.java	4 Dec 2002 16:11:18 -0000	1.1
  +++ CollatorFactoryBase.java	1 Apr 2003 21:39:16 -0000	1.2
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -69,6 +69,9 @@
   
   public class CollatorFactoryBase implements CollatorFactory {
       
  +    public static final Locale DEFAULT_LOCALE = Locale.getDefault();
  +    public static final Collator DEFAULT_COLLATOR = Collator.getInstance();
  +    
       public CollatorFactoryBase() {
       }
       
  @@ -77,6 +80,9 @@
       }
       
       public Collator getCollator(Locale locale) {
  -        return Collator.getInstance(locale);
  +        if (locale == DEFAULT_LOCALE)
  +            return DEFAULT_COLLATOR;
  +        else
  +            return Collator.getInstance(locale);
       }
   }
  
  
  
  1.3       +4 -4      xml-xalan/java/src/org/apache/xalan/xsltc/dom/CurrentNodeListFilter.java
  
  Index: CurrentNodeListFilter.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/CurrentNodeListFilter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- CurrentNodeListFilter.java	30 Jan 2003 18:46:10 -0000	1.2
  +++ CurrentNodeListFilter.java	1 Apr 2003 21:39:16 -0000	1.3
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -64,10 +64,10 @@
   
   package org.apache.xalan.xsltc.dom;
   
  -import org.apache.xalan.xsltc.NodeIterator;
   import org.apache.xalan.xsltc.runtime.AbstractTranslet;
  +import org.apache.xml.dtm.DTMAxisIterator;
   
   public interface CurrentNodeListFilter {
       public abstract boolean test(int node, int position, int last, int current,
  -				 AbstractTranslet translet, NodeIterator iter);
  +				 AbstractTranslet translet, DTMAxisIterator iter);
   }
  
  
  
  1.12      +20 -13    xml-xalan/java/src/org/apache/xalan/xsltc/dom/CurrentNodeListIterator.java
  
  Index: CurrentNodeListIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/CurrentNodeListIterator.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- CurrentNodeListIterator.java	30 Jan 2003 18:46:10 -0000	1.11
  +++ CurrentNodeListIterator.java	1 Apr 2003 21:39:16 -0000	1.12
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -64,10 +64,11 @@
   
   package org.apache.xalan.xsltc.dom;
   
  -import org.apache.xalan.xsltc.NodeIterator;
   import org.apache.xalan.xsltc.runtime.AbstractTranslet;
   import org.apache.xalan.xsltc.runtime.BasisLibrary;
   import org.apache.xalan.xsltc.util.IntegerArray;
  +import org.apache.xml.dtm.DTMAxisIterator;
  +import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
   
   /**
    * Iterators of this kind use a CurrentNodeListFilter to filter a subset of 
  @@ -79,8 +80,8 @@
    * CurrentNodeListFilter.test()). The method getLast() returns the last element 
    * after applying the filter.
    */
  -public final class CurrentNodeListIterator extends NodeIteratorBase {
   
  +public final class CurrentNodeListIterator extends DTMAxisIteratorBase {
       /**
        * A flag indicating if nodes are returned in document order.
        */
  @@ -89,7 +90,7 @@
       /**
        * The source for this iterator.
        */
  -    private NodeIterator _source;
  +    private DTMAxisIterator _source;
   
       /**
        * A reference to a filter object.
  @@ -116,7 +117,7 @@
        */
       private AbstractTranslet _translet;
   
  -    public CurrentNodeListIterator(NodeIterator source, 
  +    public CurrentNodeListIterator(DTMAxisIterator source, 
   				   CurrentNodeListFilter filter,
   				   int currentNode,
   				   AbstractTranslet translet) 
  @@ -124,7 +125,7 @@
   	this(source, !source.isReverse(), filter, currentNode, translet);
       }
   
  -    public CurrentNodeListIterator(NodeIterator source, boolean docOrder,
  +    public CurrentNodeListIterator(DTMAxisIterator source, boolean docOrder,
   				   CurrentNodeListFilter filter,
   				   int currentNode,
   				   AbstractTranslet translet) 
  @@ -136,6 +137,11 @@
   	_currentNode = currentNode;
       }
   
  +    public DTMAxisIterator forceNaturalOrder() {
  +	_docOrder = true;
  +	return this;
  +    }
  +
       public void setRestartable(boolean isRestartable) {
   	_isRestartable = isRestartable;
   	_source.setRestartable(isRestartable);
  @@ -145,7 +151,7 @@
   	return !_docOrder;
       }
   
  -    public NodeIterator cloneIterator() {
  +    public DTMAxisIterator cloneIterator() {
   	try {
   	    final CurrentNodeListIterator clone =
   		(CurrentNodeListIterator) super.clone();
  @@ -161,7 +167,7 @@
   	}
       }
       
  -    public NodeIterator reset() {
  +    public DTMAxisIterator reset() {
   	_currentIndex = 0;
   	return resetPosition();
       }
  @@ -175,7 +181,8 @@
   	    final int position = _docOrder ? index + 1 : last - index;
   	    final int node = _nodes.at(index++); 	// note increment
   
  -	    if (_filter.test(node, position, last, currentNode, translet, this)) {
  +	    if (_filter.test(node, position, last, currentNode, translet,
  +                             this)) {
   		_currentIndex = index;
   		return returnNode(node);
   	    }
  @@ -183,7 +190,7 @@
   	return END;
       }
   
  -    public NodeIterator setStartNode(int node) {
  +    public DTMAxisIterator setStartNode(int node) {
   	if (_isRestartable) {
   	    _source.setStartNode(_startNode = node);
   
  @@ -222,11 +229,11 @@
   	    final int position = _docOrder ? index + 1 : last - index;
               int nodeIndex = _nodes.at(index++); 	// note increment
   
  -            if (_filter.test(nodeIndex, position, last, currNode, translet, this)) {
  +            if (_filter.test(nodeIndex, position, last, currNode, translet,
  +                             this)) {
                   lastPosition++;
               }
           }
   	return lastPosition;
       }
   }
  -
  
  
  
  1.18      +290 -151  xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMAdapter.java
  
  Index: DOMAdapter.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMAdapter.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- DOMAdapter.java	21 Feb 2003 19:24:43 -0000	1.17
  +++ DOMAdapter.java	1 Apr 2003 21:39:16 -0000	1.18
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -64,83 +64,169 @@
   package org.apache.xalan.xsltc.dom;
   
   import org.apache.xalan.xsltc.DOM;
  -import org.apache.xalan.xsltc.NodeIterator;
   import org.apache.xalan.xsltc.StripFilter;
   import org.apache.xalan.xsltc.TransletException;
  -import org.apache.xalan.xsltc.TransletOutputHandler;
  +import org.apache.xalan.xsltc.runtime.Hashtable;
  +import org.apache.xml.dtm.DTM;
  +import org.apache.xml.dtm.DTMAxisIterator;
  +import org.apache.xml.serializer.SerializationHandler;
   
   import org.w3c.dom.Node;
   import org.w3c.dom.NodeList;
   
   public final class DOMAdapter implements DOM {
   
  -    private final DOMImpl _domImpl;
  +    // Mutually exclusive casting of DOM interface to known implementations
  +    private SAXImpl _saxImpl;
  +
  +    private DOM _dom;
  +
       private String[] _namesArray;
       private String[] _namespaceArray;
   
       // Cached mappings
       private short[] _mapping = null;
  -    private short[] _reverse = null;
  +    private int[]   _reverse = null;
       private short[] _NSmapping = null;
       private short[] _NSreverse = null;
   
       private StripFilter _filter = null;
   
       private int _multiDOMMask;
  -
  -    public DOMAdapter(DOMImpl dom,
  -		      String[] namesArray,
  -		      String[] namespaceArray)
  -    {
  -	_domImpl = dom;
  -	_namesArray = namesArray;
  -	_namespaceArray = namespaceArray;
  +    
  +    public DOMAdapter(DOM dom,
  +                      String[] namesArray,
  +                      String[] namespaceArray) {
  +        if (dom instanceof SAXImpl){
  +            _saxImpl = (SAXImpl) dom;
  +        }
  +
  +        _dom = dom;
  +        _namesArray = namesArray;
  +        _namespaceArray = namespaceArray;
       }
   
       public void setupMapping(String[] names, String[] namespaces) {
  -	_namesArray = names;
  -	_namespaceArray = namespaces;
  +        _namesArray = names;
  +        _namespaceArray = namespaces;
  +    }
  +    
  +    public String[] getNamesArray() {
  +        return _namesArray;
  +    }
  +    
  +    public String[] getNamespaceArray() {
  +        return _namespaceArray;
  +    }
  +    
  +    public DOM getDOMImpl() {
  +    	return _dom;
       }
   
       private short[] getMapping() {
  -	if (_mapping == null) {
  -	    _mapping = _domImpl.getMapping(_namesArray);
  -	}
  -	return _mapping;
  +        if (_mapping == null) {
  +            if (_saxImpl != null) {
  +                _mapping = _saxImpl.getMapping(_namesArray);
  +            } 
  +        }
  +        return _mapping;
       }
   
  -    private short[] getReverse() {
  +    private int[] getReverse() {
   	if (_reverse == null) {
  -	    _reverse = _domImpl.getReverseMapping(_namesArray);
  +            if (_saxImpl != null) {
  +	        _reverse = _saxImpl.getReverseMapping(_namesArray);
  +            }
   	}
   	return _reverse;
       }
   
       private short[] getNSMapping() {
   	if (_NSmapping == null) {
  -	    _NSmapping = _domImpl.getNamespaceMapping(_namespaceArray);
  +            if (_saxImpl != null) {
  +	        _NSmapping = _saxImpl.getNamespaceMapping(_namespaceArray);
  +            }
   	}
   	return _NSmapping;
       }
   
       private short[] getNSReverse() {
   	if (_NSreverse == null) {
  -	    _NSreverse = _domImpl.getReverseNamespaceMapping(_namespaceArray);
  +            if (_saxImpl != null) {
  +	        _NSreverse = _saxImpl.getReverseNamespaceMapping(_namespaceArray);
  +            }
   	}
   	return _NSreverse;
       }
   
  -    /**
  -      * Returns singleton iterator containg the document root
  +    /** 
  +      * Returns singleton iterator containg the document root 
         */
  -    public NodeIterator getIterator() {
  -	return _domImpl.getIterator();
  +    public DTMAxisIterator getIterator() {
  +        return _dom.getIterator();
       }
  -
  +    
       public String getStringValue() {
  -	return _domImpl.getStringValue();
  +        return _dom.getStringValue();
  +    }
  +    
  +    public DTMAxisIterator getChildren(final int node) {
  +        if (_saxImpl != null) {
  +            return _saxImpl.getChildren(node);
  +        }
  +        else {
  +            DTMAxisIterator iterator = _dom.getChildren(node);
  +            return iterator.setStartNode(node);
  +        }
       }
   
  +    public void setFilter(StripFilter filter) {
  +	_filter = filter;
  +    }
  +
  +    public DTMAxisIterator getTypedChildren(final int type) {
  +        final int[] reverse = getReverse();
  +
  +        if (_saxImpl != null) {
  +            return _saxImpl.getTypedChildren(reverse[type]);
  +        }
  +        else {
  +            return _dom.getTypedChildren(type);
  +        }      
  +    }
  +
  +    public DTMAxisIterator getNamespaceAxisIterator(final int axis,
  +                                                    final int ns) {
  +        return _dom.getNamespaceAxisIterator(axis, getNSReverse()[ns]);
  +    }
  +
  +    public DTMAxisIterator getAxisIterator(final int axis) {
  +        if (_saxImpl != null) {
  +            return _saxImpl.getAxisIterator(axis);
  +        }
  +        else {
  +            return _dom.getAxisIterator(axis);
  +        }        
  +    }
  +    
  +    public DTMAxisIterator getTypedAxisIterator(final int axis,
  +                                                final int type) {
  +        final int[] reverse = getReverse();
  +
  +        if (axis == Axis.NAMESPACE) {
  +            short[] NSReverse = getNSReverse();
  +            if (type == NO_TYPE || type > NSReverse.length) {
  +                return _dom.getAxisIterator(axis);
  +            } else {
  +                return _dom.getTypedAxisIterator(axis, NSReverse[type]);
  +            }
  +        } else if (_saxImpl != null) {
  +            return _saxImpl.getTypedAxisIterator(axis, reverse[type]);
  +        } else {
  +            return _dom.getTypedAxisIterator(axis, type);
  +        }      
  +    }
  +        
       public int getMultiDOMMask() {
   	return _multiDOMMask;
       }
  @@ -149,177 +235,230 @@
   	_multiDOMMask = mask;
       }
   
  -    public NodeIterator getChildren(final int node) {
  -	NodeIterator iterator = _domImpl.getChildren(node);
  -	if (_filter == null) {
  -	    return iterator.setStartNode(node);
  -	}
  -	else {
  -	    iterator = _domImpl.strippingIterator(iterator, getMapping(),
  -		_filter);
  -	    return iterator.setStartNode(node);
  -	}
  +    public DTMAxisIterator getNthDescendant(int type, int n,
  +                                            boolean includeself) {
  +        return _dom.getNthDescendant(getReverse()[type], n, includeself);
  +    }
  +
  +    public DTMAxisIterator getNodeValueIterator(DTMAxisIterator iterator,
  +                                                int type, String value,
  +                                                boolean op) {
  +        return _dom.getNodeValueIterator(iterator, type, value, op);
  +    }
  +
  +    public DTMAxisIterator orderNodes(DTMAxisIterator source, int node) {
  +        return _dom.orderNodes(source, node);
  +    }
  +    
  +    public int getExpandedTypeID(final int node) {
  +        if (_saxImpl != null) {
  +            return getMapping()[_saxImpl.getExpandedTypeID2(node)];
  +        }
  +        else {
  +            return getMapping()[_dom.getExpandedTypeID(node)];
  +        }
       }
   
  -    public void setFilter(StripFilter filter) {
  -	_filter = filter;
  -    }
  -
  -    public NodeIterator getTypedChildren(final int type) {
  -	final short[] reverse = getReverse();
  -
  -	NodeIterator iterator = _domImpl.getTypedChildren(reverse[type]);
  -	if (reverse[type] == DOM.TEXT && _filter != null) {
  -	    return _domImpl.strippingIterator(iterator, getMapping(), _filter);
  -	}
  -	return iterator;
  +    public int getNamespaceType(final int node) {
  +    	return getNSMapping()[_dom.getNSType(node)];
       }
   
  -    public NodeIterator getNamespaceAxisIterator(final int axis, final int ns) {
  -	return _domImpl.getNamespaceAxisIterator(axis, getNSReverse()[ns]);
  +    public int getNSType(int node) {
  +	return _dom.getNSType(node);
       }
  -
  -    public NodeIterator getAxisIterator(final int axis) {
  -	NodeIterator iterator = _domImpl.getAxisIterator(axis);
  -	if (_filter != null) {
  -	    return _domImpl.strippingIterator(iterator, getMapping(), _filter);
  -	}
  -	return iterator;
  +    
  +    public int getParent(final int node) {
  +        return _dom.getParent(node);
       }
   
  -    public NodeIterator getTypedAxisIterator(final int axis, final int type) {
  -	NodeIterator iterator;
  -	final short[] reverse = getReverse();
  -	final short[] NSreverse = getNSReverse();
  -
  -	if (axis == Axis.NAMESPACE) {
  -	    iterator = (type == NO_TYPE || type > NSreverse.length) ?
  -		_domImpl.getAxisIterator(axis) :
  -		_domImpl.getTypedAxisIterator(axis, NSreverse[type]);
  -	}
  -	else {
  -	    iterator = _domImpl.getTypedAxisIterator(axis, reverse[type]);
  -	}
  -
  -	if (reverse[type] == DOM.TEXT && _filter != null) {
  -	    iterator = _domImpl.strippingIterator(iterator, getMapping(), _filter);
  -	}
  -	return iterator;
  +    public int getAttributeNode(final int type, final int element) {
  +	return _dom.getAttributeNode(getReverse()[type], element);
       }
  -
  -    public NodeIterator getNthDescendant(int type, int n, boolean includeself) {
  -	return _domImpl.getNthDescendant(getReverse()[type], n, includeself);
  +    
  +    public String getNodeName(final int node) {
  +    	if (node == DTM.NULL) {
  +    	    return "";
  +    	}
  +        return _dom.getNodeName(node);
       }
  -
  -    public NodeIterator getNodeValueIterator(NodeIterator iterator, int type,
  -					     String value, boolean op)
  +    
  +    public String getNodeNameX(final int node) 
       {
  -	return _domImpl.getNodeValueIterator(iterator, type, value, op);
  -    }
  -
  -    public NodeIterator orderNodes(NodeIterator source, int node) {
  -	return _domImpl.orderNodes(source, node);
  +    	if (node == DTM.NULL) {
  +    	    return "";
  +    	}
  +        return _dom.getNodeNameX(node);
       }
   
  -    public int getType(final int node) {
  -	return getMapping()[_domImpl.getType(node)];
  +    public String getNamespaceName(final int node) 
  +    {
  +    	if (node == DTM.NULL) {
  +    	    return "";
  +    	}
  +        return _dom.getNamespaceName(node);
  +    }
  +    
  +    public String getStringValueX(final int node) 
  +    {    	
  +    	if (_saxImpl != null) {
  +            return _saxImpl.getStringValueX(node);
  +        }
  +        else {
  +            if (node == DTM.NULL) {
  +    	        return "";
  +    	    }
  +            return _dom.getStringValueX(node);
  +        }
  +    }
  +    
  +    public void copy(final int node, SerializationHandler handler)
  +	throws TransletException 
  +    {
  +        _dom.copy(node, handler);
       }
  -
  -    public int getNamespaceType(final int node) {
  -	return getNSMapping()[_domImpl.getNamespaceType(node)];
  +    
  +    public void copy(DTMAxisIterator nodes,SerializationHandler handler)
  +	throws TransletException 
  +    {
  +	_dom.copy(nodes, handler);
       }
   
  -    public int getParent(final int node) {
  -	return _domImpl.getParent(node);
  +    public String shallowCopy(final int node, SerializationHandler handler)
  +	throws TransletException 
  +    {
  +        if (_saxImpl != null) {
  +            return _saxImpl.shallowCopy(node, handler);
  +        }
  +        else {
  +            return _dom.shallowCopy(node, handler);
  +        }
       }
  -
  -    public int getAttributeNode(final int type, final int element) {
  -	return _domImpl.getAttributeNode(getReverse()[type], element);
  +    
  +    public boolean lessThan(final int node1, final int node2) 
  +    {
  +        return _dom.lessThan(node1, node2);
       }
  -
  -    public String getNodeName(final int node) {
  -	return _domImpl.getNodeName(node);
  +    
  +    public void characters(final int textNode, SerializationHandler handler)
  +      throws TransletException 
  +    {
  +        if (_saxImpl != null) {
  +            _saxImpl.characters(textNode, handler);
  +        }
  +        else {
  +            _dom.characters(textNode, handler);
  +        }
       }
   
  -    public String getNamespaceName(final int node) {
  -	return _domImpl.getNamespaceName(node);
  +    public Node makeNode(int index) 
  +    {
  +        return _dom.makeNode(index);
       }
   
  -    public String getNodeValue(final int node) {
  -	return _domImpl.getNodeValue(node);
  +    public Node makeNode(DTMAxisIterator iter) 
  +    {
  +        return _dom.makeNode(iter);
       }
   
  -    public void copy(final int node, TransletOutputHandler handler)
  -	throws TransletException {
  -	    _domImpl.copy(node, handler);
  +    public NodeList makeNodeList(int index) 
  +    {
  +        return _dom.makeNodeList(index);
       }
   
  -    public void copy(NodeIterator nodes, TransletOutputHandler handler)
  -	throws TransletException {
  -	    _domImpl.copy(nodes, handler);
  +    public NodeList makeNodeList(DTMAxisIterator iter) 
  +    {
  +        return _dom.makeNodeList(iter);
       }
   
  -    public String shallowCopy(final int node, TransletOutputHandler handler)
  -	throws TransletException {
  -	    return _domImpl.shallowCopy(node, handler);
  +    public String getLanguage(int node) 
  +    {
  +        return _dom.getLanguage(node);
       }
   
  -    public boolean lessThan(final int node1, final int node2) {
  -	return _domImpl.lessThan(node1, node2);
  +    public int getSize() 
  +    {
  +        return _dom.getSize();
       }
   
  -    public void characters(final int textNode, TransletOutputHandler handler)
  -	throws TransletException {
  -	_domImpl.characters(textNode, handler);
  +    public void setDocumentURI(String uri) 
  +    {
  +        if (_saxImpl != null) {
  +            _saxImpl.setDocumentURI(uri);
  +        }
       }
   
  -    public Node makeNode(int index) {
  -	return _domImpl.makeNode(index);
  +    public String getDocumentURI()
  +    {
  +        if (_saxImpl != null) {
  +            return _saxImpl.getDocumentURI();
  +        }
  +        else {
  +            return "";
  +        }
       }
   
  -    public Node makeNode(NodeIterator iter) {
  -	return _domImpl.makeNode(iter);
  +    public String getDocumentURI(int node) 
  +    {
  +        return _dom.getDocumentURI(node);
       }
   
  -    public NodeList makeNodeList(int index) {
  -	return _domImpl.makeNodeList(index);
  +    public int getDocument() 
  +    {
  +        return _dom.getDocument();
       }
   
  -    public NodeList makeNodeList(NodeIterator iter) {
  -	return _domImpl.makeNodeList(iter);
  +    public boolean isElement(final int node) 
  +    {
  +        return(_dom.isElement(node));
       }
   
  -    public String getLanguage(int node) {
  -	return _domImpl.getLanguage(node);
  +    public boolean isAttribute(final int node) 
  +    {
  +        return(_dom.isAttribute(node));
       }
  -
  -    public int getSize() {
  -	return _domImpl.getSize();
  +    
  +    public int getNodeIdent(int nodeHandle)
  +    {
  +    	return _dom.getNodeIdent(nodeHandle);
       }
  -
  -    public void setDocumentURI(String uri) {
  -	_domImpl.setDocumentURI(uri);
  +    
  +    public int getNodeHandle(int nodeId)
  +    {
  +    	return _dom.getNodeHandle(nodeId);
       }
  -
  -    public String getDocumentURI() {
  -	return(_domImpl.getDocumentURI());
  +    
  +    /**
  +     * Return a instance of a DOM class to be used as an RTF
  +     */ 
  +    public DOM getResultTreeFrag(int initSize, int rtfType)
  +    {
  +    	if (_saxImpl != null) {
  +    	    return _saxImpl.getResultTreeFrag(initSize, rtfType);
  +    	}
  +    	else {
  +    	    return _dom.getResultTreeFrag(initSize, rtfType);
  +    	}
       }
  -
  -    public String getDocumentURI(int node) {
  -	return(_domImpl.getDocumentURI());
  +    
  +    /**
  +     * Returns a SerializationHandler class wrapped in a SAX adapter.
  +     */
  +    public SerializationHandler getOutputDomBuilder()
  +    {
  +    	return _dom.getOutputDomBuilder();
       }
   
  -    public boolean isElement(final int node) {
  -	return(_domImpl.isElement(node));
  +    public String lookupNamespace(int node, String prefix) 
  +	throws TransletException 
  +    {
  +	return _dom.lookupNamespace(node, prefix);
       }
   
  -    public boolean isAttribute(final int node) {
  -	return(_domImpl.isAttribute(node));
  +    public String getUnparsedEntityURI(String entity) {
  +        return _dom.getUnparsedEntityURI(entity);
       }
   
  -    public String lookupNamespace(int node, String prefix)
  -	throws TransletException
  -    {
  -	return _domImpl.lookupNamespace(node, prefix);
  +    public Hashtable getElementsWithIDs() {
  +        return _dom.getElementsWithIDs();
       }
   }
  
  
  
  1.5       +2 -2      xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMBuilder.java
  
  Index: DOMBuilder.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMBuilder.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- DOMBuilder.java	30 Jan 2003 18:46:10 -0000	1.4
  +++ DOMBuilder.java	1 Apr 2003 21:39:16 -0000	1.5
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  
  
  
  1.9       +25 -24    xml-xalan/java/src/org/apache/xalan/xsltc/dom/DocumentCache.java
  
  Index: DocumentCache.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DocumentCache.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- DocumentCache.java	30 Jan 2003 18:46:10 -0000	1.8
  +++ DocumentCache.java	1 Apr 2003 21:39:16 -0000	1.9
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -73,13 +73,16 @@
   import javax.xml.parsers.ParserConfigurationException;
   import javax.xml.parsers.SAXParser;
   import javax.xml.parsers.SAXParserFactory;
  +import javax.xml.transform.sax.SAXSource;
   
  +import org.apache.xalan.xsltc.DOM;
   import org.apache.xalan.xsltc.DOMCache;
   import org.apache.xalan.xsltc.Translet;
   import org.apache.xalan.xsltc.runtime.AbstractTranslet;
   import org.apache.xalan.xsltc.runtime.BasisLibrary;
   import org.apache.xalan.xsltc.runtime.Constants;
   
  +import org.xml.sax.InputSource;
   import org.xml.sax.SAXException;
   import org.xml.sax.XMLReader;
   
  @@ -92,6 +95,7 @@
       private int       _current;
       private SAXParser _parser;
       private XMLReader _reader;
  +    private XSLTCDTMManager _dtmManager;
   
       private static final int REFRESH_INTERVAL = 1000;
   
  @@ -109,8 +113,7 @@
   	private long _buildTime;
   
   	// DOM and DTD handler references
  -	private DOMImpl    _dom = null;
  -	private DTDMonitor _dtdMonitor = null;
  +	private SAXImpl    _dom = null;
   	
   	/**
   	 * Constructor - load document and initialise statistics
  @@ -131,15 +134,11 @@
   	 */
   	public void loadDocument(String uri) {
   
  -	    _dom = new DOMImpl();
  -	    _dtdMonitor = new DTDMonitor();
  -
   	    try {
   		final long stamp = System.currentTimeMillis();
  -
  -		_reader.setContentHandler(_dom.getBuilder());
  -		_dtdMonitor.handleDTD(_reader);
  -		_reader.parse(uri);
  +                _dom = (SAXImpl)_dtmManager.getDTM(
  +                                 new SAXSource(_reader, new InputSource(uri)),
  +                                 false, null, true, false);
   		_dom.setDocumentURI(uri);
   
   		// The build time can be used for statistics for a better
  @@ -152,13 +151,10 @@
   	    }
   	    catch (Exception e) {
   		_dom = null;
  -		_dtdMonitor = null;
   	    }
   	}
   
  -	public DOMImpl getDocument()       { return(_dom); }
  -
  -	public DTDMonitor getDTDMonitor()  { return(_dtdMonitor); }
  +	public DOM getDocument()       { return(_dom); }
   
   	public long getFirstReferenced()   { return(_firstReferenced); }
   
  @@ -191,6 +187,15 @@
        * DocumentCache constructor
        */
       public DocumentCache(int size) throws SAXException {
  +        this(size, null);
  +        _dtmManager = XSLTCDTMManager.newInstance();
  +    }
  +
  +    /**
  +     * DocumentCache constructor
  +     */
  +    public DocumentCache(int size, XSLTCDTMManager dtmManager) throws SAXException {
  +	_dtmManager = dtmManager;
   	_count = 0;
   	_current = 0;
   	_size  = size;
  @@ -279,7 +284,7 @@
        * Returns a document either by finding it in the cache or
        * downloading it and putting it in the cache.
        */
  -    public final DOMImpl retrieveDocument(String uri, int mask, Translet trs) {
  +    public final DOM retrieveDocument(String uri, int mask, Translet trs) {
   	CachedDocument doc;
   
   	// Try to get the document from the cache first
  @@ -310,8 +315,7 @@
   	}
   
   	// Get the references to the actual DOM and DTD handler
  -	final DOMImpl    dom = doc.getDocument();
  -	final DTDMonitor dtd = doc.getDTDMonitor();
  +	final DOM dom = doc.getDocument();
   
   	// The dom reference may be null if the URL pointed to a
   	// non-existing document
  @@ -321,12 +325,9 @@
   
   	final AbstractTranslet translet = (AbstractTranslet)trs;
   
  -	// Set minimum needed size for key/id indices in the translet
  -	translet.setIndexSize(dom.getSize());
  -	// Create index for any ID attributes defined in the document DTD
  -	dtd.buildIdIndex(dom, mask, translet);
  -	// Pass all unparsed entities to the translet
  -	translet.setUnparsedEntityURIs(dtd.getUnparsedEntityURIs());
  +	// Give the translet an early opportunity to extract any
  +        // information from the DOM object that it would like.
  +	translet.prepassDocument(dom);
   
   	return(doc.getDocument());
       }
  
  
  
  1.11      +19 -13    xml-xalan/java/src/org/apache/xalan/xsltc/dom/DupFilterIterator.java
  
  Index: DupFilterIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/DupFilterIterator.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DupFilterIterator.java	30 Jan 2003 18:46:10 -0000	1.10
  +++ DupFilterIterator.java	1 Apr 2003 21:39:16 -0000	1.11
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -62,22 +62,23 @@
   
   package org.apache.xalan.xsltc.dom;
   
  -import org.apache.xalan.xsltc.DOM;
  -import org.apache.xalan.xsltc.NodeIterator;
   import org.apache.xalan.xsltc.runtime.BasisLibrary;
   import org.apache.xalan.xsltc.util.IntegerArray;
  +import org.apache.xml.dtm.DTMAxisIterator;
  +import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
  +import org.apache.xml.dtm.ref.DTMDefaultBase;
   
   /**
    * Removes duplicates and sorts a source iterator. The nodes from the 
    * source are collected in an array upon calling setStartNode(). This
    * array is later sorted and duplicates are ignored in next().
    */
  -public final class DupFilterIterator extends NodeIteratorBase {
  +public final class DupFilterIterator extends DTMAxisIteratorBase {
   
       /**
        * Reference to source iterator.
        */
  -    private NodeIterator _source;
  +    private DTMAxisIterator _source;
   
       /**
        * Array to cache all nodes from source.
  @@ -99,7 +100,7 @@
        */
       private int _lastNext = END;
   
  -    public DupFilterIterator(NodeIterator source) {
  +    public DupFilterIterator(DTMAxisIterator source) {
   	_source = source;
   // System.out.println("DFI source = " + source + " this = " + this);
   
  @@ -107,15 +108,20 @@
   	// union expressions containing multiple calls to the same index, and
   	// correct as well since start-node is irrelevant for id()/key() exrp.
   	if (source instanceof KeyIndex) {
  -	    setStartNode(DOM.ROOTNODE);
  +	    setStartNode(DTMDefaultBase.ROOTNODE);
   	}
       }
  -
  -    public NodeIterator setStartNode(int node) {
  +    /**
  +     * Set the start node for this iterator
  +     * @param node The start node
  +     * @return A reference to this node iterator
  +     */
  +    public DTMAxisIterator setStartNode(int node) {
   	if (_isRestartable) {
   	    // KeyIndex iterators are always relative to the root node, so there
   	    // is never any point in re-reading the iterator (and we SHOULD NOT).
  -	    if (_source instanceof KeyIndex && _startNode == DOM.ROOTNODE) {
  +	    if (_source instanceof KeyIndex
  +                    && _startNode == DTMDefaultBase.ROOTNODE) {
   		return this;
   	    }
   
  @@ -147,7 +153,7 @@
   	return END;
       }
   
  -    public NodeIterator cloneIterator() {
  +    public DTMAxisIterator cloneIterator() {
   	try {
   	    final DupFilterIterator clone =
   		(DupFilterIterator) super.clone();
  @@ -176,7 +182,7 @@
   	_current = _markedNode;
       }
   
  -    public NodeIterator reset() {
  +    public DTMAxisIterator reset() {
   	_current = 0;
   	_lastNext = END;
   	return resetPosition();
  
  
  
  1.2       +2 -2      xml-xalan/java/src/org/apache/xalan/xsltc/dom/EmptyFilter.java
  
  Index: EmptyFilter.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/EmptyFilter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- EmptyFilter.java	17 Apr 2001 18:52:30 -0000	1.1
  +++ EmptyFilter.java	1 Apr 2003 21:39:16 -0000	1.2
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  
  
  
  1.3       +7 -4      xml-xalan/java/src/org/apache/xalan/xsltc/dom/ExtendedSAX.java
  
  Index: ExtendedSAX.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/ExtendedSAX.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ExtendedSAX.java	24 Apr 2002 17:03:16 -0000	1.2
  +++ ExtendedSAX.java	1 Apr 2003 21:39:16 -0000	1.3
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -62,8 +62,11 @@
   package org.apache.xalan.xsltc.dom;
   
   import org.xml.sax.ContentHandler;
  +import org.xml.sax.DTDHandler;
  +import org.xml.sax.ext.DeclHandler;
   import org.xml.sax.ext.LexicalHandler;
   
  -public interface ExtendedSAX extends ContentHandler, LexicalHandler { 
  -    public boolean setEscaping(boolean escape);
  +public interface ExtendedSAX extends ContentHandler, LexicalHandler, DTDHandler,
  +                                     DeclHandler
  +{ 
   }
  
  
  
  1.2       +2 -2      xml-xalan/java/src/org/apache/xalan/xsltc/dom/Filter.java
  
  Index: Filter.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/Filter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Filter.java	17 Apr 2001 18:52:30 -0000	1.1
  +++ Filter.java	1 Apr 2003 21:39:16 -0000	1.2
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  
  
  
  1.7       +16 -11    xml-xalan/java/src/org/apache/xalan/xsltc/dom/FilterIterator.java
  
  Index: FilterIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/FilterIterator.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- FilterIterator.java	21 Oct 2002 20:40:31 -0000	1.6
  +++ FilterIterator.java	1 Apr 2003 21:39:16 -0000	1.7
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -63,8 +63,11 @@
   
   package org.apache.xalan.xsltc.dom;
   
  -import org.apache.xalan.xsltc.NodeIterator;
   import org.apache.xalan.xsltc.runtime.BasisLibrary;
  +import org.apache.xml.dtm.DTMAxisIterator;
  +import org.apache.xml.dtm.DTMFilter;
  +import org.apache.xml.dtm.DTMIterator;
  +import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
   
   /**
    * Similar to a CurrentNodeListIterator except that the filter has a 
  @@ -72,24 +75,24 @@
    * It takes a source iterator and a Filter object and returns nodes 
    * from the source after filtering them by calling filter.test(node).
    */
  -public final class FilterIterator extends NodeIteratorBase {
  +public final class FilterIterator extends DTMAxisIteratorBase {
   
       /**
        * Reference to source iterator.
        */
  -    private NodeIterator _source;
  +    private DTMAxisIterator _source;
   
       /**
        * Reference to a filter object that to be applied to each node.
        */
  -    private final Filter _filter;
  +    private final DTMFilter _filter;
   
       /**
        * A flag indicating if position is reversed.
        */
       private final boolean _isReverse;
   	
  -    public FilterIterator(NodeIterator source, Filter filter) {
  +    public FilterIterator(DTMAxisIterator source, DTMFilter filter) {
   	_source = source;
   // System.out.println("FI souce = " + source + " this = " + this);
   	_filter = filter;
  @@ -100,12 +103,14 @@
   	return _isReverse;
       }
   
  +
       public void setRestartable(boolean isRestartable) {
   	_isRestartable = isRestartable;
   	_source.setRestartable(isRestartable);
       }
   
  -    public NodeIterator cloneIterator() {
  +    public DTMAxisIterator cloneIterator() {
  +
   	try {
   	    final FilterIterator clone = (FilterIterator) super.clone();
   	    clone._source = _source.cloneIterator();
  @@ -119,7 +124,7 @@
   	}
       }
       
  -    public NodeIterator reset() {
  +    public DTMAxisIterator reset() {
   	_source.reset();
   	return resetPosition();
       }
  @@ -127,14 +132,14 @@
       public int next() {
   	int node;
   	while ((node = _source.next()) != END) {
  -	    if (_filter.test(node)) {
  +	    if (_filter.acceptNode(node, DTMFilter.SHOW_ALL) == DTMIterator.FILTER_ACCEPT) {
   		return returnNode(node);
   	    }
   	}
   	return END;
       }
   
  -    public NodeIterator setStartNode(int node) {
  +    public DTMAxisIterator setStartNode(int node) {
   	if (_isRestartable) {
   	    _source.setStartNode(_startNode = node); 
   	    return resetPosition();
  
  
  
  1.8       +6 -6      xml-xalan/java/src/org/apache/xalan/xsltc/dom/FilteredStepIterator.java
  
  Index: FilteredStepIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/FilteredStepIterator.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- FilteredStepIterator.java	30 Jan 2003 18:46:11 -0000	1.7
  +++ FilteredStepIterator.java	1 Apr 2003 21:39:16 -0000	1.8
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -64,7 +64,7 @@
   
   package org.apache.xalan.xsltc.dom;
   
  -import org.apache.xalan.xsltc.NodeIterator;
  +import org.apache.xml.dtm.DTMAxisIterator;
   
   /**
    * Extends a StepIterator by adding the ability to filter nodes. It 
  @@ -73,9 +73,9 @@
   public final class FilteredStepIterator extends StepIterator {
   
       private Filter _filter;
  -	
  -    public FilteredStepIterator(NodeIterator source,
  -				NodeIterator iterator,
  +
  +    public FilteredStepIterator(DTMAxisIterator source,
  +				DTMAxisIterator iterator,
   				Filter filter) {
   	super(source, iterator);
   	_filter = filter;
  
  
  
  1.6       +10 -13    xml-xalan/java/src/org/apache/xalan/xsltc/dom/ForwardPositionIterator.java
  
  Index: ForwardPositionIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/ForwardPositionIterator.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ForwardPositionIterator.java	22 Oct 2002 21:09:53 -0000	1.5
  +++ ForwardPositionIterator.java	1 Apr 2003 21:39:16 -0000	1.6
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -62,8 +62,9 @@
   
   package org.apache.xalan.xsltc.dom;
   
  -import org.apache.xalan.xsltc.NodeIterator;
   import org.apache.xalan.xsltc.runtime.BasisLibrary;
  +import org.apache.xml.dtm.DTMAxisIterator;
  +import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
   
   /**
    * This iterator is a wrapper that always returns the position of
  @@ -71,15 +72,15 @@
    * a call to position() occurs in the context of an XSLT element
    * such as xsl:for-each, xsl:apply-templates, etc. 
    */
  -public final class ForwardPositionIterator extends NodeIteratorBase {
  +public final class ForwardPositionIterator extends DTMAxisIteratorBase {
   
  -    private NodeIterator _source;
  +    private DTMAxisIterator _source;
   
  -    public ForwardPositionIterator(NodeIterator source) {
  +    public ForwardPositionIterator(DTMAxisIterator source) {
   	_source = source;
       }
   
  -    public NodeIterator cloneIterator() {
  +    public DTMAxisIterator cloneIterator() {
   	try {
   	    final ForwardPositionIterator clone = 
   		(ForwardPositionIterator) super.clone();
  @@ -98,18 +99,14 @@
   	return returnNode(_source.next());
       }
   	
  -    public NodeIterator setStartNode(int node) {
  +    public DTMAxisIterator setStartNode(int node) {
   	_source.setStartNode(node);
   	return this;
       }
   
  -    public NodeIterator reset() {
  +    public DTMAxisIterator reset() {
   	_source.reset();
   	return resetPosition();
  -    }
  -
  -    public int getPosition() {
  -	return _position == 0 ? 1 : _position;
       }
   
       public void setMark() {
  
  
  
  1.11      +88 -17    xml-xalan/java/src/org/apache/xalan/xsltc/dom/KeyIndex.java
  
  Index: KeyIndex.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/KeyIndex.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- KeyIndex.java	30 Jan 2003 18:46:11 -0000	1.10
  +++ KeyIndex.java	1 Apr 2003 21:39:16 -0000	1.11
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -65,11 +65,14 @@
   
   import java.util.StringTokenizer;
   
  -import org.apache.xalan.xsltc.NodeIterator;
  +import org.apache.xalan.xsltc.DOM;
   import org.apache.xalan.xsltc.runtime.Hashtable;
   import org.apache.xalan.xsltc.util.IntegerArray;
  +import org.apache.xml.dtm.DTM;
  +import org.apache.xml.dtm.DTMAxisIterator;
  +import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
   
  -public class KeyIndex extends NodeIteratorBase {
  +public class KeyIndex extends DTMAxisIteratorBase {
   
       /**
        * A mapping between values and nodesets.
  @@ -83,6 +86,14 @@
       private IntegerArray _nodes = null;
   
       /**
  +     * The XSLTC DOM object if this KeyIndex is being used to implement the
  +     * id() function.
  +     */
  +    private DOM        _dom;
  +    
  +    private SAXImpl    _saxImpl;
  +
  +    /**
        * Store position after call to setMark()
        */
       private int _markedPosition = 0;
  @@ -90,6 +101,9 @@
       public KeyIndex(int dummy) {
       }
   
  +    public void setRestartable(boolean flag) {
  +    }
  +
       /**
        * Adds a node to the node list for a given value. Nodes will
        * always be added in document order.
  @@ -131,8 +145,12 @@
   
   	final StringTokenizer values = new StringTokenizer((String) value);
   	while (values.hasMoreElements()) {
  -	    final IntegerArray nodes = 
  -		(IntegerArray) _index.get(values.nextElement());
  +            final String token = (String) values.nextElement();
  +	    IntegerArray nodes = (IntegerArray) _index.get(token);
  +
  +            if (nodes == null && _saxImpl != null && _saxImpl.hasDOMSource()) {
  +                nodes = getDOMNodeById(token);
  +            }
   
   	    if (nodes == null) continue;
   
  @@ -146,6 +164,25 @@
       }
   
       /**
  +     * Return an IntegerArray for the DOM Node which has the given id.
  +     * 
  +     * @param id The id
  +     * @return A IntegerArray representing the Node whose id is the given value.
  +     */
  +    public IntegerArray getDOMNodeById(String id) {
  +        IntegerArray nodes = null;
  +        if (_saxImpl != null) {
  +            int ident = _saxImpl.getElementById(id);
  +            if (ident != DTM.NULL) {
  +	        nodes = new IntegerArray();
  +	    	_index.put(id, nodes);
  +		nodes.add(ident);
  +            }
  +        }
  +        return nodes; 	
  +    }
  +    
  +    /**
        * This method must be called by the code generated by the key() function
        * prior to returning the node iterator.
        */
  @@ -158,10 +195,10 @@
        * Callers should not call next() after it returns END.
        */
       public int next() {
  -	if (_nodes == null) return END;
  +	if (_nodes == null) return DTMAxisIterator.END;
   
   	return (_position < _nodes.cardinality()) ? 
  -	    _nodes.at(_position++) : END;
  +	    _dom.getNodeHandle(_nodes.at(_position++)) : DTMAxisIterator.END;
       }
   
       public int containsID(int node, Object value) { 
  @@ -170,9 +207,12 @@
   	    final StringTokenizer values = new StringTokenizer(string);
   
   	    while (values.hasMoreElements()) {
  -		final IntegerArray nodes = 
  -		    (IntegerArray) _index.get(values.nextElement());
  +                final String token = (String) values.nextElement();
  +		IntegerArray nodes = (IntegerArray) _index.get(token);
   
  +		if (nodes == null && _saxImpl != null && _saxImpl.hasDOMSource()) {
  +		    nodes = getDOMNodeById(token);	
  +		}
   		if (nodes != null && nodes.indexOf(node) >= 0) {
   		    return 1;
   		}
  @@ -180,7 +220,10 @@
   	    return 0;
   	}
   	else {
  -	    final IntegerArray nodes = (IntegerArray) _index.get(value);
  +	    IntegerArray nodes = (IntegerArray) _index.get(value);
  +            if (nodes == null && _saxImpl != null && _saxImpl.hasDOMSource()) {
  +                nodes = getDOMNodeById(string);
  +            }
   	    return (nodes != null && nodes.indexOf(node) >= 0) ? 1 : 0;
   	}
       }
  @@ -193,7 +236,7 @@
       /**
        * Resets the iterator to the last start node.
        */
  -    public NodeIterator reset() {
  +    public DTMAxisIterator reset() {
   	_position = 0;
   	return this;
       }
  @@ -230,24 +273,52 @@
        * Set start to END should 'close' the iterator, 
        * i.e. subsequent call to next() should return END.
        */
  -    public NodeIterator setStartNode(int start) {
  -	if (start == END) {
  +    public DTMAxisIterator setStartNode(int start) {
  +	if (start == DTMAxisIterator.END) {
   	    _nodes = null;
   	}
   	else if (_nodes != null) {
   	    _position = 0;
   	}
  -	return this;
  +	return (DTMAxisIterator) this;
  +    }
  +    
  +    /** 
  +     * Get start to END should 'close' the iterator, 
  +     * i.e. subsequent call to next() should return END.
  +     */
  +    public int getStartNode() {      
  +        return 0;
  +    }
  +
  +    /**
  +     * True if this iterator has a reversed axis.
  +     */
  +    public boolean isReverse() {
  +	return(false);
       }
   
       /**
        * Returns a deep copy of this iterator.
        */
  -    public NodeIterator cloneIterator() {
  +    public DTMAxisIterator cloneIterator() {
   	KeyIndex other = new KeyIndex(0);
   	other._index = _index;
   	other._nodes = _nodes;
   	other._position = _position;
  -	return other;
  +	return (DTMAxisIterator) other;
  +    }
  +    
  +    public void setDom(DOM dom) {
  +    	_dom = dom;
  +    	if (dom instanceof SAXImpl) {
  +    	    _saxImpl = (SAXImpl)dom;
  +    	}
  +    	else if (dom instanceof DOMAdapter) {
  +    	    DOM idom = ((DOMAdapter)dom).getDOMImpl();
  +    	    if (idom instanceof SAXImpl) {
  +    	        _saxImpl = (SAXImpl)idom;
  +    	    }
  +    	}
       }
   }
  
  
  
  1.14      +93 -89    xml-xalan/java/src/org/apache/xalan/xsltc/dom/LoadDocument.java
  
  Index: LoadDocument.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/LoadDocument.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- LoadDocument.java	30 Jan 2003 18:46:11 -0000	1.13
  +++ LoadDocument.java	1 Apr 2003 21:39:17 -0000	1.14
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -67,13 +67,17 @@
   
   import javax.xml.parsers.SAXParser;
   import javax.xml.parsers.SAXParserFactory;
  +import javax.xml.transform.sax.SAXSource;
   
   import org.apache.xalan.xsltc.DOM;
   import org.apache.xalan.xsltc.DOMCache;
  -import org.apache.xalan.xsltc.NodeIterator;
   import org.apache.xalan.xsltc.TransletException;
   import org.apache.xalan.xsltc.runtime.AbstractTranslet;
  +import org.apache.xml.dtm.DTM;
  +import org.apache.xml.dtm.DTMAxisIterator;
  +import org.apache.xml.dtm.ref.DTMDefaultBase;
   
  +import org.xml.sax.InputSource;
   import org.xml.sax.XMLReader;
   
   public final class LoadDocument {
  @@ -85,94 +89,94 @@
        * Returns an iterator containing a set of nodes from an XML document
        * loaded by the document() function.
        */
  -    public static NodeIterator document(String uri, String base,
  +    public static DTMAxisIterator document(String uri, String base,
   					AbstractTranslet translet, DOM dom)
   	throws Exception 
       {
  -	final String originalUri = uri;
  -	MultiDOM multiplexer = (MultiDOM)dom;
  +        final String originalUri = uri;
  +        MultiDOM multiplexer = (MultiDOM)dom;
   
  -	// Return an empty iterator if the URI is clearly invalid
  -	// (to prevent some unncessary MalformedURL exceptions).
  -	if (uri == null || uri.equals("")) {
  -	    return new SingletonIterator(DOM.NULL,true);
  -	}
  -
  -	// Prepend URI base to URI (from context)
  -	if (base != null && !base.equals("")) {
  -	    if (!uri.startsWith(base)     &&   // unless URI contains base
  -		!uri.startsWith("/")      &&   // unless URI is abs. file path
  -		!uri.startsWith("http:/") &&   // unless URI is abs. http URL
  -		!uri.startsWith("file:/")) {   // unless URI is abs. file URL
  -		uri = base + uri;
  -	    }
  -	}
  -
  -	// Check if this is a local file name
  -	final File file = new File(uri);
  -	if (file.exists()) {
  -	    uri = file.toURL().toExternalForm();
  -	}
  +        // Return an empty iterator if the URI is clearly invalid
  +        // (to prevent some unncessary MalformedURL exceptions).
  +        if (uri == null || uri.equals("")) {
  +            return(new SingletonIterator(DTM.NULL,true));
  +        }
  +
  +        // Prepend URI base to URI (from context)
  +        if (base != null && !base.equals("")) {
  +            if (!uri.startsWith(base)     &&   // unless URI contains base
  +                !uri.startsWith("/")      &&   // unless URI is abs. file path
  +                !uri.startsWith("http:/") &&   // unless URI is abs. http URL
  +                !uri.startsWith("file:/")) {   // unless URI is abs. file URL
  +                uri = base + uri;
  +            }
  +        }
  +
  +        // Check if this is a local file name
  +        final File file = new File(uri);
  +        if (file.exists()) {
  +            uri = file.toURL().toExternalForm();
  +        }
   	
  -	// Check if this DOM has already been added to the multiplexer
  -	int mask = multiplexer.getDocumentMask(uri);
  -	if (mask != -1) {
  -	    return new SingletonIterator(DOM.ROOTNODE | mask, true);
  -	}
  -
  -	// Check if we can get the DOM from a DOMCache
  -	DOMCache cache = translet.getDOMCache();
  -	DOMImpl newdom;
  -
  -	mask = multiplexer.nextMask(); // peek
  -
  -	if (cache != null) {
  -	    newdom = cache.retrieveDocument(originalUri, mask, translet);
  -	    if (newdom == null) {
  -		final Exception e = new FileNotFoundException(originalUri);
  -		throw new TransletException(e);
  -	    }
  -	}
  -	else {
  -	    // Parse the input document and construct DOM object
  -	    // Create a SAX parser and get the XMLReader object it uses
  -	    final SAXParserFactory factory = SAXParserFactory.newInstance();
  -	    try {
  -		factory.setFeature(NAMESPACE_FEATURE,true);
  -	    }
  -	    catch (Exception e) {
  -		factory.setNamespaceAware(true);
  -	    }
  -	    final SAXParser parser = factory.newSAXParser();
  -	    final XMLReader reader = parser.getXMLReader();
  -
  -	    // Set the DOM's DOM builder as the XMLReader's SAX2 content handler
  -	    newdom = new DOMImpl();
  -	    reader.setContentHandler(newdom.getBuilder());
  -	    // Create a DTD monitor and pass it to the XMLReader object
  -	    DTDMonitor dtdMonitor = new DTDMonitor();
  -	    dtdMonitor.handleDTD(reader);
  -
  -	    newdom.setDocumentURI(uri);
  -	    reader.parse(uri);
  -
  -	    // Set size of key/id indices
  -	    translet.setIndexSize(newdom.getSize());
  -	    // Create index for any ID attributes defined in the document DTD
  -	    dtdMonitor.buildIdIndex(newdom, mask, translet);
  -	    // Pass any unparsed URI elements to the translet
  -	    translet.setUnparsedEntityURIs(dtdMonitor.getUnparsedEntityURIs());
  -	}
  -
  -	// Wrap the DOM object in a DOM adapter and add to multiplexer
  -	final DOMAdapter domAdapter = translet.makeDOMAdapter(newdom);
  -	mask = multiplexer.addDOMAdapter(domAdapter);
  +        // Check if this DOM has already been added to the multiplexer
  +        int mask = multiplexer.getDocumentMask(uri);
  +        if (mask != -1) {
  +            DOM newDom = ((DOMAdapter)multiplexer.getDOMAdapter(uri))
  +                                       .getDOMImpl();
  +            if (newDom instanceof SAXImpl) {
  +                return new SingletonIterator(((SAXImpl)newDom).getDocument(),
  +                                             true);
  +            } 
  +        }
  +
  +        // Check if we can get the DOM from a DOMCache
  +        DOMCache cache = translet.getDOMCache();
  +        DOM newdom;
  +
  +        mask = multiplexer.nextMask(); // peek
  +
  +        if (cache != null) {
  +            //newdom = cache.retrieveDocument(originalUri, mask, translet);
  +            newdom = cache.retrieveDocument(uri, mask, translet);
  +            if (newdom == null) {
  +                final Exception e = new FileNotFoundException(originalUri);
  +                throw new TransletException(e);
  +            }
  +        } else {
  +            // Parse the input document and construct DOM object
  +            // Create a SAX parser and get the XMLReader object it uses
  +            final SAXParserFactory factory = SAXParserFactory.newInstance();
  +            final SAXParser parser = factory.newSAXParser();
  +            final XMLReader reader = parser.getXMLReader();
  +            try {
  +                reader.setFeature(NAMESPACE_FEATURE,true);
  +            }
  +            catch (Exception e) {
  +                throw new TransletException(e);
  +            }
  +
  +            // Set the DOM's DOM builder as the XMLReader's SAX2 content handler
  +            XSLTCDTMManager dtmManager = (XSLTCDTMManager)
  +                        ((DTMDefaultBase)((DOMAdapter)multiplexer.getMain())
  +                                               .getDOMImpl()).m_mgr;
  +            newdom = (SAXImpl)dtmManager.getDTM(
  +                                 new SAXSource(reader, new InputSource(uri)),
  +                                 false, null, true, false, translet.hasIdCall());
  +
  +            translet.prepassDocument(newdom);
  +
  +            ((SAXImpl)newdom).setDocumentURI(uri);
  +        }
  +
  +        // Wrap the DOM object in a DOM adapter and add to multiplexer
  +        final DOMAdapter domAdapter = translet.makeDOMAdapter(newdom);
  +        multiplexer.addDOMAdapter(domAdapter);
   
  -	// Create index for any key elements
  -	translet.buildKeys((DOM)newdom, null, null, DOM.ROOTNODE | mask);
  +        // Create index for any key elements
  +        translet.buildKeys(domAdapter, null, null, ((SAXImpl)newdom).getDocument());
   
  -	// Return a singleton iterator containing the root node
  -	return new SingletonIterator(DOM.ROOTNODE | mask, true);
  +        // Return a singleton iterator containing the root node
  +        return new SingletonIterator(((SAXImpl)newdom).getDocument(), true);
       }
   
       /**
  @@ -181,7 +185,7 @@
        * iterator containing the requested nodes. Builds a union-iterator if
        * several documents are requested.
        */
  -    public static NodeIterator document(Object arg,String xmlURI,String xslURI,
  +    public static DTMAxisIterator document(Object arg,String xmlURI,String xslURI,
   					AbstractTranslet translet, DOM dom)
   	throws TransletException {
   	try {
  @@ -221,13 +225,13 @@
   	    }
   	    // Otherwise we must create a union iterator, add the nodes from
   	    // all the DOMs to this iterator, and return the union in the end.
  -	    else if (arg instanceof NodeIterator) {
  +	    else if (arg instanceof DTMAxisIterator) {
   		UnionIterator union = new UnionIterator(dom);
  -		NodeIterator iterator = (NodeIterator)arg;
  +		DTMAxisIterator iterator = (DTMAxisIterator)arg;
   		int node;
   
  -		while ((node = iterator.next()) != DOM.NULL) {
  -		    String uri = dom.getNodeValue(node);
  +		while ((node = iterator.next()) != DTM.NULL) {
  +		    String uri = dom.getStringValueX(node);
   		    // Get the URI from this node if no xml URI base is set
   		    if ((xmlURI == null) || xmlURI.equals("")) {
   			xmlURI = dom.getDocumentURI(node);
  
  
  
  1.8       +17 -14    xml-xalan/java/src/org/apache/xalan/xsltc/dom/MatchingIterator.java
  
  Index: MatchingIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/MatchingIterator.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- MatchingIterator.java	8 Oct 2002 21:44:14 -0000	1.7
  +++ MatchingIterator.java	1 Apr 2003 21:39:17 -0000	1.8
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -63,8 +63,9 @@
   
   package org.apache.xalan.xsltc.dom;
   
  -import org.apache.xalan.xsltc.NodeIterator;
   import org.apache.xalan.xsltc.runtime.BasisLibrary;
  +import org.apache.xml.dtm.DTMAxisIterator;
  +import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
   
   /**
    * This is a special kind of iterator that takes a source iterator and a 
  @@ -84,29 +85,31 @@
    * the parent of N. Also, and still in this example, a call to last() will 
    * return the number of elements in the source (i.e. the number of BOOKs).
    */
  -public final class MatchingIterator extends NodeIteratorBase {
  +public final class MatchingIterator extends DTMAxisIteratorBase {
   
       /**
        * A reference to a source iterator.
        */
  -    private NodeIterator _source;
  +    private DTMAxisIterator _source;
   
       /**
        * The node to match.
        */
       private final int _match;
   
  -    public MatchingIterator(int match, NodeIterator source) {
  +    public MatchingIterator(int match, DTMAxisIterator source) {
   	_source = source;
   	_match = match;
       }
   
  +
       public void setRestartable(boolean isRestartable) {
   	_isRestartable = isRestartable;
   	_source.setRestartable(isRestartable);
       }
   
  -    public NodeIterator cloneIterator() {
  +    public DTMAxisIterator cloneIterator() {
  +
   	try {
   	    final MatchingIterator clone = (MatchingIterator) super.clone();
   	    clone._source = _source.cloneIterator();
  @@ -120,13 +123,13 @@
   	}
       }
       
  -    public NodeIterator setStartNode(int node) {
  +    public DTMAxisIterator setStartNode(int node) {
   	if (_isRestartable) {
   	    // iterator is not a clone
   	    _source.setStartNode(node);
   
   	    // Calculate the position of the node in the set
  -	    _position = 1; _last = -1;
  +	    _position = 1;
   	    while ((node = _source.next()) != END && node != _match) {
   		_position++;
   	    }
  @@ -134,7 +137,7 @@
   	return this;
       }
   
  -    public NodeIterator reset() {
  +    public DTMAxisIterator reset() {
   	_source.reset();
   	return resetPosition();
       }
  @@ -144,10 +147,10 @@
       }
   	
       public int getLast() {
  -	if (_last == -1) {
  -	    _last = _source.getLast();
  -	}
  -	return _last;
  +        if (_last == -1) {
  +            _last = _source.getLast();
  +        }
  +        return _last;
       }
   
       public int getPosition() {
  
  
  
  1.26      +514 -282  xml-xalan/java/src/org/apache/xalan/xsltc/dom/MultiDOM.java
  
  Index: MultiDOM.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/MultiDOM.java,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- MultiDOM.java	21 Feb 2003 19:24:43 -0000	1.25
  +++ MultiDOM.java	1 Apr 2003 21:39:17 -0000	1.26
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -65,12 +65,17 @@
   package org.apache.xalan.xsltc.dom;
   
   import org.apache.xalan.xsltc.DOM;
  -import org.apache.xalan.xsltc.NodeIterator;
   import org.apache.xalan.xsltc.StripFilter;
  +import org.apache.xml.serializer.SerializationHandler;
   import org.apache.xalan.xsltc.TransletException;
  -import org.apache.xalan.xsltc.TransletOutputHandler;
   import org.apache.xalan.xsltc.runtime.BasisLibrary;
   import org.apache.xalan.xsltc.runtime.Hashtable;
  +import org.apache.xml.dtm.DTM;
  +import org.apache.xml.dtm.DTMAxisIterator;
  +import org.apache.xml.dtm.DTMManager;
  +import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
  +import org.apache.xml.dtm.ref.DTMDefaultBase;
  +import org.apache.xml.utils.SuballocatedIntVector;
   
   import org.w3c.dom.Node;
   import org.w3c.dom.NodeList;
  @@ -79,92 +84,113 @@
   
       private static final int NO_TYPE = DOM.FIRST_TYPE - 2;
       private static final int INITIAL_SIZE = 4;
  -    private static final int CLR = 0x00FFFFFF;
  -    private static final int SET = 0xFF000000;
  -
  +    
       private DOM[] _adapters;
  +    private DOMAdapter _main;
       private int _free;
       private int _size;
   
       private Hashtable _documents = new Hashtable();
   
  -    private final class AxisIterator implements NodeIterator {
  -	private final int _axis;
  -	private final int _type;
  -
  -	private int _mask;
  -	private NodeIterator _source = null;
  -
  -	public AxisIterator(final int axis, final int type) {
  -	    _axis = axis;
  -	    _type = type;
  -	}
  -
  -	public int next() {
  -	    if (_source == null) return(END);
  -	    if (_mask == 0) return _source.next();
  -	    final int node = _source.next();
  -	    return node != END ? (node | _mask) : END;
  -	}
  -
  -	public void setRestartable(boolean flag) {
  -	    _source.setRestartable(flag);
  -	}
  -
  -	public NodeIterator setStartNode(final int node) {
  -	    final int dom = node >>> 24;
  -	    final int mask = node & SET;
  -
  -	    // Get a new source first time and when mask changes
  -	    if (_source == null || _mask != mask) {
  -		if (_type == NO_TYPE) {
  -		    _source = _adapters[dom].getAxisIterator(_axis);
  -		}
  -		else if (_axis == Axis.CHILD && _type != ELEMENT) {
  -		    _source = _adapters[dom].getTypedChildren(_type);
  -		}
  -		else {
  -		    _source = _adapters[dom].getTypedAxisIterator(_axis, _type);
  -		}
  -	    }
  -
  -	    _mask = mask;
  -	    _source.setStartNode(node & CLR);
  -	    return this;
  -	}
  -
  -	public NodeIterator reset() {
  -	    if (_source != null) _source.reset();
  -	    return this;
  -	}
  -
  -	public int getLast() {
  -	    return _source.getLast();
  -	}
  -
  -	public int getPosition() {
  -	    return _source.getPosition();
  -	}
  -
  -	public boolean isReverse() {
  +    private final class AxisIterator extends DTMAxisIteratorBase {
  +        // constitutive data
  +        private final int _axis;
  +        private final int _type;
  +        // implementation mechanism
  +        private DTMAxisIterator _source;
  +        private int _dtmId = -1;
  +
  +        public AxisIterator(final int axis, final int type) {
  +            _axis = axis;
  +            _type = type;
  +        }
  +
  +        public int next() {
  +            if (_source == null) {
  +                return(END);
  +            }
  +            return _source.next();
  +        }
  +
  +
  +        public void setRestartable(boolean flag) {
  +            if (_source != null) {
  +                _source.setRestartable(flag);
  +            }
  +        }
  +
  +        public DTMAxisIterator setStartNode(final int node) {
  +            if (node == DTM.NULL) {
  +                return this;
  +            }
  +
  +            int dom = node >>> DTMManager.IDENT_DTM_NODE_BITS;
  +
  +            // Get a new source first time and when mask changes
  +            if (_source == null || _dtmId != dom) {
  +                if (_type == NO_TYPE) {
  +                    _source = _adapters[dom].getAxisIterator(_axis);
  +                } else if (_axis == Axis.CHILD) {
  +                    _source = _adapters[dom].getTypedChildren(_type);
  +                } else {
  +                    _source = _adapters[dom].getTypedAxisIterator(_axis, _type);
  +                }
  +            }
  +
  +            _dtmId = dom;
  +            _source.setStartNode(node);
  +            return this;
  +        }
  +
  +        public DTMAxisIterator reset() {
  +            if (_source != null) {
  +                _source.reset();
  +            }
  +            return this;
  +        }
  +    
  +        public int getLast() {
  +            if (_source != null) {
  +                return _source.getLast();
  +            }
  +            else {
  +                return END;
  +            }
  +        }
  +
  +        public int getPosition() {
  +            if (_source != null) {
  +                return _source.getPosition();
  +            }
  +            else {
  +                return END;
  +            }
  +        }
  +    
  +        public boolean isReverse() {
   	    return Axis.isReverse[_axis];
  -	}
  -
  -	public void setMark() {
  -	    _source.setMark();
  -	}
  -
  -	public void gotoMark() {
  -	    _source.gotoMark();
  -	}
  -
  -	public NodeIterator cloneIterator() {
  -	    final AxisIterator clone = new AxisIterator(_axis, _type);
  -	    clone._source = _source.cloneIterator();
  -	    clone._mask = _mask;
  -	    return clone;
  -	}
  -
  +        }
  +    
  +        public void setMark() {
  +            if (_source != null) {
  +                _source.setMark();
  +            }
  +        }
  +    
  +        public void gotoMark() {
  +            if (_source != null) {
  +                _source.gotoMark();
  +            }
  +        }
  +    
  +        public DTMAxisIterator cloneIterator() {
  +            final AxisIterator clone = new AxisIterator(_axis, _type);
  +            if (_source != null) {
  +                clone._source = _source.cloneIterator();
  +            }
  +            clone._dtmId = _dtmId;
  +            return clone;
  +        }
       } // end of AxisIterator
   
   
  @@ -172,283 +198,489 @@
        * This is a specialised iterator for predicates comparing node or
        * attribute values to variable or parameter values.
        */
  -    private final class NodeValueIterator extends NodeIteratorBase {
  +    private final class NodeValueIterator extends DTMAxisIteratorBase {
   
  -	private NodeIterator _source;
  -	private String _value;
  -	private boolean _op;
  -	private final boolean _isReverse;
  -	private int _returnType = RETURN_PARENT;
  -
  -	public NodeValueIterator(NodeIterator source, int returnType,
  -				 String value, boolean op) {
  -	    _source = source;
  -	    _returnType = returnType;
  -	    _value = value;
  -	    _op = op;
  -	    _isReverse = source.isReverse();
  -	}
  -
  -	public boolean isReverse() {
  -	    return _isReverse;
  -	}
  -
  -	public NodeIterator cloneIterator() {
  -	    try {
  -		NodeValueIterator clone = (NodeValueIterator)super.clone();
  -		clone._source = _source.cloneIterator();
  -		clone.setRestartable(false);
  -		return clone.reset();
  -	    }
  -	    catch (CloneNotSupportedException e) {
  -		BasisLibrary.runTimeError(BasisLibrary.ITERATOR_CLONE_ERR,
  -					  e.toString());
  -		return null;
  -	    }
  -	}
  -
  -	public void setRestartable(boolean isRestartable) {
  -	    _isRestartable = isRestartable;
  -	    _source.setRestartable(isRestartable);
  -	}
  -
  -	public NodeIterator reset() {
  -	    _source.reset();
  -	    return resetPosition();
  -	}
  -
  -	public int next() {
  -
  -	    int node;
  -	    while ((node = _source.next()) != END) {
  -		String val = getNodeValue(node);
  -		if (_value.equals(val) == _op) {
  -		    if (_returnType == RETURN_CURRENT)
  -			return returnNode(node);
  -		    else
  -			return returnNode(getParent(node));
  -		}
  -	    }
  -	    return END;
  -	}
  -
  -	public NodeIterator setStartNode(int node) {
  -	    if (_isRestartable) {
  -		_source.setStartNode(_startNode = node);
  -		return resetPosition();
  -	    }
  -	    return this;
  -	}
  -
  -	public void setMark() {
  -	    _source.setMark();
  -	}
  -
  -	public void gotoMark() {
  -	    _source.gotoMark();
  -	}
  -    }
  +        private DTMAxisIterator _source;
  +        private String _value;
  +        private boolean _op;
  +        private final boolean _isReverse;
  +        private int _returnType = RETURN_PARENT;
  +
  +        public NodeValueIterator(DTMAxisIterator source, int returnType,
  +                                 String value, boolean op) {
  +            _source = source;
  +            _returnType = returnType;
  +            _value = value;
  +            _op = op;
  +            _isReverse = source.isReverse();
  +        }
  +
  +        public boolean isReverse() {
  +            return _isReverse;
  +        }
  +    
  +        public DTMAxisIterator cloneIterator() {
  +            try {
  +                NodeValueIterator clone = (NodeValueIterator)super.clone();
  +                clone._source = _source.cloneIterator();
  +                clone.setRestartable(false);
  +                return clone.reset();
  +            }
  +            catch (CloneNotSupportedException e) {
  +                BasisLibrary.runTimeError(BasisLibrary.ITERATOR_CLONE_ERR,
  +                                          e.toString());
  +                return null;
  +            }
  +        }
  +
  +
  +        public void setRestartable(boolean isRestartable) {
  +            _isRestartable = isRestartable;
  +            _source.setRestartable(isRestartable);
  +        }
  +
  +        public DTMAxisIterator reset() {
  +            _source.reset();
  +            return resetPosition();
  +        }
  +
  +        public int next() {
  +
  +            int node;
  +            while ((node = _source.next()) != END) {
  +                String val = getStringValueX(node);
  +                if (_value.equals(val) == _op) {
  +                    if (_returnType == RETURN_CURRENT)
  +                        return returnNode(node);
  +                    else
  +                        return returnNode(getParent(node));
  +                }
  +            }
  +            return END;
  +        }
  +
  +        public DTMAxisIterator setStartNode(int node) {
  +            if (_isRestartable) {
  +                _source.setStartNode(_startNode = node); 
  +                return resetPosition();
  +            }
  +            return this;
  +        }
  +
  +        public void setMark() {
  +            _source.setMark();
  +        }
  +
  +        public void gotoMark() {
  +            _source.gotoMark();
  +        }
  +    }                       
   
       public MultiDOM(DOM main) {
  -	_size = INITIAL_SIZE;
  -	_free = 1;
  -	_adapters = new DOM[INITIAL_SIZE];
  -	_adapters[0] = main;
  +        _size = INITIAL_SIZE;
  +        _free = 1;
  +        _adapters = new DOM[INITIAL_SIZE];
  +        DOMAdapter adapter = (DOMAdapter)main;
  +        _adapters[0] = adapter;
  +        _main = adapter;
  +
  +        // %HZ% %REVISIT% Is this the right thing to do here?  In the old
  +        // %HZ% %REVISIT% version, the main document did not get added through
  +        // %HZ% %REVISIT% a call to addDOMAdapter, which meant it couldn't be
  +        // %HZ% %REVISIT% found by a call to getDocumentMask.  The problem is
  +        // %HZ% %REVISIT% TransformerHandler is typically constructed with a
  +        // %HZ% %REVISIT% system ID equal to the stylesheet's URI; with SAX
  +        // %HZ% %REVISIT% input, it ends up giving that URI to the document.
  +        // %HZ% %REVISIT% Then, any references to document('') are resolved
  +        // %HZ% %REVISIT% using the stylesheet's URI.
  +        // %HZ% %REVISIT% MultiDOM.getDocumentMask is called to verify that
  +        // %HZ% %REVISIT% a document associated with that URI has not been
  +        // %HZ% %REVISIT% encountered, and that method ends up returning the
  +        // %HZ% %REVISIT% mask of the main document, when what we really what
  +        // %HZ% %REVISIT% is to read the stylesheet itself!
  +        addDOMAdapter(adapter, false);
       }
   
       public int nextMask() {
  -	return(_free << 24);
  +        return _free;
       }
   
       public void setupMapping(String[] names, String[] namespaces) {
  -	// This method only has a function in DOM adapters
  +        // This method only has a function in DOM adapters
       }
   
  -    public int addDOMAdapter(DOMAdapter dom) {
  -	// Add the DOM adapter to the array of DOMs
  -	final int domNo = _free++;
  -	if (domNo == _size) {
  -	    final DOMAdapter[] newArray = new DOMAdapter[_size *= 2];
  -	    System.arraycopy(_adapters, 0, newArray, 0, domNo);
  -	    _adapters = newArray;
  -	}
  -	_adapters[domNo] = dom;
  -
  -	// Store reference to document (URI) in hashtable
  -	String uri = dom.getDocumentURI(0);
  -	_documents.put(uri, new Integer(domNo));
  -
  -	// Store mask in DOMAdapter
  -	dom.setMultiDOMMask(domNo << 24);
  -	return (domNo << 24);
  +    public int addDOMAdapter(DOMAdapter adapter) {
  +        return addDOMAdapter(adapter, true);
       }
   
  +    private int addDOMAdapter(DOMAdapter adapter, boolean indexByURI) {
  +        // Add the DOM adapter to the array of DOMs
  +        DOM dom = adapter.getDOMImpl();
  +        
  +        int domNo = 1;
  +        int dtmSize = 1;
  +        SuballocatedIntVector dtmIds = null;
  +        if (dom instanceof DTMDefaultBase) {
  +            DTMDefaultBase dtmdb = (DTMDefaultBase)dom;
  +            dtmIds = dtmdb.getDTMIDs();
  +            dtmSize = dtmIds.size();
  +            domNo = dtmIds.elementAt(dtmSize-1) >>> DTMManager.IDENT_DTM_NODE_BITS;
  +        }
  +        else if (dom instanceof SimpleResultTreeImpl) {
  +            SimpleResultTreeImpl simpleRTF = (SimpleResultTreeImpl)dom;
  +            domNo = simpleRTF.getDocument() >>> DTMManager.IDENT_DTM_NODE_BITS;
  +        }
  +                  
  +        if (domNo >= _size) {
  +            int oldSize = _size;
  +            do {
  +            	_size *= 2;
  +            } while (_size <= domNo);
  +            
  +            final DOMAdapter[] newArray = new DOMAdapter[_size];
  +            System.arraycopy(_adapters, 0, newArray, 0, oldSize);
  +            _adapters = newArray;
  +        }
  +        
  +        _free = domNo + 1;
  +        
  +        if (dtmSize == 1) {
  +            _adapters[domNo] = adapter;
  +        }
  +        else if (dtmIds != null) {
  +            int domPos = 0;
  +            for (int i = dtmSize - 1; i >= 0; i++) {
  +                domPos = dtmIds.elementAt(i) >>> DTMManager.IDENT_DTM_NODE_BITS;
  +                _adapters[domPos] = adapter;
  +            }
  +            domNo = domPos;
  +        }
  +
  +        // Store reference to document (URI) in hashtable
  +        if (indexByURI) {
  +            String uri = adapter.getDocumentURI(0);
  +            _documents.put(uri, new Integer(domNo));
  +        }
  +        
  +        // If the dom is an AdaptiveResultTreeImpl, we need to create a
  +        // DOMAdapter around its nested dom object (if it is non-null) and
  +        // add the DOMAdapter to the list.
  +        if (dom instanceof AdaptiveResultTreeImpl) {
  +            AdaptiveResultTreeImpl adaptiveRTF = (AdaptiveResultTreeImpl)dom;
  +            DOM nestedDom = adaptiveRTF.getNestedDOM();
  +            if (nestedDom != null) {
  +                DOMAdapter newAdapter = new DOMAdapter(nestedDom, 
  +                                                       adapter.getNamesArray(),
  +                                                       adapter.getNamespaceArray());
  +                addDOMAdapter(newAdapter);  
  +            } 
  +        }
  +        
  +        return domNo;
  +    }
  +        
       public int getDocumentMask(String uri) {
  -	Integer domIdx = (Integer)_documents.get(uri);
  -	if (domIdx == null)
  -	    return(-1);
  -	else
  -	    return((domIdx.intValue() << 24));
  +        Integer domIdx = (Integer)_documents.get(uri);
  +        if (domIdx == null) {
  +            return(-1);
  +        } else {
  +            return domIdx.intValue();
  +        }
  +    }
  +    
  +    public DOM getDOMAdapter(String uri) {
  +        Integer domIdx = (Integer)_documents.get(uri);
  +        if (domIdx == null) {
  +            return(null);
  +        } else {
  +            return(_adapters[domIdx.intValue()]);
  +        }
  +    }
  +    
  +    public int getDocument() 
  +    {
  +        return _main.getDocument();
       }
   
  -    /**
  -      * Returns singleton iterator containg the document root
  +    /** 
  +      * Returns singleton iterator containing the document root 
         */
  -    public NodeIterator getIterator() {
  -	// main source document @ 0
  -	return _adapters[0].getIterator();
  +    public DTMAxisIterator getIterator() {
  +        // main source document @ 0
  +        return _main.getIterator();
       }
  -
  +    
       public String getStringValue() {
  -	return _adapters[0].getStringValue();
  +        return _main.getStringValue();
       }
  -
  -    public NodeIterator getChildren(final int node) {
  -	return (node & SET) == 0
  -	    ? _adapters[0].getChildren(node)
  -	    : getAxisIterator(Axis.CHILD).setStartNode(node);
  +    
  +    public DTMAxisIterator getChildren(final int node) {
  +        return _adapters[getDTMId(node)].getChildren(node);
  +    }
  +    
  +    public DTMAxisIterator getTypedChildren(final int type) {
  +        return new AxisIterator(Axis.CHILD, type);
  +    }
  +    
  +    public DTMAxisIterator getAxisIterator(final int axis) {
  +        return new AxisIterator(axis, NO_TYPE);
       }
  -
  -    public NodeIterator getTypedChildren(final int type) {
  -	return new AxisIterator(Axis.CHILD, type);
  -    }
  -
  -    public NodeIterator getAxisIterator(final int axis) {
  -	return new AxisIterator(axis, NO_TYPE);
  -    }
  -
  -    public NodeIterator getTypedAxisIterator(final int axis, final int type) {
  -	return new AxisIterator(axis, type);
  +    
  +    public DTMAxisIterator getTypedAxisIterator(final int axis, final int type)
  +    {
  +        return new AxisIterator(axis, type);
       }
   
  -    public NodeIterator getNthDescendant(int node, int n, boolean includeself) {
  -	return _adapters[node>>>24].getNthDescendant(node & CLR,n,includeself);
  +    public DTMAxisIterator getNthDescendant(int node, int n,
  +                                            boolean includeself)
  +    {
  +        return _adapters[getDTMId(node)].getNthDescendant(node, n, includeself);
       }
   
  -    public NodeIterator getNodeValueIterator(NodeIterator iterator, int type,
  -					     String value, boolean op) {
  -	return(new NodeValueIterator(iterator, type, value, op));
  +    public DTMAxisIterator getNodeValueIterator(DTMAxisIterator iterator,
  +                                                int type, String value,
  +                                                boolean op)
  +    {
  +        return(new NodeValueIterator(iterator, type, value, op));
       }
   
  -    public NodeIterator getNamespaceAxisIterator(final int axis, final int ns) {
  -	NodeIterator iterator = _adapters[0].getNamespaceAxisIterator(axis,ns);
  -	return(iterator);
  +    public DTMAxisIterator getNamespaceAxisIterator(final int axis,
  +                                                    final int ns)
  +    {
  +        DTMAxisIterator iterator = _main.getNamespaceAxisIterator(axis, ns);
  +        return(iterator);        
       }
   
  -    public NodeIterator orderNodes(NodeIterator source, int node) {
  -	return _adapters[node>>>24].orderNodes(source, node & CLR);
  +    public DTMAxisIterator orderNodes(DTMAxisIterator source, int node) {
  +        return _adapters[getDTMId(node)].orderNodes(source, node);
       }
   
  -    public int getType(final int node) {
  -	return _adapters[node>>>24].getType(node & CLR);
  +    public int getExpandedTypeID(final int node) {
  +    	if (node != DTM.NULL) {
  +            return _adapters[node >>> DTMManager.IDENT_DTM_NODE_BITS].getExpandedTypeID(node);
  +    	}
  +    	else {
  +    	    return DTM.NULL;
  +    	}
       }
   
       public int getNamespaceType(final int node) {
  -	return _adapters[node>>>24].getNamespaceType(node & CLR);
  +        return _adapters[getDTMId(node)].getNamespaceType(node);
       }
  -
  +    
  +    public int getNSType(int node)
  +   {
  +        return _adapters[getDTMId(node)].getNSType(node);
  +   }
  +    
       public int getParent(final int node) {
  -	return _adapters[node>>>24].getParent(node & CLR) | node&SET;
  +        if (node == DTM.NULL) {
  +            return DTM.NULL;
  +        }
  +        return _adapters[node >>> DTMManager.IDENT_DTM_NODE_BITS].getParent(node);
       }
  -
  +    
       public int getAttributeNode(final int type, final int el) {
  -	return _adapters[el>>>24].getAttributeNode(type, el&CLR) | el&SET;
  +        if (el == DTM.NULL) {
  +            return DTM.NULL;
  +        }
  +        return _adapters[el >>> DTMManager.IDENT_DTM_NODE_BITS].getAttributeNode(type, el);
       }
  -
  +    
       public String getNodeName(final int node) {
  -	return _adapters[node>>>24].getNodeName(node & CLR);
  +        if (node == DTM.NULL) {
  +            return "";
  +        }
  +        return _adapters[node >>> DTMManager.IDENT_DTM_NODE_BITS].getNodeName(node);
  +    }
  +    
  +    public String getNodeNameX(final int node) {
  +        if (node == DTM.NULL) {
  +            return "";
  +        }
  +        return _adapters[node >>> DTMManager.IDENT_DTM_NODE_BITS].getNodeNameX(node);
       }
   
       public String getNamespaceName(final int node) {
  -	return _adapters[node>>>24].getNamespaceName(node & CLR);
  -    }
  -
  -    public String getNodeValue(final int node) {
  -	return _adapters[node>>>24].getNodeValue(node & CLR);
  -    }
  -
  -    public void copy(final int node, TransletOutputHandler handler)
  -	throws TransletException {
  -	_adapters[node>>>24].copy(node & CLR, handler);
  -    }
  -
  -    public void copy(NodeIterator nodes, TransletOutputHandler handler)
  -	throws TransletException {
  -	int node;
  -	while ((node = nodes.next()) != DOM.NULL) {
  -	    _adapters[node>>>24].copy(node & CLR, handler);
  -	}
  +        if (node == DTM.NULL) {
  +            return "";
  +        }
  +        return _adapters[node >>> DTMManager.IDENT_DTM_NODE_BITS].getNamespaceName(node);
  +    }
  +    
  +    public String getStringValueX(final int node) {
  +        if (node == DTM.NULL) {
  +            return "";
  +        }
  +        return _adapters[node >>> DTMManager.IDENT_DTM_NODE_BITS].getStringValueX(node);
  +    }
  +    
  +    public void copy(final int node, SerializationHandler handler)
  +        throws TransletException
  +    {
  +        if (node != DTM.NULL) {
  +            _adapters[node >>> DTMManager.IDENT_DTM_NODE_BITS].copy(node, handler);
  +        }
  +    }
  +    
  +    public void copy(DTMAxisIterator nodes, SerializationHandler handler)
  +            throws TransletException
  +    {
  +        int node;
  +        while ((node = nodes.next()) != DTM.NULL) {
  +            _adapters[node >>> DTMManager.IDENT_DTM_NODE_BITS].copy(node, handler);
  +        }
       }
   
   
  -    public String shallowCopy(final int node, TransletOutputHandler handler)
  -	throws TransletException {
  -	return _adapters[node>>>24].shallowCopy(node & CLR, handler);
  +    public String shallowCopy(final int node, SerializationHandler handler)
  +            throws TransletException
  +    {
  +        if (node == DTM.NULL) {
  +            return "";
  +        }
  +        return _adapters[node >>> DTMManager.IDENT_DTM_NODE_BITS].shallowCopy(node, handler);
       }
  -
  +    
       public boolean lessThan(final int node1, final int node2) {
  -	final int dom1 = node1>>>24;
  -	final int dom2 = node2>>>24;
  -	return dom1 == dom2
  -	    ? _adapters[dom1].lessThan(node1 & CLR, node2 & CLR)
  -	    : dom1 < dom2;
  -    }
  -
  -    public void characters(final int textNode, TransletOutputHandler handler)
  -	throws TransletException {
  -	    _adapters[textNode>>>24].characters(textNode & CLR, handler);
  +        if (node1 == DTM.NULL) {
  +            return true;
  +        }
  +        if (node2 == DTM.NULL) {
  +            return false;
  +        }
  +        final int dom1 = getDTMId(node1);
  +        final int dom2 = getDTMId(node2);
  +        return dom1 == dom2 ? _adapters[dom1].lessThan(node1, node2)
  +                            : dom1 < dom2;
  +    }
  +    
  +    public void characters(final int textNode, SerializationHandler handler)
  +                 throws TransletException
  +    {
  +        if (textNode != DTM.NULL) {
  +            _adapters[textNode >>> DTMManager.IDENT_DTM_NODE_BITS].characters(textNode, handler);
  +        }
       }
   
       public void setFilter(StripFilter filter) {
  -	for (int dom=0; dom<_free; dom++) {
  -	    _adapters[dom].setFilter(filter);
  -	}
  +        for (int dom=0; dom<_free; dom++) {
  +            if (_adapters[dom] != null) {
  +                _adapters[dom].setFilter(filter);
  +            }
  +        }
       }
   
       public Node makeNode(int index) {
  -	return _adapters[index>>>24].makeNode(index & CLR);
  +        if (index == DTM.NULL) {
  +            return null;
  +        }
  +        return _adapters[getDTMId(index)].makeNode(index);
       }
   
  -    public Node makeNode(NodeIterator iter) {
  -	// TODO: gather nodes from all DOMs ?
  -	return _adapters[0].makeNode(iter);
  +    public Node makeNode(DTMAxisIterator iter) {
  +        // TODO: gather nodes from all DOMs ?
  +        return _main.makeNode(iter);
       }
   
       public NodeList makeNodeList(int index) {
  -	return _adapters[index>>>24].makeNodeList(index & CLR);
  +        if (index == DTM.NULL) {
  +            return null;
  +        }
  +        return _adapters[getDTMId(index)].makeNodeList(index);
       }
   
  -    public NodeList makeNodeList(NodeIterator iter) {
  -	// TODO: gather nodes from all DOMs ?
  -	return _adapters[0].makeNodeList(iter);
  +    public NodeList makeNodeList(DTMAxisIterator iter) {
  +        // TODO: gather nodes from all DOMs ?
  +        return _main.makeNodeList(iter);
       }
   
       public String getLanguage(int node) {
  -	return _adapters[node>>>24].getLanguage(node & CLR);
  +        return _adapters[getDTMId(node)].getLanguage(node);
       }
   
       public int getSize() {
  -	int size = 0;
  -	for (int i=0; i<_size; i++)
  -	    size += _adapters[i].getSize();
  -	return(size);
  +        int size = 0;
  +        for (int i=0; i<_size; i++) {
  +            size += _adapters[i].getSize();
  +        }
  +        return(size);
       }
   
       public String getDocumentURI(int node) {
  -	return _adapters[node>>>24].getDocumentURI(0);
  +        if (node == DTM.NULL) {
  +            node = DOM.NULL;
  +        }
  +        return _adapters[node >>> DTMManager.IDENT_DTM_NODE_BITS].getDocumentURI(0);
       }
   
       public boolean isElement(final int node) {
  -	return(_adapters[node>>>24].isElement(node & CLR));
  +        if (node == DTM.NULL) {
  +            return false;
  +        }
  +        return(_adapters[node >>> DTMManager.IDENT_DTM_NODE_BITS].isElement(node));
       }
   
       public boolean isAttribute(final int node) {
  -	return(_adapters[node>>>24].isAttribute(node & CLR));
  +        if (node == DTM.NULL) {
  +            return false;
  +        }
  +        return(_adapters[node >>> DTMManager.IDENT_DTM_NODE_BITS].isAttribute(node));
  +    }
  +    
  +    public int getDTMId(int nodeHandle)
  +    {
  +        if (nodeHandle == DTM.NULL)
  +            return 0;
  +        
  +        int id = nodeHandle >>> DTMManager.IDENT_DTM_NODE_BITS;
  +        while (id >= 2 && _adapters[id] == _adapters[id-1]) {
  +            id--;
  +        }
  +        return id;
  +    }
  +    
  +    public int getNodeIdent(int nodeHandle)
  +    {
  +        return _adapters[nodeHandle >>> DTMManager.IDENT_DTM_NODE_BITS].getNodeIdent(nodeHandle);
  +    }
  +    
  +    public int getNodeHandle(int nodeId)
  +    {
  +        return _main.getNodeHandle(nodeId);
  +    }
  +    
  +    public DOM getResultTreeFrag(int initSize, int rtfType)
  +    {
  +        return _main.getResultTreeFrag(initSize, rtfType);
  +    }
  +    
  +    public DOM getMain()
  +    {
  +        return _main;
  +    }
  +    
  +    /**
  +     * Returns a DOMBuilder class wrapped in a SAX adapter.
  +     */
  +    public SerializationHandler getOutputDomBuilder()
  +    {
  +        return _main.getOutputDomBuilder();
       }
   
  -    public String lookupNamespace(int node, String prefix)
  -	throws TransletException
  +    public String lookupNamespace(int node, String prefix) 
  +        throws TransletException
       {
  -	return _adapters[node>>>24].lookupNamespace(node & CLR, prefix);
  +        return _main.lookupNamespace(node, prefix);
  +    }
  +
  +    // %HZ% Does this method make any sense here???
  +    public String getUnparsedEntityURI(String entity) {
  +        return _main.getUnparsedEntityURI(entity);
  +    }
  +
  +    // %HZ% Does this method make any sense here???
  +    public Hashtable getElementsWithIDs() {
  +        return _main.getElementsWithIDs();
       }
   }
  
  
  
  1.3       +8 -8      xml-xalan/java/src/org/apache/xalan/xsltc/dom/MultipleNodeCounter.java
  
  Index: MultipleNodeCounter.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/MultipleNodeCounter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- MultipleNodeCounter.java	30 Jan 2003 18:46:11 -0000	1.2
  +++ MultipleNodeCounter.java	1 Apr 2003 21:39:17 -0000	1.3
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -64,21 +64,21 @@
   package org.apache.xalan.xsltc.dom;
   
   import org.apache.xalan.xsltc.DOM;
  -import org.apache.xalan.xsltc.NodeIterator;
   import org.apache.xalan.xsltc.Translet;
   import org.apache.xalan.xsltc.util.IntegerArray;
  +import org.apache.xml.dtm.DTMAxisIterator;
   
   public abstract class MultipleNodeCounter extends NodeCounter {
  -    private NodeIterator _precSiblings = null;
  +    private DTMAxisIterator _precSiblings = null;
   
       public MultipleNodeCounter(Translet translet,
  -			       DOM document, NodeIterator iterator) {
  +			       DOM document, DTMAxisIterator iterator) {
   	super(translet, document, iterator);
       }
   	
       public NodeCounter setStartNode(int node) {
   	_node = node;
  -	_nodeType = _document.getType(node);
  +	_nodeType = _document.getExpandedTypeID(node);
   	_precSiblings = _document.getAxisIterator(PRECEDINGSIBLING);
   	return this;
       }
  @@ -129,14 +129,14 @@
   
       public static NodeCounter getDefaultNodeCounter(Translet translet,
   						    DOM document,
  -						    NodeIterator iterator) {
  +						    DTMAxisIterator iterator) {
   	return new DefaultMultipleNodeCounter(translet, document, iterator);
       }
   
       static class DefaultMultipleNodeCounter extends MultipleNodeCounter {
   	public DefaultMultipleNodeCounter(Translet translet,
   					  DOM document,
  -					  NodeIterator iterator) {
  +					  DTMAxisIterator iterator) {
   	    super(translet, document, iterator);
   	}
       }
  
  
  
  1.9       +8 -7      xml-xalan/java/src/org/apache/xalan/xsltc/dom/NodeCounter.java
  
  Index: NodeCounter.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/NodeCounter.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- NodeCounter.java	30 Jan 2003 18:46:11 -0000	1.8
  +++ NodeCounter.java	1 Apr 2003 21:39:17 -0000	1.9
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -67,18 +67,19 @@
   import java.util.Vector;
   
   import org.apache.xalan.xsltc.DOM;
  -import org.apache.xalan.xsltc.NodeIterator;
   import org.apache.xalan.xsltc.Translet;
  +import org.apache.xml.dtm.DTM;
  +import org.apache.xml.dtm.DTMAxisIterator;
   
   public abstract class NodeCounter implements Axis {
  -    public static final int END = DOM.NULL;
  +    public static final int END = DTM.NULL;
   
       protected int _node = END;
       protected int _nodeType = DOM.FIRST_TYPE - 1;
       protected int _value = Integer.MIN_VALUE;
   
       public final DOM          _document;
  -    public final NodeIterator _iterator;
  +    public final DTMAxisIterator _iterator;
       public final Translet     _translet;
   
       protected String _format;
  @@ -104,7 +105,7 @@
   	{"", "i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix"};
   
       protected NodeCounter(Translet translet,
  -			  DOM document, NodeIterator iterator) {
  +			  DOM document, DTMAxisIterator iterator) {
   	_translet = translet;
   	_document = document;
   	_iterator = iterator;
  @@ -225,7 +226,7 @@
        * same type as the starting node.
        */
       public boolean matchesCount(int node) {
  -	return _nodeType == _document.getType(node);
  +	return _nodeType == _document.getExpandedTypeID(node);
       }
   
       /**
  
  
  
  1.9       +2 -2      xml-xalan/java/src/org/apache/xalan/xsltc/dom/NodeIteratorBase.java
  
  Index: NodeIteratorBase.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/NodeIteratorBase.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- NodeIteratorBase.java	8 Oct 2002 21:44:14 -0000	1.8
  +++ NodeIteratorBase.java	1 Apr 2003 21:39:17 -0000	1.9
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  
  
  
  1.12      +8 -3      xml-xalan/java/src/org/apache/xalan/xsltc/dom/NodeSortRecord.java
  
  Index: NodeSortRecord.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/NodeSortRecord.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- NodeSortRecord.java	30 Jan 2003 18:46:11 -0000	1.11
  +++ NodeSortRecord.java	1 Apr 2003 21:39:17 -0000	1.12
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -88,13 +88,15 @@
        * A reference to a locale. May be updated by subclass if the stylesheet
        * specifies a different language.
        */
  +    protected static final Locale DEFAULT_LOCALE = Locale.getDefault();
       protected Locale _locale = Locale.getDefault();
   
       /**
        * A reference to a collator. May be updated by subclass if the stylesheet
        * specifies a different language (will be updated iff _locale is updated).
        */
  -    protected Collator _collator = Collator.getInstance();
  +    protected static final Collator DEFAULT_COLLATOR = Collator.getInstance();
  +    protected Collator _collator = DEFAULT_COLLATOR;
       protected CollatorFactory _collatorFactory;
   
       protected int   _levels = 1;
  @@ -118,6 +120,9 @@
        */ 
       public NodeSortRecord(int node) {
   	_node = node;
  +	if (_locale != DEFAULT_LOCALE) {
  +	    _collator = Collator.getInstance(_locale);
  +	}
       }
   
       public NodeSortRecord() {
  
  
  
  1.9       +2 -2      xml-xalan/java/src/org/apache/xalan/xsltc/dom/NodeSortRecordFactory.java
  
  Index: NodeSortRecordFactory.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/NodeSortRecordFactory.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- NodeSortRecordFactory.java	4 Dec 2002 16:11:18 -0000	1.8
  +++ NodeSortRecordFactory.java	1 Apr 2003 21:39:17 -0000	1.9
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  
  
  
  1.13      +19 -11    xml-xalan/java/src/org/apache/xalan/xsltc/dom/NthIterator.java
  
  Index: NthIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/NthIterator.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- NthIterator.java	30 Jan 2003 18:46:11 -0000	1.12
  +++ NthIterator.java	1 Apr 2003 21:39:17 -0000	1.13
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -63,16 +63,17 @@
   
   package org.apache.xalan.xsltc.dom;
   
  -import org.apache.xalan.xsltc.NodeIterator;
   import org.apache.xalan.xsltc.runtime.BasisLibrary;
  +import org.apache.xml.dtm.DTMAxisIterator;
  +import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
   
  -public final class NthIterator extends NodeIteratorBase {
  +public final class NthIterator extends DTMAxisIteratorBase {
       // ...[N]
  -    private NodeIterator _source;
  +    private DTMAxisIterator _source;
       private final int _position;
       private boolean _ready;
   
  -    public NthIterator(NodeIterator source, int n) {
  +    public NthIterator(DTMAxisIterator source, int n) {
   	_source = source;
   	_position = n;
       }
  @@ -82,7 +83,7 @@
   	_source.setRestartable(isRestartable);
       }
       
  -    public NodeIterator cloneIterator() {
  +    public DTMAxisIterator cloneIterator() {
   	try {
   	    final NthIterator clone = (NthIterator) super.clone();
   	    clone._source = _source.cloneIterator();	// resets source
  @@ -97,6 +98,12 @@
       }
   
       public int next() {
  +	if (_ready) {
  +	    _ready = false;
  +	    return _source.getNodeByPosition(_position);
  +	}
  +	return DTMAxisIterator.END;
  +	/*
   	if (_ready && _position > 0) {
               final int pos = _source.isReverse()
                                          ? _source.getLast() - _position + 1
  @@ -104,16 +111,17 @@
   
   	    _ready = false;
   	    int node;
  -	    while ((node = _source.next()) != END) {
  +	    while ((node = _source.next()) != DTMAxisIterator.END) {
   		if (pos == _source.getPosition()) {
   		    return node;
   		}
   	    }
   	}
  -	return END;
  +	return DTMAxisIterator.END;
  +	*/
       }
   
  -    public NodeIterator setStartNode(final int node) {
  +    public DTMAxisIterator setStartNode(final int node) {
   	if (_isRestartable) {
   	    _source.setStartNode(node);
   	    _ready = true;
  @@ -121,7 +129,7 @@
   	return this;
       }
   	
  -    public NodeIterator reset() {
  +    public DTMAxisIterator reset() {
   	_source.reset();
   	_ready = true;
   	return this;
  
  
  
  1.4       +10 -10    xml-xalan/java/src/org/apache/xalan/xsltc/dom/SingleNodeCounter.java
  
  Index: SingleNodeCounter.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/SingleNodeCounter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SingleNodeCounter.java	30 Jan 2003 18:46:11 -0000	1.3
  +++ SingleNodeCounter.java	1 Apr 2003 21:39:17 -0000	1.4
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -64,22 +64,22 @@
   package org.apache.xalan.xsltc.dom;
   
   import org.apache.xalan.xsltc.DOM;
  -import org.apache.xalan.xsltc.NodeIterator;
   import org.apache.xalan.xsltc.Translet;
  +import org.apache.xml.dtm.DTMAxisIterator;
   
   public abstract class SingleNodeCounter extends NodeCounter {
       static private final int[] EmptyArray = new int[] { };
  -    NodeIterator _countSiblings = null;
  +    DTMAxisIterator _countSiblings = null;
   
       public SingleNodeCounter(Translet translet,
   			     DOM document,
  -			     NodeIterator iterator) {
  +			     DTMAxisIterator iterator) {
   	super(translet, document, iterator);
       }
   
       public NodeCounter setStartNode(int node) {
   	_node = node;
  -	_nodeType = _document.getType(node);
  +	_nodeType = _document.getExpandedTypeID(node);
   	_countSiblings = _document.getAxisIterator(PRECEDINGSIBLING);
   	return this;
       }
  @@ -120,22 +120,22 @@
   
       public static NodeCounter getDefaultNodeCounter(Translet translet,
   						    DOM document,
  -						    NodeIterator iterator) {
  +						    DTMAxisIterator iterator) {
   	return new DefaultSingleNodeCounter(translet, document, iterator);
       }
   
       static class DefaultSingleNodeCounter extends SingleNodeCounter {
   	public DefaultSingleNodeCounter(Translet translet,
  -					DOM document, NodeIterator iterator) {
  +					DOM document, DTMAxisIterator iterator) {
   	    super(translet, document, iterator);
   	}
   
   	public NodeCounter setStartNode(int node) {
   	    _node = node;
  -	    _nodeType = _document.getType(node);
  +	    _nodeType = _document.getExpandedTypeID(node);
   	    _countSiblings =
   		_document.getTypedAxisIterator(PRECEDINGSIBLING,
  -					       _document.getType(node));
  +					       _document.getExpandedTypeID(node));
   	    return this;
   	}
   
  
  
  
  1.3       +8 -7      xml-xalan/java/src/org/apache/xalan/xsltc/dom/SingletonIterator.java
  
  Index: SingletonIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/SingletonIterator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SingletonIterator.java	13 Jun 2001 12:06:25 -0000	1.2
  +++ SingletonIterator.java	1 Apr 2003 21:39:17 -0000	1.3
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -63,9 +63,10 @@
   
   package org.apache.xalan.xsltc.dom;
   
  -import org.apache.xalan.xsltc.NodeIterator;
  +import org.apache.xml.dtm.DTMAxisIterator;
  +import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
   
  -public class SingletonIterator extends NodeIteratorBase {
  +public class SingletonIterator extends DTMAxisIteratorBase {
       private int _node;
       private final boolean _isConstant;
   
  @@ -86,7 +87,7 @@
        * Override the value of <tt>_node</tt> only when this
        * object was constructed using the empty constructor.
        */
  -    public NodeIterator setStartNode(int node) {
  +    public DTMAxisIterator setStartNode(int node) {
   	if (_isConstant) {
   	    _node = _startNode;
   	    return resetPosition();
  @@ -99,7 +100,7 @@
   	return this;
       }
   	
  -    public NodeIterator reset() {
  +    public DTMAxisIterator reset() {
   	if (_isConstant) {
   	    _node = _startNode;
   	    return resetPosition();
  @@ -115,7 +116,7 @@
       
       public int next() {
   	final int result = _node;
  -	_node = NodeIterator.END;
  +	_node = DTMAxisIterator.END;
   	return returnNode(result);
       }
   
  
  
  
  1.5       +11 -8     xml-xalan/java/src/org/apache/xalan/xsltc/dom/SortingIterator.java
  
  Index: SortingIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/SortingIterator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SortingIterator.java	30 Jan 2003 18:46:11 -0000	1.4
  +++ SortingIterator.java	1 Apr 2003 21:39:17 -0000	1.5
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -64,18 +64,21 @@
   
   package org.apache.xalan.xsltc.dom;
   
  -import org.apache.xalan.xsltc.NodeIterator;
   import org.apache.xalan.xsltc.runtime.BasisLibrary;
  +import org.apache.xml.dtm.DTMAxisIterator;
  +import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
   
  -public final class SortingIterator extends NodeIteratorBase {
  +public final class SortingIterator extends DTMAxisIteratorBase {
       private final static int INIT_DATA_SIZE = 16;
  -    private NodeIterator _source;
  +
  +    private DTMAxisIterator _source;
       private NodeSortRecordFactory _factory;
  +
       private NodeSortRecord[] _data;
       private int _free = 0;
       private int _current;	// index in _nodes of the next node to try
   
  -    public SortingIterator(NodeIterator source, 
  +    public SortingIterator(DTMAxisIterator source, 
   			   NodeSortRecordFactory factory) {
   	_source = source;
   	_factory = factory;
  @@ -85,7 +88,7 @@
   	return _current < _free ? _data[_current++].getNode() : END;
       }
   	
  -    public NodeIterator setStartNode(int node) {
  +    public DTMAxisIterator setStartNode(int node) {
   	try {
   	    _source.setStartNode(_startNode = node);
   	    _data = new NodeSortRecord[INIT_DATA_SIZE];
  @@ -129,7 +132,7 @@
        * iterator and then sharing the factory and the array of
        * <code>NodeSortRecords</code>.
        */
  -    public NodeIterator cloneIterator() {
  +    public DTMAxisIterator cloneIterator() {
   	try {
   	    final SortingIterator clone = (SortingIterator) super.clone();
   	    clone._source = _source.cloneIterator();  
  
  
  
  1.14      +15 -12    xml-xalan/java/src/org/apache/xalan/xsltc/dom/StepIterator.java
  
  Index: StepIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/StepIterator.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- StepIterator.java	8 Oct 2002 21:44:14 -0000	1.13
  +++ StepIterator.java	1 Apr 2003 21:39:17 -0000	1.14
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -65,8 +65,9 @@
   
   package org.apache.xalan.xsltc.dom;
   
  -import org.apache.xalan.xsltc.NodeIterator;
   import org.apache.xalan.xsltc.runtime.BasisLibrary;
  +import org.apache.xml.dtm.DTMAxisIterator;
  +import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
   
   /**
    * A step iterator is used to evaluate expressions like "BOOK/TITLE". 
  @@ -78,37 +79,39 @@
    * After this initialization, every node from the inner iterator is 
    * returned (in essence, implementing a "nested loop").
    */
  -public class StepIterator extends NodeIteratorBase {
  +public class StepIterator extends DTMAxisIteratorBase {
   
       /**
        * A reference to the "outer" iterator.
        */
  -    protected NodeIterator _source;
  +    protected DTMAxisIterator _source;
   
       /**
        * A reference to the "inner" iterator.
        */
  -    protected NodeIterator _iterator;
  +    protected DTMAxisIterator _iterator;
   
       /**
        * Temp variable to store a marked position.
        */
       private int _pos = -1;
   
  -    public StepIterator(NodeIterator source, NodeIterator iterator) {
  +    public StepIterator(DTMAxisIterator source, DTMAxisIterator iterator) {
   	_source = source;
   	_iterator = iterator;
   // System.out.println("SI source = " + source + " this = " + this);
   // System.out.println("SI iterator = " + iterator + " this = " + this);
       }
   
  +
       public void setRestartable(boolean isRestartable) {
   	_isRestartable = isRestartable;
   	_source.setRestartable(isRestartable);
   	_iterator.setRestartable(true); 	// must be restartable
       }
   
  -    public NodeIterator cloneIterator() {
  +    public DTMAxisIterator cloneIterator() {
  +	_isRestartable = false;
   	try {
   	    final StepIterator clone = (StepIterator) super.clone();
   	    clone._source = _source.cloneIterator();
  @@ -124,7 +127,7 @@
   	}
       }
       
  -    public NodeIterator setStartNode(int node) {
  +    public DTMAxisIterator setStartNode(int node) {
   	if (_isRestartable) {
   	    // Set start node for left-hand iterator...
   	    _source.setStartNode(_startNode = node);
  @@ -137,7 +140,7 @@
   	return this;
       }
   
  -    public NodeIterator reset() {
  +    public DTMAxisIterator reset() {
   	_source.reset();
   	// Special case for //* path - see ParentLocationPath
   	_iterator.setStartNode(_includeSelf ? _startNode : _source.next());
  @@ -164,12 +167,12 @@
       public void setMark() {
   	_source.setMark();
   	_iterator.setMark();
  -	_pos = _position;
  +	//_pos = _position;
       }
   
       public void gotoMark() {
   	_source.gotoMark();
   	_iterator.gotoMark();
  -	_position = _pos;
  +	//_position = _pos;
       }
   }
  
  
  
  1.2       +2 -2      xml-xalan/java/src/org/apache/xalan/xsltc/dom/StripWhitespaceFilter.java
  
  Index: StripWhitespaceFilter.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/StripWhitespaceFilter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StripWhitespaceFilter.java	17 Apr 2001 18:52:36 -0000	1.1
  +++ StripWhitespaceFilter.java	1 Apr 2003 21:39:17 -0000	1.2
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  
  
  
  1.15      +13 -10    xml-xalan/java/src/org/apache/xalan/xsltc/dom/UnionIterator.java
  
  Index: UnionIterator.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/dom/UnionIterator.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- UnionIterator.java	25 Oct 2002 17:59:07 -0000	1.14
  +++ UnionIterator.java	1 Apr 2003 21:39:17 -0000	1.15
  @@ -4,7 +4,7 @@
    * The Apache Software License, Version 1.1
    *
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2001-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -64,8 +64,9 @@
   package org.apache.xalan.xsltc.dom;
   
   import org.apache.xalan.xsltc.DOM;
  -import org.apache.xalan.xsltc.NodeIterator;
   import org.apache.xalan.xsltc.runtime.BasisLibrary;
  +import org.apache.xml.dtm.DTMAxisIterator;
  +import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
   
   /**
    * UnionIterator takes a set of NodeIterators and produces
  @@ -73,7 +74,7 @@
    * The individual iterators are supposed to generate nodes
    * in document order
    */
  -public final class UnionIterator extends NodeIteratorBase {
  +public final class UnionIterator extends DTMAxisIteratorBase {
       /** wrapper for NodeIterators to support iterator
   	comparison on the value of their next() method
       */
  @@ -81,9 +82,9 @@
   
       private final static class LookAheadIterator {
   	public int node, markedNode;
  -	public NodeIterator iterator;
  +	public DTMAxisIterator iterator;
   		
  -	public LookAheadIterator(NodeIterator iterator) {
  +	public LookAheadIterator(DTMAxisIterator iterator) {
   	    this.iterator = iterator;
   	}
   		
  @@ -127,7 +128,9 @@
   	_dom = dom;
       }
   
  -    public NodeIterator cloneIterator() {
  +
  +    public DTMAxisIterator cloneIterator() {
  +	_isRestartable = false;
   	final LookAheadIterator[] heapCopy = 
   	    new LookAheadIterator[_heap.length];
   	try {
  @@ -146,7 +149,7 @@
   	}
       }
       
  -    public UnionIterator addIterator(NodeIterator iterator) {
  +    public UnionIterator addIterator(DTMAxisIterator iterator) {
   	if (_free == _size) {
   	    LookAheadIterator[] newArray = new LookAheadIterator[_size *= 2];
   	    System.arraycopy(_heap, 0, newArray, 0, _free);
  @@ -185,7 +188,7 @@
   	return END;
       }
     
  -    public NodeIterator setStartNode(int node) {
  +    public DTMAxisIterator setStartNode(int node) {
   	if (_isRestartable) {
   	    _startNode = node;
   	    for (int i = 0; i < _free; i++) {
  @@ -234,7 +237,7 @@
   	}
       }
   
  -    public NodeIterator reset() {
  +    public DTMAxisIterator reset() {
   	for (int i = 0; i < _free; i++) {
   	    _heap[i].iterator.reset();
   	    _heap[i].step();
  
  
  
  1.2       +1331 -0   xml-xalan/java/src/org/apache/xalan/xsltc/dom/AdaptiveResultTreeImpl.java
  
  
  
  
  1.2       +165 -0    xml-xalan/java/src/org/apache/xalan/xsltc/dom/DOMWSFilter.java
  
  
  
  
  1.2       +1566 -0   xml-xalan/java/src/org/apache/xalan/xsltc/dom/SAXImpl.java
  
  
  
  
  1.2       +1044 -0   xml-xalan/java/src/org/apache/xalan/xsltc/dom/SimpleResultTreeImpl.java
  
  
  
  
  1.2       +348 -0    xml-xalan/java/src/org/apache/xalan/xsltc/dom/XSLTCDTMManager.java
  
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org


Mime
View raw message