xalan-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zong...@apache.org
Subject cvs commit: xml-xalan/java/src/org/apache/xml/utils SystemIDResolver.java TreeWalker.java
Date Thu, 01 Aug 2002 19:55:31 GMT
zongaro     2002/08/01 12:55:31

  Modified:    java/src/org/apache/xalan/extensions Tag: XSLTC_DTM
                        ExtensionHandlerJavaClass.java
               java/src/org/apache/xalan/lib Tag: XSLTC_DTM
                        ExsltCommon.java ExsltMath.java ExsltSets.java
                        Extensions.java
               java/src/org/apache/xalan/processor Tag: XSLTC_DTM
                        ProcessorInclude.java
               java/src/org/apache/xalan/xsltc/compiler Tag: XSLTC_DTM
                        CastExpr.java Expression.java FlowList.java
                        FunctionCall.java Mode.java StepPattern.java
                        TestSeq.java
               java/src/org/apache/xalan/xsltc/compiler/util Tag: XSLTC_DTM
                        MultiHashtable.java ReferenceType.java
                        ResultTreeType.java
               java/src/org/apache/xml/utils Tag: XSLTC_DTM
                        SystemIDResolver.java TreeWalker.java
  Log:
  Bringing branch back up-to-date with respect to changes in MAIN branch.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.10.12.1 +9 -0      xml-xalan/java/src/org/apache/xalan/extensions/ExtensionHandlerJavaClass.java
  
  Index: ExtensionHandlerJavaClass.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/extensions/ExtensionHandlerJavaClass.java,v
  retrieving revision 1.10
  retrieving revision 1.10.12.1
  diff -u -r1.10 -r1.10.12.1
  --- ExtensionHandlerJavaClass.java	12 Jun 2001 19:14:33 -0000	1.10
  +++ ExtensionHandlerJavaClass.java	1 Aug 2002 19:55:30 -0000	1.10.12.1
  @@ -412,6 +412,15 @@
       {
         result = m.invoke(m_defaultInstance, new Object[] {xpc, element});
       }
  +    catch (InvocationTargetException e)
  +    {
  +      Throwable targetException = e.getTargetException();
  +      
  +      if (targetException != null)
  +        throw new TransformerException (targetException.getMessage (), targetException);
  +      else
  +        throw new TransformerException (e.getMessage (), e);
  +    }
       catch (Exception e)
       {
         // e.printStackTrace ();
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.2.2.2   +1 -1      xml-xalan/java/src/org/apache/xalan/lib/ExsltCommon.java
  
  Index: ExsltCommon.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/lib/ExsltCommon.java,v
  retrieving revision 1.2.2.1
  retrieving revision 1.2.2.2
  diff -u -r1.2.2.1 -r1.2.2.2
  --- ExsltCommon.java	29 Jul 2002 00:01:17 -0000	1.2.2.1
  +++ ExsltCommon.java	1 Aug 2002 19:55:30 -0000	1.2.2.2
  @@ -94,7 +94,7 @@
    * This class contains EXSLT common extension functions.
    * It is accessed by specifying a namespace URI as follows:
    * <pre>
  - *    xmlns:exslt="http://exslt.org/xalan/common"
  + *    xmlns:exslt="http://exslt.org/common"
    * </pre>
    * 
    * The documentation for each function has been copied from the relevant
  
  
  
  1.2.2.1   +2 -2      xml-xalan/java/src/org/apache/xalan/lib/ExsltMath.java
  
  Index: ExsltMath.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/lib/ExsltMath.java,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- ExsltMath.java	22 Mar 2002 18:54:57 -0000	1.2
  +++ ExsltMath.java	1 Aug 2002 19:55:30 -0000	1.2.2.1
  @@ -195,7 +195,7 @@
      * @param expCon is passed in by the Xalan extension processor
      * @param ni The NodeIterator for the node-set to be evaluated.
      * 
  -   * @return node-set with nodes containing the minimum value found, an empty node-set
  +   * @return node-set with nodes containing the maximum value found, an empty node-set
      * if any node cannot be converted to a number.
      */
     public static NodeSet highest (ExpressionContext expCon, NodeIterator ni)
  @@ -234,7 +234,7 @@
      * @param expCon is passed in by the Xalan extension processor
      * @param ni The NodeIterator for the node-set to be evaluated.
      * 
  -   * @return node-set with nodes containing the maximum value found, an empty node-set
  +   * @return node-set with nodes containing the minimum value found, an empty node-set
      * if any node cannot be converted to a number.
      * 
      */
  
  
  
  1.2.2.1   +3 -3      xml-xalan/java/src/org/apache/xalan/lib/ExsltSets.java
  
  Index: ExsltSets.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/lib/ExsltSets.java,v
  retrieving revision 1.2
  retrieving revision 1.2.2.1
  diff -u -r1.2 -r1.2.2.1
  --- ExsltSets.java	22 Mar 2002 18:54:57 -0000	1.2
  +++ ExsltSets.java	1 Aug 2002 19:55:30 -0000	1.2.2.1
  @@ -93,7 +93,7 @@
    * This class contains EXSLT set extension functions.
    * It is accessed by specifying a namespace URI as follows:
    * <pre>
  - *    xmlns:set="http://exslt.org/xalan/sets"
  + *    xmlns:set="http://exslt.org/sets"
    * </pre>
    * 
    * The documentation for each function has been copied from the relevant
  @@ -145,8 +145,8 @@
      * 
      * @param ni1 NodeIterator for first node-set.
      * @param ni2 NodeIterator for second node-set.
  -   * @return a node-set containing the nodes in ni1 that precede in document order the first
  -   * node in ni2; an empty node-set if the first noe in ni2 is not in ni1; all of ni1 if ni2
  +   * @return a node-set containing the nodes in ni1 that follow in document order the first
  +   * node in ni2; an empty node-set if the first node in ni2 is not in ni1; all of ni1 if ni2
      * is empty.
      * 
      * @see <a href="http://www.exslt.org/">EXSLT</a>
  
  
  
  1.17.2.2  +1 -1      xml-xalan/java/src/org/apache/xalan/lib/Extensions.java
  
  Index: Extensions.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/lib/Extensions.java,v
  retrieving revision 1.17.2.1
  retrieving revision 1.17.2.2
  diff -u -r1.17.2.1 -r1.17.2.2
  --- Extensions.java	29 Jul 2002 00:01:17 -0000	1.17.2.1
  +++ Extensions.java	1 Aug 2002 19:55:30 -0000	1.17.2.2
  @@ -280,7 +280,7 @@
     }
   
     /**
  -   * Returns true of both node-sets contain the same set of nodes.
  +   * Returns true if both node-sets contain the same set of nodes.
      * @param n1 NodeIterator for first node-set
      *
      * NEEDSDOC @param ni1
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.20.10.1 +10 -1     xml-xalan/java/src/org/apache/xalan/processor/ProcessorInclude.java
  
  Index: ProcessorInclude.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/processor/ProcessorInclude.java,v
  retrieving revision 1.20
  retrieving revision 1.20.10.1
  diff -u -r1.20 -r1.20.10.1
  --- ProcessorInclude.java	8 Nov 2001 20:15:48 -0000	1.20
  +++ ProcessorInclude.java	1 Aug 2002 19:55:30 -0000	1.20.10.1
  @@ -238,7 +238,16 @@
           if (null != source && source instanceof DOMSource)
           {
             Node node = ((DOMSource)source).getNode();
  -          TreeWalker walker = new TreeWalker(handler, new org.apache.xpath.DOM2Helper(), source.getSystemId());
  +          
  +          String systemId = source.getSystemId();
  +          if (systemId == null)
  +          {
  +            systemId = SystemIDResolver.getAbsoluteURI(getHref(),
  +                         handler.getBaseIdentifier());
  +            
  +          }
  +          
  +          TreeWalker walker = new TreeWalker(handler, new org.apache.xpath.DOM2Helper(), systemId);
   
             try
             {
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.10.6.2  +2 -2      xml-xalan/java/src/org/apache/xalan/xsltc/compiler/CastExpr.java
  
  Index: CastExpr.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/CastExpr.java,v
  retrieving revision 1.10.6.1
  retrieving revision 1.10.6.2
  diff -u -r1.10.6.1 -r1.10.6.2
  --- CastExpr.java	29 Jul 2002 00:01:22 -0000	1.10.6.1
  +++ CastExpr.java	1 Aug 2002 19:55:30 -0000	1.10.6.2
  @@ -202,7 +202,7 @@
   	else if (tleft instanceof ResultTreeType) {
   	    tleft = Type.ResultTree; // multiple instances
   	}
  -	if (InternalTypeMap.maps(tleft, _type)) {
  +	if (InternalTypeMap.maps(tleft, _type) != null) {
   	    return _type;
   	}
   	throw new TypeCheckError(this);	
  
  
  
  1.11.2.2  +9 -1      xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Expression.java
  
  Index: Expression.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Expression.java,v
  retrieving revision 1.11.2.1
  retrieving revision 1.11.2.2
  diff -u -r1.11.2.1 -r1.11.2.2
  --- Expression.java	29 Jul 2002 00:01:22 -0000	1.11.2.1
  +++ Expression.java	1 Aug 2002 19:55:30 -0000	1.11.2.2
  @@ -214,6 +214,14 @@
   	_falseList.add(il.append(new IFEQ(null)));
       }
   
  +    public FlowList getFalseList() {
  +	return _falseList;
  +    }
  +
  +    public FlowList getTrueList() {
  +	return _trueList;
  +    }
  +
       public void backPatchFalseList(InstructionHandle ih) {
   	_falseList.backPatch(ih);
       }
  
  
  
  1.2.6.1   +31 -1     xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FlowList.java
  
  Index: FlowList.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FlowList.java,v
  retrieving revision 1.2
  retrieving revision 1.2.6.1
  diff -u -r1.2 -r1.2.6.1
  --- FlowList.java	1 Feb 2002 20:07:08 -0000	1.2
  +++ FlowList.java	1 Aug 2002 19:55:30 -0000	1.2.6.1
  @@ -64,6 +64,7 @@
   package org.apache.xalan.xsltc.compiler;
   
   import java.util.Vector;
  +import java.util.Iterator;
   import org.apache.bcel.generic.*;
   
   public final class FlowList {
  @@ -118,5 +119,34 @@
   	    }
   	    _elements.clear();		// avoid backpatching more than once
   	}
  +    }
  +
  +    /**
  +     * Redirect the handles from oldList to newList. "This" flow list
  +     * is assumed to be relative to oldList.
  +     */
  +    public FlowList copyAndRedirect(InstructionList oldList, 
  +	InstructionList newList) 
  +    {
  +	final FlowList result = new FlowList();
  +	if (_elements == null) {
  +	    return result;
  +	}
  +
  +	final int n = _elements.size();
  +	final Iterator oldIter = oldList.iterator();
  +	final Iterator newIter = newList.iterator();
  +	
  +	while (oldIter.hasNext()) {
  +	    final InstructionHandle oldIh = (InstructionHandle) oldIter.next();
  +	    final InstructionHandle newIh = (InstructionHandle) newIter.next();
  +
  +	    for (int i = 0; i < n; i++) {
  +		if (_elements.elementAt(i) == oldIh) {
  +		    result.add(newIh);
  +		}
  +	    }
  +	}
  +	return result;
       }
   }
  
  
  
  1.14.2.2  +95 -43    xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FunctionCall.java
  
  Index: FunctionCall.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/FunctionCall.java,v
  retrieving revision 1.14.2.1
  retrieving revision 1.14.2.2
  diff -u -r1.14.2.1 -r1.14.2.2
  --- FunctionCall.java	29 Jul 2002 00:01:22 -0000	1.14.2.1
  +++ FunctionCall.java	1 Aug 2002 19:55:30 -0000	1.14.2.2
  @@ -133,12 +133,31 @@
       private static final Hashtable _java2Internal = new Hashtable();
   
       /**
  +     * inner class to used in internal2Java mappings, contains
  +     * the Java type and the distance between the internal type and
  +     * the Java type. 
  +     */
  +    static class JavaType {
  +	public Class  type;
  +	public int distance;
  +	
  +	public JavaType(Class type, int distance){
  +	    this.type = type;
  +	    this.distance = distance;
  +	}
  +	public boolean equals(Object query){
  +	    return query.equals(type);
  +	}
  +    } 
  +
  +    /**
        * Defines 2 conversion tables:
        * 1. From internal types to Java types and
        * 2. From Java types to internal types.
        * These two tables are used when calling external (Java) functions.
        */
       static {
  +
   	try {
   	    final Class objectClass   = Class.forName("java.lang.Object");
   	    final Class stringClass   = Class.forName("java.lang.String");
  @@ -146,42 +165,43 @@
   	    final Class nodeListClass = Class.forName("org.w3c.dom.NodeList");
   
   	    // Possible conversions between internal and Java types
  -	    _internal2Java.put(Type.Boolean, Boolean.TYPE);
  -
  -	    _internal2Java.put(Type.Int, Character.TYPE);
  -	    _internal2Java.put(Type.Int, Byte.TYPE);
  -	    _internal2Java.put(Type.Int, Short.TYPE);
  -	    _internal2Java.put(Type.Int, Integer.TYPE);
  -	    _internal2Java.put(Type.Int, Long.TYPE);
  -	    _internal2Java.put(Type.Int, Float.TYPE);
  -	    _internal2Java.put(Type.Int, Double.TYPE);
  -
  -	    _internal2Java.put(Type.Real, Character.TYPE);
  -	    _internal2Java.put(Type.Real, Byte.TYPE);
  -	    _internal2Java.put(Type.Real, Short.TYPE);
  -	    _internal2Java.put(Type.Real, Integer.TYPE);
  -	    _internal2Java.put(Type.Real, Long.TYPE);
  -	    _internal2Java.put(Type.Real, Float.TYPE);
  -	    _internal2Java.put(Type.Real, Double.TYPE);
  -
  -	    _internal2Java.put(Type.String, stringClass);
  -
  -	    _internal2Java.put(Type.Node, nodeClass);
  -	    _internal2Java.put(Type.Node, nodeListClass);
  -
  -	    _internal2Java.put(Type.NodeSet, Integer.TYPE);
  -	    _internal2Java.put(Type.NodeSet, nodeClass);
  -	    _internal2Java.put(Type.NodeSet, nodeListClass);
  +	    _internal2Java.put(Type.Boolean, new JavaType(Boolean.TYPE,0));
   
  -	    _internal2Java.put(Type.ResultTree, nodeClass);
  -	    _internal2Java.put(Type.ResultTree, nodeListClass);
  +	    _internal2Java.put(Type.Int, new JavaType(Character.TYPE, 6)); 
  +	    _internal2Java.put(Type.Int, new JavaType(Byte.TYPE, 5));
  +	    _internal2Java.put(Type.Int, new JavaType(Short.TYPE, 4));
  +	    _internal2Java.put(Type.Int, new JavaType(Integer.TYPE, 0));
  +	    _internal2Java.put(Type.Int, new JavaType(Long.TYPE, 1));
  +	    _internal2Java.put(Type.Int, new JavaType(Float.TYPE, 2));
  +	    _internal2Java.put(Type.Int, new JavaType(Double.TYPE, 3));
  +
  +	    _internal2Java.put(Type.Real, new JavaType(Character.TYPE, 6)); 
  +	    _internal2Java.put(Type.Real, new JavaType(Byte.TYPE, 5));
  +	    _internal2Java.put(Type.Real, new JavaType(Short.TYPE, 4));
  +	    _internal2Java.put(Type.Real, new JavaType(Integer.TYPE, 3));
  +	    _internal2Java.put(Type.Real, new JavaType(Long.TYPE, 2));
  +	    _internal2Java.put(Type.Real, new JavaType(Float.TYPE, 1));
  +	    _internal2Java.put(Type.Real, new JavaType(Double.TYPE, 0));
  +
  +	    _internal2Java.put(Type.String, new JavaType(stringClass, 0)); 
  +
  +	    _internal2Java.put(Type.Node, new JavaType(nodeClass, 0));  
  +	    _internal2Java.put(Type.Node, new JavaType(nodeListClass, 1));
  +
  +	    _internal2Java.put(Type.NodeSet, new JavaType(Integer.TYPE, 10)); 
  +	    _internal2Java.put(Type.NodeSet, new JavaType(nodeClass, 1)); 
  +	    _internal2Java.put(Type.NodeSet, new JavaType(nodeListClass,0)); 
  +
  +	    _internal2Java.put(Type.ResultTree, new JavaType(nodeClass, 1)); 
  +	    _internal2Java.put(Type.ResultTree, new JavaType(nodeListClass,0));
  +	    _internal2Java.put(Type.ResultTree, new JavaType(objectClass,2));
   
  -	    _internal2Java.put(Type.Reference, objectClass);
  +	    _internal2Java.put(Type.Reference, new JavaType(objectClass,0));
   
   	    // Possible conversions between Java and internal types
  -	    _java2Internal.put(Boolean.TYPE, Type.Boolean);
  +	    _java2Internal.put(Boolean.TYPE, Type.Boolean); 
   
  -	    _java2Internal.put(Character.TYPE, Type.Real);
  +	    _java2Internal.put(Character.TYPE, Type.Real); 
   	    _java2Internal.put(Byte.TYPE, Type.Real);
   	    _java2Internal.put(Short.TYPE, Type.Real);
   	    _java2Internal.put(Integer.TYPE, Type.Real);
  @@ -338,6 +358,8 @@
   	final Vector argsType = typeCheckArgs(stable);
   
   	// Try all constructors 
  +	int bestConstrDistance = Integer.MAX_VALUE;
  +	_type = null;			// reset
   	for (int j, i = 0; i < nConstructors; i++) {
   	    // Check if all parameters to this constructor can be converted
   	    final Constructor constructor = 
  @@ -345,20 +367,34 @@
   	    final Class[] paramTypes = constructor.getParameterTypes();
   
   	    Class extType = null;
  +	    int currConstrDistance = 0;
   	    for (j = 0; j < nArgs; j++) {
   		// Convert from internal (translet) type to external (Java) type
   		extType = paramTypes[j];
   		final Type intType = (Type)argsType.elementAt(j);
  -		if (!_internal2Java.maps(intType, extType)) break;
  +		Object match = _internal2Java.maps(intType, extType);
  +		if (match != null) {
  +		    currConstrDistance += ((JavaType)match).distance;
  +		}
  +		else {
  +		    // no mapping available
  +		    currConstrDistance = Integer.MAX_VALUE;
  +		    break;
  +		} 
   	    }
   
  -	    if (j == nArgs) {
  +	    if (j == nArgs && currConstrDistance < bestConstrDistance ) {
   	        _chosenConstructor = constructor;
   	        _isExtConstructor = true;
  -		return _type = new ObjectType(_className);
  +		bestConstrDistance = currConstrDistance;
  +		_type = new ObjectType(_className);
   	    }
   	}
   
  +	if (_type != null) {
  +	    return _type;
  +	}
  +
   	final StringBuffer buf = new StringBuffer(_className);
   	buf.append('.').append(_fname.getLocalPart()).append('(');
   	for (int i = 0; i < nArgs; i++) {
  @@ -430,18 +466,30 @@
   	final int nMethods = methods.size();
   	final Vector argsType = typeCheckArgs(stable);
   
  -	// Try all methods with the same name as this function
  +	// Try all methods to identify the best fit 
  +	int bestMethodDistance  = Integer.MAX_VALUE;
  +	_type = null;                       // reset internal type 
   	for (int j, i = 0; i < nMethods; i++) {
   
   	    // Check if all paramteters to this method can be converted
   	    final Method method = (Method)methods.elementAt(i);
   	    final Class[] paramTypes = method.getParameterTypes();
  -
  +	    
  +	    int currMethodDistance = 0;
   	    for (j = 0; j < nArgs; j++) {
   		// Convert from internal (translet) type to external (Java) type
   		extType = paramTypes[j];
   		final Type intType = (Type)argsType.elementAt(j);
  -		if (!_internal2Java.maps(intType, extType)) break;
  +		Object match = _internal2Java.maps(intType, extType);
  +		if (match != null) {
  +		   currMethodDistance += 
  +			((JavaType)match).distance; 
  +		}
  +		else {
  +		    // no mapping available
  +		    currMethodDistance = Integer.MAX_VALUE;
  +		    break;
  +		}
   	    }
   
   	    if (j == nArgs) {
  @@ -451,14 +499,18 @@
   		    : (Type) _java2Internal.get(extType);
   
   		// Use this method if all parameters & return type match
  -		if (_type != null) {
  +		if (_type != null && currMethodDistance < bestMethodDistance) {
   		    _chosenMethod = method;
  -		    if (_type == Type.NodeSet){
  -		        getXSLTC().setMultiDocument(true);
  -		    }
  -		    return _type;
  +		    bestMethodDistance = currMethodDistance;
   		}
   	    }
  +	}
  +
  +	if (_type != null) {
  +	    if (_type == Type.NodeSet){
  +                getXSLTC().setMultiDocument(true);
  +            }
  +	    return _type;
   	}
   
   	final StringBuffer buf = new StringBuffer(_className);
  
  
  
  1.19.6.4  +162 -61   xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Mode.java
  
  Index: Mode.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Mode.java,v
  retrieving revision 1.19.6.3
  retrieving revision 1.19.6.4
  diff -u -r1.19.6.3 -r1.19.6.4
  --- Mode.java	29 Jul 2002 00:01:22 -0000	1.19.6.3
  +++ Mode.java	1 Aug 2002 19:55:30 -0000	1.19.6.4
  @@ -79,8 +79,9 @@
   import org.apache.xml.dtm.DTM;
   
   /**
  - * Mode gathers all the templates belonging to a given mode; it is responsible
  - * for generating an appropriate applyTemplates + (mode name) function
  + * Mode gathers all the templates belonging to a given mode; 
  + * it is responsible for generating an appropriate 
  + * applyTemplates + (mode name) method in the translet.
    */
   final class Mode implements Constants {
   
  @@ -122,32 +123,67 @@
       /**
        * Test sequence for patterns with id() or key()-type kernel.
        */
  -    private TestSeq  _idxTestSeq = null;
  +    private TestSeq _idxTestSeq = null;
   
       /**
        * Group for patterns with any other kernel type.
        */
  -    private Vector[]  _patternGroups;
  +    private Vector[] _patternGroups;
   
       /**
        * Test sequence for patterns with any other kernel type.
        */
       private TestSeq[] _testSeq;
   
  +    /**
  +     * A mapping between patterns and instruction lists used by 
  +     * test sequences to avoid compiling the same pattern multiple 
  +     * times. Note that patterns whose kernels are "*", "node()" 
  +     * and "@*" can between shared by test sequences.
  +     */
  +    private Hashtable _preCompiled = new Hashtable();
  +
  +    /**
  +     * A mapping between templates and test sequences.
  +     */
       private Hashtable _neededTemplates = new Hashtable();
  +
  +    /**
  +     * A mapping between named templates and Mode objects.
  +     */
       private Hashtable _namedTemplates = new Hashtable();
  +
  +    /**
  +     * A mapping between templates and instruction handles.
  +     */
       private Hashtable _templateIHs = new Hashtable();
  +
  +    /**
  +     * A mapping between templates and instruction lists.
  +     */
       private Hashtable _templateILs = new Hashtable();
  +
  +    /**
  +     * A reference to the pattern matching the root node.
  +     */
       private LocationPathPattern _rootPattern = null;
   
  +    /**
  +     * Stores ranges of template precendences for the compilation 
  +     * of apply-imports (a Hashtable for historical reasons).
  +     */
       private Hashtable _importLevels = null;
   
  +    /**
  +     * A mapping between key names and keys.
  +     */
       private Hashtable _keys = null;
   
  -    // Variable index for the current node - used in code generation
  +    /**
  +     * Variable index for the current node used in code generation.
  +     */
       private int _currentIndex;
   
  -
       /**
        * Creates a new Mode.
        *
  @@ -157,19 +193,18 @@
        *               (normally a sequence number - still in a String).
        */
       public Mode(QName name, Stylesheet stylesheet, String suffix) {
  -	// Save global info
   	_name = name;
   	_stylesheet = stylesheet;
   	_methodName = APPLY_TEMPLATES + suffix;
  -	// Initialise some data structures
   	_templates = new Vector();
   	_patternGroups = new Vector[32];
       }
   
       /**
  -     * Returns the name of the method (_not_ function) that will be compiled
  -     * for this mode. Normally takes the form 'applyTemplates()' or
  -     * 'applyTemplates2()'.
  +     * Returns the name of the method (_not_ function) that will be 
  +     * compiled for this mode. Normally takes the form 'applyTemplates()' 
  +     * or * 'applyTemplates2()'.
  +     *
        * @return Method name for this mode
        */
       public String functionName() {
  @@ -177,9 +212,28 @@
       }
   
       public String functionName(int min, int max) {
  -	if (_importLevels == null) _importLevels = new Hashtable();
  +	if (_importLevels == null) {
  +	    _importLevels = new Hashtable();
  +	}
   	_importLevels.put(new Integer(max), new Integer(min));
  -	return _methodName+'_'+max;
  +	return _methodName + '_' + max;
  +    }
  +
  +    /**
  +     * Add a pre-compiled pattern to this mode. 
  +     */
  +    public void addInstructionList(Pattern pattern, 
  +	InstructionList ilist) 
  +    {
  +	_preCompiled.put(pattern, ilist);
  +    }
  +
  +    /**
  +     * Get the instruction list for a pre-compiled pattern. Used by 
  +     * test sequences to avoid compiling patterns more than once.
  +     */
  +    public InstructionList getInstructionList(Pattern pattern) {
  +	return (InstructionList) _preCompiled.get(pattern);
       }
   
       /**
  @@ -189,10 +243,10 @@
   	return _stylesheet.getClassName();
       }
   
  -    /**
  -     * Add a template to this mode
  -     * @param template The template to add
  -     */
  +    public Stylesheet getStylesheet() {
  +	return _stylesheet;
  +    }
  +
       public void addTemplate(Template template) {
   	_templates.addElement(template);
       }
  @@ -306,10 +360,32 @@
       }
   
       /**
  +     * Group patterns by NodeTests of their last Step
  +     * Keep them sorted by priority within group
  +     */
  +    private void addPatternToGroup(final LocationPathPattern lpp) {
  +	// id() and key()-type patterns do not have a kernel type
  +	if (lpp instanceof IdKeyPattern) {
  +	    addPattern(-1, lpp);
  +	}
  +	// Otherwise get the kernel pattern from the LPP
  +	else {
  +	    // kernel pattern is the last (maybe only) Step
  +	    final StepPattern kernel = lpp.getKernelPattern();
  +	    if (kernel != null) {
  +		addPattern(kernel.getNodeType(), lpp);
  +	    }
  +	    else if (_rootPattern == null ||
  +		     lpp.noSmallerThan(_rootPattern)) {
  +		_rootPattern = lpp;
  +	    }
  +	}
  +    }
  +
  +    /**
        * Adds a pattern to a pattern group
        */
       private void addPattern(int kernelType, LocationPathPattern pattern) {
  -
   	// Make sure the array of pattern groups is long enough
   	final int oldLength = _patternGroups.length;
   	if (kernelType >= oldLength) {
  @@ -328,10 +404,13 @@
   	if (patterns == null) {
   	    patterns = new Vector(2);
   	    patterns.addElement(pattern);
  -	    if (kernelType == -1)
  +
  +	    if (kernelType == -1) {
   		_nodeGroup = patterns;
  -	    else
  +	    }
  +	    else {
   		_patternGroups[kernelType] = patterns;
  +	    }
   	}
   	// Otherwise make sure patterns are ordered by precedence/priorities
   	else {
  @@ -352,40 +431,58 @@
       }
       
       /**
  -     * Group patterns by NodeTests of their last Step
  -     * Keep them sorted by priority within group
  +     * Build test sequences. The first step is to complete the test sequences 
  +     * by including patterns of "*" and "node()" kernel to all element test 
  +     * sequences, and of "@*" to all attribute test sequences.
        */
  -    private void addPatternToGroup(final LocationPathPattern lpp) {
  -	// id() and key()-type patterns do not have a kernel type
  -	if (lpp instanceof IdKeyPattern) {
  -	    addPattern(-1, lpp);
  -	}
  -	// Otherwise get the kernel pattern from the LPP
  -	else {
  -	    // kernel pattern is the last (maybe only) Step
  -	    final StepPattern kernel = lpp.getKernelPattern();
  -	    if (kernel != null) {
  -		addPattern(kernel.getNodeType(), lpp);
  -	    }
  -	    else if (_rootPattern == null ||
  -		     lpp.noSmallerThan(_rootPattern)) {
  -		_rootPattern = lpp;
  +    private void prepareTestSequences() {
  +	final Vector names = _stylesheet.getXSLTC().getNamesIndex();
  +
  +	final Vector starGroup = _patternGroups[DTM.ELEMENT_NODE];
  +	final Vector atStarGroup = _patternGroups[DTM.ATTRIBUTE_NODE];
  +
  +	// Complete test sequences with "*", "@*" and "node()"
  +	if (starGroup != null || atStarGroup != null || _nodeGroup != null) {
  +	    final int n = _patternGroups.length;
  +
  +	    for (int m, i = DTM.NTYPES; i < n; i++) {
  +		if (_patternGroups[i] == null) continue;
  +
  +		final String name = (String) names.elementAt(i - DTM.NTYPES);
  +
  +		if (isAttributeName(name)) {
  +		    // If an attribute then copy "@*" to its test sequence
  +		    m = (atStarGroup != null) ? atStarGroup.size() : 0;
  +		    for (int j = 0; j < m; j++) {
  +			addPattern(i, 
  +			    (LocationPathPattern) atStarGroup.elementAt(j));
  +		    }
  +		}
  +		else {
  +		    // If an element then copy "*" to its test sequence
  +		    m = (starGroup != null) ? starGroup.size() : 0;
  +		    for (int j = 0; j < m; j++) {
  +			addPattern(i, 
  +			    (LocationPathPattern) starGroup.elementAt(j));
  +		    }
  +
  +		    // And also copy "node()" to its test sequence
  +		    m = (_nodeGroup != null) ? _nodeGroup.size() : 0;
  +		    for (int j = 0; j < m; j++) {
  +			addPattern(i, 
  +			    (LocationPathPattern) _nodeGroup.elementAt(j));
  +		    }
  +		}
   	    }
   	}
  -    }
   
  -    /**
  -     * Build test sequences
  -     */
  -    private void prepareTestSequences() {
  -	final Vector names = _stylesheet.getXSLTC().getNamesIndex();
   	_testSeq = new TestSeq[DTM.NTYPES + names.size()];
   	
   	final int n = _patternGroups.length;
   	for (int i = 0; i < n; i++) {
   	    final Vector patterns = _patternGroups[i];
   	    if (patterns != null) {
  -		final TestSeq testSeq = new TestSeq(patterns, this);
  +		final TestSeq testSeq = new TestSeq(patterns, i, this);
   		testSeq.reduce();
   		_testSeq[i] = testSeq;
   		testSeq.findTemplates(_neededTemplates);
  @@ -393,7 +490,7 @@
   	}
   
   	if ((_nodeGroup != null) && (_nodeGroup.size() > 0)) {
  -	    _nodeTestSeq = new TestSeq(_nodeGroup, this);
  +	    _nodeTestSeq = new TestSeq(_nodeGroup, -1, this);
   	    _nodeTestSeq.reduce();
   	    _nodeTestSeq.findTemplates(_neededTemplates);
   	}
  @@ -621,20 +718,7 @@
   	}
       }
   
  -    /**
  -     * Auxiliary method to determine if a qname describes an attribute/element
  -     */
  -    private static boolean isAttributeName(String qname) {
  -	final int col = qname.lastIndexOf(':') + 1;
  -	return (qname.charAt(col) == '@');
  -    }
  -
  -    private static boolean isNamespaceName(String qname) {
  -	final int col = qname.lastIndexOf(':');
  -	return (col > -1 && qname.charAt(qname.length()-1) == '*');
  -    }
  -
  -    /**
  +   /**
        * Compiles the applyTemplates() method and adds it to the translet.
        * This is the main dispatch method.
        */
  @@ -744,7 +828,6 @@
   	// If there is a match on node() we need to replace ihElem
   	// and ihText if the priority of node() is higher
   	if (_nodeTestSeq != null) {
  -
   	    // Compare priorities of node() and "*"
   	    double nodePrio = _nodeTestSeq.getPriority();
   	    int    nodePos  = _nodeTestSeq.getPosition();
  @@ -817,6 +900,7 @@
   	    }
   	}
   
  +
   	// Handle pattern with match on root node - default: traverse children
   	targets[DTM.ROOT_NODE] = _rootPattern != null
   	    ? getTemplateInstructionHandle(_rootPattern.getTemplate())
  @@ -1370,5 +1454,22 @@
   
       public InstructionHandle getTemplateInstructionHandle(Template template) {
   	return (InstructionHandle)_templateIHs.get(template);
  +    }
  +
  +    /**
  +     * Auxiliary method to determine if a qname is an attribute.
  +     */
  +    private static boolean isAttributeName(String qname) {
  +	final int col = qname.lastIndexOf(':') + 1;
  +	return (qname.charAt(col) == '@');
  +    }
  +
  +    /**
  +     * Auxiliary method to determine if a qname is a namespace 
  +     * qualified "*".
  +     */
  +    private static boolean isNamespaceName(String qname) {
  +	final int col = qname.lastIndexOf(':');
  +	return (col > -1 && qname.charAt(qname.length()-1) == '*');
       }
   }
  
  
  
  1.14.2.3  +4 -2      xml-xalan/java/src/org/apache/xalan/xsltc/compiler/StepPattern.java
  
  Index: StepPattern.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/StepPattern.java,v
  retrieving revision 1.14.2.2
  retrieving revision 1.14.2.3
  diff -u -r1.14.2.2 -r1.14.2.3
  --- StepPattern.java	29 Jul 2002 00:01:23 -0000	1.14.2.2
  +++ StepPattern.java	1 Aug 2002 19:55:30 -0000	1.14.2.3
  @@ -152,7 +152,9 @@
   	final StringBuffer buffer = new StringBuffer("stepPattern(\"");
   	buffer.append(Axis.names[_axis])
   	    .append("\", ")
  -	    .append(_isEpsilon ? "epsilon" : Integer.toString(_nodeType));
  +	    .append(_isEpsilon ? 
  +			("epsilon{" + Integer.toString(_nodeType) + "}") :
  +			 Integer.toString(_nodeType));
   	if (_predicates != null)
   	    buffer.append(", ").append(_predicates.toString());
   	return buffer.append(')').toString();
  
  
  
  1.6.6.2   +154 -101  xml-xalan/java/src/org/apache/xalan/xsltc/compiler/TestSeq.java
  
  Index: TestSeq.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/TestSeq.java,v
  retrieving revision 1.6.6.1
  retrieving revision 1.6.6.2
  diff -u -r1.6.6.1 -r1.6.6.2
  --- TestSeq.java	29 Jul 2002 00:01:23 -0000	1.6.6.1
  +++ TestSeq.java	1 Aug 2002 19:55:30 -0000	1.6.6.2
  @@ -69,6 +69,7 @@
   import java.util.Hashtable;
   import java.util.Dictionary;
   import java.util.Enumeration;
  +import java.util.Iterator;
   
   import org.apache.bcel.generic.*;
   import org.apache.xalan.xsltc.compiler.util.*;
  @@ -77,110 +78,149 @@
    * A test sequence is a sequence of patterns that
    *
    *  (1) occured in templates in the same mode
  - *  (2) share the same kernel node type (such as A/B and C/C/B).
  + *  (2) share the same kernel node type (e.g. A/B and C/C/B)
  + *  (3) may also contain patterns matching "*" and "node()"
  + *      (element sequence only) or matching "@*" (attribute
  + *      sequence only).
    *
  - * A test sequence may have a default template, which will be run if
  - * none of the patterns do not match. This template is always a template
  - * that matches solely on the shared kernel node type.
  + * A test sequence may have a default template, which will be 
  + * instantiated if none of the other patterns match. 
    */
   final class TestSeq {
   
  -    private Vector   _patterns = null; // all patterns
  -    private Mode     _mode     = null; // the shared mode
  -    private Template _default  = null; // the default template
  +    /**
  +     * Integer code for the kernel type of this test sequence
  +     */
  +    private int _kernelType;
  +
  +    /**
  +     * Vector of all patterns in the test sequence. May include
  +     * patterns with "*", "@*" or "node()" kernel.
  +     */
  +    private Vector _patterns = null;
  +
  +    /**
  +     * A reference to the Mode object.
  +     */
  +    private Mode _mode = null;
  +
  +    /**
  +     * Default template for this test sequence
  +     */
  +    private Template _default = null;
   
  +    /**
  +     * Instruction list representing this test sequence.
  +     */
       private InstructionList _instructionList;
   
       /**
  -     * Creates a new test sequence, given a set of patterns and a mode.
  +     * Cached handle to avoid compiling more than once.
  +     */
  +    private InstructionHandle _start = null;
  +
  +    /**
  +     * Creates a new test sequence given a set of patterns and a mode.
        */
       public TestSeq(Vector patterns, Mode mode) {
  +	this(patterns, -2, mode);
  +    }
  +
  +    public TestSeq(Vector patterns, int kernelType, Mode mode) {
   	_patterns = patterns;
  +	_kernelType = kernelType;
   	_mode = mode;
       }
   
       /**
  -     * The priority is only calculated if the test sequence has a default
  -     * template. This is bad, bad, bad. We should get the priority from the
  -     * other templates that make up the test sequence.
  +     * Returns a string representation of this test sequence. Notice
  +     * that test sequences are mutable, so the value returned by this
  +     * method is different before and after calling reduce().
        */
  -    public double getPriority() {
  -	double prio = (0 - Double.MAX_VALUE);
  +    public String toString() {
   	final int count = _patterns.size();
  +	final StringBuffer result = new StringBuffer();
   
   	for (int i = 0; i < count; i++) {
  -	    final Pattern pattern = (Pattern)_patterns.elementAt(i);
  -	    final Template template = pattern.getTemplate();
  -	    final double tp = template.getPriority();
  -	    if (tp > prio) prio = tp;
  -	}
  -	if (_default != null) {
  -	    final double tp = _default.getPriority();
  -	    if (tp > prio) prio = tp;
  +	    final LocationPathPattern pattern =
  +		(LocationPathPattern) _patterns.elementAt(i);
  +
  +	    if (i == 0) {
  +		result.append("Testseq for kernel " + _kernelType)
  +		      .append('\n');
  +	    }
  +	    result.append("   pattern " + i + ": ")
  +	          .append(pattern.toString())
  +		  .append('\n');
   	}
  -	return prio;
  +	return result.toString();
       }
   
       /**
  -     * This method should return the last position of any template included
  -     * in this test sequence.
  +     * Returns the instruction list for this test sequence
        */
  -    public int getPosition() {
  -	int pos = Integer.MIN_VALUE;
  -	final int count = _patterns.size();
  +    public InstructionList getInstructionList() {
  +	return _instructionList;
  +    }
   
  -	for (int i = 0; i < count; i++) {
  -	    final Pattern pattern = (Pattern)_patterns.elementAt(i);
  -	    final Template template = pattern.getTemplate();
  -	    final int tp = template.getPosition();
  -	    if (tp > pos) pos = tp;
  -	}
  -	if (_default != null) {
  -	    final int tp = _default.getPosition();
  -	    if (tp > pos) pos = tp;
  -	}
  -	return pos;
  +    /**
  +     * Return the highest priority for a pattern in this test
  +     * sequence. This is either the priority of the first or
  +     * of the default pattern.
  +     */
  +    public double getPriority() {
  +	final Template template = (_patterns.size() == 0) ? _default 
  +	    : ((Pattern) _patterns.elementAt(0)).getTemplate();
  +	return template.getPriority();
       }
  -	
  +
  +    /**
  +     * Returns the position of the highest priority pattern in 
  +     * this test sequence.
  +     */
  +    public int getPosition() {
  +	final Template template = (_patterns.size() == 0) ? _default 
  +	    : ((Pattern) _patterns.elementAt(0)).getTemplate();
  +	return template.getPosition();
  +    }
  +
       /**
  -     * Reduce the patterns in this test sequence to exclude the shared
  -     * kernel node type. After the switch() in the translet's applyTemplates()
  -     * we already know that we have a hit for the kernel node type, we only
  -     * have the check the rest of the pattern.
  +     * Reduce the patterns in this test sequence. Creates a new
  +     * vector of patterns and sets the default pattern if it
  +     * finds a patterns that is fully reduced.
        */
       public void reduce() {
   	final Vector newPatterns = new Vector();
  -	final int count = _patterns.size();
   
  -	// Traverse the existing set of patterns (they are in prioritised order)
  +	final int count = _patterns.size();
   	for (int i = 0; i < count; i++) {
   	    final LocationPathPattern pattern =
   		(LocationPathPattern)_patterns.elementAt(i);
  -	    // Reduce this pattern (get rid of kernel node type)
  +		
  +	    // Reduce this pattern
   	    pattern.reduceKernelPattern();
   			
  -	    // Add this pattern to the new vector of patterns.
  -	    if (!pattern.isWildcard()) {
  -		newPatterns.addElement(pattern);
  +	    // Is this pattern fully reduced?
  +	    if (pattern.isWildcard()) {
  +		_default = pattern.getTemplate();
  +		break; 		// Ignore following patterns 
   	    }
  -	    // Set template as default if its pattern matches purely on kernel
   	    else {
  -		_default = pattern.getTemplate();
  -		// Following patterns can be ignored since default has priority
  -		break;
  +		newPatterns.addElement(pattern);
   	    }
   	}
   	_patterns = newPatterns;
       }
   
       /**
  -     * Returns, by reference, the templates that are included in this test
  -     * sequence. Remember that a single template can occur in several test
  -     * sequences if its pattern is a union (ex. match="A/B | A/C").
  +     * Returns, by reference, the templates that are included in 
  +     * this test sequence. Note that a single template can occur 
  +     * in several test sequences if its pattern is a union.
        */
       public void findTemplates(Dictionary templates) {
  -	if (_default != null)
  +	if (_default != null) {
   	    templates.put(_default, this);
  +	}
   	for (int i = 0; i < _patterns.size(); i++) {
   	    final LocationPathPattern pattern =
   		(LocationPathPattern)_patterns.elementAt(i);
  @@ -189,9 +229,10 @@
       }
   
       /**
  -     * Get the instruction handle to a template's code. This is used when
  -     * a single template occurs in several test sequences; that is, if its
  -     * pattern is a union of patterns (ex. match="A/B | A/C").
  +     * Get the instruction handle to a template's code. This is 
  +     * used when a single template occurs in several test 
  +     * sequences; that is, if its pattern is a union of patterns 
  +     * (e.g. match="A/B | A/C").
        */
       private InstructionHandle getTemplateHandle(Template template) {
   	return (InstructionHandle)_mode.getTemplateInstructionHandle(template);
  @@ -204,71 +245,83 @@
   	return (LocationPathPattern)_patterns.elementAt(n);
       }
   
  -
  -    private InstructionHandle _start = null;
  -
       /**
  -     * Copile the code for this test sequence. The code will first test for
  -     * the pattern with the highest priority, then go on to the next ones,
  -     * until it hits or finds the default template.
  +     * Compile the code for this test sequence. Compile patterns 
  +     * from highest to lowest priority. Note that since patterns 
  +     * can be share by multiple test sequences, instruction lists 
  +     * must be copied before backpatching.
        */
       public InstructionHandle compile(ClassGenerator classGen,
   				     MethodGenerator methodGen,
  -				     InstructionHandle continuation) {
  +				     InstructionHandle continuation) 
  +    {
  +	// Returned cached value if already compiled
  +	if (_start != null) {
  +	    return _start;
  +	}
   
  +	// If not patterns, then return handle for default template
   	final int count = _patterns.size();
  -	
  -	if (_start != null) return(_start);
  -
  -	// EZ DC if there is only one (default) pattern
  -	if (count == 0) getTemplateHandle(_default);
  +	if (count == 0) {
  +	    return (_start = getTemplateHandle(_default));
  +	}
   
  -	// The 'fail' instruction handle represents a branch to go to when
  -	// test fails. It is updated in each iteration, so that the tests
  -	// are linked together in the  if-elseif-elseif-else fashion.
  -	InstructionHandle fail;
  +	// Init handle to jump when all patterns failed
  +	InstructionHandle fail = (_default == null) ? continuation
  +	    : getTemplateHandle(_default);
   	
  -	// Initialize 'fail' to either the code for the default template
  -	if (_default != null)
  -	    fail = getTemplateHandle(_default);
  -	// ..or if that does not exist, to a location set by the caller.
  -	else
  -	    fail = continuation;
  -
  -	for (int n = (count - 1); n >= 0; n--) {
  +	// Compile all patterns in reverse order
  +	for (int n = count - 1; n >= 0; n--) {
   	    final LocationPathPattern pattern = getPattern(n);
   	    final Template template = pattern.getTemplate();
   	    final InstructionList il = new InstructionList();
   
   	    // Patterns expect current node on top of stack
   	    il.append(methodGen.loadCurrentNode());
  +
   	    // Apply the test-code compiled for the pattern
  -	    il.append(pattern.compile(classGen, methodGen));
  +	    InstructionList ilist = _mode.getInstructionList(pattern);
  +	    if (ilist == null) {
  +		ilist = pattern.compile(classGen, methodGen);
  +		_mode.addInstructionList(pattern, ilist);
  +	    }
  +
  +	    // Make a copy of the instruction list for backpatching
  +	    InstructionList copyOfilist = ilist.copy();
  +
  +	    FlowList trueList = pattern.getTrueList();
  +	    if (trueList != null) {
  +		trueList = trueList.copyAndRedirect(ilist, copyOfilist);
  +	    }
  +	    FlowList falseList = pattern.getFalseList();
  +	    if (falseList != null) {
  +		falseList = falseList.copyAndRedirect(ilist, copyOfilist);
  +	    }
  +
  +	    il.append(copyOfilist);
   
   	    // On success branch to the template code
   	    final InstructionHandle gtmpl = getTemplateHandle(template);
   	    final InstructionHandle success = il.append(new GOTO_W(gtmpl));
  -	    pattern.backPatchTrueList(success);
  -	    pattern.backPatchFalseList(fail);
   
  -	    // We're working backwards here. The next pattern's 'fail' target
  -	    // is this pattern's first instruction
  +	    if (trueList != null) {
  +		trueList.backPatch(success);
  +	    }
  +	    if (falseList != null) {
  +		falseList.backPatch(fail);
  +	    } 
  +
  +	    // Next pattern's 'fail' target is this pattern's first instruction
   	    fail = il.getStart();
   
   	    // Append existing instruction list to the end of this one
  -	    if (_instructionList != null) il.append(_instructionList);
  +	    if (_instructionList != null) {
  +		il.append(_instructionList);
  +	    }
   
  -	    // Set current instruction list to be this one.
  +	    // Set current instruction list to be this one
   	    _instructionList = il;
   	}
  -	return(_start = fail);
  -    }
  -
  -    /**
  -     * Returns the instruction list for this test sequence
  -     */
  -    public InstructionList getInstructionList() {
  -	return _instructionList;
  +	return (_start = fail);
       }
  -
   }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.2.10.1  +7 -6      xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/MultiHashtable.java
  
  Index: MultiHashtable.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/MultiHashtable.java,v
  retrieving revision 1.2
  retrieving revision 1.2.10.1
  diff -u -r1.2 -r1.2.10.1
  --- MultiHashtable.java	20 Aug 2001 14:50:32 -0000	1.2
  +++ MultiHashtable.java	1 Aug 2002 19:55:31 -0000	1.2.10.1
  @@ -75,17 +75,18 @@
   	return vector;
       }
   	
  -    public boolean maps(Object from, Object to) {
  -	if (from == null) return false;
  +    public Object maps(Object from, Object to) {
  +	if (from == null) return null;
   	final Vector vector = (Vector) get(from);
   	if (vector != null) {
   	    final int n = vector.size();
   	    for (int i = 0; i < n; i++) {
  -		if (vector.elementAt(i).equals(to)) {
  -		    return true;
  +                final Object item = vector.elementAt(i);
  +		if (item.equals(to)) {
  +		    return item;
   		}
   	    }
   	}
  -	return false;
  +	return null;
       }
   }
  
  
  
  1.7.6.2   +2 -3      xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ReferenceType.java
  
  Index: ReferenceType.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ReferenceType.java,v
  retrieving revision 1.7.6.1
  retrieving revision 1.7.6.2
  diff -u -r1.7.6.1 -r1.7.6.2
  --- ReferenceType.java	29 Jul 2002 00:01:26 -0000	1.7.6.1
  +++ ReferenceType.java	1 Aug 2002 19:55:31 -0000	1.7.6.2
  @@ -230,7 +230,6 @@
   	il.append(new INVOKESTATIC(index));
       }
   
  -
       /**
        * Subsume reference into ObjectType.
        *
  @@ -238,7 +237,7 @@
        */
       public void translateTo(ClassGenerator classGen, MethodGenerator methodGen, 
   			    ObjectType type) {
  -	    methodGen.getInstructionList().append(NOP);	
  +	methodGen.getInstructionList().append(NOP);	
       }
   
       /**
  
  
  
  1.10.6.2  +18 -1     xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ResultTreeType.java
  
  Index: ResultTreeType.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/util/ResultTreeType.java,v
  retrieving revision 1.10.6.1
  retrieving revision 1.10.6.2
  diff -u -r1.10.6.1 -r1.10.6.2
  --- ResultTreeType.java	17 Apr 2002 18:13:43 -0000	1.10.6.1
  +++ ResultTreeType.java	1 Aug 2002 19:55:31 -0000	1.10.6.2
  @@ -136,6 +136,9 @@
   	else if (type == Type.Reference) {
   	    translateTo(classGen, methodGen, (ReferenceType)type);
   	}
  +	else if (type == Type.Object) {
  +	    translateTo(classGen, methodGen, (ObjectType) type);
  +	}
   	else {
   	    ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
   					toString(), type.toString());
  @@ -380,6 +383,16 @@
       }
   
       /**
  +     * Subsume result tree into ObjectType.
  +     *
  +     * @see	org.apache.xalan.xsltc.compiler.util.Type#translateTo
  +     */
  +    public void translateTo(ClassGenerator classGen, MethodGenerator methodGen, 
  +			    ObjectType type) {
  +	methodGen.getInstructionList().append(NOP);	
  +    }
  +
  +    /**
        * Translates a result tree into a non-synthesized boolean.
        * It does not push a 0 or a 1 but instead returns branchhandle list
        * to be appended to the false list.
  @@ -429,7 +442,11 @@
   						  MAKE_NODE_LIST_SIG2);
   	    il.append(new INVOKEINTERFACE(index, 2));
   	}
  +	else if (className.equals("java.lang.Object")) {
  +	    il.append(NOP);
  +	}
   	else {
  +System.out.println("ResultTreeType.translateTo()");
   	    ErrorMsg err = new ErrorMsg(ErrorMsg.DATA_CONVERSION_ERR,
   					toString(), className);
   	    classGen.getParser().reportError(Constants.FATAL, err);
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.15.2.1  +2 -2      xml-xalan/java/src/org/apache/xml/utils/SystemIDResolver.java
  
  Index: SystemIDResolver.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/utils/SystemIDResolver.java,v
  retrieving revision 1.15
  retrieving revision 1.15.2.1
  diff -u -r1.15 -r1.15.2.1
  --- SystemIDResolver.java	22 Mar 2002 00:43:41 -0000	1.15
  +++ SystemIDResolver.java	1 Aug 2002 19:55:31 -0000	1.15.2.1
  @@ -263,8 +263,8 @@
       // Not so sure if this is good.  But, for now, I'll try it. We really must 
       // make sure the return from this function is a URL!
       if((Character.isLetter(uriStr.charAt(0)) && (uriStr.charAt(1) == ':') 
  -     && (uriStr.charAt(2) == '/') && (uriStr.charAt(3) != '/'))
  -       || ((uriStr.charAt(0) == '/') && (uriStr.charAt(1) != '/')))
  +     && (uriStr.charAt(2) == '/') && (uriStr.length() == 3 || uriStr.charAt(3) != '/'))
  +       || ((uriStr.charAt(0) == '/') && (uriStr.length() == 1 || uriStr.charAt(1) != '/')))
       {
       	uriStr = "file:///"+uriStr;
       }
  
  
  
  1.14.10.1 +20 -3     xml-xalan/java/src/org/apache/xml/utils/TreeWalker.java
  
  Index: TreeWalker.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/utils/TreeWalker.java,v
  retrieving revision 1.14
  retrieving revision 1.14.10.1
  diff -u -r1.14 -r1.14.10.1
  --- TreeWalker.java	11 Oct 2001 15:01:35 -0000	1.14
  +++ TreeWalker.java	1 Aug 2002 19:55:31 -0000	1.14.10.1
  @@ -71,6 +71,7 @@
    * This class does a pre-order walk of the DOM tree, calling a ContentHandler
    * interface as it goes.
    */
  +
   public class TreeWalker
   {
   
  @@ -167,8 +168,13 @@
     }
   
     /**
  -   * Perform a pre-order traversal non-recursive style.
  +   * Perform a pre-order traversal non-recursive style.  
      *
  +   * Note that TreeWalker assumes that the subtree is intended to represent 
  +   * a complete (though not necessarily well-formed) document and, during a 
  +   * traversal, startDocument and endDocument will always be issued to the 
  +   * SAX listener.
  +   *  
      * @param pos Node in the tree where to start traversal
      *
      * @throws TransformerException
  @@ -176,6 +182,8 @@
     public void traverse(Node pos) throws org.xml.sax.SAXException
     {
   
  +   	this.m_contentHandler.startDocument();
  +
       Node top = pos;
   
       while (null != pos)
  @@ -211,10 +219,16 @@
   
         pos = nextNode;
       }
  +    this.m_contentHandler.endDocument();
     }
   
     /**
      * Perform a pre-order traversal non-recursive style.
  +
  +   * Note that TreeWalker assumes that the subtree is intended to represent 
  +   * a complete (though not necessarily well-formed) document and, during a 
  +   * traversal, startDocument and endDocument will always be issued to the 
  +   * SAX listener.
      *
      * @param pos Node in the tree where to start traversal
      * @param top Node in the tree where to end traversal
  @@ -224,6 +238,8 @@
     public void traverse(Node pos, Node top) throws org.xml.sax.SAXException
     {
   
  +	this.m_contentHandler.startDocument();
  +	
       while (null != pos)
       {
         startNode(pos);
  @@ -254,6 +270,7 @@
   
         pos = nextNode;
       }
  +    this.m_contentHandler.endDocument();
     }
   
     /** Flag indicating whether following text to be processed is raw text          */
  @@ -325,7 +342,7 @@
         // ??;
         break;
       case Node.DOCUMENT_NODE :
  -      this.m_contentHandler.startDocument();
  +    
         break;
       case Node.ELEMENT_NODE :
         NamedNodeMap atts = ((Element) node).getAttributes();
  @@ -454,8 +471,8 @@
       switch (node.getNodeType())
       {
       case Node.DOCUMENT_NODE :
  -      this.m_contentHandler.endDocument();
         break;
  +      
       case Node.ELEMENT_NODE :
         String ns = m_dh.getNamespaceOfNode(node);
         if(null == ns)
  
  
  

---------------------------------------------------------------------
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