You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mo...@apache.org on 2001/06/06 16:32:48 UTC

cvs commit: xml-xalan/java/src/org/apache/xalan/xsltc/compiler LocationPathPattern.java Parser.java Template.java

morten      01/06/06 07:32:47

  Modified:    java/src/org/apache/xalan/xsltc/compiler
                        LocationPathPattern.java Parser.java Template.java
  Log:
  Fixed the code that resolves conflicts between templates with identical
  patterns. The order of the templates is not taken into account - after
  import precedence and priority has been checked.
  Submitted by:	morten@xml.apache.org
  Reviewed by:	morten@xml.apache.org
  
  Revision  Changes    Path
  1.2       +27 -6     xml-xalan/java/src/org/apache/xalan/xsltc/compiler/LocationPathPattern.java
  
  Index: LocationPathPattern.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/LocationPathPattern.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LocationPathPattern.java	2001/04/17 18:51:35	1.1
  +++ LocationPathPattern.java	2001/06/06 14:32:38	1.2
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: LocationPathPattern.java,v 1.1 2001/04/17 18:51:35 sboag Exp $
  + * @(#)$Id: LocationPathPattern.java,v 1.2 2001/06/06 14:32:38 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -71,7 +71,8 @@
       private Template _template;
       private int _importPrecedence;
       private double _priority = Double.NaN;
  -		
  +    private int _position = 0;
  +
       public Type typeCheck(SymbolTable stable) throws TypeCheckError {
   	return Type.Void;		// TODO
       }
  @@ -84,6 +85,7 @@
   	_template = template;
   	_priority = template.getPriority();
   	_importPrecedence = template.getImportPrecedence();
  +	_position = template.getPosition();
       }
   		
       public Template getTemplate() {
  @@ -97,11 +99,30 @@
       public double getDefaultPriority() {
   	return 0.5;
       }
  -		
  +
  +    /**
  +     * This method is used by the Mode class to prioritise patterns and
  +     * template. This method is called for templates that are in the same
  +     * mode and that match on the same core pattern. The rules used are:
  +     *  o) first check precedence - highest precedence wins
  +     *  o) then check priority - highest priority wins
  +     *  o) then check the position - the template that occured last wins
  +     */
       public boolean noSmallerThan(LocationPathPattern other) {
  -	return (_importPrecedence > other._importPrecedence ||
  -		(_importPrecedence == other._importPrecedence &&
  -		 getPriority() >= other.getPriority()));
  +	if (_importPrecedence > other._importPrecedence) {
  +	    return true;
  +	}
  +	else if (_importPrecedence == other._importPrecedence) {
  +	    if (_priority > other._priority) {
  +		return true;
  +	    }
  +	    else if (_priority == other._priority) {
  +		if (_position > other._position) {
  +		    return true;
  +		}
  +	    }
  +	}
  +	return false;
       }
       
       /** return last pattern (matching the current node) */
  
  
  
  1.7       +2 -3      xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Parser.java
  
  Index: Parser.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Parser.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Parser.java	2001/06/06 10:45:21	1.6
  +++ Parser.java	2001/06/06 14:32:41	1.7
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Parser.java,v 1.6 2001/06/06 10:45:21 morten Exp $
  + * @(#)$Id: Parser.java,v 1.7 2001/06/06 14:32:41 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -683,12 +683,11 @@
   	_template = template;
       }
   
  -    /*
       private int _templateIndex = 0;
  +
       public int getTemplateIndex() {
   	return(_templateIndex++);
       }
  -    */
   
       /**
        * Creates a new node in the abstract syntax tree. This node can be
  
  
  
  1.6       +3 -1      xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Template.java
  
  Index: Template.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/compiler/Template.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Template.java	2001/06/06 10:45:32	1.5
  +++ Template.java	2001/06/06 14:32:43	1.6
  @@ -1,5 +1,5 @@
   /*
  - * @(#)$Id: Template.java,v 1.5 2001/06/06 10:45:32 morten Exp $
  + * @(#)$Id: Template.java,v 1.6 2001/06/06 14:32:43 morten Exp $
    *
    * The Apache Software License, Version 1.1
    *
  @@ -235,6 +235,8 @@
   	    else
   		_priority = Double.NaN;
   	}
  +
  +	_position = parser.getTemplateIndex();
   
   	// Add the (named) template to the symbol table
   	if (_name != null) {
  
  
  

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